import eu.etaxonomy.taxeditor.featuretree.FeatureTreeContentProvider;
import eu.etaxonomy.taxeditor.featuretree.FeatureTreeLabelProvider;
import eu.etaxonomy.taxeditor.l10n.Messages;
+import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
import eu.etaxonomy.taxeditor.model.ImageResources;
import eu.etaxonomy.taxeditor.ui.dialog.selection.FeatureTreeSelectionDialog;
btnOpenFeatureTree.setToolTipText(Messages.FeatureTreeEditorComposite_OPEN_TREE);
btnOpenFeatureTree.setImage(ImageResources.getImage(ImageResources.BROWSE_ICON));
- viewer = new TreeViewer(new Tree(this, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
+ viewer = new TreeViewer(new Tree(this, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI));
Tree tree = viewer.getTree();
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
viewer.getControl().setLayoutData(
new GridData(SWT.FILL, SWT.FILL, true, true));
}
+ public void init(String label, DragSourceListener dragSourceListener, DropTargetListener dropTargetListener,
+ ISelectionChangedListener viewerSelectionChangedListener, IDirtyMarkable dirtyMarkable,
+ ModifyListener textModifyListener) {
+ this.init(label, dragSourceListener, dropTargetListener, viewerSelectionChangedListener, null, dirtyMarkable,
+ textModifyListener);
+ }
public void init(DragSourceListener dragSourceListener, DropTargetListener dropTargetListener,
ISelectionChangedListener viewerSelectionChangedListener,
- SelectionListener openFeatureTreeSelectionListener) {
+ SelectionListener openFeatureTreeSelectionListener,
+ ModifyListener textModifyListener) {
+ init(null, dragSourceListener, dropTargetListener, viewerSelectionChangedListener, openFeatureTreeSelectionListener,
+ null, textModifyListener);
+ }
+ private void init(String label, DragSourceListener dragSourceListener,
+ DropTargetListener dropTargetListener,
+ ISelectionChangedListener viewerSelectionChangedListener,
+ SelectionListener openFeatureTreeSelectionListener, IDirtyMarkable dirtyMarkable,
+ ModifyListener textModifyListener) {
+ if(label!=null){
+ label_title.setText(label);
+ }
+
viewer.setContentProvider(new FeatureTreeContentProvider());
viewer.setLabelProvider(new FeatureTreeLabelProvider());
viewer.addSelectionChangedListener(viewerSelectionChangedListener);
}
+ if(textModifyListener!=null){
+ text_title.addModifyListener(textModifyListener);
+ }
+
//add specific selection listener
if(openFeatureTreeSelectionListener!=null){
btnOpenFeatureTree.addSelectionListener(openFeatureTreeSelectionListener);
FeatureTree tree = FeatureTreeSelectionDialog.select(getDisplay().getActiveShell(),
null);
if(tree!=null){
- setSelectedTree(tree, null);
- getText_title().setEnabled(false);
+ setSelectedTree(tree);
+ text_title.setEnabled(false);
+ if(dirtyMarkable!=null){
+ dirtyMarkable.forceDirty();
+ }
}
}
});
}
}
- public void setSelectedTree(FeatureTree featureTree, ModifyListener modifyListener) {
+ public void setSelectedTree(FeatureTree featureTree) {
this.featureTree = featureTree;
- getViewer().setInput(featureTree);
+ viewer.setInput(featureTree);
- Listener[] listeners = getText_title().getListeners(SWT.Modify);
+ Listener[] listeners = text_title.getListeners(SWT.Modify);
for (Listener listener : listeners) {
- getText_title().removeListener(SWT.Modify, listener);
+ text_title.removeListener(SWT.Modify, listener);
}
- getText_title().setText(featureTree.getTitleCache());
+ text_title.setText(featureTree!=null?featureTree.getTitleCache():"");
for (Listener listener : listeners) {
- getText_title().addListener(SWT.Modify, listener);
+ text_title.addListener(SWT.Modify, listener);
}
- getText_title().setEnabled(true);
+ text_title.setEnabled(true);
text_title.setEnabled(true);
}
- /**
- * @return the featureTree
- */
public FeatureTree getFeatureTree() {
return featureTree;
}
- /**
- * @return the label_title
- */
- public Label getLabel_title() {
- return label_title;
- }
-
- /**
- * @return the text_title
- */
public Text getText_title() {
return text_title;
}
- /**
- * @return the btnOpenFeatureTree
- */
+ public Label getLabel_title() {
+ return label_title;
+ }
+
public Button getBtnOpenFeatureTree() {
return btnOpenFeatureTree;
}
- /**
- * @return the viewer
- */
public TreeViewer getViewer() {
return viewer;
}