Révision 368
tmp/org.txm.rcp/src/main/java/org/txm/rcp/preferences/ConcordancerPreferencePage.java (revision 368) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.rcp.preferences; |
|
29 |
|
|
30 |
import org.eclipse.jface.preference.IntegerFieldEditor; |
|
31 |
import org.txm.rcp.Messages; |
|
32 |
// TODO: Auto-generated Javadoc |
|
33 |
/** |
|
34 |
* The Class ConcordancerPreferencePage. |
|
35 |
*/ |
|
36 |
public class ConcordancerPreferencePage extends RCPPreferencesPage { |
|
37 |
|
|
38 |
/** The n_line_per_page. */ |
|
39 |
private IntegerFieldEditor n_line_per_page; |
|
40 |
|
|
41 |
/** The left context size. */ |
|
42 |
private IntegerFieldEditor leftContextSize; |
|
43 |
|
|
44 |
/** The right context size. */ |
|
45 |
private IntegerFieldEditor rightContextSize; |
|
46 |
|
|
47 |
/** |
|
48 |
* Instantiates a new concordancer preference page. |
|
49 |
*/ |
|
50 |
public ConcordancerPreferencePage() { |
|
51 |
super(); |
|
52 |
setTitle(Messages.ConcordancerPreferencePage_3); |
|
53 |
} |
|
54 |
|
|
55 |
/* (non-Javadoc) |
|
56 |
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() |
|
57 |
*/ |
|
58 |
@Override |
|
59 |
protected void createFieldEditors() { |
|
60 |
n_line_per_page = new IntegerFieldEditor(RCPPreferences.N_LINE_PER_PAGE, |
|
61 |
Messages.ConcordancerPreferencePage_4, getFieldEditorParent()); |
|
62 |
addField(n_line_per_page); |
|
63 |
leftContextSize = new IntegerFieldEditor(RCPPreferences.LEFT_CONTEXT_SIZE, |
|
64 |
Messages.ConcordancerPreferencePage_5, getFieldEditorParent()); |
|
65 |
addField(leftContextSize); |
|
66 |
rightContextSize = new IntegerFieldEditor(RCPPreferences.RIGHT_CONTEXT_SIZE, |
|
67 |
Messages.ConcordancerPreferencePage_6, getFieldEditorParent()); |
|
68 |
addField(rightContextSize); |
|
69 |
} |
|
70 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/preferences/TXMPreferencePage.java (revision 368) | ||
---|---|---|
47 | 47 |
|
48 | 48 |
|
49 | 49 |
/** |
50 |
* |
|
50 |
* Creates a preferences page.
|
|
51 | 51 |
*/ |
52 | 52 |
public TXMPreferencePage() { |
53 | 53 |
super(GRID); |
... | ... | |
64 | 64 |
super.addField(editor); |
65 | 65 |
} |
66 | 66 |
|
67 |
//FIXME: is it really useful? |
|
67 | 68 |
/* (non-Javadoc) |
68 | 69 |
* @see org.eclipse.jface.preference.PreferencePage#isValid() |
69 | 70 |
*/ |
... | ... | |
80 | 81 |
try { |
81 | 82 |
super.performOk(); |
82 | 83 |
((ScopedPreferenceStore) this.getPreferenceStore()).save(); |
83 |
// FIXME: to remove after the plug-ins split |
|
84 |
//Toolbox.updateProperties(org.txm.rcp.ApplicationWorkbenchAdvisor.getProperties()); |
|
85 | 84 |
} catch (Exception e) { |
86 | 85 |
System.err.println(org.txm.rcp.Messages.FAILED_TO_SAVE_PREFERENCES + e); |
87 | 86 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/preferences/RCPPreferences.java (revision 368) | ||
---|---|---|
4 | 4 |
import org.osgi.service.prefs.Preferences; |
5 | 5 |
import org.txm.core.preferences.TBXPreferences; |
6 | 6 |
import org.txm.core.preferences.TXMPreferences; |
7 |
import org.txm.core.results.ITXMResult; |
|
8 | 7 |
|
9 | 8 |
public class RCPPreferences extends TXMPreferences { |
10 | 9 |
|
... | ... | |
51 | 50 |
/** The Constant RIGHT_CONTEXT_SIZE_DEFAULT. */ |
52 | 51 |
public static final int RIGHT_CONTEXT_SIZE_DEFAULT = 15; |
53 | 52 |
|
54 |
public static final String N_LINE_PER_PAGE = "n_line_per_page"; |
|
55 | 53 |
|
56 |
public static final String RIGHT_CONTEXT_SIZE = "right_context_size"; |
|
57 |
|
|
58 |
public static final String LEFT_CONTEXT_SIZE = "left_context_size"; |
|
59 |
|
|
60 | 54 |
public static final String ANNOTATION_MODE = "annotation_mode"; |
61 | 55 |
|
62 | 56 |
|
... | ... | |
70 | 64 |
preferences.put(TBXPreferences.EXPORT_TXTSEPARATOR, ""); //$NON-NLS-1$ |
71 | 65 |
|
72 | 66 |
preferences.putBoolean(AUTO_UPDATE_EDITOR, false); |
73 |
preferences.putBoolean(SHOW_SEVERE_DIALOG, false); //$NON-NLS-1$
|
|
74 |
preferences.putBoolean(USER_ALERT_DELETE, false); //$NON-NLS-1$
|
|
75 |
preferences.putBoolean(SAVE_BEFORE_EXECUTION, false); //$NON-NLS-1$
|
|
67 |
preferences.putBoolean(SHOW_SEVERE_DIALOG, false); |
|
68 |
preferences.putBoolean(USER_ALERT_DELETE, false); |
|
69 |
preferences.putBoolean(SAVE_BEFORE_EXECUTION, false); |
|
76 | 70 |
|
77 | 71 |
preferences.putInt(RCPPreferences.NO_SESSION, 1); |
78 | 72 |
|
79 |
preferences.put(ANNOTATION_MODE, "simple"); |
|
73 |
preferences.put(ANNOTATION_MODE, "simple"); //$NON-NLS-1$
|
|
80 | 74 |
|
81 | 75 |
} |
82 | 76 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/input/ConcordancesEditorInput.java (revision 368) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.rcp.editors.input; |
|
29 |
|
|
30 |
import org.eclipse.jface.resource.ImageDescriptor; |
|
31 |
import org.eclipse.ui.IEditorInput; |
|
32 |
import org.eclipse.ui.IPersistableElement; |
|
33 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
|
34 |
import org.txm.concordances.functions.Concordance; |
|
35 |
import org.txm.rcp.Application; |
|
36 |
import org.txm.rcp.IImageKeys; |
|
37 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
38 |
|
|
39 |
// TODO: Auto-generated Javadoc |
|
40 |
/** |
|
41 |
* The Class ConcordancesEditorInput. |
|
42 |
*/ |
|
43 |
@SuppressWarnings("rawtypes") //$NON-NLS-1$ |
|
44 |
public class ConcordancesEditorInput implements IEditorInput { |
|
45 |
|
|
46 |
/** The corpus. */ |
|
47 |
private Corpus corpus; |
|
48 |
|
|
49 |
/** The concordance. */ |
|
50 |
private Concordance concordance; |
|
51 |
|
|
52 |
/** |
|
53 |
* Instantiates a new concordances editor input. |
|
54 |
* |
|
55 |
* @param corpus the corpus |
|
56 |
* @param concordance the concordance |
|
57 |
*/ |
|
58 |
public ConcordancesEditorInput(Corpus corpus, Concordance concordance) { |
|
59 |
if (concordance != null) |
|
60 |
this.corpus = concordance.getCorpus(); |
|
61 |
else |
|
62 |
this.corpus = corpus; |
|
63 |
this.concordance = concordance; |
|
64 |
} |
|
65 |
|
|
66 |
/* (non-Javadoc) |
|
67 |
* @see org.eclipse.ui.IEditorInput#getImageDescriptor() |
|
68 |
*/ |
|
69 |
@Override |
|
70 |
public ImageDescriptor getImageDescriptor() { |
|
71 |
return AbstractUIPlugin.imageDescriptorFromPlugin( |
|
72 |
Application.PLUGIN_ID, IImageKeys.ACTION_CONCORDANCES); |
|
73 |
} |
|
74 |
|
|
75 |
/* (non-Javadoc) |
|
76 |
* @see org.eclipse.ui.IEditorInput#getName() |
|
77 |
*/ |
|
78 |
@Override |
|
79 |
public String getName() { |
|
80 |
return corpus.getName(); |
|
81 |
} |
|
82 |
|
|
83 |
/* (non-Javadoc) |
|
84 |
* @see org.eclipse.ui.IEditorInput#getPersistable() |
|
85 |
*/ |
|
86 |
@Override |
|
87 |
public IPersistableElement getPersistable() { |
|
88 |
return null; |
|
89 |
} |
|
90 |
|
|
91 |
/* (non-Javadoc) |
|
92 |
* @see org.eclipse.ui.IEditorInput#getToolTipText() |
|
93 |
*/ |
|
94 |
@Override |
|
95 |
public String getToolTipText() { |
|
96 |
return getName(); |
|
97 |
} |
|
98 |
|
|
99 |
/* (non-Javadoc) |
|
100 |
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) |
|
101 |
*/ |
|
102 |
@Override |
|
103 |
public Object getAdapter(Class adapter) { |
|
104 |
return null; |
|
105 |
} |
|
106 |
|
|
107 |
/** |
|
108 |
* Gets the corpus. |
|
109 |
* |
|
110 |
* @return the corpus |
|
111 |
*/ |
|
112 |
public Corpus getCorpus() { |
|
113 |
return corpus; |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* Gets the concordance. |
|
118 |
* |
|
119 |
* @return the concordance |
|
120 |
*/ |
|
121 |
public Concordance getConcordance() { |
|
122 |
return concordance; |
|
123 |
} |
|
124 |
|
|
125 |
/* (non-Javadoc) |
|
126 |
* @see org.eclipse.ui.IEditorInput#exists() |
|
127 |
*/ |
|
128 |
@Override |
|
129 |
public boolean exists() { |
|
130 |
return false; |
|
131 |
} |
|
132 |
|
|
133 |
public void setCorpus(Corpus newCorpus) { |
|
134 |
this.corpus = newCorpus; |
|
135 |
} |
|
136 |
|
|
137 |
public void setConcordance(Concordance conc) { |
|
138 |
this.concordance = conc; |
|
139 |
} |
|
140 |
|
|
141 |
@Override |
|
142 |
public boolean equals(Object obj) { |
|
143 |
if(obj instanceof ConcordancesEditorInput) { |
|
144 |
return this.concordance == ((ConcordancesEditorInput) obj).getConcordance() |
|
145 |
&& (this.concordance != null && ((ConcordancesEditorInput) obj).getConcordance() != null && this.concordance.getQuery() == ((ConcordancesEditorInput) obj).getConcordance().getQuery()); |
|
146 |
} |
|
147 |
return false; |
|
148 |
} |
|
149 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/internal/InternalViewEditor.java (revision 368) | ||
---|---|---|
1 | 1 |
package org.txm.rcp.editors.internal; |
2 | 2 |
|
3 | 3 |
import java.util.ArrayList; |
4 |
import java.util.Arrays; |
|
5 | 4 |
import java.util.HashMap; |
6 | 5 |
import java.util.HashSet; |
7 | 6 |
import java.util.List; |
... | ... | |
15 | 14 |
import org.eclipse.jface.viewers.TableViewer; |
16 | 15 |
import org.eclipse.jface.viewers.TableViewerColumn; |
17 | 16 |
import org.eclipse.jface.viewers.Viewer; |
18 |
import org.eclipse.jface.window.Window; |
|
19 | 17 |
import org.eclipse.osgi.util.NLS; |
20 | 18 |
import org.eclipse.swt.SWT; |
21 | 19 |
import org.eclipse.swt.events.KeyEvent; |
... | ... | |
39 | 37 |
import org.eclipse.ui.PartInitException; |
40 | 38 |
import org.eclipse.ui.part.EditorPart; |
41 | 39 |
import org.txm.Toolbox; |
42 |
import org.txm.concordances.functions.Line; |
|
40 |
import org.txm.concordance.core.functions.Line; |
|
41 |
import org.txm.concordance.rcp.editors.ConcordanceEditor; |
|
42 |
import org.txm.concordance.rcp.editors.ConcordanceEditorInput; |
|
43 | 43 |
import org.txm.functions.internal.InternalView; |
44 | 44 |
import org.txm.index.rcp.editors.IndexEditor; |
45 | 45 |
import org.txm.index.rcp.editors.IndexEditorInput; |
46 |
import org.txm.progression.rcp.dialogs.ProgressionDialog; |
|
47 |
import org.txm.progression.rcp.handlers.ComputeProgression; |
|
48 | 46 |
import org.txm.rcp.IImageKeys; |
49 | 47 |
import org.txm.rcp.JobsTimer; |
50 | 48 |
import org.txm.rcp.Messages; |
51 | 49 |
import org.txm.rcp.commands.editor.CustomizableEditor; |
52 | 50 |
import org.txm.rcp.editors.TableKeyListener; |
53 |
import org.txm.rcp.editors.concordances.ConcordancesEditor; |
|
54 |
import org.txm.rcp.editors.input.ConcordancesEditorInput; |
|
55 | 51 |
import org.txm.rcp.editors.input.InternalViewEditorInput; |
56 | 52 |
import org.txm.rcp.swt.widget.NavigationWidget; |
57 | 53 |
import org.txm.rcp.swt.widget.PropertiesSelector; |
... | ... | |
690 | 686 |
String query = buildQuery(); |
691 | 687 |
if (query == null) return null; |
692 | 688 |
|
693 |
ConcordancesEditorInput editorInput = new ConcordancesEditorInput(corpus, null);
|
|
689 |
ConcordanceEditorInput editorInput = new ConcordanceEditorInput(corpus, null);
|
|
694 | 690 |
IWorkbenchPage page = this.getSite().getPage(); |
695 | 691 |
try { |
696 |
ConcordancesEditor conceditor = (ConcordancesEditor) page |
|
697 |
.openEditor(editorInput, |
|
698 |
"org.txm.rcp.editors.ConcordancesEditor"); //$NON-NLS-1$ |
|
692 |
ConcordanceEditor conceditor = (ConcordanceEditor) page |
|
693 |
.openEditor(editorInput, "ConcordanceEditor"); //$NON-NLS-1$ |
|
699 | 694 |
conceditor.setQuery(query); |
700 | 695 |
conceditor.compute(); |
701 | 696 |
return conceditor; |
... | ... | |
717 | 712 |
.openEditor(editorInput, |
718 | 713 |
"org.txm.rcp.editors.index.IndexEditor"); //$NON-NLS-1$ |
719 | 714 |
voceditor.setFocus(query); |
720 |
voceditor.compute(); |
|
715 |
voceditor.computeResult();
|
|
721 | 716 |
return voceditor; |
722 | 717 |
} catch (PartInitException e) { |
723 | 718 |
System.err.println(NLS.bind(Messages.GetConcordances_4, e)); |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/ViewPropertySelectionDialog.java (revision 368) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.rcp.swt.dialog; |
|
29 |
|
|
30 |
import java.util.List; |
|
31 |
|
|
32 |
import org.eclipse.jface.dialogs.Dialog; |
|
33 |
import org.eclipse.jface.window.IShellProvider; |
|
34 |
import org.eclipse.swt.SWT; |
|
35 |
import org.eclipse.swt.events.MouseAdapter; |
|
36 |
import org.eclipse.swt.events.MouseEvent; |
|
37 |
import org.eclipse.swt.events.SelectionAdapter; |
|
38 |
import org.eclipse.swt.events.SelectionEvent; |
|
39 |
import org.eclipse.swt.layout.GridData; |
|
40 |
import org.eclipse.swt.layout.GridLayout; |
|
41 |
import org.eclipse.swt.widgets.Button; |
|
42 |
import org.eclipse.swt.widgets.Composite; |
|
43 |
import org.eclipse.swt.widgets.Control; |
|
44 |
import org.eclipse.swt.widgets.Shell; |
|
45 |
import org.txm.rcp.Messages; |
|
46 |
import org.txm.searchengine.cqp.corpus.Property; |
|
47 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
|
48 |
|
|
49 |
// TODO: Auto-generated Javadoc |
|
50 |
/** |
|
51 |
* the dialog box called to select the view properties @ author mdecorde. |
|
52 |
*/ |
|
53 |
public class ViewPropertySelectionDialog extends Dialog { |
|
54 |
|
|
55 |
/** The available properties. */ |
|
56 |
final private List<Property> availableProperties; |
|
57 |
|
|
58 |
/** The selected properties. */ |
|
59 |
final private List<Property> selectedProperties; |
|
60 |
|
|
61 |
/** The maxprops. */ |
|
62 |
int maxprops = -1; |
|
63 |
|
|
64 |
/** The available properties view. */ |
|
65 |
org.eclipse.swt.widgets.List availablePropertiesView; |
|
66 |
|
|
67 |
/** The selected properties view. */ |
|
68 |
org.eclipse.swt.widgets.List selectedPropertiesView; |
|
69 |
|
|
70 |
/** |
|
71 |
* Instantiates a new view property selection dialog. |
|
72 |
* |
|
73 |
* @param parentShell the parent shell |
|
74 |
* @param availableProperties the available properties |
|
75 |
* @param selectedProperties the selected properties |
|
76 |
*/ |
|
77 |
public ViewPropertySelectionDialog(IShellProvider parentShell, |
|
78 |
List<Property> availableProperties, |
|
79 |
List<Property> selectedProperties) { |
|
80 |
super(parentShell); |
|
81 |
|
|
82 |
this.availableProperties = availableProperties; |
|
83 |
this.selectedProperties = selectedProperties; |
|
84 |
this.setShellStyle(this.getShellStyle() | SWT.RESIZE); |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* Instantiates a new view property selection dialog. |
|
89 |
* |
|
90 |
* @param shell the shell |
|
91 |
* @param availableProperties the available properties |
|
92 |
* @param selectedProperties the selected properties |
|
93 |
*/ |
|
94 |
public ViewPropertySelectionDialog(Shell shell, |
|
95 |
List<Property> availableProperties, |
|
96 |
List<Property> selectedProperties) { |
|
97 |
super(shell); |
|
98 |
|
|
99 |
this.availableProperties = availableProperties; |
|
100 |
this.selectedProperties = selectedProperties; |
|
101 |
this.setShellStyle(this.getShellStyle() | SWT.RESIZE); |
|
102 |
} |
|
103 |
|
|
104 |
/** |
|
105 |
* Instantiates a new view property selection dialog. |
|
106 |
* |
|
107 |
* @param shell the shell |
|
108 |
* @param availableProperties the available properties |
|
109 |
* @param selectedProperties the selected properties |
|
110 |
* @param maxprops the maxprops |
|
111 |
*/ |
|
112 |
public ViewPropertySelectionDialog(Shell shell, |
|
113 |
List<Property> availableProperties, |
|
114 |
List<Property> selectedProperties, int maxprops) { |
|
115 |
super(shell); |
|
116 |
|
|
117 |
this.availableProperties = availableProperties; |
|
118 |
this.selectedProperties = selectedProperties; |
|
119 |
this.setShellStyle(this.getShellStyle() | SWT.RESIZE); |
|
120 |
this.maxprops = maxprops; |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* Gets the selected properties. |
|
125 |
* |
|
126 |
* @return the selected properties |
|
127 |
*/ |
|
128 |
public List<Property> getSelectedProperties() { |
|
129 |
return selectedProperties; |
|
130 |
} |
|
131 |
|
|
132 |
/* (non-Javadoc) |
|
133 |
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) |
|
134 |
*/ |
|
135 |
@Override |
|
136 |
protected void configureShell(Shell newShell) { |
|
137 |
super.configureShell(newShell); |
|
138 |
newShell.setText(Messages.ViewPropertySelectionDialog_0); |
|
139 |
newShell.setMinimumSize(300, 200); |
|
140 |
} |
|
141 |
|
|
142 |
/* (non-Javadoc) |
|
143 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
|
144 |
*/ |
|
145 |
@Override |
|
146 |
protected Control createDialogArea(Composite parent) { |
|
147 |
// parent.setLayout(new FormLayout()); |
|
148 |
Composite mainArea = new Composite(parent, SWT.NONE); |
|
149 |
mainArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
|
150 |
|
|
151 |
// 4 columns |
|
152 |
GridLayout layout = new GridLayout(4, false); |
|
153 |
mainArea.setLayout(layout); |
|
154 |
|
|
155 |
availablePropertiesView = new org.eclipse.swt.widgets.List(mainArea, |
|
156 |
SWT.BORDER | SWT.V_SCROLL); |
|
157 |
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); |
|
158 |
availablePropertiesView.setLayoutData(gridData); |
|
159 |
|
|
160 |
Composite selectionButtons = new Composite(mainArea, SWT.NONE); |
|
161 |
selectionButtons.setLayout(new GridLayout(1, false)); |
|
162 |
Button select = new Button(selectionButtons, SWT.ARROW | SWT.RIGHT); |
|
163 |
Button unselect = new Button(selectionButtons, SWT.ARROW | SWT.LEFT); |
|
164 |
|
|
165 |
selectedPropertiesView = new org.eclipse.swt.widgets.List(mainArea, |
|
166 |
SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); |
|
167 |
gridData = new GridData(SWT.FILL, SWT.FILL, true, true); |
|
168 |
selectedPropertiesView.setLayoutData(gridData); |
|
169 |
|
|
170 |
Composite orderButtons = new Composite(mainArea, SWT.NONE); |
|
171 |
orderButtons.setLayout(new GridLayout(1, false)); |
|
172 |
Button up = new Button(orderButtons, SWT.ARROW | SWT.UP); |
|
173 |
Button down = new Button(orderButtons, SWT.ARROW | SWT.DOWN); |
|
174 |
|
|
175 |
select.addSelectionListener(new SelectionAdapter() { |
|
176 |
@Override |
|
177 |
public void widgetSelected(SelectionEvent e) { |
|
178 |
int index = availablePropertiesView.getSelectionIndex(); |
|
179 |
if (maxprops == 1) { |
|
180 |
selectedProperties.add(availableProperties.get(index)); |
|
181 |
availableProperties.remove(index); |
|
182 |
|
|
183 |
availableProperties.add(selectedProperties.get(0)); |
|
184 |
selectedProperties.remove(0); |
|
185 |
} else { |
|
186 |
if (maxprops > 0) { |
|
187 |
if (selectedProperties.size() >= maxprops) |
|
188 |
return; |
|
189 |
} |
|
190 |
if (index >= 0) { |
|
191 |
selectedProperties.add(availableProperties.get(index)); |
|
192 |
availableProperties.remove(index); |
|
193 |
} |
|
194 |
} |
|
195 |
reload(); |
|
196 |
availablePropertiesView.setSelection(index); |
|
197 |
} |
|
198 |
}); |
|
199 |
|
|
200 |
unselect.addSelectionListener(new SelectionAdapter() { |
|
201 |
@Override |
|
202 |
public void widgetSelected(SelectionEvent e) { |
|
203 |
deselectProperties(); |
|
204 |
} |
|
205 |
}); |
|
206 |
|
|
207 |
up.addSelectionListener(new SelectionAdapter() { |
|
208 |
@Override |
|
209 |
public void widgetSelected(SelectionEvent e) { |
|
210 |
int index = selectedPropertiesView.getSelectionIndex(); |
|
211 |
if (index > 0) { |
|
212 |
Property selectedP = selectedProperties.get(index); |
|
213 |
Property upperP = selectedProperties.get(index - 1); |
|
214 |
|
|
215 |
selectedProperties.set(index, upperP); |
|
216 |
selectedProperties.set(index - 1, selectedP); |
|
217 |
|
|
218 |
reload(); |
|
219 |
selectedPropertiesView.setSelection(index - 1); |
|
220 |
} |
|
221 |
} |
|
222 |
}); |
|
223 |
|
|
224 |
down.addSelectionListener(new SelectionAdapter() { |
|
225 |
@Override |
|
226 |
public void widgetSelected(SelectionEvent e) { |
|
227 |
int index = selectedPropertiesView.getSelectionIndex(); |
|
228 |
if (index < selectedProperties.size() - 1 && index >= 0) { |
|
229 |
Property selectedP = selectedProperties.get(index); |
|
230 |
Property bellowP = selectedProperties.get(index + 1); |
|
231 |
|
|
232 |
selectedProperties.set(index, bellowP); |
|
233 |
selectedProperties.set(index + 1, selectedP); |
|
234 |
|
|
235 |
reload(); |
|
236 |
selectedPropertiesView.setSelection(index + 1); |
|
237 |
} |
|
238 |
} |
|
239 |
}); |
|
240 |
|
|
241 |
availablePropertiesView.addMouseListener(new MouseAdapter() { |
|
242 |
@Override |
|
243 |
public void mouseDoubleClick(MouseEvent e) { |
|
244 |
|
|
245 |
if ( maxprops == 1) { |
|
246 |
int index = availablePropertiesView.getSelectionIndex(); |
|
247 |
//System.out.println("dl click, maxprops="+maxprops+" idx="+index); |
|
248 |
selectedProperties.add(availableProperties.get(index)); |
|
249 |
availableProperties.remove(index); |
|
250 |
|
|
251 |
availableProperties.add(selectedProperties.get(0)); |
|
252 |
selectedProperties.remove(0); |
|
253 |
|
|
254 |
reload(); |
|
255 |
|
|
256 |
} else { |
|
257 |
int index = availablePropertiesView.getSelectionIndex(); |
|
258 |
if (index >= 0) { |
|
259 |
selectedProperties.add(availableProperties.get(index)); |
|
260 |
availableProperties.remove(index); |
|
261 |
|
|
262 |
reload(); |
|
263 |
availablePropertiesView.setSelection(index); |
|
264 |
} |
|
265 |
} |
|
266 |
} |
|
267 |
}); |
|
268 |
|
|
269 |
selectedPropertiesView.addMouseListener(new MouseAdapter() { |
|
270 |
@Override |
|
271 |
public void mouseDoubleClick(MouseEvent e) { |
|
272 |
deselectProperties(); |
|
273 |
} |
|
274 |
}); |
|
275 |
|
|
276 |
reload(); |
|
277 |
return mainArea; |
|
278 |
} |
|
279 |
|
|
280 |
private void deselectProperties() { |
|
281 |
if (selectedProperties.size() > 1) { |
|
282 |
int index = selectedPropertiesView.getSelectionIndex(); |
|
283 |
|
|
284 |
availableProperties.add(selectedProperties.get(index)); |
|
285 |
selectedProperties.remove(index); |
|
286 |
|
|
287 |
reload(); |
|
288 |
selectedPropertiesView.setSelection(index); |
|
289 |
} |
|
290 |
} |
|
291 |
|
|
292 |
/** |
|
293 |
* Reload. |
|
294 |
*/ |
|
295 |
public void reload() { |
|
296 |
if (availableProperties == null) { |
|
297 |
System.out.println("Error: the available properties list is NULL."); |
|
298 |
return; |
|
299 |
} |
|
300 |
availablePropertiesView.removeAll(); |
|
301 |
for (Property property : availableProperties) { |
|
302 |
//if (!property.getName().equals("id")) //$NON-NLS-1$ |
|
303 |
if (property instanceof StructuralUnitProperty) |
|
304 |
availablePropertiesView.add(((StructuralUnitProperty)property).getFullName()); |
|
305 |
else |
|
306 |
availablePropertiesView.add(property.getName()); |
|
307 |
} |
|
308 |
selectedPropertiesView.removeAll(); |
|
309 |
for (Property property : selectedProperties) { |
|
310 |
//if (!property.getName().equals("id")) //$NON-NLS-1$ |
|
311 |
if (property instanceof StructuralUnitProperty) |
|
312 |
selectedPropertiesView.add(((StructuralUnitProperty)property).getFullName()); |
|
313 |
else |
|
314 |
selectedPropertiesView.add(property.getName()); |
|
315 |
} |
|
316 |
|
|
317 |
availablePropertiesView.getParent().layout(); |
|
318 |
} |
|
319 |
|
|
320 |
/* (non-Javadoc) |
|
321 |
* @see org.eclipse.jface.dialogs.Dialog#okPressed() |
|
322 |
*/ |
|
323 |
@Override |
|
324 |
protected void okPressed() { |
|
325 |
if (selectedProperties.size() != 0) |
|
326 |
super.okPressed(); |
|
327 |
} |
|
328 |
|
|
329 |
} |
|
0 | 330 |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/ComplexSortSelector.java (revision 368) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate:$ |
|
25 |
// $LastChangedRevision:$ |
|
26 |
// $LastChangedBy:$ |
|
27 |
// |
|
28 |
package org.txm.rcp.swt.widget; |
|
29 |
|
|
30 |
import java.util.ArrayList; |
|
31 |
import java.util.HashMap; |
|
32 |
import java.util.List; |
|
33 |
|
|
34 |
import org.eclipse.osgi.util.NLS; |
|
35 |
import org.eclipse.swt.SWT; |
|
36 |
import org.eclipse.swt.events.SelectionEvent; |
|
37 |
import org.eclipse.swt.events.SelectionListener; |
|
38 |
import org.eclipse.swt.layout.GridData; |
|
39 |
import org.eclipse.swt.layout.GridLayout; |
|
40 |
import org.eclipse.swt.widgets.Button; |
|
41 |
import org.eclipse.swt.widgets.Combo; |
|
42 |
import org.eclipse.swt.widgets.Composite; |
|
43 |
import org.eclipse.swt.widgets.Label; |
|
44 |
import org.txm.concordances.functions.comparators.CompositeComparator; |
|
45 |
import org.txm.concordances.functions.comparators.LineComparator; |
|
46 |
import org.txm.rcp.Messages; |
|
47 |
import org.txm.rcp.editors.concordances.ConcordancesEditor; |
|
48 |
import org.txm.rcp.utils.Logger; |
|
49 |
// TODO: Auto-generated Javadoc |
|
50 |
/** |
|
51 |
* allow to build a Composite sorter of 1 to 4 keys @ author mdecorde. |
|
52 |
*/ |
|
53 |
public class ComplexSortSelector extends Composite { |
|
54 |
|
|
55 |
/** The standard comparators. */ |
|
56 |
HashMap<String, LineComparator> standardComparators = new HashMap<String, LineComparator>(); |
|
57 |
|
|
58 |
/** The comparators names. */ |
|
59 |
List<String> comparatorsNames; |
|
60 |
|
|
61 |
/** The editor. */ |
|
62 |
ConcordancesEditor editor; |
|
63 |
|
|
64 |
/** The default comparator. */ |
|
65 |
CompositeComparator defaultComparator; |
|
66 |
|
|
67 |
/** The first key. */ |
|
68 |
Combo firstKey; |
|
69 |
|
|
70 |
/** The second key. */ |
|
71 |
Combo secondKey; |
|
72 |
|
|
73 |
/** The third key. */ |
|
74 |
Combo thirdKey; |
|
75 |
|
|
76 |
/** The fourth key. */ |
|
77 |
Combo fourthKey; |
|
78 |
|
|
79 |
/** |
|
80 |
* Instantiates a new complex sort selector. |
|
81 |
* |
|
82 |
* @param parent the parent |
|
83 |
* @param style the style |
|
84 |
*/ |
|
85 |
public ComplexSortSelector(Composite parent, int style) { |
|
86 |
super(parent, style); |
|
87 |
GridLayout gl = new GridLayout(10, false); |
|
88 |
gl.marginWidth = 0; |
|
89 |
gl.marginLeft = 0; |
|
90 |
gl.marginRight = 0; |
|
91 |
this.setLayout(gl); |
|
92 |
|
|
93 |
SelectionListener listener = new SelectionListener() { |
|
94 |
@Override |
|
95 |
public void widgetSelected(SelectionEvent e) { |
|
96 |
updateDefaultComparator(); |
|
97 |
} |
|
98 |
|
|
99 |
@Override |
|
100 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
101 |
} |
|
102 |
}; |
|
103 |
new Label(this, SWT.NONE).setText(Messages.ComplexSortSelector_0); |
|
104 |
new Label(this, SWT.NONE).setText("#1"); //$NON-NLS-1$ |
|
105 |
firstKey = new Combo(this, SWT.NONE | SWT.READ_ONLY); |
|
106 |
//firstKey.addSelectionListener(listener); |
|
107 |
GridData griddata = new GridData(GridData.FILL, GridData.FILL, false, |
|
108 |
true); |
|
109 |
griddata.widthHint = 100; |
|
110 |
firstKey.setLayoutData(griddata); |
|
111 |
|
|
112 |
new Label(this, SWT.NONE).setText("#2"); //$NON-NLS-1$ |
|
113 |
secondKey = new Combo(this, SWT.NONE | SWT.READ_ONLY); |
|
114 |
//secondKey.addSelectionListener(listener); |
|
115 |
secondKey.setLayoutData(griddata); |
|
116 |
|
|
117 |
new Label(this, SWT.NONE).setText("#3"); //$NON-NLS-1$ |
|
118 |
thirdKey = new Combo(this, SWT.NONE | SWT.READ_ONLY); |
|
119 |
//thirdKey.addSelectionListener(listener); |
|
120 |
thirdKey.setLayoutData(griddata); |
|
121 |
|
|
122 |
new Label(this, SWT.NONE).setText("#4"); //$NON-NLS-1$ |
|
123 |
fourthKey = new Combo(this, SWT.NONE | SWT.READ_ONLY); |
|
124 |
//fourthKey.addSelectionListener(listener); |
|
125 |
fourthKey.setLayoutData(griddata); |
|
126 |
|
|
127 |
Button sortButton = new Button(this, SWT.PUSH); |
|
128 |
sortButton.setText(Messages.ComplexSortSelector_2); |
|
129 |
sortButton.addSelectionListener(listener); |
|
130 |
|
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* Update default comparator. |
|
135 |
*/ |
|
136 |
public void updateDefaultComparator() { |
|
137 |
try { |
|
138 |
ArrayList<LineComparator> comp = new ArrayList<LineComparator>(); |
|
139 |
comp.add(standardComparators.get(firstKey.getText())); |
|
140 |
comp.add(standardComparators.get(secondKey.getText())); |
|
141 |
comp.add(standardComparators.get(thirdKey.getText())); |
|
142 |
comp.add(standardComparators.get(fourthKey.getText())); |
|
143 |
defaultComparator.setComparators(comp); |
|
144 |
System.out.println(Messages.ComplexSortSelector_1+comp); |
|
145 |
editor.resetSortedColumn(firstKey.getSelectionIndex()); |
|
146 |
editor.setCurrentComparator(defaultComparator); |
|
147 |
editor.sort(); |
|
148 |
} catch (Exception e) { |
|
149 |
System.err.println(NLS.bind(Messages.ComplexSortSelector_5, e)); |
|
150 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
151 |
} |
|
152 |
} |
|
153 |
|
|
154 |
/** |
|
155 |
* Sets the key. |
|
156 |
* |
|
157 |
* @param no the new key |
|
158 |
*/ |
|
159 |
public void setKey(int no) |
|
160 |
{ |
|
161 |
firstKey.select(no); |
|
162 |
secondKey.select(0); |
|
163 |
thirdKey.select(0); |
|
164 |
fourthKey.select(0); |
|
165 |
|
|
166 |
} |
|
167 |
|
|
168 |
/** |
|
169 |
* Sets the comparators. |
|
170 |
* |
|
171 |
* @param editor the new comparators |
|
172 |
*/ |
|
173 |
public void setComparators(ConcordancesEditor editor) { |
|
174 |
this.editor = editor; |
|
175 |
|
|
176 |
List<LineComparator> standardComparatorslist = editor |
|
177 |
.getStandardComparators(); |
|
178 |
comparatorsNames = new ArrayList<String>(standardComparatorslist.size()); |
|
179 |
String[] tcomparatorsNames = new String[standardComparatorslist.size()]; |
|
180 |
for (int i = 0; i < standardComparatorslist.size(); i++) { |
|
181 |
LineComparator comparator = standardComparatorslist.get(i); |
|
182 |
comparatorsNames.add(comparator.getName()); |
|
183 |
tcomparatorsNames[i] = comparator.getName(); |
|
184 |
this.standardComparators.put(comparator.getName(), comparator); |
|
185 |
} |
|
186 |
|
|
187 |
firstKey.setItems(tcomparatorsNames); |
|
188 |
secondKey.setItems(tcomparatorsNames); |
|
189 |
thirdKey.setItems(tcomparatorsNames); |
|
190 |
fourthKey.setItems(tcomparatorsNames); |
|
191 |
|
|
192 |
List<LineComparator> userDefinedComparators = editor |
|
193 |
.getUserDefinedComparators(); |
|
194 |
for (LineComparator c : userDefinedComparators) { |
|
195 |
if (c.getName().equals(Messages.ComplexSortSelector_6)) { |
|
196 |
defaultComparator = (CompositeComparator) c; |
|
197 |
List<LineComparator> comp = defaultComparator.getComparators(); |
|
198 |
if (comp.size() >= 4) { |
|
199 |
firstKey.select(comparatorsNames.indexOf(comp.get(0))); |
|
200 |
secondKey.select(comparatorsNames.indexOf(comp.get(1))); |
|
201 |
thirdKey.select(comparatorsNames.indexOf(comp.get(2))); |
|
202 |
fourthKey.select(comparatorsNames.indexOf(comp.get(3))); |
|
203 |
} else if (comp.size() >= 3) { |
|
204 |
firstKey.select(comparatorsNames.indexOf(comp.get(0))); |
|
205 |
secondKey.select(comparatorsNames.indexOf(comp.get(1))); |
|
206 |
thirdKey.select(comparatorsNames.indexOf(comp.get(2))); |
|
207 |
fourthKey.select(comparatorsNames.indexOf(comp.get(2))); |
|
208 |
} else if (comp.size() == 2) { |
|
209 |
firstKey.select(comparatorsNames.indexOf(comp.get(0))); |
|
210 |
secondKey.select(comparatorsNames.indexOf(comp.get(1))); |
|
211 |
thirdKey.select(comparatorsNames.indexOf(comp.get(1))); |
|
212 |
fourthKey.select(comparatorsNames.indexOf(comp.get(1))); |
|
213 |
} else if (comp.size() == 1) { |
|
214 |
firstKey.select(comparatorsNames.indexOf(comp.get(0))); |
|
215 |
secondKey.select(comparatorsNames.indexOf(comp.get(0))); |
|
216 |
thirdKey.select(comparatorsNames.indexOf(comp.get(0))); |
|
217 |
fourthKey.select(comparatorsNames.indexOf(comp.get(0))); |
|
218 |
} |
|
219 |
return; |
|
220 |
} |
|
221 |
} |
|
222 |
|
|
223 |
// no default comparator found -> create one |
|
224 |
defaultComparator = new CompositeComparator( |
|
225 |
Messages.ComplexSortSelector_6, standardComparatorslist); |
|
226 |
firstKey.select(0); |
|
227 |
secondKey.select(0); |
|
228 |
thirdKey.select(0); |
|
229 |
fourthKey.select(0); |
|
230 |
editor.getUserDefinedComparators().add(defaultComparator); |
|
231 |
editor.setCurrentComparator(defaultComparator); |
|
232 |
editor.sort(); |
|
233 |
} |
|
234 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/PropertiesSelector.java (revision 368) | ||
---|---|---|
40 | 40 |
import org.eclipse.swt.widgets.Label; |
41 | 41 |
import org.eclipse.swt.widgets.Listener; |
42 | 42 |
import org.txm.rcp.Messages; |
43 |
import org.txm.rcp.editors.concordances.ViewPropertySelectionDialog;
|
|
43 |
import org.txm.rcp.swt.dialog.ViewPropertySelectionDialog;
|
|
44 | 44 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
45 | 45 |
import org.txm.searchengine.cqp.corpus.Corpus; |
46 | 46 |
import org.txm.searchengine.cqp.corpus.Property; |
Formats disponibles : Unified diff