// $Id$
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.desc"{trunked}</code> */
public static final String ID = "eu.etaxonomy.taxeditor.editor.view.descriptive";
-
- private TreeViewer viewer;
-
- private Map<TaxonDescription, FeatureNodeContainerTree> featureNodeContainerCache = new HashMap<TaxonDescription, FeatureNodeContainerTree>();
- private ToggleDescriptionAction showAllElementsAction;
+ protected TreeViewer viewer;
- private ToggleDescriptionAction hideAllElementsAction;
+ protected Map<TaxonDescription, FeatureNodeContainerTree> featureNodeContainerCache = new HashMap<TaxonDescription, FeatureNodeContainerTree>();
+
+ protected ToggleDescriptionAction showAllElementsAction;
+
+ protected ToggleDescriptionAction hideAllElementsAction;
+
+ protected int dndOperations = DND.DROP_COPY | DND.DROP_MOVE;
- private int dndOperations = DND.DROP_COPY | DND.DROP_MOVE;
-
/** {@inheritDoc} */
@Override
public void createViewer(Composite parent) {
viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL
| SWT.V_SCROLL | SWT.FULL_SELECTION));
- viewer.setContentProvider(new DescriptiveContentProvider(featureNodeContainerCache));
+ viewer.setContentProvider(new DescriptiveContentProvider(featureNodeContainerCache));
viewer.setLabelProvider(new DescriptiveLabelProvider());
viewer.setSorter(new DescriptiveViewerSorter());
viewer.setAutoExpandLevel(2);
this));
viewer.addDropSupport(dndOperations, transfers,
new DescriptionElementDropAdapter(viewer));
-
+
// Propagate selection from viewer
getSite().setSelectionProvider(viewer);
-
- showAllElementsAction = new ToggleDescriptionAction(false);
+
+ showAllElementsAction = new ToggleDescriptionAction(false);
hideAllElementsAction = new ToggleDescriptionAction(true);
-
+
// Add context menu to tree
createMenu();
-
+
createToolbar();
-
+
// set initial input
// if(getEditor() != null){
// viewer.setInput(getEditor().getEditorInput());
// }
}
-
+
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#getInitialSelection()
*/
protected ISelection getInitialSelection() {
if(getEditor() != null){
return new StructuredSelection(getEditor().getEditorInput());
- }
-
+ }
+
return super.getInitialSelection();
}
- private void createToolbar() {
+ protected void createToolbar() {
IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
toolBarManager.add(showAllElementsAction);
toolBarManager.add(hideAllElementsAction);
}
-
+
/*
* TODO add to the views menu
*/
- private void createMenu(){
+ protected void createMenu(){
MenuManager menuManager = new MenuManager();
menuManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
-
+
getSite().registerContextMenu(menuManager, viewer);
// FIXME for some reason this is not working
menuManager.add(showAllElementsAction);
menuManager.add(hideAllElementsAction);
-
+
Control control = viewer.getControl();
Menu menu = menuManager.createContextMenu(control);
-
- control.setMenu(menu);
+
+ control.setMenu(menu);
}
/** {@inheritDoc} */
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if(EditorUtil.getActiveEditor() == null){
showEmptyPage();
return;
}
-
+
if(part instanceof BulkEditor){
showEmptyPage();
return;
}
-
+
if(part instanceof AbstractGraphKeyEditor){
showEmptyPage();
return;
}
-
+
if(part instanceof DefinedTermEditor){
showEmptyPage();
return;
}
-
+
if(part instanceof MultiPageTaxonEditor){
if(! part.equals(this.part)){
IEditorInput input = ((IEditorPart) part).getEditorInput();
showViewer();
}
}
-
+
/**
- *
+ *
* @author n.hoffmann
* @created May 28, 2010
* @version 1.0
*/
- private class ToggleDescriptionAction extends Action{
- private boolean expanded;
-
+ protected class ToggleDescriptionAction extends Action{
+ private final boolean expanded;
+
public ToggleDescriptionAction(boolean expand){
super(null, Action.AS_PUSH_BUTTON);
expanded = expand;
setImageAndTooltip();
}
-
+
private void setImageAndTooltip(){
setImageDescriptor(new ImageDescriptor() {
@Override
return ImageResources.getImage(resource).getImageData();
}
});
-
- String toolTipText = expanded ? "Collapse all" : "Show all descriptive data";
+
+ String toolTipText = expanded ? "Collapse all" : "Show all factual data";
setToolTipText(toolTipText);
}
-
+
@Override
public void run() {
if(expanded){
containerTree.buildTree();
}
viewer.refresh();
-
+
if(object instanceof DescriptionElementBase){
DescriptionElementBase descriptionElement = (DescriptionElementBase) object;
DescriptionBase description = descriptionElement.getInDescription();
FeatureNodeContainerTree containerTree = featureNodeContainerCache.get(description);
-
+
FeatureNodeContainer featureNodeContainer = containerTree.getFeatureNodeContainerForDescriptionElement(descriptionElement);
viewer.expandToLevel(featureNodeContainer, 1);
-
+
}
if(object != null){
*
* @return a boolean.
*/
- public boolean onComplete() {
+ @Override
+ public boolean onComplete() {
return false;
}
}