13 |
13 |
import org.txm.objects.CorpusCommandPreferences;
|
14 |
14 |
import org.txm.objects.Project;
|
15 |
15 |
import org.txm.rcp.messages.TXMUIMessages;
|
16 |
|
import org.w3c.dom.Element;
|
17 |
16 |
|
18 |
17 |
public class UISection extends ImportEditorSection {
|
19 |
18 |
|
20 |
19 |
private static final int SECTION_SIZE = 1;
|
|
20 |
|
21 |
21 |
private Text structLimitsText;
|
22 |
22 |
|
|
23 |
private Text referencePatternText;
|
|
24 |
|
23 |
25 |
public UISection(FormToolkit toolkit2, ScrolledForm form2, Composite parent, int style) {
|
24 |
26 |
super(toolkit2, form2, parent, style);
|
25 |
|
|
|
27 |
|
26 |
28 |
this.section.setText(TXMUIMessages.commands);
|
27 |
29 |
TableWrapLayout layout = new TableWrapLayout();
|
28 |
30 |
layout.makeColumnsEqualWidth = true;
|
... | ... | |
30 |
32 |
this.section.setLayoutData(getSectionGridData(SECTION_SIZE));
|
31 |
33 |
this.section.setEnabled(false);
|
32 |
34 |
this.section.addExpansionListener(new ExpansionAdapter() {
|
|
35 |
|
33 |
36 |
@Override
|
34 |
|
public void expansionStateChanged(ExpansionEvent e) {form.layout(true);}
|
|
37 |
public void expansionStateChanged(ExpansionEvent e) {
|
|
38 |
form.layout(true);
|
|
39 |
}
|
35 |
40 |
});
|
36 |
|
|
|
41 |
|
37 |
42 |
Composite sectionClient = toolkit.createComposite(this.section);
|
38 |
43 |
TableWrapLayout slayout = new TableWrapLayout();
|
39 |
44 |
slayout.makeColumnsEqualWidth = false;
|
40 |
45 |
slayout.numColumns = 2;
|
41 |
46 |
sectionClient.setLayout(slayout);
|
42 |
47 |
this.section.setClient(sectionClient);
|
43 |
|
|
|
48 |
|
|
49 |
Label sep = toolkit.createLabel(sectionClient, "Concordance");
|
|
50 |
sep.setToolTipText(TXMUIMessages.cannotSaveImportConfigurationNoSourceFolderSelected);
|
|
51 |
sep.setLayoutData(getSectionGridData(2));
|
|
52 |
|
44 |
53 |
Label tmpLabel = toolkit.createLabel(sectionClient, TXMUIMessages.concordanceContextStructureLimits);
|
45 |
54 |
tmpLabel.setToolTipText(TXMUIMessages.cannotSaveImportConfigurationNoSourceFolderSelected);
|
46 |
55 |
tmpLabel.setLayoutData(getLabelGridData());
|
47 |
|
|
|
56 |
|
48 |
57 |
structLimitsText = toolkit.createText(sectionClient, "text", SWT.BORDER); //$NON-NLS-1$
|
|
58 |
structLimitsText.setToolTipText(TXMUIMessages.cannotSaveImportConfigurationNoSourceFolderSelected);
|
49 |
59 |
TableWrapData gdata = getTextGridData();
|
50 |
60 |
structLimitsText.setLayoutData(gdata);
|
|
61 |
|
|
62 |
Label tmp2Label = toolkit.createLabel(sectionClient, "Reference pattern");
|
|
63 |
tmp2Label.setToolTipText("Reference pattern string. Properties must be wrapped in the '${}' tags. eg 'text id = ${text_id} and word = ${word}'");
|
|
64 |
tmp2Label.setLayoutData(getLabelGridData());
|
|
65 |
|
|
66 |
referencePatternText = toolkit.createText(sectionClient, "", SWT.BORDER); //$NON-NLS-1$
|
|
67 |
referencePatternText.setToolTipText("Reference pattern string. Properties must be wrapped in the '${}' tags. eg 'text id = ${text_id} and word = ${word}'");
|
|
68 |
TableWrapData gdata2 = getTextGridData();
|
|
69 |
referencePatternText.setLayoutData(gdata2);
|
51 |
70 |
}
|
52 |
|
|
|
71 |
|
53 |
72 |
@Override
|
54 |
73 |
public void update(Project project) {
|
55 |
74 |
CorpusCommandPreferences concPrefs = project.getCommandPreferences("concordance");
|
56 |
75 |
if (concPrefs.get("context_limits") != null) {
|
57 |
76 |
structLimitsText.setText(concPrefs.get("context_limits"));
|
58 |
77 |
}
|
|
78 |
else {
|
|
79 |
structLimitsText.setText("");
|
|
80 |
}
|
|
81 |
if (concPrefs.get("view_reference_pattern") != null) {
|
|
82 |
referencePatternText.setText(concPrefs.get("view_reference_pattern"));
|
|
83 |
}
|
|
84 |
else {
|
|
85 |
referencePatternText.setText("");
|
|
86 |
}
|
59 |
87 |
}
|
60 |
|
|
|
88 |
|
61 |
89 |
@Override
|
62 |
90 |
public boolean save(Project project) {
|
63 |
91 |
if (this.section != null && !section.isDisposed()) {
|
64 |
92 |
CorpusCommandPreferences concPrefs = project.getCommandPreferences("concordance");
|
65 |
93 |
concPrefs.set("context_limits_type", "list");
|
66 |
|
concPrefs.set("context_limits", structLimitsText.getText());
|
|
94 |
concPrefs.set("view_reference_pattern", referencePatternText.getText());
|
67 |
95 |
}
|
68 |
|
|
|
96 |
|
69 |
97 |
return true;
|
70 |
98 |
}
|
71 |
|
|
|
99 |
|
72 |
100 |
@Override
|
73 |
101 |
public boolean checkFields() {
|
74 |
102 |
return true;
|
75 |
103 |
}
|
76 |
|
|
|
104 |
|
77 |
105 |
@Override
|
78 |
106 |
public int getSectionSize() {
|
79 |
107 |
return SECTION_SIZE;
|
80 |
108 |
}
|
81 |
|
}
|
|
109 |
}
|