1 |
1 |
package eu.etaxonomy.taxeditor.preference;
|
2 |
2 |
|
3 |
|
import java.io.IOException;
|
4 |
|
|
5 |
3 |
import org.eclipse.jface.dialogs.MessageDialog;
|
6 |
4 |
import org.eclipse.jface.preference.PreferencePage;
|
7 |
|
import org.eclipse.jface.resource.ImageDescriptor;
|
8 |
|
import org.eclipse.jface.viewers.ArrayContentProvider;
|
9 |
|
import org.eclipse.jface.viewers.LabelProvider;
|
10 |
5 |
import org.eclipse.swt.SWT;
|
11 |
6 |
import org.eclipse.swt.events.SelectionAdapter;
|
12 |
7 |
import org.eclipse.swt.events.SelectionEvent;
|
13 |
|
import org.eclipse.swt.graphics.Image;
|
14 |
|
import org.eclipse.swt.graphics.Point;
|
15 |
8 |
import org.eclipse.swt.layout.GridLayout;
|
16 |
9 |
import org.eclipse.swt.widgets.Button;
|
17 |
10 |
import org.eclipse.swt.widgets.Composite;
|
... | ... | |
19 |
12 |
import org.eclipse.swt.widgets.Label;
|
20 |
13 |
import org.eclipse.ui.IWorkbench;
|
21 |
14 |
import org.eclipse.ui.IWorkbenchPreferencePage;
|
22 |
|
import org.eclipse.ui.PlatformUI;
|
23 |
|
import org.eclipse.ui.dialogs.ListSelectionDialog;
|
24 |
15 |
|
25 |
16 |
import eu.etaxonomy.taxeditor.Messages;
|
26 |
17 |
|
27 |
18 |
public class OrderPreferences extends PreferencePage implements IWorkbenchPreferencePage {
|
28 |
|
|
|
19 |
|
29 |
20 |
|
30 |
21 |
boolean isNaturalOrderActivated;
|
31 |
22 |
boolean isAlphabeticalOrderActivated;
|
32 |
23 |
boolean isRankAndNameOrderActivated;
|
|
24 |
boolean isRestoreTaxonNavigator;
|
33 |
25 |
boolean isSelectionChanged = false;
|
34 |
26 |
boolean isStrictlyAlphabeticallyOrdered;
|
35 |
27 |
/*
|
... | ... | |
42 |
34 |
@Override
|
43 |
35 |
protected Control createContents(Composite parent) {
|
44 |
36 |
|
45 |
|
Composite composite = new Composite(parent, SWT.NULL);
|
|
37 |
isRestoreTaxonNavigator = PreferencesUtil.isRestoreNavigator();
|
|
38 |
|
|
39 |
Composite secondComposite = new Composite(parent, SWT.NULL);
|
|
40 |
secondComposite.setLayout(new GridLayout());
|
|
41 |
|
|
42 |
final Button activateRestoreNavigatorButton = new Button(secondComposite, SWT.CHECK | SWT.LEFT);
|
|
43 |
activateRestoreNavigatorButton.setText("Restore the last Taxon Navigator state.");
|
|
44 |
activateRestoreNavigatorButton.setSelection(isRestoreTaxonNavigator);
|
|
45 |
activateRestoreNavigatorButton.addSelectionListener(new SelectionAdapter(){
|
|
46 |
@Override
|
|
47 |
public void widgetSelected(SelectionEvent e) {
|
|
48 |
if(isRestoreTaxonNavigator != activateRestoreNavigatorButton.getSelection()) {
|
|
49 |
isRestoreTaxonNavigator = activateRestoreNavigatorButton.getSelection();
|
|
50 |
PreferencesUtil.setRestoreNavigator(isRestoreTaxonNavigator);
|
|
51 |
}
|
|
52 |
}
|
|
53 |
|
|
54 |
});
|
|
55 |
|
|
56 |
|
|
57 |
Composite composite = new Composite(parent, SWT.NULL);
|
46 |
58 |
composite.setLayout(new GridLayout());
|
47 |
|
final Label description = new Label(parent, SWT.NONE);
|
48 |
|
description.setText(Messages.OrderPreferencePage_NewNavigatorWindowRequired);
|
|
59 |
|
49 |
60 |
isNaturalOrderActivated = PreferencesUtil.getSortNodesNaturally();
|
50 |
61 |
final Button activateNaturalOrderCheckButton = new Button(composite, SWT.RADIO);
|
51 |
62 |
activateNaturalOrderCheckButton.setText("Enable Natural Order");
|
52 |
63 |
activateNaturalOrderCheckButton.setSelection(isNaturalOrderActivated);
|
53 |
|
|
|
64 |
|
54 |
65 |
isRankAndNameOrderActivated = !PreferencesUtil.getSortNodesStrictlyAlphabetically() && !PreferencesUtil.getSortNodesNaturally();
|
55 |
66 |
final Button activateRankAndNameOrderActivatedCheckButton = new Button(composite, SWT.RADIO);
|
56 |
67 |
activateRankAndNameOrderActivatedCheckButton.setText("Enable Rank and Aplhabetical Order");
|
57 |
68 |
activateRankAndNameOrderActivatedCheckButton.setSelection(isRankAndNameOrderActivated);
|
58 |
|
|
|
69 |
|
59 |
70 |
isAlphabeticalOrderActivated = PreferencesUtil.getSortNodesStrictlyAlphabetically();
|
60 |
71 |
final Button activateAlphabeticallyOrderedCheckButton = new Button(composite, SWT.RADIO);
|
61 |
72 |
activateAlphabeticallyOrderedCheckButton.setText("Enable Alphabetical Order");
|
62 |
73 |
activateAlphabeticallyOrderedCheckButton.setSelection(isAlphabeticalOrderActivated);
|
63 |
|
|
|
74 |
|
64 |
75 |
activateNaturalOrderCheckButton.addSelectionListener(new SelectionAdapter(){
|
65 |
76 |
@Override
|
66 |
77 |
public void widgetSelected(SelectionEvent e) {
|
... | ... | |
69 |
80 |
if (isAlphabeticalOrderActivated && isNaturalOrderActivated){
|
70 |
81 |
isAlphabeticalOrderActivated = false;
|
71 |
82 |
PreferencesUtil.setSortNodesStrictlyAlphabetically(isAlphabeticalOrderActivated);
|
72 |
|
}
|
|
83 |
}
|
73 |
84 |
if (isRankAndNameOrderActivated && isNaturalOrderActivated){
|
74 |
85 |
isRankAndNameOrderActivated = false;
|
75 |
|
}
|
|
86 |
}
|
76 |
87 |
PreferencesUtil.setSortNodesNaturally(isNaturalOrderActivated);
|
77 |
88 |
isSelectionChanged = true;
|
78 |
89 |
}else{
|
... | ... | |
89 |
100 |
if (isNaturalOrderActivated && isAlphabeticalOrderActivated){
|
90 |
101 |
isNaturalOrderActivated = false;
|
91 |
102 |
PreferencesUtil.setSortNodesNaturally(isNaturalOrderActivated);
|
92 |
|
}
|
|
103 |
}
|
93 |
104 |
if (isRankAndNameOrderActivated && isAlphabeticalOrderActivated){
|
94 |
105 |
isRankAndNameOrderActivated = false;
|
95 |
|
}
|
|
106 |
}
|
96 |
107 |
PreferencesUtil.setSortNodesStrictlyAlphabetically(isAlphabeticalOrderActivated);
|
97 |
108 |
isSelectionChanged = true;
|
98 |
109 |
}else{
|
... | ... | |
101 |
112 |
|
102 |
113 |
}
|
103 |
114 |
});
|
104 |
|
|
|
115 |
|
105 |
116 |
activateRankAndNameOrderActivatedCheckButton.addSelectionListener(new SelectionAdapter(){
|
106 |
117 |
@Override
|
107 |
118 |
public void widgetSelected(SelectionEvent e) {
|
... | ... | |
109 |
120 |
isRankAndNameOrderActivated = activateRankAndNameOrderActivatedCheckButton.getSelection();
|
110 |
121 |
if (isAlphabeticalOrderActivated && isRankAndNameOrderActivated){
|
111 |
122 |
isAlphabeticalOrderActivated = false;
|
112 |
|
}
|
|
123 |
}
|
113 |
124 |
if (isNaturalOrderActivated && isRankAndNameOrderActivated){
|
114 |
125 |
isNaturalOrderActivated = false;
|
115 |
|
}
|
116 |
|
|
|
126 |
}
|
|
127 |
|
117 |
128 |
if (isRankAndNameOrderActivated ||(!isNaturalOrderActivated && !isAlphabeticalOrderActivated)){
|
118 |
129 |
PreferencesUtil.setSortNodesStrictlyAlphabetically(false);
|
119 |
130 |
PreferencesUtil.setSortNodesNaturally(false);
|
... | ... | |
127 |
138 |
});
|
128 |
139 |
|
129 |
140 |
|
130 |
|
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
final Label description = new Label(parent, SWT.NONE);
|
|
145 |
description.setText(Messages.OrderPreferencePage_NewNavigatorWindowRequired);
|
131 |
146 |
|
132 |
147 |
return composite;
|
133 |
148 |
}
|
134 |
149 |
|
135 |
|
|
|
150 |
|
136 |
151 |
@Override
|
137 |
152 |
public void init(IWorkbench workbench) {
|
138 |
153 |
// TODO Auto-generated method stub
|
139 |
|
|
|
154 |
|
140 |
155 |
}
|
141 |
156 |
|
142 |
157 |
/* (non-Javadoc)
|
move restore navigator status to taxonNavigator preferences