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;
text_title = new Text(composite_treeTitle, SWT.BORDER);
text_title.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
- text_title.setEnabled(false);
+ text_title.setEditable(false);
btnOpenFeatureTree = new Button(composite_treeTitle, SWT.NONE);
btnOpenFeatureTree.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
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(DragSourceListener dragSourceListener, DropTargetListener dropTargetListener,
+ public void init(String label,
+ DragSourceListener dragSourceListener,
+ DropTargetListener dropTargetListener,
ISelectionChangedListener viewerSelectionChangedListener,
- SelectionListener openFeatureTreeSelectionListener) {
+ IDirtyMarkable dirtyMarkable,
+ ModifyListener textModifyListener) {
+ this.init(label,
+ dragSourceListener,
+ dropTargetListener,
+ null,
+ viewerSelectionChangedListener,
+ null,
+ dirtyMarkable,
+ textModifyListener);
+ }
+ public void init(DragSourceListener dragSourceListener,
+ DropTargetListener dropTargetListener,
+ Transfer[] transfers,
+ ISelectionChangedListener viewerSelectionChangedListener,
+ SelectionListener openFeatureTreeSelectionListener,
+ ModifyListener textModifyListener) {
+ init(null, dragSourceListener,
+ dropTargetListener,
+ transfers,
+ viewerSelectionChangedListener,
+ openFeatureTreeSelectionListener,
+ null,
+ textModifyListener);
+ }
+ private void init(String label, DragSourceListener dragSourceListener,
+ DropTargetListener dropTargetListener,
+ Transfer[] transfers,
+ ISelectionChangedListener viewerSelectionChangedListener,
+ SelectionListener openFeatureTreeSelectionListener,
+ IDirtyMarkable dirtyMarkable,
+ ModifyListener textModifyListener) {
+ if(label!=null){
+ label_title.setText(label);
+ }
+
viewer.setContentProvider(new FeatureTreeContentProvider());
viewer.setLabelProvider(new FeatureTreeLabelProvider());
int ops = DND.DROP_COPY | DND.DROP_MOVE;
- Transfer[] transfers = new Transfer[] { FeatureNodeTransfer
- .getInstance(), TermTransfer.getInstance() };
+ if(transfers==null){
+ transfers = new Transfer[] {
+ FeatureNodeTransfer.getInstance(),
+ TermTransfer.getInstance(),
+ };
+ }
if(dragSourceListener!=null){
viewer.addDragSupport(ops, transfers, dragSourceListener);
}
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);
+ 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);
}
- /**
- * @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 Button getBtnOpenFeatureTree() {
return btnOpenFeatureTree;
}
- /**
- * @return the viewer
- */
public TreeViewer getViewer() {
return viewer;
}