From e58a5e6bd48ab19c6469cd9896b36a6d2e52b15c Mon Sep 17 00:00:00 2001 From: Patrick Plitzner Date: Tue, 21 Jul 2015 08:54:31 +0200 Subject: [PATCH] Add @Override --- .../definedterm/DefinedTermMenuFactory.java | 120 +++++++++--------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/DefinedTermMenuFactory.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/DefinedTermMenuFactory.java index 9bd7ccbda..f26672956 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/DefinedTermMenuFactory.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/DefinedTermMenuFactory.java @@ -1,9 +1,9 @@ // $Id$ /** * Copyright (C) 2009 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. */ @@ -34,78 +34,77 @@ import eu.etaxonomy.cdm.model.common.TermType; /** * Menu factory used in the store plugin xml to dynamically generate menu (sub-menu) contribution items * for term types which when clicked open the defined term editor for the chosen term type - * + * * @author c.mathew * @date 18 Jul 2013 * */ -public class DefinedTermMenuFactory extends ExtensionContributionFactory { - +public class DefinedTermMenuFactory extends ExtensionContributionFactory { + @Override public void createContributionItems(IServiceLocator serviceLocator, - IContributionRoot additions) { - - MenuManager dtMenuManager = - new MenuManager("Term Editor","eu.etaxonomy.taxeditor.store.definedTermEditorMenu"); - - dtMenuManager.setVisible(true); - - additions.addContributionItem(dtMenuManager, null); - List ttList = new ArrayList(EnumSet.allOf(TermType.class)); - Collections.sort(ttList,new SortByTermTypeMessage()); - for (TermType tt : ttList) - { - // if term type has a parent, do not add it - // it will be added in the recursive call - if(tt.getKindOf() == null) { - IContributionItem ici = addChildTermsToMenuManager(tt, serviceLocator); - if(ici != null) { - dtMenuManager.add(ici); - } - } - } + IContributionRoot additions) { + MenuManager dtMenuManager = + new MenuManager("Term Editor","eu.etaxonomy.taxeditor.store.definedTermEditorMenu"); + + dtMenuManager.setVisible(true); + + additions.addContributionItem(dtMenuManager, null); + List ttList = new ArrayList(EnumSet.allOf(TermType.class)); + Collections.sort(ttList,new SortByTermTypeMessage()); + for (TermType tt : ttList) + { + // if term type has a parent, do not add it + // it will be added in the recursive call + if(tt.getKindOf() == null) { + IContributionItem ici = addChildTermsToMenuManager(tt, serviceLocator); + if(ici != null) { + dtMenuManager.add(ici); + } + } + } } - + private IContributionItem addChildTermsToMenuManager(TermType termType, IServiceLocator serviceLocator) { - + //FIXME : need a better way to find out if a term type can be editable (ticket 3853) if(termType.getEmptyDefinedTermBase() != null) { Set children = termType.getGeneralizationOf(); // term type has no children, so create menu item - if(children.isEmpty()) { + if(children.isEmpty()) { return createMenuItem(termType, serviceLocator); } - // term type has children, so create sub menu - MenuManager dtMenuManager = - new MenuManager(termType.getMessage(),"eu.etaxonomy.taxeditor.store." + termType.getKey() + "Menu"); + // term type has children, so create sub menu + MenuManager dtMenuManager = + new MenuManager(termType.getMessage(),"eu.etaxonomy.taxeditor.store." + termType.getKey() + "Menu"); dtMenuManager.setVisible(true); dtMenuManager.add(createDefaultMenuItem(termType, serviceLocator)); Separator sep = new Separator(); dtMenuManager.add(sep); // add child items to the sub menu - for(TermType tt : children) { + for(TermType tt : children) { IContributionItem item = addChildTermsToMenuManager(tt,serviceLocator); - if(item != null) { + if(item != null) { dtMenuManager.add(item); - } - } + } + } return dtMenuManager; } else { return null; } - + } - + private CommandContributionItem createMenuItem(TermType termType, IServiceLocator serviceLocator) { - + Map params = new HashMap(); params.put("eu.etaxonomy.taxeditor.store.openDefinedTermEditor.termTypeUuid", - termType.getUuid().toString()); - + termType.getUuid().toString()); + CommandContributionItemParameter p = new CommandContributionItemParameter( - serviceLocator, + serviceLocator, "", "eu.etaxonomy.taxeditor.store.openDefinedTermEditor", params, @@ -114,24 +113,24 @@ public class DefinedTermMenuFactory extends ExtensionContributionFactory { null, termType.getMessage(), "", - "", + "", SWT.PUSH, "", true); - - CommandContributionItem item = new CommandContributionItem(p); + + CommandContributionItem item = new CommandContributionItem(p); return item; - + } - + private CommandContributionItem createDefaultMenuItem(TermType termType, IServiceLocator serviceLocator) { - + Map params = new HashMap(); params.put("eu.etaxonomy.taxeditor.store.openDefinedTermEditor.termTypeUuid", - termType.getUuid().toString()); - + termType.getUuid().toString()); + CommandContributionItemParameter p = new CommandContributionItemParameter( - serviceLocator, + serviceLocator, "", "eu.etaxonomy.taxeditor.store.openDefinedTermEditor", params, @@ -140,23 +139,24 @@ public class DefinedTermMenuFactory extends ExtensionContributionFactory { null, "Other " + termType.getMessage() + "s", "", - "", + "", SWT.PUSH, "", true); - - - - CommandContributionItem item = new CommandContributionItem(p); + + + + CommandContributionItem item = new CommandContributionItem(p); return item; - + } - + private class SortByTermTypeMessage implements Comparator { - public int compare(TermType t1, TermType t2) { + @Override + public int compare(TermType t1, TermType t2) { return t1.getMessage().compareTo(t2.getMessage()); } } - + } -- 2.34.1