1 package eu
.etaxonomy
.taxeditor
.prototype2
.view
;
3 import org
.eclipse
.jface
.action
.IMenuManager
;
4 import org
.eclipse
.jface
.action
.IToolBarManager
;
5 import org
.eclipse
.jface
.viewers
.TableViewer
;
6 import org
.eclipse
.jface
.viewers
.TreeViewer
;
7 import org
.eclipse
.swt
.SWT
;
8 import org
.eclipse
.swt
.events
.FocusEvent
;
9 import org
.eclipse
.swt
.events
.FocusListener
;
10 import org
.eclipse
.swt
.layout
.FillLayout
;
11 import org
.eclipse
.swt
.layout
.GridData
;
12 import org
.eclipse
.swt
.layout
.GridLayout
;
13 import org
.eclipse
.swt
.widgets
.Button
;
14 import org
.eclipse
.swt
.widgets
.Composite
;
15 import org
.eclipse
.swt
.widgets
.Control
;
16 import org
.eclipse
.swt
.widgets
.Display
;
17 import org
.eclipse
.swt
.widgets
.ExpandBar
;
18 import org
.eclipse
.swt
.widgets
.ExpandItem
;
19 import org
.eclipse
.swt
.widgets
.Label
;
20 import org
.eclipse
.swt
.widgets
.Menu
;
21 import org
.eclipse
.swt
.widgets
.MenuItem
;
22 import org
.eclipse
.swt
.widgets
.Text
;
23 import org
.eclipse
.ui
.part
.ViewPart
;
25 import com
.swtdesigner
.ResourceManager
;
26 import com
.swtdesigner
.SWTResourceManager
;
28 import eu
.etaxonomy
.taxeditor
.prototype2
.Activator
;
34 public class NameListView
extends ViewPart
{
36 private Text searchText
;
37 private Composite composite
;
38 private Composite taxTreeComposite
= null;
39 private Composite recentNamesComposite
= null;
40 private Composite searchComposite
= null;
41 private Composite top
= null;
42 private ExpandBar expandBar
= null;
43 private ExpandItem taxTreeExpandItem
;
44 private ExpandItem recentNamesExpandItem
;
45 private ExpandItem searchExpandItem
;
46 private TableViewer recentNamesViewer
;
47 public static final String ID
= "eu.etaxonomy.taxeditor.prototype2.view.namelistview"; //$NON-NLS-1$
49 private TreeViewer treeViewer
;
52 * Create contents of the view part
56 public void createPartControl(Composite parent
) {
58 parent
.setLayout(new FillLayout());
59 GridLayout gridLayout
= new GridLayout();
60 gridLayout
.horizontalSpacing
= 0;
61 gridLayout
.marginWidth
= 0;
62 gridLayout
.marginHeight
= 0;
63 gridLayout
.verticalSpacing
= 0;
65 top
= new Composite(parent
, SWT
.NONE
);
66 top
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
68 composite
= new Composite(top
, SWT
.NONE
);
69 composite
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
70 final GridLayout gridLayout_1
= new GridLayout();
71 gridLayout_1
.numColumns
= 2;
72 composite
.setLayout(gridLayout_1
);
73 final Label lblDataSourceTitle
= new Label(composite
, SWT
.NONE
);
74 lblDataSourceTitle
.setFont(SWTResourceManager
.getFont("Arial", 14, SWT
.BOLD
));
75 lblDataSourceTitle
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
76 lblDataSourceTitle
.setAlignment(SWT
.CENTER
);
77 lblDataSourceTitle
.setText(" Euro+Med");
79 final Label lblDbImg
= new Label(composite
, SWT
.NONE
);
80 lblDbImg
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
81 lblDbImg
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
82 lblDbImg
.setImage(ResourceManager
.getPluginImage(Activator
.getDefault(), "icons/db.gif"));
84 final Menu menu
= new Menu(lblDbImg
);
85 lblDbImg
.setMenu(menu
);
87 final MenuItem checkboxMenuItem
= new MenuItem(menu
, SWT
.CHECK
);
88 checkboxMenuItem
.setSelection(true);
89 checkboxMenuItem
.setText("Euro+Med (mssql://128.14.101.12:80/europlusmed)");
91 final MenuItem checkboxMenuItem_1
= new MenuItem(menu
, SWT
.CHECK
);
92 checkboxMenuItem_1
.setText("WP6 (mssql://128.14.101.13:80/wp6)");
94 final MenuItem palmWebora1922299480pwMenuItem
= new MenuItem(menu
, SWT
.NONE
);
95 palmWebora1922299480pwMenuItem
.setText("Palm Web (ora://192.22.99.4:80/pw)");
97 new MenuItem(menu
, SWT
.SEPARATOR
);
99 final MenuItem newDataSourceMenuItem
= new MenuItem(menu
, SWT
.NONE
);
100 newDataSourceMenuItem
.setText("New data source ...");
102 final Label lblDataSource
= new Label(composite
, SWT
.NONE
);
103 final GridData gd_lblDataSource
= new GridData(SWT
.LEFT
, SWT
.CENTER
, false, false, 2, 1);
104 gd_lblDataSource
.heightHint
= 16;
105 lblDataSource
.setLayoutData(gd_lblDataSource
);
106 lblDataSource
.setFont(SWTResourceManager
.getFont("Arial", 8, SWT
.NONE
));
107 lblDataSource
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
108 lblDataSource
.setAlignment(SWT
.CENTER
);
109 lblDataSource
.setText(" mssql://128.14.101.12:80/europlusmed");
112 top
.setLayout(gridLayout
);
113 top
.setTabList(new Control
[] {composite
, expandBar
});
117 * This method initializes expandBar
120 private void createExpandBar() {
121 expandBar
= new ExpandBar(top
, SWT
.V_SCROLL
);
122 GridData gridData
= new GridData();
123 gridData
.horizontalAlignment
= GridData
.FILL
;
124 gridData
.grabExcessHorizontalSpace
= true;
125 gridData
.grabExcessVerticalSpace
= true;
126 gridData
.verticalAlignment
= GridData
.FILL
;
127 expandBar
.setLayoutData(gridData
);
128 createNameListComposite();
129 createRecentNamesComposite();
130 createSearchComposite();
138 private void createNameListComposite() {
139 taxTreeExpandItem
= new ExpandItem(expandBar
, SWT
.NONE
, 0);
140 taxTreeExpandItem
.setExpanded(true);
141 taxTreeExpandItem
.setHeight(200);
142 taxTreeExpandItem
.setText("Taxonomic Tree");
144 taxTreeComposite
= new Composite(expandBar
, SWT
.NONE
);
145 taxTreeComposite
.setLayout(new FillLayout());
146 taxTreeComposite
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_WHITE
));
148 taxTreeExpandItem
.setControl(taxTreeComposite
);
150 treeViewer
= new TaxonomicTreeViewer(taxTreeComposite
);
153 private void createRecentNamesComposite() {
154 recentNamesExpandItem
= new ExpandItem(expandBar
, SWT
.NONE
, 1);
155 recentNamesExpandItem
.setHeight(130);
156 recentNamesExpandItem
.setExpanded(true);
157 recentNamesExpandItem
.setText("Recently viewed names");
158 recentNamesComposite
= new Composite(expandBar
, SWT
.NONE
);
159 recentNamesComposite
.setLayout(new GridLayout());
161 recentNamesExpandItem
.setControl(recentNamesComposite
);
163 recentNamesViewer
= new RecentNamesTableViewer(recentNamesComposite
);
166 private void createSearchComposite() {
167 searchExpandItem
= new ExpandItem(expandBar
, SWT
.NONE
, 2);
168 searchExpandItem
.setHeight(50);
169 searchExpandItem
.setExpanded(true);
170 searchExpandItem
.setText("Search");
171 searchComposite
= new Composite(expandBar
, SWT
.NONE
);
172 final GridLayout gridLayout
= new GridLayout();
173 gridLayout
.numColumns
= 2;
174 searchComposite
.setLayout(gridLayout
);
176 searchExpandItem
.setControl(searchComposite
);
178 searchText
= new Text(searchComposite
, SWT
.BORDER
);
179 searchText
.setForeground(SWTResourceManager
.getColor(192, 192, 192));
180 searchText
.setText("Use \"*\" for wildcard searching");
181 final GridData gd_useForText
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false);
182 searchText
.setLayoutData(gd_useForText
);
183 searchText
.addFocusListener(new FocusListener() {
185 public void focusGained(FocusEvent e
) {
186 searchText
.setForeground(SWTResourceManager
.getColor(0,0,0));
187 searchText
.setText("");
190 public void focusLost(FocusEvent e
) {
191 if (searchText
.getText() == "") {
192 searchText
.setForeground(SWTResourceManager
.getColor(192, 192, 192));
193 searchText
.setText("Use \"*\" for wildcard searching");
200 final Button searchButton
= new Button(searchComposite
, SWT
.NONE
);
201 searchButton
.setText("Search");
203 // Image image = FileArrangerImages.getImageRegistry().get(
204 // IFileArrangerImages.IMG_FTP);
205 // ftpExpandItem.setImage(image);
208 private void createActions() {
209 // Create the actions
213 * Initialize the toolbar
215 private void initializeToolBar() {
216 IToolBarManager toolbarManager
= getViewSite().getActionBars()
217 .getToolBarManager();
221 * Initialize the menu
223 private void initializeMenu() {
224 IMenuManager menuManager
= getViewSite().getActionBars()
229 public void setFocus() {
234 * Expose TreeViewer, i.e. to manipulate tree nodes
237 public TreeViewer
getTreeViewer() {