Project

General

Profile

Revision ba34fb74

IDba34fb74878fa1d785add4542dd405598c32413d
Parent 324d3d05
Child 6d460ad2

Added by Patrick Plitzner almost 8 years ago

  • added context menu to DerivateView

View differences:

.gitattributes
466 466
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/handler/OpenRelatedConceptHandler.java -text
467 467
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/operation/CreateConceptRelationOperation.java -text
468 468
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/operation/DeleteConceptRelationOperation.java -text
469
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/CreateDerivateContextMenu.java -text
469 470
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateContentProvider.java -text
470 471
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateLabelProvider.java -text
471 472
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java -text
eu.etaxonomy.taxeditor.editor/plugin.xml
542 542
               style="push">
543 543
         </command>
544 544
      </menuContribution>
545
      <menuContribution
546
            locationURI="popup:eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView">
547
         <command
548
               commandId="eu.etaxonomy.taxeditor.description.commands.adddescrip"
549
               label="New DerivedUni"
550
               style="push">
551
         </command>
552
         <separator
553
               name="eu.etaxonomy.taxeditor.editor.separator1"
554
               visible="true">
555
         </separator>
556
         <dynamic
557
               class="eu.etaxonomy.taxeditor.editor.view.derivate.CreateDerivateContextMenu"
558
               id="eu.etaxonomy.taxeditor.editor.view.derivate.CreateDerivateContextMenu">
559
         </dynamic>
560
         <command
561
               commandId="eu.etaxonomy.taxeditor.editor.command1"
562
               label="bla"
563
               style="push"
564
               tooltip="bla">
565
         </command>
566
      </menuContribution>
545 567
      
546 568
      
547 569
      
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/CreateDerivateContextMenu.java
1
package eu.etaxonomy.taxeditor.editor.view.derivate;
2

  
3
import org.eclipse.jface.action.ContributionItem;
4
import org.eclipse.jface.action.IContributionItem;
5
import org.eclipse.swt.SWT;
6
import org.eclipse.swt.widgets.Menu;
7
import org.eclipse.swt.widgets.MenuItem;
8
import org.eclipse.ui.actions.CompoundContributionItem;
9

  
10
public class CreateDerivateContextMenu extends CompoundContributionItem {
11

  
12
    /* (non-Javadoc)
13
     * @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
14
     */
15
    @Override
16
    protected IContributionItem[] getContributionItems() {
17
        IContributionItem[] contributionItems = new IContributionItem[] {
18
                new ContributionItem() {
19
                    @Override
20
                    public void fill(Menu menu, int index) {
21
                        MenuItem menuItem = new MenuItem(menu, SWT.None);
22
                        menuItem.setText("menuItem");
23
                    };
24
                }
25
        };
26
        return contributionItems;
27
    }
28

  
29
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateLabelProvider.java
3 3
import org.eclipse.jface.viewers.ColumnLabelProvider;
4 4
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
5 5
import org.eclipse.jface.viewers.StyledString;
6
import org.eclipse.swt.graphics.Image;
6 7

  
7 8
public class DerivateLabelProvider extends ColumnLabelProvider implements IStyledLabelProvider {
8 9

  
......
12 13
		return null;
13 14
	}
14 15

  
16
	/* (non-Javadoc)
17
	 * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
18
	 */
19
	@Override
20
	public String getText(Object element) {
21
	    return super.getText(element);
22
	}
23

  
24
	/* (non-Javadoc)
25
	 * @see org.eclipse.jface.viewers.ColumnLabelProvider#getImage(java.lang.Object)
26
	 */
27
	@Override
28
	public Image getImage(Object element) {
29
	    return super.getImage(element);
30
	}
31

  
15 32
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java
1 1
package eu.etaxonomy.taxeditor.editor.view.derivate;
2 2

  
3
import org.eclipse.jface.action.MenuManager;
3 4
import org.eclipse.jface.viewers.ISelection;
4 5
import org.eclipse.jface.viewers.IStructuredSelection;
5 6
import org.eclipse.jface.viewers.TreeViewer;
6 7
import org.eclipse.jface.viewers.Viewer;
7 8
import org.eclipse.swt.SWT;
8 9
import org.eclipse.swt.widgets.Composite;
10
import org.eclipse.swt.widgets.Control;
11
import org.eclipse.swt.widgets.Menu;
9 12
import org.eclipse.swt.widgets.Tree;
10 13
import org.eclipse.ui.IWorkbenchPart;
11 14

  
......
23 26
public class DerivateView extends AbstractCdmEditorViewPart implements IPartContentHasDetails, IPartContentHasSupplementalData {
24 27

  
25 28
	/** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.desc"{trunked}</code> */
26
	public static final String ID = "eu.etaxonomy.taxeditor.editor.view.derivate.SpecimenView";
29
	public static final String ID = "eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView";
27 30

  
28 31
	protected TreeViewer viewer;
29 32

  
......
35 38
		viewer.setAutoExpandLevel(2);
36 39
        // Propagate selection from viewer
37 40
        getSite().setSelectionProvider(viewer);
41

  
42
        //create context menu
43
        MenuManager menuManager = new MenuManager();
44

  
45
        getSite().registerContextMenu(menuManager, viewer);
46

  
47
        Control control = viewer.getControl();
48
        Menu menu = menuManager.createContextMenu(control);
49

  
50
        control.setMenu(menu);
38 51
	}
39 52

  
40 53
	@Override

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)