- Cleanup, remove unused functions
Signed-off-by: Ansgar Radermacher <ansgar.radermacher@cea.fr>
diff --git a/core/org.polarsys.esf.core.common.ui/META-INF/MANIFEST.MF b/core/org.polarsys.esf.core.common.ui/META-INF/MANIFEST.MF
index 2b5f5e0..be756e3 100644
--- a/core/org.polarsys.esf.core.common.ui/META-INF/MANIFEST.MF
+++ b/core/org.polarsys.esf.core.common.ui/META-INF/MANIFEST.MF
@@ -27,16 +27,9 @@
org.polarsys.esf.core.common.ui.constants,
org.polarsys.esf.core.common.ui.diagram,
org.polarsys.esf.core.common.ui.editingsupport,
- org.polarsys.esf.core.common.ui.editor,
- org.polarsys.esf.core.common.ui.fieldeditor,
org.polarsys.esf.core.common.ui.filter,
org.polarsys.esf.core.common.ui.job,
org.polarsys.esf.core.common.ui.provider,
org.polarsys.esf.core.common.ui.selection,
org.polarsys.esf.core.common.ui.statusline,
- org.polarsys.esf.core.common.ui.treeviewer,
- org.polarsys.esf.core.common.ui.view,
- org.polarsys.esf.core.common.ui.view.properties,
- org.polarsys.esf.core.common.ui.widget,
- org.polarsys.esf.core.common.ui.widget.listener,
- org.polarsys.esf.core.common.ui.wizard
+ org.polarsys.esf.core.common.ui.treeviewer
diff --git a/core/org.polarsys.esf.core.common.ui/plugin.xml b/core/org.polarsys.esf.core.common.ui/plugin.xml
index 6e76fd0..f51971d 100644
--- a/core/org.polarsys.esf.core.common.ui/plugin.xml
+++ b/core/org.polarsys.esf.core.common.ui/plugin.xml
@@ -3,33 +3,7 @@
<plugin>
<extension
point="org.eclipse.ui.menus">
- <menuContribution
- locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
- <toolbar
- id="org.polarsys.esf.core.common.ui.toolbar.toolbar"
- label="%toolbar.esf.label">
- <separator
- name="org.polarsys.esf.core.common.ui.toolbar.before"
- visible="true">
- </separator>
- <control
- class="org.polarsys.esf.core.common.ui.widget.ActiveProjectControlContribution">
- </control>
- <control
- class="org.polarsys.esf.core.common.ui.actions.FilterPartControlContribution">
- </control>
- <separator
- name="org.polarsys.esf.core.common.ui.toolbar.additions"
- visible="true">
- </separator>
- <command
- commandId="org.eclipse.ui.help.helpContents"
- label="%command.help"
- style="push">
- </command>
- </toolbar>
- </menuContribution>
- <menuContribution
+ <menuContribution
allPopups="false"
locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup?before=newelements">
<separator
@@ -40,6 +14,6 @@
name="esf.general.bottom"
visible="true">
</separator>
- </menuContribution>
+ </menuContribution>
</extension>
</plugin>
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/actions/ActionBarContributorUtils.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/actions/ActionBarContributorUtils.java
deleted file mode 100644
index ff71a1a..0000000
--- a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/actions/ActionBarContributorUtils.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.common.ui.actions;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.apache.commons.lang3.StringUtils;
-import org.eclipse.emf.edit.ui.action.CreateChildAction;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IContributionManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.SubContributionItem;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.polarsys.esf.core.common.ui.CommonUIActivator;
-
-/**
- * Utility class used to centralise shared constants, and shared methods
- * for all the action bar contributors.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public final class ActionBarContributorUtils {
-
- /** The singleton instance of the utility class. */
- public static final ActionBarContributorUtils INSTANCE = new ActionBarContributorUtils();
-
- /** The show properties action id. */
- public static final String SHOW_PROPERTIES_ACTION_ID = "show_properties_action"; //$NON-NLS-1$
-
- /** The refresh action id. */
- public static final String REFRESH_ACTION_ID = "refresh_action"; //$NON-NLS-1$
-
- /** Id for the collapse all action. */
- public static final String COLLAPSE_ALL_ACTION_ID = "action.collapseall.id"; //$NON-NLS-1$
-
- /** Id for the expand all action. */
- public static final String EXPAND_ALL_ACTION_ID = "action.expandall.id"; //$NON-NLS-1$
-
- /** The edit separator id. */
- public static final String EDIT_SEPARATOR_ID = "edit"; //$NON-NLS-1$
-
- /** The additions separator id. */
- public static final String ADDITIONS_SEPARATOR_ID = "additions"; //$NON-NLS-1$
-
- /** The additions end id. */
- public static final String ADDITIONS_END_SEPARATOR_ID = "additions-end"; //$NON-NLS-1$
-
- /** The ui actions id. */
- public static final String UI_ACTIONS_SEPARATOR_ID = "ui-actions"; //$NON-NLS-1$
-
- /** The create child menu id. */
- public static final String CREATECHILD_MENU_ID = "createChildMenu"; //$NON-NLS-1$
-
- /** Separator id, for the toolbar actions linked to the selected element. */
- public static final String TOOLBAR_SEP_SELECTION_ACTIONS = "toolbar-selection-actions"; //$NON-NLS-1$
-
- /** Separator id, for the toolbar delete action linked to the selected element. */
- public static final String TOOLBAR_SEP_DELETE_ACTION = "toolbar-delete-action"; //$NON-NLS-1$
-
- /** Prefix used to create the id of toolbar actions which create child on the current selection. */
- public static final String CREATECHILD_ACTION_ID_PREFIX = "selection.createchild.action."; //$NON-NLS-1$
-
- /** Label for the create child menu. */
- public static final String CREATECHILD_MENU_LABEL =
- CommonUIActivator.getMessages().getString(
- "ActionBarContributorUtils.menu.child.new"); //$NON-NLS-1$
-
- /** Label for the show properties action. */
- public static final String SHOW_PROPERTIES_ACTION_LABEL =
- CommonUIActivator.getMessages().getString(
- "ActionBarContributorUtils.actions.showpropertiesview"); //$NON-NLS-1$
-
- /** Label for the refresh action. */
- public static final String REFRESH_ACTION_LABEL =
- CommonUIActivator.getMessages().getString(
- "ActionBarContributorUtils.actions.refresh"); //$NON-NLS-1$
-
- /** Label for the expand all action. */
- public static final String EXPAND_ALL_ACTION_LABEL =
- CommonUIActivator.getMessages().getString(
- "ActionBarContributorUtils.actions.expandall"); //$NON-NLS-1$
-
- /** Label for the collapse all action. */
- public static final String COLLAPSE_ALL_ACTION_LABEL =
- CommonUIActivator.getMessages().getString(
- "ActionBarContributorUtils.actions.collapseall"); //$NON-NLS-1$
-
-
- /**
- * Private constructor, as it's a utility class.
- */
- private ActionBarContributorUtils() {
- }
-
- /**
- * Generate a {@link CreateChildAction}, to add content under the selection. An action is created
- * for each object described by the given <code>descriptors</code>.
- *
- * The action id is automatically generated, and is prefixed by a custom
- * string {@link #CREATECHILD_ACTION_ID_PREFIX}, to be able to find them easily later.
- *
- * @param pWorkbenchPart The part from which the editing domain will be found, if it's an editing domain provider
- * @param pDescriptors The collection of descriptors corresponding to the child which may be created
- * @param pSelection The selection containing the object for which the children can be created
- * @return The collection of actions created
- */
- public Collection<IAction> generateCreateChildActionsCollection(
- final IWorkbenchPart pWorkbenchPart,
- final Collection<?> pDescriptors,
- final ISelection pSelection) {
-
- // Initialise the collection of actions
- final Collection<IAction> vActionsCollection = new ArrayList<IAction>();
-
- if (pDescriptors != null) {
-
- int i = 0;
-
- // Loop on the given descriptors to create an action for each one
- for (final Object vDescriptor : pDescriptors) {
- // Create the action
- IAction vCreateChildAction = new CreateChildAction(pWorkbenchPart, pSelection, vDescriptor);
-
- // Set its unique id
- vCreateChildAction.setId(
- ActionBarContributorUtils.CREATECHILD_ACTION_ID_PREFIX.concat(String.valueOf(i++)));
-
- // Finally add it to the returned collection
- vActionsCollection.add(vCreateChildAction);
- }
- }
-
- return vActionsCollection;
- }
-
- /**
- * This populates the specified <code>manager</code> with {@link ActionContributionItem}s
- * based on the {@link IAction}s contained in the given collection,
- * by inserting them before the specified contribution item <code>contributionID</code>.
- * If <code>contributionID</code> is <code>null</code>, they are simply added.
- *
- * @param pManager The contribution manager to populate
- * @param pActionsCollection The actions to add in the manager
- * @param pContributionID The ID defining where the actions must be inserted. May be null
- */
- public void populateManager(
- final IContributionManager pManager,
- final Collection<? extends IAction> pActionsCollection,
- final String pContributionID) {
-
- if (pManager != null && pActionsCollection != null) {
- // Loop on the actions to add in the manager
- for (final IAction vAction : pActionsCollection) {
- if (StringUtils.isNotEmpty(pContributionID)) {
- // Insert the action at the right location
- pManager.insertBefore(pContributionID, vAction);
- } else {
- // Simply add the action in the manager
- pManager.add(vAction);
- }
- }
- }
- }
-
-
- /**
- * This populates the specified <code>manager</code> with {@link MenuManager}s containing
- * {@link ActionContributionItem}s based on the {@link IAction}s contained in the given collection,
- * by inserting them before the specified contribution item <code>contributionID</code>.
- * If <code>contributionID</code> is <code>null</code>, they are simply added.
- *
- * @param pManager The contribution manager to populate
- * @param pSubmenuActionsMap The submenu actions to add in the manager
- * @param pContributionID The ID defining where the actions must be inserted. May be null
- */
- public void populateManager(
- final IContributionManager pManager,
- final Map<String, Collection<IAction>> pSubmenuActionsMap,
- final String pContributionID) {
-
- if (pManager != null && pSubmenuActionsMap != null) {
- // Loop on the submenu action to add in the manager
- for (final Map.Entry<String, Collection<IAction>> vSubmenuActionsMapEntry : pSubmenuActionsMap.entrySet()) {
-
- // Create the submenu manager from the map entry key
- MenuManager vSubmenuManager = new MenuManager(vSubmenuActionsMapEntry.getKey());
-
- // Add the submenu in the given contribution manager
- if (StringUtils.isNotEmpty(pContributionID)) {
- // Insert the action at the right location
- pManager.insertBefore(pContributionID, vSubmenuManager);
- } else {
- // Simply add the action in the manager
- pManager.add(vSubmenuManager);
- }
-
- // Finally populate the submenu with all the linked actions, contained in the map value
- populateManager(vSubmenuManager, vSubmenuActionsMapEntry.getValue(), null);
- }
- }
- }
-
- /**
- * This removes from the specified <code>manager</code> all {@link ActionContributionItem}s
- * based on the {@link IAction}s contained in the given collection.
- *
- * @param pManager The contribution manager to depopulate
- * @param pActionsCollection The actions to remove from the manager
- */
- public void depopulateManager(
- final IContributionManager pManager,
- final Collection<? extends IAction> pActionsCollection) {
-
- if (pManager != null && pActionsCollection != null) {
- // Loop on the items currently contained in the contribution manager
- for (final IContributionItem vContributionItem : pManager.getItems()) {
-
- // Look into sub-contribution items to find the leaf of the menus
- IContributionItem vSubcontributionItem = vContributionItem;
- while (vSubcontributionItem instanceof SubContributionItem) {
- vSubcontributionItem = ((SubContributionItem) vSubcontributionItem).getInnerItem();
- }
-
- // Delete the sub-contribution corresponding to the actions to remove
- if (vSubcontributionItem instanceof ActionContributionItem) {
- IAction vSubcontributionAction = ((ActionContributionItem) vSubcontributionItem).getAction();
- if (pActionsCollection.contains(vSubcontributionAction)) {
- pManager.remove(vSubcontributionItem);
- }
- }
- }
- }
- }
-
- /**
- * This removes from the specified <code>manager</code> all {@link MenuManager}s and their
- * {@link ActionContributionItem}s based on the {@link IAction}s contained in the given map.
- *
- * @param pManager The contribution manager to depopulate
- * @param pSubmenuActionsMap The submenu actions to remove from the manager
- */
- public void depopulateManager(
- final IContributionManager pManager,
- final Map<String, Collection<IAction>> pSubmenuActionsMap) {
-
- if (pManager != null && pSubmenuActionsMap != null) {
- // Loop on the items currently contained in the contribution manager
- for (final IContributionItem vContributionItem : pManager.getItems()) {
-
- if (vContributionItem instanceof MenuManager) {
- final MenuManager vSubmenuManager = (MenuManager) vContributionItem;
-
- // If the map contains the menu to remove, depopulate the menu and then
- // remove it from the parent contribution manager
- if (pSubmenuActionsMap.containsKey(vSubmenuManager.getMenuText())) {
- depopulateManager(vSubmenuManager, pSubmenuActionsMap.get(vContributionItem));
- pManager.remove(vContributionItem);
- }
- }
- }
- }
- }
-
- /**
- * This extracts those actions in the given collection whose text is qualified and returns
- * a map of these actions, keyed by submenu text.
- *
- * @param pActionsCollection The collection of actions for which the submenus must be extracted
- * @return The map of extracted submenus, with their text as key and all theirs actions as value
- */
- public Map<String, Collection<IAction>> extractSubmenuActions(final Collection<IAction> pActionsCollection) {
- // Initialise the map
- final Map<String, Collection<IAction>> vExtractedSubmenuActionsMap =
- new LinkedHashMap<String, Collection<IAction>>();
-
- if (pActionsCollection != null) {
- // Loop on the given actions collection with an iterator as the collection may be modified
- Iterator<IAction> vActionsIterator = pActionsCollection.iterator();
- while (vActionsIterator.hasNext()) {
- // Get the current action
- final IAction vAction = vActionsIterator.next();
-
- // Get the action text, to parse it and extract the submenus
- // NB : Use an empty String by default to avoid the exception on the tokenizer if null
- String vTextToTokenize = StringUtils.EMPTY;
- if (StringUtils.isNotEmpty(vAction.getText())) {
- vTextToTokenize = vAction.getText();
- }
-
- // Parse the action text to find the submenus to create
- final StringTokenizer vActionTextTokenizer = new StringTokenizer(vTextToTokenize, "|"); //$NON-NLS-1$
-
- // Ensure that a submenu is needed
- if (vActionTextTokenizer.countTokens() == 2) {
- // Get the submenu text, and the action text
- String vSubMenuText = vActionTextTokenizer.nextToken().trim();
- String vActionText = vActionTextTokenizer.nextToken().trim();
-
- // Get the collection of action corresponding to this submenu, to populate it
- Collection<IAction> vSubmenuActionsCollection = vExtractedSubmenuActionsMap.get(vSubMenuText);
-
- if (vSubmenuActionsCollection == null) {
- // The collection doesn't already exists, thus create it and add it in the map
- vSubmenuActionsCollection = new ArrayList<IAction>();
- vExtractedSubmenuActionsMap.put(vSubMenuText, vSubmenuActionsCollection);
- }
-
- // Then update the current action text and add it in the collection
- // of actions associated to the current submenu
- vAction.setText(vActionText);
- vSubmenuActionsCollection.add(vAction);
-
- // Finally remove the current action
- vActionsIterator.remove();
- }
- }
- }
-
- return vExtractedSubmenuActionsMap;
- }
-
-}
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/actions/FilterPartControlContribution.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/actions/FilterPartControlContribution.java
deleted file mode 100644
index fec6d89..0000000
--- a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/actions/FilterPartControlContribution.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.common.ui.actions;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.menus.WorkbenchWindowControlContribution;
-import org.polarsys.esf.core.common.ui.widget.FilterComposite;
-
-/**
- * Control contribution used to manage the widgets used to apply
- * filters on listener parts.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public class FilterPartControlContribution
- extends WorkbenchWindowControlContribution {
-
- /** The filter composite. */
- private FilterComposite mFilterComposite = null;
-
- /**
- * The default constructor.
- */
- public FilterPartControlContribution() {
- // Call the parent constructor
- super();
- }
-
- /**
- * Creates and returns the control for this contribution item
- * under the given parent composite.
- *
- * @param pParent The parent composite
- * @return The new control
- */
- @Override
- protected Control createControl(final Composite pParent) {
- // Create and remember of the filter composite
- mFilterComposite = new FilterComposite(pParent);
-
- return mFilterComposite;
- }
-}
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/actions/NoModifiesActionBarContributor.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/actions/NoModifiesActionBarContributor.java
deleted file mode 100644
index 49f10f6..0000000
--- a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/actions/NoModifiesActionBarContributor.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.common.ui.actions;
-
-import java.util.Collection;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.UnexecutableCommand;
-import org.eclipse.emf.edit.ui.action.CopyAction;
-import org.eclipse.emf.edit.ui.action.CutAction;
-import org.eclipse.emf.edit.ui.action.DeleteAction;
-import org.eclipse.emf.edit.ui.action.PasteAction;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-
-
-/**
- *
- * Action bar contributor
- *
- * Overridden to remove all editions action, and clean popmenu.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public class NoModifiesActionBarContributor
- extends ViewActionBarContributor {
-
- /**
- * Default constructor.
- */
- public NoModifiesActionBarContributor() {
- super();
- }
-
- /**
- * {@inheritDoc}
- *
- * @return an unexecutable command, to handle global delete action.
- */
- @Override
- protected DeleteAction createDeleteAction() {
- return new DeleteAction() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Command createCommand(final Collection<?> pSelection) {
- return UnexecutableCommand.INSTANCE;
- }
- };
- }
-
- /**
- * {@inheritDoc}
- *
- * @return an unexecutable command, to handle global cut action.
- */
- @Override
- protected CutAction createCutAction() {
- return new CutAction() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Command createCommand(final Collection<?> pSelection) {
- return UnexecutableCommand.INSTANCE;
- }
- };
- }
-
- /**
- * {@inheritDoc}
- *
- * @return an unexecutable command, to handle global paste action.
- */
- @Override
- protected PasteAction createPasteAction() {
- return new PasteAction() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Command createCommand(final Collection<?> pSelection) {
- return UnexecutableCommand.INSTANCE;
- }
- };
- }
-
- /**
- * {@inheritDoc}
- *
- * @return an unexecutable command, to handle global copy action.
- */
- @Override
- protected CopyAction createCopyAction() {
- return new CopyAction() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Command createCommand(final Collection<?> pSelection) {
- return UnexecutableCommand.INSTANCE;
- }
- };
- }
-
- /**
- * {@inheritDoc}
- *
- * Customise the add global action to remove the Show Properties
- * which is not useful in this context.
- */
- @Override
- protected void addGlobalActions(final IMenuManager pMenuManager) {
-
- // Call the parent method
- super.addGlobalActions(pMenuManager);
-
- // Remove the show properties action
- pMenuManager.remove(ActionBarContributorUtils.SHOW_PROPERTIES_ACTION_ID);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void menuAboutToShow(final IMenuManager pMenuManager) {
- // Add our standard marker.
- if ((style & ADDITIONS_LAST_STYLE) == 0) {
- pMenuManager.add(new Separator(ActionBarContributorUtils.ADDITIONS_SEPARATOR_ID));
- }
- pMenuManager.add(new Separator(ActionBarContributorUtils.EDIT_SEPARATOR_ID));
-
- pMenuManager.add(new ActionContributionItem(undoAction));
- pMenuManager.add(new ActionContributionItem(redoAction));
- pMenuManager.add(new Separator());
-
- if ((style & ADDITIONS_LAST_STYLE) != 0) {
- pMenuManager.add(new Separator(ActionBarContributorUtils.ADDITIONS_SEPARATOR_ID));
- pMenuManager.add(new Separator());
- }
- // Add our other standard marker.
- pMenuManager.add(new Separator(ActionBarContributorUtils.ADDITIONS_END_SEPARATOR_ID));
-
- addGlobalActions(pMenuManager);
- }
-}
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/actions/ViewActionBarContributor.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/actions/ViewActionBarContributor.java
deleted file mode 100644
index cee64dd..0000000
--- a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/actions/ViewActionBarContributor.java
+++ /dev/null
@@ -1,452 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.common.ui.actions;
-
-import java.util.Collection;
-
-import org.eclipse.emf.common.ui.viewer.IViewerProvider;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
-import org.eclipse.emf.edit.ui.action.ValidateAction;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PartInitException;
-import org.polarsys.esf.core.common.ui.CommonUIActivator;
-
-/**
- * This is the action bar contributor used for all the views linked to a resource of ESF.
- * Its first implementation is coming from hmhanna.
- *
- * It extends {@link EditingDomainActionBarContributor} which provide the standard mechanisms
- * to provide the actions on an editing domain.
- *
- * It implements {@link ISelectionChangedListener} to be able to react when the selection changed in the
- * active editor, to update the action linked to the current selection.
- *
- * This contributor will populate the view tool bar and menus with different kind of actions :
- * <ul>
- * <li>Actions not linked to the current context (ie: expand / collapse tree)</li>
- * <li>Actions linked to the current selection when one is set (ie: create children elements)</li>
- * </ul>
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public class ViewActionBarContributor
- extends EditingDomainActionBarContributor
- implements ISelectionChangedListener {
-
- /** Instance of utility class used by the action contributors. */
- private ActionBarContributorUtils mActionBarContributorUtils = ActionBarContributorUtils.INSTANCE;
-
- /** This keeps track of the active editor. */
- private IWorkbenchPart mActivePart = null;
-
- /** This keeps track of the current selection provider. */
- private ISelectionProvider mSelectionProvider = null;
-
- /**
- * The id of the properties view that will be showed
- * when the {@link #mShowPropertiesViewAction} run.
- */
- private String mPropertyViewsId = IPageLayout.ID_PROP_SHEET;
-
- /**
- * This action opens the Properties view.
- */
- private IAction mShowPropertiesViewAction =
- new Action(ActionBarContributorUtils.SHOW_PROPERTIES_ACTION_LABEL) {
-
- @Override
- public void run() {
- try {
- ViewActionBarContributor.this.getPage().showView(mPropertyViewsId);
- } catch (final PartInitException pException) {
- CommonUIActivator.INSTANCE.log(pException);
- }
- }
- };
-
- /**
- * This action refreshes the viewer of the current editor if the editor implements
- * {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}.
- */
- private IAction mRefreshViewerAction =
- new Action(ActionBarContributorUtils.REFRESH_ACTION_LABEL) {
-
- @Override
- public boolean isEnabled() {
- return mActivePart instanceof IViewerProvider;
- }
-
- @Override
- public void run() {
- if (mActivePart instanceof IViewerProvider) {
- final Viewer vViewer = ((IViewerProvider) mActivePart).getViewer();
- if (vViewer != null) {
- vViewer.refresh();
- }
- }
- }
- };
-
- /**
- * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction}
- * for each descriptor generated for the current selection, by the item provider.
- */
- private Collection<IAction> mCreateChildActionsCollection = null;
-
- /**
- * This creates an instance of the contributor with the default style
- * {@link EditingDomainActionBarContributor#ADDITIONS_LAST_STYLE}.
- */
- public ViewActionBarContributor() {
- super(ADDITIONS_LAST_STYLE);
- validateAction = createValidateAction();
-
- // Initialise the created actions id
- initialiseActionsId();
- }
-
- /**
- * Initialise the identifier for the actions created by this instance.
- * This is mandatory to be able to identify the actions in the menus after their insertion.
- */
- private void initialiseActionsId() {
- mRefreshViewerAction.setId(ActionBarContributorUtils.REFRESH_ACTION_ID);
- mShowPropertiesViewAction.setId(ActionBarContributorUtils.SHOW_PROPERTIES_ACTION_ID);
- }
-
- /**
- * Create and return a new Validate action.
- * @return The validate action created
- */
- protected ValidateAction createValidateAction() {
- return new ValidateAction();
- }
-
- /**
- * Set the style for managing the separators and the actions.
- * By default the style is {@link EditingDomainActionBarContributor#ADDITIONS_LAST_STYLE}.
- *
- * @param pStyle The style to set
- */
- public void setStyle(final int pStyle) {
- this.style = pStyle;
- }
-
- /**
- * {@inheritDoc}
- *
- * This adds the separators for 'additions' and 'settings' action in the tool bar.
- */
- @Override
- public void contributeToToolBar(final IToolBarManager pToolBarManager) {
- pToolBarManager.add(new Separator("views-settings")); //$NON-NLS-1$
- pToolBarManager.add(new Separator("views-additions")); //$NON-NLS-1$
- }
-
- /**
- * {@inheritDoc}
- *
- * When the active editor changes, this remembers the change and registers
- * this instance with it as a selection provider.
- */
- @Override
- public void setActiveEditor(final IEditorPart pPart) {
- // Call the parent method
- super.setActiveEditor(pPart);
-
- // Consider the active editor as the active part
- setActivePart(pPart);
- }
-
- /**
- * When the active part changes, this remembers the change and registers
- * this instance with it as a selection provider.
- *
- * @param pWorkbenchPart The active workbench part
- */
- public void setActivePart(final IWorkbenchPart pWorkbenchPart) {
- // Ensure that the given part is valid and different from the
- // current part referenced as active
- if (pWorkbenchPart != null && !pWorkbenchPart.equals(mActivePart)) {
- if (mActivePart != null) {
- deactivate();
- }
-
- if (pWorkbenchPart instanceof IEditingDomainProvider) {
- mActivePart = pWorkbenchPart;
- activate();
- }
-
- mActivePart = pWorkbenchPart;
- if (mSelectionProvider != null) {
- mSelectionProvider.removeSelectionChangedListener(this);
- }
- if (pWorkbenchPart != null) {
- mSelectionProvider = pWorkbenchPart.getSite().getSelectionProvider();
- mSelectionProvider.addSelectionChangedListener(this);
- if (mSelectionProvider.getSelection() != null) {
- selectionChanged(new SelectionChangedEvent(mSelectionProvider, mSelectionProvider.getSelection()));
- }
- }
- }
- getActionBars().updateActionBars();
- }
-
- /**
- * Set the id of the property view which will be shown with
- * the action {@link #mShowPropertiesViewAction}.
- *
- * @param pPropertyViewsId The properties view id
- */
- public void setPropertyViewsId(final String pPropertyViewsId) {
- mPropertyViewsId = pPropertyViewsId;
- }
-
- /**
- * @return The active part
- */
- public IWorkbenchPart getActivePart() {
- return mActivePart;
- }
-
- /**
- * {@inheritDoc}
- *
- * This implements {@link ISelectionChangedListener}, handling {@link SelectionChangedEvent}s
- * by querying for the children and siblings that can be added to the selected object
- * and updating the menus accordingly.
- */
- @Override
- public void selectionChanged(final SelectionChangedEvent pEvent) {
- // Query the new selection for appropriate new child/descriptors
- Collection<?> vNewChildDescriptorsCollection = null;
-
- final ISelection vSelection = pEvent.getSelection();
- if ((vSelection instanceof IStructuredSelection) && (((IStructuredSelection) vSelection).size() == 1)) {
- final Object vObject = ((IStructuredSelection) vSelection).getFirstElement();
-
- final EditingDomain vDomain = ((IEditingDomainProvider) mActivePart).getEditingDomain();
-
- vNewChildDescriptorsCollection = vDomain.getNewChildDescriptors(vObject, null);
- }
-
- // Generate actions for selection, then populate and redraw the menus
- mCreateChildActionsCollection = mActionBarContributorUtils.generateCreateChildActionsCollection(
- mActivePart,
- vNewChildDescriptorsCollection,
- vSelection);
- }
-
- /**
- * {@inheritDoc}
- *
- * This populates the pop-up menu before it appears with the child creation actions.
- */
- @Override
- public void menuAboutToShow(final IMenuManager pMenuManager) {
- // Call the parent method
- super.menuAboutToShow(pMenuManager);
-
- // Create the create child submenu
- MenuManager vCreateChildSubmenuManager = new MenuManager(ActionBarContributorUtils.CREATECHILD_MENU_ID);
-
- // Populate the submenu and insert it in the parent menu manager
- mActionBarContributorUtils.populateManager(vCreateChildSubmenuManager, mCreateChildActionsCollection, null);
- pMenuManager.insertBefore(ActionBarContributorUtils.EDIT_SEPARATOR_ID, vCreateChildSubmenuManager);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void addGlobalActions(final IMenuManager pMenuManager) {
- // Insert the show properties action after a custom separator for the ui actions
- pMenuManager.insertAfter(
- ActionBarContributorUtils.ADDITIONS_END_SEPARATOR_ID,
- new Separator(ActionBarContributorUtils.UI_ACTIONS_SEPARATOR_ID));
- pMenuManager.insertAfter(
- ActionBarContributorUtils.UI_ACTIONS_SEPARATOR_ID,
- mShowPropertiesViewAction);
-
- // Insert the refresh action, and update its state, after the the ui actions separator
- mRefreshViewerAction.setEnabled(mRefreshViewerAction.isEnabled());
- pMenuManager.insertAfter(ActionBarContributorUtils.UI_ACTIONS_SEPARATOR_ID, mRefreshViewerAction);
-
- // Call the parent method to add the others global actions (Validate, etc.)
- super.addGlobalActions(pMenuManager);
- }
-
- /**
- * {@inheritDoc}
- *
- * Called when a view is deactivated to deactivate all the linked actions.
- */
- @Override
- public void deactivate() {
- mActivePart.removePropertyListener(this);
-
- deleteAction.setActiveWorkbenchPart(null);
- cutAction.setActiveWorkbenchPart(null);
- copyAction.setActiveWorkbenchPart(null);
- pasteAction.setActiveWorkbenchPart(null);
- undoAction.setActiveWorkbenchPart(null);
- redoAction.setActiveWorkbenchPart(null);
-
- if (loadResourceAction != null) {
- loadResourceAction.setActiveWorkbenchPart(null);
- }
-
- if (controlAction != null) {
- controlAction.setActiveWorkbenchPart(null);
- }
-
- if (validateAction != null) {
- validateAction.setActiveWorkbenchPart(null);
- }
-
- ISelectionProvider vSelectionProvider = null;
- if (mActivePart instanceof ISelectionProvider) {
- vSelectionProvider = (ISelectionProvider) mActivePart;
- } else {
- vSelectionProvider = mActivePart.getSite().getSelectionProvider();
- }
-
- if (vSelectionProvider != null) {
- vSelectionProvider.removeSelectionChangedListener(deleteAction);
- vSelectionProvider.removeSelectionChangedListener(cutAction);
- vSelectionProvider.removeSelectionChangedListener(copyAction);
- vSelectionProvider.removeSelectionChangedListener(pasteAction);
-
- if (validateAction != null) {
- vSelectionProvider.removeSelectionChangedListener(validateAction);
- }
-
- if (controlAction != null) {
- vSelectionProvider.removeSelectionChangedListener(controlAction);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * Called when a view is activated to enable all the linked actions.
- */
- @Override
- public void activate() {
- mActivePart.addPropertyListener(this);
-
- deleteAction.setActiveWorkbenchPart(mActivePart);
- cutAction.setActiveWorkbenchPart(mActivePart);
- copyAction.setActiveWorkbenchPart(mActivePart);
- pasteAction.setActiveWorkbenchPart(mActivePart);
- undoAction.setActiveWorkbenchPart(mActivePart);
- redoAction.setActiveWorkbenchPart(mActivePart);
-
- if (validateAction != null) {
- validateAction.setActiveWorkbenchPart(mActivePart);
- }
-
- ISelectionProvider vSelectionProvider = null;
- if (mActivePart instanceof ISelectionProvider) {
- vSelectionProvider = (ISelectionProvider) mActivePart;
- } else {
- vSelectionProvider = mActivePart.getSite().getSelectionProvider();
- }
-
- if (vSelectionProvider != null) {
- vSelectionProvider.addSelectionChangedListener(deleteAction);
- vSelectionProvider.addSelectionChangedListener(cutAction);
- vSelectionProvider.addSelectionChangedListener(copyAction);
- vSelectionProvider.addSelectionChangedListener(pasteAction);
-
- if (validateAction != null) {
- vSelectionProvider.addSelectionChangedListener(validateAction);
- }
- }
-
- update();
- }
-
- /**
- * {@inheritDoc}
- *
- * Update the actions to the current selection context.
- */
- @Override
- public void update() {
- // Try to get the selection provider from the active part. It can be the active part itself
- // if it's a selection provider
- ISelectionProvider vSelectionProvider = null;
- if (mActivePart instanceof ISelectionProvider) {
- vSelectionProvider = (ISelectionProvider) mActivePart;
- } else if (mActivePart != null) {
- vSelectionProvider = mActivePart.getSite().getSelectionProvider();
- }
-
- if (vSelectionProvider != null) {
- IStructuredSelection vStructuredSelection = null;
- if (vSelectionProvider.getSelection() instanceof IStructuredSelection) {
- vStructuredSelection = (IStructuredSelection) vSelectionProvider.getSelection();
- } else {
- vStructuredSelection = StructuredSelection.EMPTY;
- }
-
- deleteAction.updateSelection(vStructuredSelection);
- cutAction.updateSelection(vStructuredSelection);
- copyAction.updateSelection(vStructuredSelection);
- pasteAction.updateSelection(vStructuredSelection);
-
- if (validateAction != null) {
- validateAction.updateSelection(vStructuredSelection);
- }
- }
-
- // Ensure that the undo and redo action have a domain to update them
- // In they don't, the update action will throw a NPE
- if (undoAction.getEditingDomain() != null) {
- undoAction.update();
- }
- if (redoAction.getEditingDomain() != null) {
- redoAction.update();
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * This implementation ensures that a delete action will clean up all references to deleted objects.
- */
- @Override
- protected boolean removeAllReferencesOnDelete() {
- return true;
- }
-}
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/editingsupport/ParameterValueEditingSupport.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/editingsupport/ParameterValueEditingSupport.java
index b260437..b68c042 100644
--- a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/editingsupport/ParameterValueEditingSupport.java
+++ b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/editingsupport/ParameterValueEditingSupport.java
@@ -30,7 +30,7 @@
/**
- * Implementation of editing support for set value of probability rule's parameters.
+ * Implementation of editing support for set value of probability rule parameters.
*
* @author $Author: jdumont $
* @version $Revision: 83 $
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/editor/AbstractActionBarContributor.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/editor/AbstractActionBarContributor.java
deleted file mode 100644
index 988c7ae..0000000
--- a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/editor/AbstractActionBarContributor.java
+++ /dev/null
@@ -1,639 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.common.ui.editor;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
-import org.apache.commons.lang3.StringUtils;
-import org.eclipse.emf.common.ui.viewer.IViewerProvider;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.emf.edit.ui.action.DeleteAction;
-import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
-import org.eclipse.emf.edit.ui.action.ValidateAction;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.handlers.CollapseAllHandler;
-import org.eclipse.ui.handlers.ExpandAllHandler;
-import org.polarsys.esf.core.common.ui.CommonUIActivator;
-import org.polarsys.esf.core.common.ui.CommonUIActivator.Implementation;
-import org.polarsys.esf.core.common.ui.actions.ActionBarContributorUtils;
-import org.polarsys.esf.core.common.ui.provider.IToolBarManagerProvider;
-
-/**
- * This is the abstract action bar contributor used for all the multi pages editors.
- *
- * It extends {@link EditingDomainActionBarContributor} which provide the standard mechanisms
- * to provide the actions on an editing domain.
- *
- * It implements {@link ISelectionChangedListener} to be able to react when the selection changed in the
- * active editor, to update the action linked to the current selection.
- *
- * This contributor will populate the editor tool bar with different kind of actions :
- * <ul>
- * <li>Actions not linked to the current context (ie: expand / collapse tree)</li>
- * <li>Actions linked to the current selection when one is set (ie: create children elements)</li>
- * </ul>
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public abstract class AbstractActionBarContributor
- extends EditingDomainActionBarContributor
- implements ISelectionChangedListener {
-
- /** Instance of utility class used by the action contributors. */
- private ActionBarContributorUtils mActionBarContributorUtils = ActionBarContributorUtils.INSTANCE;
-
- /** This keeps track of the active editor on which the actions are applied. */
- private IEditorPart mActiveEditorPart = null;
-
- /** This keeps track of the current selection provider. */
- private ISelectionProvider mSelectionProvider = null;
-
- /** This action opens the Properties view. */
- private IAction mShowPropertiesViewAction = new Action(ActionBarContributorUtils.SHOW_PROPERTIES_ACTION_LABEL) {
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- try {
- getPage().showView(IPageLayout.ID_PROP_SHEET);
- } catch (final PartInitException pException) {
- CommonUIActivator.logError(
- "Error during the opening of the Properties view", //$NON-NLS-1$
- pException);
- }
- }
- };
-
- /** This action expands the active editor content, if possible. */
- private IAction mExpandAllAction = createExpandAllAction();
-
- /** This action collapse the active editor content, if possible. */
- private IAction mCollapseAllAction = createCollapseAllAction();
-
- /**
- * This action refreshes the viewer of the current editor if the editor
- * implements {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}.
- */
- private IAction mRefreshViewerAction = new Action(ActionBarContributorUtils.REFRESH_ACTION_LABEL) {
-
- /**
- * {@inheritDoc}
- *
- * The action is enabled only if the editor implements {@link IViewerProvider}
- * to provide its owned viewer.
- */
- @Override
- public boolean isEnabled() {
- return mActiveEditorPart instanceof IViewerProvider;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- if (mActiveEditorPart instanceof IViewerProvider) {
- final Viewer vViewer = ((IViewerProvider) mActiveEditorPart).getViewer();
- if (vViewer != null) {
- vViewer.refresh();
- }
- }
- }
- };
-
- /**
- * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction} corresponding to each descriptor
- * generated for the current selection by the item provider.
- */
- private Collection<IAction> mCreateSelectChildActionsColl = Collections.emptyList();
-
- /**
- * This will contain a map of {@link org.eclipse.emf.edit.ui.action.CreateChildAction}s, keyed by sub-menu text
- * for all the create child action relative to the current selection.
- */
- private Map<String, Collection<IAction>> mCreateSelectChildMenuActionsMap = null;
-
- /** This is the menu manager into which menu contribution items should be added for CreateChild actions. */
- private IMenuManager mCreateSelectChildMenuManager = null;
-
- /**
- * Default constructor.
- * This creates an instance of the contributor with the default style
- * {@link EditingDomainActionBarContributor#ADDITIONS_LAST_STYLE}.
- */
- public AbstractActionBarContributor() {
- // Call the parent constructor and ask to add an 'additions' anchor at the end of the menu
- super(ADDITIONS_LAST_STYLE);
-
- // Create the parent action specific to the editing domain context
- // NB : The 'load resource' and 'control' actions are not needed
- validateAction = new ValidateAction();
- }
-
- /**
- * {@inheritDoc}
- *
- * This implementation also call the method to contribute to any toolbar
- * potentially provided by the active editor.
- */
- @Override
- public void init(final IActionBars pActionBars) {
- // Call the parent method
- super.init(pActionBars);
- }
-
- /**
- * Contribute to the editor toolbar, if the active editor provide a tool bar manager.
- * This method may be called only once as it will create all the actions, even the global
- * actions which doesn't need to change or be updated after their creation.
- */
- public void contributeToEditorToolBar() {
-
- // Check if the editor provide a custom toolbar manager
- if (mActiveEditorPart instanceof IToolBarManagerProvider) {
- // Get the tool bar manager from the active editor
- ToolBarManager vEditorToolBarManager = ((IToolBarManagerProvider) mActiveEditorPart).getToolBarManager();
-
- // Use a flag to known if the tool bar content have been modified
- boolean vNeedToUpdate = false;
-
- // Add the expand all action if it's not already in it
- if (vEditorToolBarManager.find(ActionBarContributorUtils.EXPAND_ALL_ACTION_ID) == null) {
- vEditorToolBarManager.add(mExpandAllAction);
- vNeedToUpdate = true;
- }
-
- // Add the collapse all action if it's not already in it
- if (vEditorToolBarManager.find(ActionBarContributorUtils.COLLAPSE_ALL_ACTION_ID) == null) {
- vEditorToolBarManager.add(mCollapseAllAction);
- vNeedToUpdate = true;
- }
-
- // Add the separator for the actions on the selected element, if it's not already in it
- if (vEditorToolBarManager.find(ActionBarContributorUtils.TOOLBAR_SEP_SELECTION_ACTIONS) == null) {
- vEditorToolBarManager.add(new Separator(ActionBarContributorUtils.TOOLBAR_SEP_SELECTION_ACTIONS));
- vNeedToUpdate = true;
- }
-
- // Add the delete action to the toolbar if it's not already in it
- // This action will react to the selection change automatically
- if (vEditorToolBarManager.find(ActionFactory.DELETE.getId()) == null) {
- vEditorToolBarManager.add(new Separator(ActionBarContributorUtils.TOOLBAR_SEP_DELETE_ACTION));
- vEditorToolBarManager.appendToGroup(ActionBarContributorUtils.TOOLBAR_SEP_DELETE_ACTION, deleteAction);
- vNeedToUpdate = true;
- }
-
-
- // Finally update the toolbar if needed
- if (vNeedToUpdate) {
- vEditorToolBarManager.update(true);
-
- vEditorToolBarManager.getControl().pack(true);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * By default, no menu is added.
- */
- @Override
- public void contributeToMenu(final IMenuManager pMenuManager) {
- // Nothing to do
- }
-
- /**
- * {@inheritDoc}
- *
- * When the active editor changes, this remembers the change and registers
- * this instance with it as a selection provider.
- */
- @Override
- public void setActiveEditor(final IEditorPart pPart) {
- // Call the parent method
- super.setActiveEditor(pPart);
-
- // Remember the active editor
- mActiveEditorPart = pPart;
-
- // If any selection provider was already registered, remove it
- if (mSelectionProvider != null) {
- mSelectionProvider.removeSelectionChangedListener(this);
- }
-
- // Then switch to the new selection provider if possible
- if (mActiveEditorPart != null) {
- // Get the selection provider from the new active editor
- mSelectionProvider = mActiveEditorPart.getSite().getSelectionProvider();
-
- // Register this instance to listen to the change on this selection provider
- mSelectionProvider.addSelectionChangedListener(this);
-
- // Fake a selection changed event to update the menus
- if (mSelectionProvider.getSelection() != null) {
- selectionChanged(new SelectionChangedEvent(mSelectionProvider, mSelectionProvider.getSelection()));
- }
-
- } else {
- // Reset the selection provider
- mSelectionProvider = null;
- }
-
- // Try to contribute to the tool bar that the active editor may provide
- contributeToEditorToolBar();
- }
-
- /**
- * {@inheritDoc}
- *
- * This implements {@link ISelectionChangedListener}, handling {@link SelectionChangedEvent}s
- * by querying for the children that can be created under the selected object and updating the menus accordingly.
- */
- @Override
- public void selectionChanged(final SelectionChangedEvent pEvent) {
- // Recreate the actions linked to the current selection in the contextual menus and in the editor toolbar
- addCreateSelectChildActions(pEvent.getSelection());
- }
-
- /**
- * Create the new child actions for the current selection, in the context menu
- * and the editor toolbar.
- *
- * @param pSelection The current selection for which the actions must be created
- */
- protected void addCreateSelectChildActions(final ISelection pSelection) {
- // Force to update the action from the current selection,
- // and recreate the actions in the menu
- addCreateSelectChildActionsToMenu(pSelection, true);
-
- // The recreate the actions in the tool bar, but without updating the
- // actions as the selection has not changed
- addCreateSelectChildActionsToEditorToolbar(pSelection, false);
- }
-
- /**
- * Create the new child actions for the current selection in the editor context menu.
- * The actions may be updated according to the given flag value. If no, the list of action
- * is not updated according to the current selection, but the menu content is refresh even so.
- *
- * @param pSelection The current selection for which the actions must be created
- * @param pUpdateActions If <code>true</code> the list of actions is updated according to the given selection
- */
- protected void addCreateSelectChildActionsToMenu(final ISelection pSelection, final boolean pUpdateActions) {
- // Remove any menu items created for the old selection
- if (mCreateSelectChildMenuManager != null) {
- mActionBarContributorUtils.depopulateManager(
- mCreateSelectChildMenuManager,
- mCreateSelectChildMenuActionsMap);
-
- mActionBarContributorUtils.depopulateManager(
- mCreateSelectChildMenuManager,
- mCreateSelectChildActionsColl);
- }
-
- // Update the list of actions used to create child for the
- // given selection only if needed
- if (pUpdateActions) {
- updateCreateSelectChildActionsCollection(pSelection);
- }
-
- // Finally populate and redraw the menus
- if (mCreateSelectChildMenuManager != null) {
- mActionBarContributorUtils.populateManager(
- mCreateSelectChildMenuManager,
- mCreateSelectChildMenuActionsMap,
- null);
-
- mActionBarContributorUtils.populateManager(
- mCreateSelectChildMenuManager,
- mCreateSelectChildActionsColl,
- null);
-
- mCreateSelectChildMenuManager.update(true);
- }
- }
-
- /**
- * Create the new child actions for the current selection in the editor toolbar.
- * The actions may be updated according to the given flag value. If no, the list of action
- * is not updated according to the current selection, but the toolbar content is refresh even so.
- *
- * @param pSelection The current selection for which the actions must be created
- * @param pUpdateActions If <code>true</code> the list of actions is updated according to the given selection
- */
- protected void addCreateSelectChildActionsToEditorToolbar(
- final ISelection pSelection,
- final boolean pUpdateActions) {
-
- // Check if the editor provide a custom toolbar manager
- if (mActiveEditorPart instanceof IToolBarManagerProvider) {
- // Use a flag to known if the tool bar content have been modified
- boolean vNeedToUpdate = false;
-
- // Get the tool bar manager from the active editor
- ToolBarManager vEditorToolBarManager = ((IToolBarManagerProvider) mActiveEditorPart).getToolBarManager();
-
- // Depopulate the tool bar with the potential existing create child actions
- for (IContributionItem vContributionItem : vEditorToolBarManager.getItems()) {
- // The actions to remove are identified with their id prefix, thus check it
- if (StringUtils.startsWith(
- vContributionItem.getId(),
- ActionBarContributorUtils.CREATECHILD_ACTION_ID_PREFIX)) {
-
- // Remove the action
- vEditorToolBarManager.remove(vContributionItem);
- vNeedToUpdate = true;
- }
- }
-
- // Update the list of actions used to create child for the
- // given selection only if needed
- if (pUpdateActions) {
- updateCreateSelectChildActionsCollection(pSelection);
- }
-
- // Then populate the tool bar with the new actions
- for (IAction vAction : mCreateSelectChildActionsColl) {
- // Check if the action is not already in the tool bar
- if (vEditorToolBarManager.find(vAction.getId()) == null) {
- // Insert the action
- vEditorToolBarManager.appendToGroup(
- ActionBarContributorUtils.TOOLBAR_SEP_SELECTION_ACTIONS,
- vAction);
-
- // Remember that the toolbar must be updated
- vNeedToUpdate = true;
- }
- }
-
- // Finally, update the toolbar if needed
- if (vNeedToUpdate) {
- vEditorToolBarManager.update(true);
- }
- }
- }
-
- /**
- * Generate the list of create child actions corresponding to the selection given in parameter,
- * and update this instance property {@link #mCreateSelectChildActionsColl} with it.
- *
- * The map of menus linked to the created action {@link #mCreateSelectChildMenuActionsMap}, is
- * also updated.
- *
- * @param pSelection The current selection in the active editor
- */
- protected void updateCreateSelectChildActionsCollection(final ISelection pSelection) {
-
- Collection<?> vNewChildDescrCollection = null;
-
- // Ensure that the selection contains only one element
- if (pSelection instanceof IStructuredSelection && ((IStructuredSelection) pSelection).size() == 1) {
- // Get the selected object
- Object vSelectedObject = ((IStructuredSelection) pSelection).getFirstElement();
-
- // Get the editing domain from the active editor, and then
- // query the new selection to find the appropriate new child descriptors
- EditingDomain vEditingDomain = null;
- if (mActiveEditorPart instanceof IEditingDomainProvider) {
- vEditingDomain = ((IEditingDomainProvider) mActiveEditorPart).getEditingDomain();
-
- // Find the new child actions corresponding to the selected objects
- // and the editing domain used in the active editor
- vNewChildDescrCollection = vEditingDomain.getNewChildDescriptors(vSelectedObject, null);
- }
- }
-
- // Generate the actions corresponding to the current selection
- mCreateSelectChildActionsColl = mActionBarContributorUtils.generateCreateChildActionsCollection(
- mActiveEditorPart,
- vNewChildDescrCollection,
- pSelection);
-
- // Then update the map menus with the created actions
- mCreateSelectChildMenuActionsMap =
- mActionBarContributorUtils.extractSubmenuActions(mCreateSelectChildActionsColl);
- }
-
- /**
- * {@inheritDoc}
- *
- * This populates the pop-up menu before it appears with the child creation actions.
- */
- @Override
- public void menuAboutToShow(final IMenuManager pMenuManager) {
- // Call the parent method
- super.menuAboutToShow(pMenuManager);
-
- // Create the create child submenu
- MenuManager vCreateChildSubmenuManager = new MenuManager(ActionBarContributorUtils.CREATECHILD_MENU_LABEL);
-
- // Populate the submenu and insert it in the parent menu manager
- mActionBarContributorUtils.populateManager(
- vCreateChildSubmenuManager,
- mCreateSelectChildMenuActionsMap,
- null);
-
- mActionBarContributorUtils.populateManager(
- vCreateChildSubmenuManager,
- mCreateSelectChildActionsColl,
- null);
-
- pMenuManager.insertBefore(ActionBarContributorUtils.EDIT_SEPARATOR_ID, vCreateChildSubmenuManager);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void addGlobalActions(final IMenuManager pMenuManager) {
-
- // Insert the show properties action after a custom separator for the ui actions
- pMenuManager.insertAfter(
- ActionBarContributorUtils.ADDITIONS_END_SEPARATOR_ID,
- new Separator(ActionBarContributorUtils.UI_ACTIONS_SEPARATOR_ID));
- pMenuManager.insertAfter(
- ActionBarContributorUtils.UI_ACTIONS_SEPARATOR_ID,
- mShowPropertiesViewAction);
-
- // Insert the refresh action, and update its state, after the the ui actions separator
- mRefreshViewerAction.setEnabled(mRefreshViewerAction.isEnabled());
- pMenuManager.insertAfter(ActionBarContributorUtils.UI_ACTIONS_SEPARATOR_ID, mRefreshViewerAction);
-
- // Call the parent method to add the others global actions (Validate, etc.)
- super.addGlobalActions(pMenuManager);
- }
-
- /**
- * {@inheritDoc}
- *
- * This implementation ensures that a delete action will clean up all references to deleted objects.
- */
- @Override
- protected boolean removeAllReferencesOnDelete() {
- return true;
- }
-
- /**
- * {@inheritDoc}
- *
- * Overridden to ensure that the delete action id is set.
- */
- @Override
- protected DeleteAction createDeleteAction() {
- // Create the custom action
- DeleteAction vDeleteAction = new DeleteAction(removeAllReferencesOnDelete());
-
- // Update the action to set its id
- vDeleteAction.setId(ActionFactory.DELETE.getId());
-
- return vDeleteAction;
- }
-
- /**
- * Create the expand all action to apply on the active editor,
- * if this one is a viewer provider.
- *
- * @return The expand all action created
- */
- protected IAction createExpandAllAction() {
- // Get the action image
- final ImageDescriptor vImageDescriptor =
- CommonUIActivator.getPlugin().getImageRegistry().getDescriptor(
- Implementation.ICON_EXPAND_ALL_KEY);
-
- // Create the action
- final IAction vExpandAllAction = new Action(
- ActionBarContributorUtils.EXPAND_ALL_ACTION_LABEL,
- vImageDescriptor) {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- // Ensure that the active editor is a viewer provider
- if (mActiveEditorPart instanceof IViewerProvider) {
- // Get the viewer from the active editor
- final Viewer vActiveViewer = ((IViewerProvider) mActiveEditorPart).getViewer();
-
- // Check if the viewer is eligible for an expand action
- if (vActiveViewer instanceof AbstractTreeViewer) {
- // Prepare the expand action asynchronously, on the UI thread
- mActiveEditorPart.getSite().getShell().getDisplay().asyncExec(new Runnable() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- // Create the action handler on the viewer
- final ExpandAllHandler vExpandAllHandler =
- new ExpandAllHandler((AbstractTreeViewer) vActiveViewer);
-
- // And finally execute it
- vExpandAllHandler.execute(null);
- }
- });
- }
- }
- }
- };
-
- // Set the unique id for this action
- vExpandAllAction.setId(ActionBarContributorUtils.EXPAND_ALL_ACTION_ID);
-
- return vExpandAllAction;
- }
-
- /**
- * Create the collapse all action to apply on the active editor,
- * if this one is a viewer provider.
- *
- * @return The collapse all action created
- */
- protected IAction createCollapseAllAction() {
- // Get the action image
- final ImageDescriptor vImageDescriptor =
- CommonUIActivator.getPlugin().getImageRegistry().getDescriptor(
- Implementation.ICON_COLLAPSE_ALL_KEY);
-
- // Create the action
- final IAction vCollapseAllAction = new Action(
- ActionBarContributorUtils.COLLAPSE_ALL_ACTION_LABEL,
- vImageDescriptor) {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- // Ensure that the active editor is a viewer provider
- if (mActiveEditorPart instanceof IViewerProvider) {
- // Get the viewer from the active editor
- final Viewer vActiveViewer = ((IViewerProvider) mActiveEditorPart).getViewer();
-
- // Check if the viewer is eligible for an expand action
- if (vActiveViewer instanceof AbstractTreeViewer) {
- // Prepare the expand action asynchronously, on the UI thread
- mActiveEditorPart.getSite().getShell().getDisplay().asyncExec(new Runnable() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- // Create the action handler on the viewer
- final CollapseAllHandler vCollapseAllHandler =
- new CollapseAllHandler((AbstractTreeViewer) vActiveViewer);
-
- // And finally execute it
- vCollapseAllHandler.execute(null);
- }
- });
- }
- }
- }
- };
-
- // Set the unique id for this action
- vCollapseAllAction.setId(ActionBarContributorUtils.COLLAPSE_ALL_ACTION_ID);
-
- return vCollapseAllAction;
- }
-
-}
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/editor/AbstractMultiPageEditor.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/editor/AbstractMultiPageEditor.java
deleted file mode 100644
index fd8220c..0000000
--- a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/editor/AbstractMultiPageEditor.java
+++ /dev/null
@@ -1,1653 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.common.ui.editor;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EventObject;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.lang3.StringUtils;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.common.command.BasicCommandStack;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CommandStack;
-import org.eclipse.emf.common.command.CommandStackListener;
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.common.ui.MarkerHelper;
-import org.eclipse.emf.common.ui.editor.ProblemEditorPart;
-import org.eclipse.emf.common.ui.viewer.IViewerProvider;
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.common.util.WrappedException;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator;
-import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
-import org.eclipse.emf.edit.provider.IDisposable;
-import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
-import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter;
-import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
-import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter;
-import org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider;
-import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper;
-import org.eclipse.emf.edit.ui.util.EditUIUtil;
-import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.TreeViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-import org.eclipse.ui.ide.IGotoMarker;
-import org.eclipse.ui.part.MultiPageEditorPart;
-import org.eclipse.ui.views.properties.IPropertySheetPage;
-import org.eclipse.ui.views.properties.IPropertySourceProvider;
-import org.eclipse.ui.views.properties.PropertyColumnLabelProvider;
-import org.eclipse.ui.views.properties.PropertySheet;
-import org.eclipse.ui.views.properties.PropertySheetPage;
-import org.eclipse.uml2.uml.UMLPackage;
-import org.polarsys.esf.core.common.adapter.ProblemIndicationAdapter;
-import org.polarsys.esf.core.common.listener.IProblemIndicationListener;
-import org.polarsys.esf.core.common.ui.CommonUIActivator;
-import org.polarsys.esf.core.common.ui.adapter.PartListenerAdapter;
-import org.polarsys.esf.core.common.ui.filter.AbstractFilter;
-import org.polarsys.esf.core.common.ui.filter.IFilterPartListener;
-import org.polarsys.esf.core.common.ui.filter.NamePropertyFilter;
-import org.polarsys.esf.core.common.ui.provider.AdapterFactoryColumnLabelProvider;
-import org.polarsys.esf.core.common.ui.provider.IToolBarManagerProvider;
-import org.polarsys.esf.core.common.ui.view.properties.ArrayInputPropertySourceProvider;
-import org.polarsys.esf.core.common.ui.view.properties.PropertySourceProvider;
-import org.polarsys.esf.core.common.ui.widget.TreeViewerUtils;
-import org.polarsys.esf.core.common.visitor.ResourceDeltaVisitor;
-
-/**
- * This is the abstract base for all the multi page editor, used to create and edit a resource content.
- * The default implementation will manage a main page with a tree viewer and a toolbar, and a optional page
- * only displayed if an error is identified in the resource content.
- *
- * It extends {@link MultiPageEditorPart} by convenience, even if it actually contains only one page.
- *
- * It implements :
- * <ul>
- * <li>{@link IEditingDomainProvider} : To provide the editing domain that it edits</li>
- * <li>{@link ISelectionProvider} : To provide its selection to potential listeners</li>
- * <li>{@link IMenuListener} : To be able to react when its context menu is going to be opened</li>
- * <li>{@link IViewerProvider} : To provide its viewer</li>
- * <li>{@link IGotoMarker} : To be able to react to a 'Go to' action, pointing to an element in its viewer</li>
- * <li>{@link IToolBarManagerProvider} : To be able to provide the manager of the custom toolbar in the main page</li>
- * <li>{@link IProblemIndicationListener} : To be able to react to the resources analysis, and warn the user if any
- * error is detected</li>
- * <li>{@link IFilterPartListener} : To be able to filter its content according to a text value.</li>
- * </ul>
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public abstract class AbstractMultiPageEditor
- extends MultiPageEditorPart
- implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider, IGotoMarker,
- IToolBarManagerProvider, IProblemIndicationListener, IFilterPartListener {
-
- /** Size of the first column. */
- private static final int FIRST_COLUMN_DEFAULT_SIZE = 400;
-
- /** This keeps track of the editing domain that is used to track all changes to the resource. */
- private AdapterFactoryEditingDomain mEditingDomain = null;
-
- /** This is the adapter factory used for providing views of the resource content. */
- private AdapterFactory mAdapterFactory = null;
-
- /** The property source provider used in the viewer. */
- private IPropertySourceProvider mPropertySourceProvider = null;
-
- /**
- * The listener to plug to the command stack of the editing domain used,
- * to be warned when any change append.
- */
- private CommandStackListener mCommandStackListener = new CommandStackListener() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void commandStackChanged(final EventObject pEvent) {
- // Use an asynchronous UI thread, to call the 'handleCommandStackChanged' method
- // to react to the commands execution
- AbstractMultiPageEditor.this.getSite().getShell().getDisplay().asyncExec(new Runnable() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- handleCommandStackChanged(((CommandStack) pEvent.getSource()).getMostRecentCommand());
- }
- });
- }
- };
-
- /** This is the property sheet page provided by the editor. */
- private PropertySheetPage mPropertySheetPage = null;
-
- /** This is the tool bar displayed in the main page of the editor. */
- private ToolBarManager mEditorToolBarManager = null;
-
- /**
- * This is the tree viewer displayed in the editor main page,
- * to edit the resource content.
- */
- private TreeViewer mEditorTreeViewer = null;
-
- /** This listens to the selection in the active viewer. */
- private ISelectionChangedListener mSelectionChangedListener = null;
-
- /** This keeps track of all the ISelectionChangedListener that are listening to this editor. */
- private List<ISelectionChangedListener> mSelectionChangedListenersList = new ArrayList<ISelectionChangedListener>();
-
- /** This keeps track of the selection of the editor as a whole. */
- private ISelection mEditorSelection = StructuredSelection.EMPTY;
-
- /**
- * The MarkerHelper is responsible for creating workspace resource markers presented
- * in Eclipse's Problems View.
- */
- private MarkerHelper mMarkerHelper = new EditUIMarkerHelper();
-
- /**
- * This listens to the parts activation to react when
- * the properties view or this editor instance becomes active for example.
- */
- private IPartListener mPartListener = createPartListener();
-
- /** Resources that have been removed since last activation. */
- private List<Resource> mRemovedResourcesList = new ArrayList<Resource>();
-
- /** Resources that have been changed since last activation from other editors or views. */
- private List<Resource> mChangedResourcesList = new ArrayList<Resource>();
-
- /** Resources that have been saved. */
- private List<Resource> mSavedResourcesList = new ArrayList<Resource>();
-
- /** Controls whether the problem indication should be updated or not. */
- private boolean mUpdateProblemIndication = true;
-
- /** Adapter used to analyse the resources when they are going to be loaded. */
- private ProblemIndicationAdapter mProblemIndicationAdapter = new ProblemIndicationAdapter();
-
- /**
- * This listens for workspace changes to maintain the lists of changed or removed resources.
- * This is mandatory to treat any edition conflict with other views or editors.
- */
- private IResourceChangeListener mWorkspaceChangeListener = new IResourceChangeListener() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void resourceChanged(final IResourceChangeEvent pEvent) {
- // Get the delta identifying all the changes
- IResourceDelta vDelta = pEvent.getDelta();
-
- try {
- // Build the visitor instance and launch it
- final ResourceDeltaVisitor vVisitor = new ResourceDeltaVisitor(mEditingDomain.getResourceSet());
- vDelta.accept(vVisitor);
-
- // Check if any resources have been removed
- if (!vVisitor.getRemovedResources().isEmpty()) {
-
- // Remove from the saved resources those which have been removed
- mSavedResourcesList.removeAll(vVisitor.getChangedResources());
-
- // Remember of the resources which have been removed
- mRemovedResourcesList.addAll(vVisitor.getRemovedResources());
-
- // Use an asynchronous UI thread to close the editor if the
- // resources used are deleted
- getSite().getShell().getDisplay().asyncExec(new Runnable() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- if (!isDirty()) {
- getSite().getPage().closeEditor(AbstractMultiPageEditor.this, false);
- }
- }
- });
- }
-
- // Check if any resources have changed
- if (!vVisitor.getChangedResources().isEmpty()) {
-
- // Loop on the changed resource found by the visitor to update the list
- // of resources managed by this editor
- for (Resource vResource : vVisitor.getChangedResources()) {
-
- // Check if the resource is considered as saved
- if (mSavedResourcesList.contains(vResource)) {
- // The resource is considered as saved by the editor, thus
- // the change found by the visitor is linked to the save action.
- // In other words, the resource is not changed from the editor point of view,
- // but it can now be removed from the saved resources list to prepare its next change
- mSavedResourcesList.remove(vResource);
- } else {
- // The resource is not considered as saved, the change
- // found by the visitor was a real change from an other editor
- // Thus add the resource in the corresponding list
- mChangedResourcesList.add(vResource);
- }
- }
-
- // Use an asynchronous UI thread to refresh the editor if the
- // resources used have changed
- getSite().getShell().getDisplay().asyncExec(new Runnable() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- if (AbstractMultiPageEditor.this.equals(getSite().getPage().getActiveEditor())) {
- handleActivate();
- }
- }
- });
- }
-
- } catch (final CoreException pException) {
- CommonUIActivator.logError("Error due to a resource change", //$NON-NLS-1$
- pException);
- }
- }
- };
-
- /**
- * Default constructor.
- */
- public AbstractMultiPageEditor() {
- // Call the parent constructor
- super();
-
- // Initialise the editing domain used by the editor
- initializeEditingDomain();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dispose() {
- // Disable the problems indication update
- mUpdateProblemIndication = false;
-
- // Remove the listeners from the different services
- // ... The workspace listener
- ResourcesPlugin.getWorkspace().removeResourceChangeListener(mWorkspaceChangeListener);
- // ... The parts listener
- if (mPartListener != null) {
- getSite().getPage().removePartListener(mPartListener);
- }
-
- // Dispose the adapter factory used in the editor
- if (mAdapterFactory instanceof IDisposable) {
- ((IDisposable) mAdapterFactory).dispose();
- }
-
- // Unregister the active editor from the action bar
- if (this.equals(getActionBarContributor().getActiveEditor())) {
- getActionBarContributor().setActiveEditor(null);
- }
-
- // Dispose the views provided by this editor
- // ... The property sheet page
- if (mPropertySheetPage != null) {
- mPropertySheetPage.dispose();
- }
-
- super.dispose();
- }
-
- /**
- * {@inheritDoc}
- *
- * This implementation sets the editor site to the given site, its
- * input to the given input, and the site's selection provider this editor instance.
- */
- @Override
- public void init(final IEditorSite pSite, final IEditorInput pEditorInput) {
- // Set the editor site
- setSite(pSite);
-
- // Set the editor input and launch an notification for this update
- setInputWithNotify(pEditorInput);
-
- // Set the editor title, with the input name
- setPartName(pEditorInput.getName());
-
- // Set this instance as selection provider of the site
- pSite.setSelectionProvider(this);
-
- // If a part listener is created, register it
- if (mPartListener != null) {
- pSite.getPage().addPartListener(mPartListener);
- }
-
- // Register to listen to the problems indication
- mProblemIndicationAdapter.addProblemIndicationListener(this);
-
- // Finally, add a listener to the workspace resources
- ResourcesPlugin.getWorkspace().addResourceChangeListener(
- mWorkspaceChangeListener,
- IResourceChangeEvent.POST_CHANGE);
- }
-
- /**
- * This sets up the editing domain for the model editor.
- */
- protected void initializeEditingDomain() {
- // Create the adapter factory
- mAdapterFactory = createAdapterFactory();
-
- // Create the command stack used to notify this editor as commands are executed
- CommandStack vCommandStack = createCommandStack();
-
- // Create the editing domain with the created command stack
- mEditingDomain =
- new AdapterFactoryEditingDomain(mAdapterFactory, vCommandStack, new HashMap<Resource, Boolean>());
- }
-
- /**
- * {@inheritDoc}
- *
- * This is important for implementing the static methods of {@link AdapterFactoryEditingDomain} and for supporting
- * {@link org.eclipse.emf.edit.ui.action.CommandAction}.
- */
- @Override
- public EditingDomain getEditingDomain() {
- return mEditingDomain;
- }
-
- /**
- * Create and return an instance of {@link AdapterFactory} and initialise it with the adapter factories
- * linked to the manipulated resources.
- *
- * @return The created {@link ComposedAdapterFactory}
- */
- protected abstract AdapterFactory createAdapterFactory();
-
- /**
- * Create and return a default command stack, which allow to react to its changes
- * using the {@link AbstractMultiPageEditor#handleCommandStackChanged(Command)} method.
- *
- * @return The command stack created
- */
- protected CommandStack createCommandStack() {
- // Create the command stack that will notify this editor as commands are executed
- BasicCommandStack vCommandStack = new BasicCommandStack();
-
- // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus
- vCommandStack.addCommandStackListener(mCommandStackListener);
-
- return vCommandStack;
- }
-
- /**
- * This method is called when the command stack is changed, to allow the
- * page to react. By default, this will simply select the objects
- * affected by the command in the viewer, and refresh the provided property
- * sheet page.
- *
- * @param pMostRecentCommand The most recent command
- */
- protected void handleCommandStackChanged(final Command pMostRecentCommand) {
-
- // Change the editor state to dirty
- firePropertyChange(IEditorPart.PROP_DIRTY);
-
- if (pMostRecentCommand != null) {
-
- // Refresh the tree content
- // NB : As a same object can be displayed several times in the tree,
- // the standard refresh which uses the first affected object instance
- // is not sufficient. A full refresh is mandatory, for example to display
- // correctly a new child on each object representation, and not only on the first one
- if (mEditorTreeViewer != null) {
- mEditorTreeViewer.refresh();
- }
-
- // Try to select the objects affected by the last command
- setSelectionToViewer(pMostRecentCommand.getAffectedObjects());
- }
-
- // Refresh the property sheet page content with the new selection
- if (mPropertySheetPage != null && !mPropertySheetPage.getControl().isDisposed()) {
- mPropertySheetPage.refresh();
- }
- }
-
- /**
- * Handles activation of the editor or it's associated views, like the properties view.
- */
- protected void handleActivate() {
-
- // Recompute the read only state of the resources
- if (mEditingDomain.getResourceToReadOnlyMap() != null) {
- mEditingDomain.getResourceToReadOnlyMap().clear();
-
- // Refresh any actions that may become enabled or disabled
- setSelection(getSelection());
- }
-
- if (!mRemovedResourcesList.isEmpty()) {
- // If some resources have been removed since
- // the last activation, ask the user if the changes
- // must be discarded
- if (handleDirtyConflict()) {
- // The user has chosen to close the editor and discard the changes
- getSite().getPage().closeEditor(AbstractMultiPageEditor.this, false);
- } else {
- // The user wants to keep the changes, so clear the changes collections
- mRemovedResourcesList.clear();
- mChangedResourcesList.clear();
- mSavedResourcesList.clear();
- }
-
- } else if (!mChangedResourcesList.isEmpty()) {
- // If some resources have been changed since
- // the last activation, handle it
-
- // ... First remove form the changes all what has been saved
- mChangedResourcesList.removeAll(mSavedResourcesList);
-
- // ... Then handle the changes
- handleChangedResources();
-
- // ... And finally clear the changes collections
- mChangedResourcesList.clear();
- mSavedResourcesList.clear();
- }
- }
-
- /**
- * Handles what to do with changed resources on activation.
- */
- protected void handleChangedResources() {
- // Check if some changes have been identified since last activation
- if (!mChangedResourcesList.isEmpty()) {
-
- if (!isDirty() || handleDirtyConflict()) {
- // If the editor is not dirty or if the user has chosen
- // to discard the changes, the editor resources must be
- // reloaded, and revalidated
-
- if (isDirty()) {
- // If the editor is dirty, all the resources of the
- // current resources set are considered as changed
- mChangedResourcesList.addAll(mEditingDomain.getResourceSet().getResources());
- }
-
- // Dispose all the commands of the stack
- mEditingDomain.getCommandStack().flush();
-
- // Temporary disable the problems indication, while the
- // diagnostics are updated
- mUpdateProblemIndication = false;
-
- // Loop on the resources considered as changed since the last activation
- // to try to load them and ensure that they are valid
- for (Resource vResource : mChangedResourcesList) {
- if (vResource.isLoaded()) {
- // If the resource is already loaded, unload it
- vResource.unload();
-
- try {
- // Then try to reload it
- vResource.load(Collections.EMPTY_MAP);
- } catch (final IOException pException) {
- // An exception as been thrown during the resource load,
- // remember of the resource problem
- mProblemIndicationAdapter.analyzeResource(vResource, pException);
- }
- }
- }
-
- // If the editor selection points to something which is unloaded,
- // reset the selection
- if (AdapterFactoryEditingDomain.isStale(mEditorSelection)) {
- setSelection(StructuredSelection.EMPTY);
- }
-
- // Finally, reactivate the problems indication
- mUpdateProblemIndication = true;
-
- // Finally, get the diagnostic from the problem indication adapter
- // and update its content
- updateProblemIndication(mProblemIndicationAdapter.getDiagnostic());
- }
- }
- }
-
- /**
- * Shows a dialog that asks if conflicting changes should be discarded.
- *
- * @return <code>true</code> if the changes in the editor must be discarded
- */
- protected boolean handleDirtyConflict() {
- return MessageDialog.openQuestion(
- getSite().getShell(),
- CommonUIActivator.getMessages().getString("AbstractMultiPageEditor.fileconflict.title"), //$NON-NLS-1$
- CommonUIActivator.getMessages().getString("AbstractMultiPageEditor.fileconflict.message")); //$NON-NLS-1$
- }
-
- /**
- * This sets the selection into whichever viewer is active.
- * It can be the viewer in the editor or in one of its linked view.
- *
- * @param pSelectionCollection The collection of elements to select
- */
- protected void setSelectionToViewer(final Collection<?> pSelectionCollection) {
-
- // Ensure that the collection to select is valid
- if (pSelectionCollection != null && !pSelectionCollection.isEmpty()) {
-
- // Use an asynchronous UI thread to update the selection
- getSite().getShell().getDisplay().asyncExec(new Runnable() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- // Try to select the items in the editor content viewer
- if (mEditorTreeViewer != null) {
- mEditorTreeViewer.setSelection(new StructuredSelection(pSelectionCollection.toArray()), true);
- }
- }
- });
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * This returns the viewer used to edit the resource content,
- * as required by the {@link IViewerProvider} interface.
- *
- * Moreover, it's overridden to return a {@link TreeViewer} instead of a {@link Viewer}.
- *
- */
- @Override
- public TreeViewer getViewer() {
- return mEditorTreeViewer;
- }
-
- /**
- * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
- *
- * @param pViewer The viewer for which the context menu will be created
- */
- protected void createContextMenuFor(final StructuredViewer pViewer) {
- // Create the context menu manager
- MenuManager vContextMenuManager = new MenuManager("#PopUp"); //$NON-NLS-1$
-
- vContextMenuManager.add(new Separator("additions")); //$NON-NLS-1$
- vContextMenuManager.setRemoveAllWhenShown(true);
- vContextMenuManager.addMenuListener(this);
-
- // Register the menu manager created as the viewer context menu
- Menu vContextMenu = vContextMenuManager.createContextMenu(pViewer.getControl());
- pViewer.getControl().setMenu(vContextMenu);
- getSite().registerContextMenu(vContextMenuManager, new UnwrappingSelectionProvider(pViewer));
- }
-
- /**
- * This creates the drag and drop support mechanisms for the given viewer.
- *
- * @param pViewer The viewer for which the drag and drop supports will be created
- */
- protected void createDragAndDropSupportFor(final StructuredViewer pViewer) {
- // Get the drag and drop operations supported
- int vDndOperations = getDragAndDropSupportedOperations();
-
- Transfer[] vTransfersArray = new Transfer[] {LocalTransfer.getInstance()};
-
- // Add the drag and drop support to the viewer
- pViewer.addDragSupport(vDndOperations, vTransfersArray, new ViewerDragAdapter(pViewer));
-
- pViewer.addDropSupport(vDndOperations, vTransfersArray, new EditingDomainViewerDropAdapter(
- mEditingDomain,
- pViewer));
- }
-
- /**
- * Return an <code>int</code> corresponding to the operations
- * supported by the drag and drop actions.
- *
- * By default, the drag and drop are allowed for a 'move' action only.
- *
- * @return The supported drag and drop operation flag
- */
- protected int getDragAndDropSupportedOperations() {
- return DND.DROP_MOVE;
- }
-
- /**
- * This is the method called to load the resource used as input
- * from the editing domain's resource set.
- *
- * This will analyse the resource to find any problem.
- */
- protected void initializeInputResource() {
- // Get the URI of the resource used as input for the editor
- URI vResourceURI = EditUIUtil.getURI(getEditorInput());
-
- Exception vException = null;
- Resource vResource = null;
-
- try {
- // Try to load the resource through the editing domain
- vResource = mEditingDomain.getResourceSet().getResource(vResourceURI, true);
-
- } catch (final WrappedException pException) {
- // An exception is thrown during the load, get the resource without loading it
- vException = pException;
- vResource = mEditingDomain.getResourceSet().getResource(vResourceURI, false);
- }
-
- // Analyse the resource and remember of the resulting diagnostic if there is any error
- mProblemIndicationAdapter.analyzeResource(vResource, vException);
-
- // Finally, register the problem indication adapter to the resource set adapter
- // to listen to the events on the resources
- mEditingDomain.getResourceSet().eAdapters().add(mProblemIndicationAdapter);
- }
-
- /**
- * Find the initial input used in the viewer of this editor.
- *
- * @return The initial input found
- */
- protected abstract Object getInitialInput();
-
- /**
- * {@inheritDoc}
- *
- * This is the method used by the framework to install your own pages
- * in the editor. This default implementation will create and add a main page,
- * and prepare the editor to be able to display tabs if other pages are added.
- */
- @Override
- public void createPages() {
- // Creates the model from the editor input
- initializeInputResource();
-
- // Only creates the other pages if there is something that can be edited
- if (!getEditingDomain().getResourceSet().getResources().isEmpty()) {
-
- // Create the main page, used to edit the resource content
- Composite vMainPage = createMainPage();
-
- // Then add the new page to the editor and set its title
- final int vPageIndex = addPage(vMainPage);
- setPageText(vPageIndex, getMainPageTitle());
-
- // Add optionally others pages
- createOptionalPages();
-
- // Use and asynchronous UI thread to activate the new page
- getSite().getShell().getDisplay().asyncExec(new Runnable() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- setActivePage(vPageIndex);
- }
- });
-
- }
-
- // Ensures that this editor will only display the page's tab
- // area if there are more than one page
- getContainer().addControlListener(new ControlAdapter() {
-
- /** Flag used to prevent from untimely resized events. */
- private boolean mGuard = false;
-
- /**
- * {@inheritDoc}
- *
- * Hide the tabs during the resizing.
- */
- @Override
- public void controlResized(final ControlEvent pEvent) {
- // Use a guard to prevent from untimely events as the
- // tabs hiding will launch resized events
- if (!mGuard) {
- mGuard = true;
- hideTabs();
- mGuard = false;
- }
- }
- });
-
- // Finally, get the diagnostic from the problem indication adapter
- // and update its content
- updateProblemIndication(mProblemIndicationAdapter.getDiagnostic());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setFocus() {
- // Set the focus to the active page
- getControl(getActivePage()).setFocus();
- }
-
- /**
- * If there is just one page in the multi-page editor part,
- * this hides the single tab at the bottom.
- */
- private void hideTabs() {
- // Ensure that there is just one page
- if (getPageCount() <= 1) {
- // Reset the first page text
- setPageText(0, StringUtils.EMPTY);
-
- if (getContainer() instanceof CTabFolder) {
- // Remove the tabs from the container
- ((CTabFolder) getContainer()).setTabHeight(1);
- Point vPoint = getContainer().getSize();
- getContainer().setSize(vPoint.x, vPoint.y + 6);
- }
- }
- }
-
- /**
- * If there is more than one page in the multi-page editor part,
- * this shows the tabs at the bottom.
- */
- private void showTabs() {
- // Ensure that there is more than one page
- if (getPageCount() > 1) {
- // Update the page text
- setPageText(0, getMainPageTitle());
-
- if (getContainer() instanceof CTabFolder) {
- // Display the tabs in the container
- ((CTabFolder) getContainer()).setTabHeight(SWT.DEFAULT);
- Point vPoint = getContainer().getSize();
- getContainer().setSize(vPoint.x, vPoint.y - 6);
- }
- }
- }
-
- /**
- * Create optional pages. By default, nothing is done.
- */
- protected void createOptionalPages() {
- // Nothing to do
- }
-
- /**
- * Create a composite corresponding to the main page of the editor, containing a
- * custom toolbar and a tree viewer used to edit the resource content.
- *
- * @return The main composite corresponding to the page created
- */
- protected Composite createMainPage() {
- // Create the page main composite
- Composite vMainComposite = new Composite(getContainer(), SWT.NONE);
-
- // Set the main composite layout
- GridLayout vMainLayout = new GridLayout();
- vMainLayout.horizontalSpacing = 0;
- vMainLayout.verticalSpacing = 0;
- vMainLayout.marginHeight = 0;
- vMainLayout.marginWidth = 0;
- vMainComposite.setLayout(vMainLayout);
- vMainComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- // Create the editor toolbar
- createMainToolbar(vMainComposite);
-
- // Create and initialise the tree viewer
- createMainTreeViewer(vMainComposite);
-
- // Create the context menu for the viewer, once the selection is updated
- createContextMenuFor(mEditorTreeViewer);
-
- // Create the drag and drop support for the new viewer
- createDragAndDropSupportFor(mEditorTreeViewer);
-
- return vMainComposite;
- }
-
- /**
- * Return the title for the main page created by the method {@link AbstractMultiPageEditor#createMainPage()}.
- *
- * @return The main page title
- */
- protected abstract String getMainPageTitle();
-
- /**
- * Create the tool bar for the main page, in the parent composite
- * given. This will also create the tool bar manager used to add
- * the actions in the toolbar.
- *
- * @param pParent The parent composite where the toolbar must be created
- */
- protected void createMainToolbar(final Composite pParent) {
- // Create the toolbar at the top of the page main composite
- // NB : Use the flat style, to allow the display of separator bars, and don't
- // set any layout to avoid UI bugs (see ToolBar javadoc)
- ToolBar vEditorToolBar = new ToolBar(pParent, SWT.FLAT | SWT.RIGHT | SWT.HORIZONTAL);
- vEditorToolBar.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false));
-
- // Create the toolbar manager, linked to the tool bar
- // It will be this manager which will be used to add actions in the toolbar
- mEditorToolBarManager = new ToolBarManager(vEditorToolBar);
- }
-
- /**
- * Create the tree viewer in the main page to edit the resource content.
- * The tree viewer is created in the parent composite given.
- *
- * This will also create the selection change listener and attach it to the
- * tree viewer created.
- *
- * Moreover, the tree viewer is directly initialised with the needed label and
- * content provider, and with its input.
- *
- * @param pParent The parent composite where the toolbar must be created
- */
- protected void createMainTreeViewer(final Composite pParent) {
- // Create a tree viewer, allowing multiple selection
- mEditorTreeViewer = new TreeViewer(pParent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
-
- mEditorTreeViewer.getTree().setLayout(new GridLayout());
- mEditorTreeViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- mEditorTreeViewer.getTree().setLinesVisible(true);
-
- // Add all the known filters to the tree viewer
- for (AbstractFilter vFilter : getFilters()) {
- mEditorTreeViewer.addFilter(vFilter);
- }
-
- // Create the selection changed listener on the new tree viewer
- if (mSelectionChangedListener == null) {
- mSelectionChangedListener = new ISelectionChangedListener() {
-
- /**
- * {@inheritDoc}
- *
- * This just notifies those things that are affected by the section.
- */
- @Override
- public void selectionChanged(final SelectionChangedEvent pSelectionChangedEvent) {
- setSelection(pSelectionChangedEvent.getSelection());
- }
- };
- }
-
- // Start listening to the new tree viewer
- mEditorTreeViewer.addSelectionChangedListener(mSelectionChangedListener);
-
- // Create the required column for the tree viewer
- // NB : This column will use the label provider which will be set the
- // the tree viewer hereafter
- int vFirstColumnSize = FIRST_COLUMN_DEFAULT_SIZE;
- if (1 == getFinalColumnNumber()) {
- // There will be only one column, take a maximum size
- vFirstColumnSize = FIRST_COLUMN_DEFAULT_SIZE * 2;
- }
- createMainTreeViewerRequiredColumn(vFirstColumnSize);
-
- // Set the behaviour of the tree viewer, to customise how the elements are displayed
- // and what is the content of the tree
- mEditorTreeViewer.setContentProvider(createContentProvider());
- mEditorTreeViewer.setLabelProvider(createLabelProvider());
-
- // Create the optional columns
- // NB : These columns will use their own label provider,
- // defined from the property that they will display
- createMainTreeViewerOptionalColumns();
-
- // Once all the columns are added, ensure that the header will be displayed
- mEditorTreeViewer.getTree().setHeaderVisible(true);
-
- // Set the viewer input
- mEditorTreeViewer.setInput(getInitialInput());
-
- // Then expand the first level if possible to don't display
- // only the root element by default
- mEditorTreeViewer.expandToLevel(2);
- }
-
- /**
- * Create the first required column in the tree viewer of the main page.
- * This column will use the tree viewer label provider.
- *
- * In the default implementation, the required column is used to display
- * the value of the 'name' property, for all the elements.
- *
- * @param pInitialSize The initial width of column
- */
- protected void createMainTreeViewerRequiredColumn(final int pInitialSize) {
- // Create the required column, to display the object name
- createMainTreeViewerColumn(
- CommonUIActivator.getMessages().getString("AbstractMultiPageEditor.requiredcolumn.header"), //$NON-NLS-1$
- SWT.LEFT,
- pInitialSize,
- UMLPackage.Literals.NAMED_ELEMENT__NAME.getName());
- }
-
- /**
- * Create the others columns in the tree viewer of the main page.
- * Theses columns will use their own label provider.
- *
- * In the default implementation, no column is added.
- */
- protected void createMainTreeViewerOptionalColumns() {
- // Nothing to do by default
- }
-
- /**
- * Return the property source provider to associate to the viewer.
- * If no property source provider is known, create a default one.
- *
- * @return Return the property source provider to associate to the viewer
- */
- protected IPropertySourceProvider getPropertySourceProvider() {
- if (mPropertySourceProvider == null) {
- mPropertySourceProvider = createPropertySourceProvider();
- }
- return mPropertySourceProvider;
- }
-
- /**
- * Create and return a default property source provider based on the adapter factory.
- *
- * @return The created property source provider
- */
- protected IPropertySourceProvider createPropertySourceProvider() {
- return new PropertySourceProvider(getAdapterFactory());
- }
-
- /**
- * Create a new column in the tree viewer of the main page.
- * This column will be initialised with the given name, width and alignment.
- *
- * Moreover, if a property Id is given, the column content and behaviour will
- * be adapted to work on this property.
- *
- * @param pColumnName The name of the column
- * @param pAlignment The column alignment
- * @param pColumnWidth The column width
- * @param pPropertyID The ID of the property that this column will display
- * @return The column created
- */
- protected TreeViewerColumn createMainTreeViewerColumn(
- final String pColumnName,
- final int pAlignment,
- final int pColumnWidth,
- final String pPropertyID) {
-
- PropertyColumnLabelProvider vLabelProvider = null;
-
- if (pPropertyID != null) {
- // Build the label provider, based on the property whose
- // id is given in parameter
- vLabelProvider = new PropertyColumnLabelProvider(getPropertySourceProvider(), pPropertyID);
- }
-
- // Finally, create the new column
- // NB : Doesn't set an editing support : the main column is voluntary never editable
- final TreeViewerColumn vTreeViewerColumn =
- TreeViewerUtils.createViewerColumn(getViewer(), pColumnName, pAlignment, pColumnWidth, vLabelProvider);
-
- return vTreeViewerColumn;
- }
-
- /**
- * Create and return a label provider based on the adapter factory
- * to be able to find the texts and images to display in the viewer.
- *
- * @return The created label provider
- */
- protected IBaseLabelProvider createLabelProvider() {
- // Create a custom label provider which is able to
- // manage the tree viewer with columns
- IBaseLabelProvider vLabelProvider = new AdapterFactoryColumnLabelProvider(getAdapterFactory());
-
- return vLabelProvider;
- }
-
- /**
- * Create and return a default content provider.
- * This will manage directly different kinds of input, like a resource, or
- * an array, to display their content directly in the viewer.
- *
- * @return The created content provider
- */
- protected IContentProvider createContentProvider() {
- return new ArrayInputPropertySourceProvider(getAdapterFactory());
- }
-
- /**
- * Create a new part listener specific to the behaviour of this instance.
- *
- * The default implementation will react to the activation of this editor instance
- * or to the activation of the property sheet page provided.
- *
- * @return The part listener created
- */
- protected IPartListener createPartListener() {
- return new PartListenerAdapter() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void partActivated(final IWorkbenchPart pPart) {
- // Check what is the part activated ...
- if (pPart instanceof PropertySheet) {
- // ... The properties view is activated, check if the page
- // activated is the one provided by this editor
- if (((PropertySheet) pPart).getCurrentPage().equals(mPropertySheetPage)) {
- // Activate the actions linked to this editor instance
- getActionBarContributor().setActiveEditor(AbstractMultiPageEditor.this);
-
- // React to the associated page activation
- handleActivate();
- }
-
- } else if (pPart.equals(AbstractMultiPageEditor.this)) {
- // ... The current editor instance is activated
-
- // Activate the actions linked to this editor instance
- getActionBarContributor().setActiveEditor(AbstractMultiPageEditor.this);
-
- // React to the editor instance activation
- handleActivate();
- }
- }
- };
- }
-
- /**
- * {@inheritDoc}
- *
- * This is how the framework determines which interfaces we implement.
- */
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(final Class pKeyClass) {
- Object vAdapter = null;
-
- if (pKeyClass.equals(IPropertySheetPage.class)) {
- // If the expecting result is a properties page, provide
- // the page corresponding
- vAdapter = getPropertySheetPage();
-
- } else if (pKeyClass.equals(IGotoMarker.class)) {
- // If the expecting result is a marker provider
- // return the editor instance
- vAdapter = this;
-
- } else {
- // For all the others cases, call the parent method to find an adapter
- vAdapter = super.getAdapter(pKeyClass);
- }
-
- return vAdapter;
- }
-
- /**
- * This accesses a cached version of the property sheet.
- * If the page doesn't exist, it can be created.
- *
- * @return The property sheet page provided by the editor
- */
- protected IPropertySheetPage getPropertySheetPage() {
- // Check if the page already exists
- if (mPropertySheetPage == null) {
-
- // Create a new property sheet page, which
- // will use the editor editing domain
- mPropertySheetPage = new ExtendedPropertySheetPage(mEditingDomain) {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setSelectionToViewer(final List<?> pSelection) {
- // Set the selection to the editor viewer
- AbstractMultiPageEditor.this.setSelectionToViewer(pSelection);
- AbstractMultiPageEditor.this.setFocus();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setActionBars(final IActionBars pActionBars) {
- // Call the parent method to prepare the standard actions
- super.setActionBars(pActionBars);
-
- // Add the global actions (undo, redo, etc.)
- getActionBarContributor().shareGlobalActions(this, pActionBars);
- }
- };
-
- // Set the property source provider to the property sheet page,
- // using the editor adapter factory
- mPropertySheetPage.setPropertySourceProvider(new PropertySourceProvider(mAdapterFactory));
- }
-
- return mPropertySheetPage;
- }
-
- /**
- * {@inheritDoc}
- *
- * This simply tests the command stack to known if there is unsaved changes.
- */
- @Override
- public boolean isDirty() {
- return ((BasicCommandStack) mEditingDomain.getCommandStack()).isSaveNeeded();
- }
-
- /**
- * {@inheritDoc}
- *
- * This simply saves the resources of the managed editing domain, which are not opened in read-only.
- */
- @Override
- public void doSave(final IProgressMonitor pProgressMonitor) {
- // Save only resources that have actually changed
- final Map<Object, Object> vSaveOptions = new HashMap<Object, Object>();
- vSaveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
-
- // Do the work within an operation because this is a long running activity that modifies the workbench
- WorkspaceModifyOperation vWorkspaceModifyOperation = new WorkspaceModifyOperation() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void execute(final IProgressMonitor pMonitor) {
- // Loop on the resources to save them to the file system
- boolean vIsFirstResource = true;
- for (Resource vResource : mEditingDomain.getResourceSet().getResources()) {
- // Check if the resource is not in read only mode, and if the resource content
- // is not empty and is persisted. Moreover, the first resource not in read only
- // is always saved
- if (!mEditingDomain.isReadOnly(vResource)
- && (vIsFirstResource || !vResource.getContents().isEmpty() || isPersisted(vResource))) {
-
- try {
- // Get the time when the resource was previously saved or loaded
- long vTimeStamp = vResource.getTimeStamp();
-
- // Try to save the resource
- vResource.save(vSaveOptions);
-
- // Check if the resource time stamp changed, this means that the save
- // was really effective, and thus remember the resource in the
- // saved resources collection
- if (vResource.getTimeStamp() != vTimeStamp) {
- mSavedResourcesList.add(vResource);
- }
-
- } catch (final IOException pException) {
- // An error occurred during the save, analyse the resource and add the
- // result to the diagnostics map
- mProblemIndicationAdapter.analyzeResource(vResource, pException);
- }
-
- // Remember that a resource has been saved, the followings won't be the first one
- vIsFirstResource = false;
- }
- }
- }
- };
-
- // Temporary disable the problems update while the save will be performed
- mUpdateProblemIndication = false;
-
- // Run the save action, and show progress
- try {
- new ProgressMonitorDialog(getSite().getShell()).run(true, false, vWorkspaceModifyOperation);
-
- // Refresh the dirty state once the save is done
- ((BasicCommandStack) mEditingDomain.getCommandStack()).saveIsDone();
- firePropertyChange(IEditorPart.PROP_DIRTY);
-
- } catch (final InvocationTargetException pException) {
- CommonUIActivator.logError("Error during the save of the resource", pException); //$NON-NLS-1$
- } catch (final InterruptedException pException) {
- CommonUIActivator.logError("Save of the resource interrupted", pException); //$NON-NLS-1$
- }
-
- // Re-enable the problems update and do it
- mUpdateProblemIndication = true;
-
- // Finally, get the diagnostic from the problem indication adapter
- // and update its content
- updateProblemIndication(mProblemIndicationAdapter.getDiagnostic());
- }
-
- /**
- * This returns whether something has been persisted to the URI of the specified resource.
- * The implementation uses the URI converter from the editor's resource set to try to open an input stream.
- *
- * This means that if a file already exists at the resource URI location, the resource is considered as persisted.
- *
- * @param pResource The resource to check
- * @return <code>true</code> if the resource is persisted, this means if a file exists at the resource URI location
- */
- private boolean isPersisted(final Resource pResource) {
- boolean vIsPersisted = false;
-
- InputStream vResourceStream = null;
- try {
- // Try to open a stream to the resource URI location
- vResourceStream = mEditingDomain.getResourceSet().getURIConverter().createInputStream(pResource.getURI());
- if (vResourceStream != null) {
- // The stream can be opened, the resource is thus rightly persisted to a file
- vIsPersisted = true;
- }
-
- } catch (final IOException pException) {
- // A stream can't be opened to the resource URI location, just
- // set the flag value but don't log anything
- vIsPersisted = false;
-
- } finally {
- // Close the stream
- if (vResourceStream != null) {
- try {
- vResourceStream.close();
- } catch (final IOException pException) {
- CommonUIActivator.logError("Error during the close of a stream", //$NON-NLS-1$
- pException);
- }
- }
- }
-
- return vIsPersisted;
- }
-
- /**
- * {@inheritDoc}
- *
- * This always returns false because it is not currently supported.
- */
- @Override
- public boolean isSaveAsAllowed() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- *
- * Not implemented for this editor.
- */
- @Override
- public void doSaveAs() {
- // Not implemented
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void gotoMarker(final IMarker pMarker) {
- // Get the objects pointed by the given marker
- List<?> vTargetObjects = mMarkerHelper.getTargetObjects(mEditingDomain, pMarker);
-
- if (!vTargetObjects.isEmpty()) {
- // Update the selection to focus on the objects corresponding to the marker
- setSelectionToViewer(vTargetObjects);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void addSelectionChangedListener(final ISelectionChangedListener pListener) {
- mSelectionChangedListenersList.add(pListener);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void removeSelectionChangedListener(final ISelectionChangedListener pListener) {
- mSelectionChangedListenersList.remove(pListener);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ISelection getSelection() {
- return mEditorSelection;
- }
-
- /**
- * {@inheritDoc}
- *
- * Calling this result will notify the listeners, and update the status line content.
- */
- @Override
- public void setSelection(final ISelection pSelection) {
- // Update the selection
- mEditorSelection = pSelection;
-
- // Warn all the registered listeners
- for (ISelectionChangedListener vListener : mSelectionChangedListenersList) {
- vListener.selectionChanged(new SelectionChangedEvent(this, pSelection));
- }
-
- // Update the status line content
- updateStatusLineManager(pSelection);
- }
-
- /**
- * Update the status line manager according to the selection given in parameter.
- *
- * @param pSelection The selection used to build the status line message
- */
- protected void updateStatusLineManager(final ISelection pSelection) {
-
- // Find the status line manager from the action bar
- IStatusLineManager vStatusLineManager = getActionBars().getStatusLineManager();
-
- if (vStatusLineManager != null) {
- String vMessage = StringUtils.EMPTY;
-
- if (pSelection instanceof IStructuredSelection) {
- // Cast the selection
- IStructuredSelection vStructuredSelection = (IStructuredSelection) pSelection;
- int vSelectionSize = vStructuredSelection.size();
-
- // Adapt the status message according to the selection size
- switch (vStructuredSelection.size()) {
- case 0:
- vMessage =
- CommonUIActivator.getMessages().getString(
- "AbstractMultiPageEditor.statusline.noobjectselected"); //$NON-NLS-1$
- break;
-
- case 1:
- // Get the text corresponding to the selected object
- String vText =
- new AdapterFactoryItemDelegator(mAdapterFactory).getText(vStructuredSelection
- .getFirstElement());
-
- vMessage =
- CommonUIActivator.getMessages().getString(
- "AbstractMultiPageEditor.statusline.singleobjectselected", //$NON-NLS-1$
- new Object[] {vText});
- break;
-
- default:
- vMessage =
- CommonUIActivator.getMessages().getString(
- "AbstractMultiPageEditor.statusline.multiobjectsselected", //$NON-NLS-1$
- new Object[] {vSelectionSize});
- break;
- }
- }
-
- // Update the status line message
- vStatusLineManager.setMessage(vMessage);
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * This implementation will notify the action bar contributor that the menu is about to be shown.
- */
- @Override
- public void menuAboutToShow(final IMenuManager pMenuManager) {
- ((IMenuListener) getEditorSite().getActionBarContributor()).menuAboutToShow(pMenuManager);
- }
-
- /**
- * @return The action bar contributor managed by this editor site.
- */
- protected EditingDomainActionBarContributor getActionBarContributor() {
- return (EditingDomainActionBarContributor) getEditorSite().getActionBarContributor();
- }
-
- /**
- * @return The action bar managed by the action bar contributor of this editor.
- */
- protected IActionBars getActionBars() {
- return getActionBarContributor().getActionBars();
- }
-
- /**
- * @return The adapter factory used in this editor.
- */
- protected AdapterFactory getAdapterFactory() {
- return mAdapterFactory;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ToolBarManager getToolBarManager() {
- return mEditorToolBarManager;
- }
-
- /**
- * {@inheritDoc}
- *
- * Updates the problems indication with the information described in the specified diagnostic.
- */
- @Override
- public void updateProblemIndication(final Diagnostic pDiagnostic) {
- // Ensure that the problems indication can be updated
- if (mUpdateProblemIndication) {
-
- // Use and asynchronous UI thread to update the problems indication if needed
- // This can create a second page for the problems
- getSite().getShell().getDisplay().asyncExec(new Runnable() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
-
- // Get the last editor page index
- int vLastEditorPageIndex = getPageCount() - 1;
-
- // Check if the last editor page is a already 'Problems' page
- if (vLastEditorPageIndex >= 0 && getEditor(vLastEditorPageIndex) instanceof ProblemEditorPart) {
- // The problem page is ready, update its content with the root diagnostic,
- // and if it corresponds to an error, activate the problem page
- ((ProblemEditorPart) getEditor(vLastEditorPageIndex)).setDiagnostic(pDiagnostic);
- if (pDiagnostic.getSeverity() != Diagnostic.OK) {
- setActivePage(vLastEditorPageIndex);
- }
-
- } else if (pDiagnostic.getSeverity() != Diagnostic.OK) {
- // The problem page is not already created, so do it
- ProblemEditorPart vProblemEditorPart = new ProblemEditorPart();
-
- // Update the problem page content with the root diagnostic
- vProblemEditorPart.setDiagnostic(pDiagnostic);
- vProblemEditorPart.setMarkerHelper(mMarkerHelper);
-
- try {
- // Once that the problem page has been created, add it to the editor,
- // activate it and display the tabs to allow the user to navigate between
- // the different pages
- addPage(++vLastEditorPageIndex, vProblemEditorPart, getEditorInput());
- setPageText(vLastEditorPageIndex, vProblemEditorPart.getPartName());
- setActivePage(vLastEditorPageIndex);
- showTabs();
-
- } catch (final PartInitException pException) {
- CommonUIActivator.logError("Error during the problem page creation", //$NON-NLS-1$
- pException);
- }
- }
-
- // Finally, manage the markers
- if (mMarkerHelper.hasMarkers(mEditingDomain.getResourceSet())) {
- mMarkerHelper.deleteMarkers(mEditingDomain.getResourceSet());
- if (pDiagnostic.getSeverity() != Diagnostic.OK) {
- try {
- mMarkerHelper.createMarkers(pDiagnostic);
- } catch (final CoreException pException) {
- CommonUIActivator.logError("Error during the markers creation", //$NON-NLS-1$
- pException);
- }
- }
- }
-
- }
- });
- }
- }
-
- /**
- * Return the filters that will be associated to the viewer during its creation.
- * By default, this returns a table of filters containing a new {@link NamePropertyFilter} filter.
- *
- * @return The table of filters to associate to the viewer
- */
- protected AbstractFilter[] getFilters() {
- return new AbstractFilter[] {new NamePropertyFilter()};
- }
-
- /**
- * {@inheritDoc}
- *
- * For a multi page editor, the filter is applied on the
- * current viewer.
- */
- @Override
- public void filterTextChanged(final String pNewFilterText) {
- TreeViewer vViewer = getViewer();
-
- if (vViewer != null) {
- // Loop on the registered filters to apply the new text
- for (final ViewerFilter vViewerFilter : vViewer.getFilters()) {
- if (vViewerFilter instanceof AbstractFilter) {
- ((AbstractFilter) vViewerFilter).setFilter(pNewFilterText);
- }
- }
-
- // Finally refresh the viewer content
- refreshViewer();
- }
- }
-
- /**
- * Refresh the viewer.
- */
- protected void refreshViewer() {
- // Use an asynchronous UI thread to refresh the viewer
- getSite().getShell().getDisplay().asyncExec(new Runnable() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- TreeViewer vViewer = getViewer();
-
- // Ensure that the viewer is still available
- if (vViewer != null && !vViewer.getControl().isDisposed()) {
- synchronized (vViewer) {
- vViewer.refresh();
- }
- }
- }
- });
- }
-
- /**
- * @return The final number of column, including the first one. This is used to calculate a correct size even for
- * first column
- */
- protected int getFinalColumnNumber() {
- return 1;
- }
-
-}
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/editor/ArchiveActionBarContributor.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/editor/ArchiveActionBarContributor.java
deleted file mode 100644
index 7f74e21..0000000
--- a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/editor/ArchiveActionBarContributor.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.common.ui.editor;
-
-import java.util.Collection;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.UnexecutableCommand;
-import org.eclipse.emf.edit.ui.action.CopyAction;
-import org.eclipse.emf.edit.ui.action.CutAction;
-import org.eclipse.emf.edit.ui.action.PasteAction;
-import org.eclipse.emf.edit.ui.action.RedoAction;
-import org.eclipse.emf.edit.ui.action.UndoAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.polarsys.esf.core.common.ui.actions.ActionBarContributorUtils;
-
-/**
- * This is the action bar contributor used to edit the archived files.
- *
- * This contributor avoid any action which can modify the archive content.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public class ArchiveActionBarContributor
- extends EmptyActionBarContributor {
-
- /**
- * Default constructor.
- */
- public ArchiveActionBarContributor() {
- // Call the parent constructor
- super();
- }
-
- /**
- * {@inheritDoc}
- *
- * Overridden to hide all the edit actions like undo, redo, cut, copy, paste, etc.
- */
- @Override
- public void menuAboutToShow(final IMenuManager pMenuManager) {
- // Add the standard addition marker at the beginning if needed
- if ((style & ADDITIONS_LAST_STYLE) == 0) {
- pMenuManager.add(new Separator(ActionBarContributorUtils.ADDITIONS_SEPARATOR_ID));
- }
-
- // Add the standard edit marker but not all the related actions
- pMenuManager.add(new Separator(ActionBarContributorUtils.EDIT_SEPARATOR_ID));
-
- // Add the standard addition marker at the end if needed
- if ((style & ADDITIONS_LAST_STYLE) != 0) {
- pMenuManager.add(new Separator(ActionBarContributorUtils.ADDITIONS_SEPARATOR_ID));
- }
-
- // Add the standard additions-end marker
- pMenuManager.add(new Separator(ActionBarContributorUtils.ADDITIONS_END_SEPARATOR_ID));
-
- // Finally add all the global actions
- addGlobalActions(pMenuManager);
- }
-
- /**
- * {@inheritDoc}
- *
- * Avoid the copy action.
- */
- @Override
- protected CopyAction createCopyAction() {
-
- CopyAction vAction = new CopyAction() {
- /**
- * {@inheritDoc}
- */
- @Override
- public Command createCommand(final Collection<?> pSelection) {
- return UnexecutableCommand.INSTANCE;
- }
- };
-
- return vAction;
- }
-
- /**
- * {@inheritDoc}
- *
- * Avoid the paste action.
- */
- @Override
- protected PasteAction createPasteAction() {
-
- PasteAction vAction = new PasteAction() {
- /**
- * {@inheritDoc}
- */
- @Override
- public Command createCommand(final Collection<?> pSelection) {
- return UnexecutableCommand.INSTANCE;
- }
- };
-
- return vAction;
- }
-
- /**
- * {@inheritDoc}
- *
- * Avoid the cut action.
- */
- @Override
- protected CutAction createCutAction() {
-
- CutAction vAction = new CutAction() {
- /**
- * {@inheritDoc}
- */
- @Override
- public Command createCommand(final Collection<?> pSelection) {
- return UnexecutableCommand.INSTANCE;
- }
- };
-
- return vAction;
- }
-
- /**
- * {@inheritDoc}
- *
- * Avoid the undo action.
- */
- @Override
- protected UndoAction createUndoAction() {
-
- // Create the action and disable it
- UndoAction vAction = super.createUndoAction();
- vAction.setEnabled(false);
-
- return vAction;
- }
-
- /**
- * {@inheritDoc}
- *
- * Avoid the redo action.
- */
- @Override
- protected RedoAction createRedoAction() {
-
- // Create the action and disable it
- RedoAction vAction = super.createRedoAction();
- vAction.setEnabled(false);
-
- return vAction;
- }
-}
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/editor/EmptyActionBarContributor.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/editor/EmptyActionBarContributor.java
deleted file mode 100644
index 9616e09..0000000
--- a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/editor/EmptyActionBarContributor.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.common.ui.editor;
-
-import java.util.Collection;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.UnexecutableCommand;
-import org.eclipse.emf.edit.ui.action.DeleteAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.actions.ActionFactory;
-import org.polarsys.esf.core.common.ui.actions.ActionBarContributorUtils;
-
-/**
- * This is the empty action bar contributor.
- * It doesn't allow to add or delete elements from the input model.
- *
- * It's primary used is for the propagation tree editor, and overridden
- * for the archived file editors.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public class EmptyActionBarContributor
- extends AbstractActionBarContributor {
-
- /**
- * Default constructor.
- */
- public EmptyActionBarContributor() {
- // Call the parent constructor
- super();
- }
-
- /**
- * {@inheritDoc}
- *
- * Overridden to avoid the creation of new elements in the model.
- * This implementation disable the creation of action in the context menu
- * and in the editor tool bar.
- */
- @Override
- protected void addCreateSelectChildActions(final ISelection pSelection) {
- // Do nothing voluntary
- }
-
- /**
- * {@inheritDoc}
- *
- * Overridden to ensure there is no delete action possible.
- */
- @Override
- protected DeleteAction createDeleteAction() {
-
- DeleteAction vAction = new DeleteAction(removeAllReferencesOnDelete()) {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Command createCommand(final Collection<?> pSelection) {
- return UnexecutableCommand.INSTANCE;
- }
- };
-
- vAction.setId(ActionFactory.DELETE.getId());
-
- return vAction;
- }
-
- /**
- * {@inheritDoc}
- *
- * Overridden to hide all the edit actions like undo, redo, cut, copy, paste, etc.
- */
- @Override
- public void menuAboutToShow(final IMenuManager pMenuManager) {
- // Add the standard addition marker at the beginning if needed
- if ((style & ADDITIONS_LAST_STYLE) == 0) {
- pMenuManager.add(new Separator(ActionBarContributorUtils.ADDITIONS_SEPARATOR_ID));
- }
-
- // Add the standard edit marker but not all the related actions
- pMenuManager.add(new Separator(ActionBarContributorUtils.EDIT_SEPARATOR_ID));
-
- // Add the standard addition marker at the end if needed
- if ((style & ADDITIONS_LAST_STYLE) != 0) {
- pMenuManager.add(new Separator(ActionBarContributorUtils.ADDITIONS_SEPARATOR_ID));
- }
-
- // Add the standard additions-end marker
- pMenuManager.add(new Separator(ActionBarContributorUtils.ADDITIONS_END_SEPARATOR_ID));
-
- // Finally add all the global actions
- addGlobalActions(pMenuManager);
- }
-}
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/view/AbstractColumnViewerPage.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/view/AbstractColumnViewerPage.java
deleted file mode 100644
index f6da1a4..0000000
--- a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/view/AbstractColumnViewerPage.java
+++ /dev/null
@@ -1,533 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.common.ui.view;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.lang3.StringUtils;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ColumnViewer;
-import org.eclipse.jface.viewers.EditingSupport;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.ViewerColumn;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ListSelectionDialog;
-import org.polarsys.esf.core.common.ui.CommonUIActivator;
-
-/**
- * Abstract base of all the Pages to use in a PageBookView,
- * and which includes a tree.
- *
- * This implementation doesn't manage the columns in the tree,
- * but it inherits of all the standard mechanisms like the filters, the editing domain mechanisms, etc.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public abstract class AbstractColumnViewerPage
- extends AbstractPage {
-
- /**
- * Name of the required column.
- * The required column is mandatory and can't be hidden.
- */
- private String mRequiredColumnName = null;
-
- /** Arrays of the optional columns names, which can be displayed in the tree view. */
- private String[] mColumnsNamesArray = null;
-
- /**
- * Default constructor, which allows to specify if the viewer must be read only or not.
- *
- * @param pReadOnlyMode <code>true</code> if this view is in read only mode, <code>false</code> otherwise
- */
- public AbstractColumnViewerPage(final boolean pReadOnlyMode) {
- // Call the advanced constructor with default values
- this(StringUtils.EMPTY, new String[0], pReadOnlyMode);
- }
-
- /**
- * Advanced constructor which takes the name of the required column, an array with the optional columns name,
- * and a boolean which specifies if the viewer must be in read only mode or not.
- *
- * The required column will mandatory be visible and can't be hidden.
- *
- * @param pRequiredColumnName The name of the required column name
- * @param pColumnsName The array of optional columns name. This list must not contain the required column name
- * @param pReadOnlyMode <code>true</code> if this view is in read only mode, <code>false</code> otherwise
- */
- public AbstractColumnViewerPage(
- final String pRequiredColumnName,
- final String[] pColumnsName,
- final boolean pReadOnlyMode) {
-
- // Call the parent constructor
- super(pReadOnlyMode);
-
- // Remember the given columns names
- mRequiredColumnName = pRequiredColumnName;
- mColumnsNamesArray = pColumnsName.clone();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void setViewerProviders() {
- // We call the createRequiredViewerColumn() and then we associate
- // the providers to associate the default label provider to the required column
- createRequiredViewerColumn();
- super.setViewerProviders();
- createInitialViewerColumns();
- }
-
- /**
- * Create the required column in the viewer.
- * @return The created column
- */
- protected abstract ViewerColumn createRequiredViewerColumn();
-
- /**
- * Create the initial viewer columns, from the optional ones, which must be initially displayed.
- * By default, no optional columns are initially displayed.
- */
- protected void createInitialViewerColumns() {
- // Nothing to do
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected abstract ColumnViewer createViewer(final Composite pParent);
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ColumnViewer getViewer() {
- return (ColumnViewer) super.getViewer();
- }
-
- /**
- * {@inheritDoc}
- *
- * Overridden to add the actions for the columns, the headers and the lines visibility.
- */
- @Override
- protected void addMenuBarActions() {
- addColumnsVisibilityAction();
- addMenuBarSeparator();
- addHideHeaderAction();
- addHideLinesAction();
- super.addMenuBarActions();
- }
-
- /**
- * Add the columns visibility action to the menu bar.
- */
- protected void addColumnsVisibilityAction() {
- addMenuBarAction(createColumnsVisibilityAction());
- }
-
- /**
- * Add the hide header action to the menu bar.
- */
- protected void addHideHeaderAction() {
- addMenuBarAction(createHideHeaderAction(isViewerHeaderInitiallyVisible()));
- }
-
- /**
- * Add the hide lines action to the menu bar.
- */
- protected void addHideLinesAction() {
- addMenuBarAction(createHideLinesAction(isViewerLinesInitiallyVisible()));
- }
-
- /**
- * Return <code>true</code>if the header of the viewer is initially visible.
- * @return <code>true</code>if the header of the viewer is initially visible.
- */
- protected abstract boolean isViewerHeaderInitiallyVisible();
-
- /**
- * Return <code>true</code>if the lines of the viewer are initially visible.
- * @return <code>true</code>if the lines of the viewer are initially visible.
- */
- protected abstract boolean isViewerLinesInitiallyVisible();
-
- /**
- * Create and return the columns visibility action
- * linked to the managed viewer.
- *
- * @return A new instance of the column visibility action
- */
- protected IAction createColumnsVisibilityAction() {
- return new ColumnsVisibilityAction();
- }
-
- /**
- * Create and return the hide lines action.
- *
- * @param pVisible <code>true</code> if the lines are visible by default, <code>false</code> otherwise
- * @return A new instance of the hide lines action
- */
- protected IAction createHideLinesAction(final boolean pVisible) {
- // Create the action, with the right label and display it as a checkbox
- final Action vHideLinesAction = new Action(
- CommonUIActivator.getMessages().getString("AbstractColumnViewerPage.action.showlines"), //$NON-NLS-1$
- IAction.AS_CHECK_BOX) {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- AbstractColumnViewerPage.this.setLinesVisible(isChecked());
- }
- };
-
- // Set the initial state to the action
- vHideLinesAction.setChecked(pVisible);
-
- return vHideLinesAction;
- }
-
- /**
- * Create and return the hide header action.
- *
- * @param pVisible <code>true</code> if the header is visible by default, <code>false</code> otherwise
- * @return A new instance of the hide header action
- */
- protected IAction createHideHeaderAction(final boolean pVisible) {
- // Create the action, with the right label and display it as a checkbox
- final Action vHideHeaderAction = new Action(
- CommonUIActivator.getMessages().getString("AbstractColumnViewerPage.action.showheaders"), //$NON-NLS-1$
- IAction.AS_CHECK_BOX) {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- AbstractColumnViewerPage.this.setHeaderVisible(isChecked());
- }
- };
-
- // Set the initial state to the action
- vHideHeaderAction.setChecked(pVisible);
-
- return vHideHeaderAction;
- }
-
- /**
- * Set the visibility of the lines in the viewer.
- *
- * @param pVisible <code>true</code> if the lines must be visible, <code>false</code> otherwise
- */
- public abstract void setLinesVisible(final boolean pVisible);
-
- /**
- * Set the visibility of the header in the viewer.
- *
- * @param pVisible <code>true</code> if the header must be visible, <code>false</code> otherwise
- */
- public abstract void setHeaderVisible(final boolean pVisible);
-
- /**
- * Create a new column at the end of the viewer, with the name given in parameter.
- *
- * @param pColumnName The name of the column
- * @return The created tree viewer column, or null if the concrete implementation of this page doesn't support
- * the column viewers
- */
- protected abstract ViewerColumn createViewerColumn(final String pColumnName);
-
- /**
- * Create a new column in the viewer, at the specified location, with the name given in parameter.
- *
- * @param pColumnName The name of the column
- * @param pIndex The location index where the column must be created in the viewer
- * @return The created tree viewer column, or null if the concrete implementation of this page doesn't support
- * the column viewers
- */
- protected abstract ViewerColumn createViewerColumn(final String pColumnName, final int pIndex);
-
- /**
- * Create a new column at the end of the viewer, with the name given in parameter, and associate to it a
- * label provider also given in parameter.
- *
- * @param pColumnName The name of the column
- * @param pColumnLabelProvider The column label provider to use in the column
- *
- * @return The created tree viewer column, or null if the concrete implementation of this page doesn't support
- * the column viewers
- */
- protected abstract ViewerColumn createViewerColumn(
- final String pColumnName,
- final ColumnLabelProvider pColumnLabelProvider);
-
- /**
- * Create a new column at the end of the viewer, with the name given in parameter, and associate to it a
- * label provider and an editing support also given in parameter.
- *
- * @param pColumnName The name of the column
- * @param pColumnLabelProvider The column label provider to use in the column
- * @param pEditingSupport The editing support to use in the column
- *
- * @return The created tree viewer column, or null if the concrete implementation of this page doesn't support
- * the column viewers
- */
- protected abstract ViewerColumn createViewerColumn(
- final String pColumnName,
- final ColumnLabelProvider pColumnLabelProvider,
- final EditingSupport pEditingSupport);
-
- /**
- * Create a new column at the end of the viewer, with the name given in parameter, and associate to it a
- * label provider and an editing support according to the property whose ID is given in parameter.
- *
- * @param pColumnName The name of the column
- * @param pPropertyID The id of the property to display in the column
- *
- * @return The created tree viewer column, or null if the concrete implementation of this page doesn't support
- * the column viewers
- */
- protected abstract ViewerColumn createViewerColumn(final String pColumnName, final String pPropertyID);
-
- /**
- * Show a list of columns whose name is given in parameter.
- *
- * @param pColumnsNamesArray The array of the columns names to display.
- */
- protected void showColumns(final String[] pColumnsNamesArray) {
- boolean vRefreshNeeded = false;
-
- if (pColumnsNamesArray != null) {
- // Loop on the names to find and display the corresponding column
- for (String vColumnName : pColumnsNamesArray) {
- // Check if the column in not already visible
- if (!isColumnVisible(vColumnName)) {
- // Show the column and remember that a refresh is needed on the tree
- vRefreshNeeded = showColumn(vColumnName) || vRefreshNeeded;
- }
- }
-
- // Refresh the tree content if at least one new column is displayed
- if (vRefreshNeeded) {
- getViewer().refresh();
- }
- }
- }
-
- /**
- * Hide a list of columns, whose name is given in parameter.
- *
- * @param pColumnsNamesArray The array of the columns names to hide.
- */
- protected void hideColumns(final String[] pColumnsNamesArray) {
- if (pColumnsNamesArray != null) {
- // Loop on the names to find and hide the corresponding column
- for (final String vColumnName : pColumnsNamesArray) {
- // Check if the column is really visible and then hide it
- if (isColumnVisible(vColumnName)) {
- hideColumn(vColumnName);
- }
- }
- }
- }
-
- /**
- * Show a column, whose name is given in parameter.
- * The column may be created if needed.
- *
- * @param pColumnName The column name
- * @return <code>true</code> if a column was found and shown, <code>false</code> otherwise
- */
- protected abstract boolean showColumn(final String pColumnName);
-
- /**
- * Hide the column whose name is given in parameter.
- *
- * @param pColumnName The column name
- * @return <code>true</code> if a column was found and hidden, <code>false</code> otherwise
- */
- protected abstract boolean hideColumn(final String pColumnName);
-
- /**
- * Return a map containing in key the name of the columns
- * and in value a flag specifying if it is currently visible or not.
- *
- * This map will contain the name of all the optional columns which may
- * be added in the viewer, but not the required column which is considered
- * as always visible.
- *
- * @return A map containing in key the name of the columns in the viewer,
- * and in value a flag specifying if the column is visible or not
- */
- protected Map<String, Boolean> getColumnsVisibility() {
- // Create the returned map
- final Map<String, Boolean> vColumnsVisibilityMap = new HashMap<String, Boolean>(mColumnsNamesArray.length);
-
- // Loop on the names of optional columns
- for (final String vColumnName : mColumnsNamesArray) {
- // Add in the map the corresponding key and flag value
- vColumnsVisibilityMap.put(vColumnName, isColumnVisible(vColumnName));
- }
-
- return vColumnsVisibilityMap;
- }
-
- /**
- * Return the names of the optional columns which can be displayed in the tree view.
- *
- * @return The names of the optional columns which can be displayed in the tree view.
- */
- public String[] getColumnsName() {
- return mColumnsNamesArray;
- }
-
- /**
- * Return the name of the required column for the tree view.
- *
- * @return The required column name
- */
- public String getRequiredColumnName() {
- return mRequiredColumnName;
- }
-
- /**
- * Return <code>true</code> if a column exists in the viewer,
- * and <code>false</code> otherwise.
- *
- * @param pColumnName The name of the column to check
- * @return <code>true</code> if the table column is visible, <code>false</code> otherwise
- */
- protected abstract boolean isColumnVisible(final String pColumnName);
-
- /**
- * Custom action used to manage and change the visibility of the columns of the viewer.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
- private class ColumnsVisibilityAction
- extends Action {
-
- /**
- * Default constructor.
- */
- ColumnsVisibilityAction() {
- super(CommonUIActivator.getMessages()
- .getString("AbstractColumnViewerPage.menu.columnsvisibility")); //$NON-NLS-1$
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- final List<String> vColumnsNameArray = new ArrayList<String>();
- final List<String> vVisibleColumnsNamesArray = new ArrayList<String>();
-
- // Get the map specifying the visibility of each column
- final Map<String, Boolean> vColumnsVisibilityMap = getColumnsVisibility();
-
- // Loop on all the column visibility map to build two arrays :
- // - one for all the columns names
- // - one with only the name of visible columns
- for (final String vColumnName : vColumnsVisibilityMap.keySet()) {
- // Remember the column name
- vColumnsNameArray.add(vColumnName);
-
- // Remember the name of the visible column
- if (vColumnsVisibilityMap.get(vColumnName)) {
- vVisibleColumnsNamesArray.add(vColumnName);
- }
- }
-
- // Open a dialog to allow the user which columns must be visible
- final Object[] vResultsArray = openColumnsSelectionDialog(
- vColumnsNameArray,
- vVisibleColumnsNamesArray);
-
- if (vResultsArray != null) {
-
- // Loop on the results array to build a set containing all the
- // names of the column to show
- Set<String> vShownColumnsNamesSet = new HashSet<String>();
- for (final Object vResult : vResultsArray) {
- // NB : The result is normally already a String with the column name
- vShownColumnsNamesSet.add(vResult.toString());
- }
-
- // Then build the list of columns to hide, by removing from the whole list
- // of columns, those to hide
- Set<String> vHiddenColumnsNamesSet = new HashSet<String>(vColumnsVisibilityMap.keySet());
- vHiddenColumnsNamesSet.removeAll(vShownColumnsNamesSet);
-
- // Finally, hide and show the columns according to the user choices
- hideColumns(vHiddenColumnsNamesSet.toArray(new String[vHiddenColumnsNamesSet.size()]));
- showColumns(vShownColumnsNamesSet.toArray(new String[vShownColumnsNamesSet.size()]));
- }
- }
-
- /**
- * Open a dialog allowing the user to select which columns must
- * be visible in the viewer.
- *
- * The array of selected columns is directly returned.
- *
- * @param pColumnsNamesArray The array of all the column names
- * @param pVisibleColumnsNamesArray The array of all the columns names already currently visible
- * @return The array of all the columns names to show
- */
- private Object[] openColumnsSelectionDialog(
- final List<String> pColumnsNamesArray,
- final List<String> pVisibleColumnsNamesArray) {
-
- Object[] vResultsArray = null;
-
- // Build the selection dialog
- final ListSelectionDialog vDialog = new ListSelectionDialog(
- PlatformUI.getWorkbench().getDisplay().getActiveShell(),
- pColumnsNamesArray,
- new ArrayContentProvider(),
- new LabelProvider(),
- CommonUIActivator.getMessages()
- .getString("AbstractColumnViewerPage.label.columnsvisibility")); //$NON-NLS-1$
-
- // Set the dialog title and select by default the columns which are currently visible
- vDialog.setTitle(CommonUIActivator.getMessages()
- .getString("AbstractColumnViewerPage.title.columnsvisibility")); //$NON-NLS-1$
- vDialog.setInitialElementSelections(pVisibleColumnsNamesArray);
-
- // Finally open the dialog and remember of its result if the user validate its choice
- if (vDialog.open() == Window.OK) {
- vResultsArray = vDialog.getResult();
- }
-
- return vResultsArray;
- }
- }
-}
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/view/AbstractModelPage.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/view/AbstractModelPage.java
deleted file mode 100644
index c0d4c60..0000000
--- a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/view/AbstractModelPage.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.common.ui.view;
-
-import java.util.Iterator;
-
-import org.apache.commons.lang3.StringUtils;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.EditingSupport;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.views.properties.PropertyColumnLabelProvider;
-import org.polarsys.esf.core.common.ui.actions.NoModifiesActionBarContributor;
-import org.polarsys.esf.core.common.ui.actions.ViewActionBarContributor;
-import org.polarsys.esf.core.common.ui.editingsupport.ValidatedPropertyEditingSupport;
-import org.polarsys.esf.core.common.ui.provider.FirstColumnLabelProvider;
-
-/**
- * Base for pages which are looking at a ESF Model,
- * and which will be displayed in a page book view.
- *
- * This allows to put several pages in a same view, in order
- * to link the view content to the active editor for example.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public abstract class AbstractModelPage
- extends AbstractTreeTablePage {
-
- /** Default column width. */
- private static final int COLUMN_WIDTH = 150;
-
- /** The resource set on which the page will be plugged. */
- private ResourceSet mResourceSet = null;
-
- /** The resource, contained in the resource set, which will be used as input for the page viewer. */
- private Resource mResource = null;
-
- /** The source part, containing the resource set and the editing domain, to link to this page. */
- private IWorkbenchPart mSourcePart = null;
-
- /**
- * Default constructor.
- *
- * @param pSourcePart The source part to link to this page
- * @param pRequiredColumnName Name of the required columns for the viewer
- * @param pColumnsName Names of other columns
- * @param pReadOnlyMode <code>true</code> if the page must be in read only mode
- */
- public AbstractModelPage(
- final IWorkbenchPart pSourcePart,
- final String pRequiredColumnName,
- final String[] pColumnsName,
- final boolean pReadOnlyMode) {
-
- super(pRequiredColumnName, pColumnsName, pReadOnlyMode);
- mSourcePart = pSourcePart;
- }
-
- /**
- * Return the part linked to this page instance and used
- * to get the source model.
- *
- * @return The sourcePart
- */
- public IWorkbenchPart getSourcePart() {
- return mSourcePart;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected IBaseLabelProvider createLabelProvider() {
- return new FirstColumnLabelProvider(getAdapterFactory());
- }
-
- /**
- * {@inheritDoc}
- *
- * For a page used to display an ESF model content, from the source editor linked
- * to this instance, the initial input is the resource found in this editor.
- *
- * Thus, this method will initialise the {@link #mResource} and {@link #mResourceSet} properties
- * to ensure that the page is plugged to the editor data.
- */
- @Override
- protected Object getInitialInput() {
- // Check if the source part is able to provide an editing domain provider
- // If this is not the case, no input can be found
- if (mSourcePart instanceof IEditingDomainProvider) {
-
- // Get the resource set on which works the source part
- mResourceSet = ((IEditingDomainProvider) mSourcePart).getEditingDomain().getResourceSet();
-
- // Then loop on the resource set to find the ESF Resource to use as input
- Iterator<Resource> vIterator = mResourceSet.getResources().iterator();
- while (vIterator.hasNext() && mResource == null) {
- Resource vResource = (Resource) vIterator.next();
-
- // Check if the current resource is a ESF model
- // TODO : Check the right resource type
- if (vResource instanceof Resource) {
- // Remember of this resource to use it as input
- mResource = vResource;
- }
- }
- }
-
- return mResource;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ResourceSet getResourceSet() {
- return mResourceSet;
- }
-
-
- /**
- * {@inheritDoc}
- *
- * This method is overridden to ensure that the source part editing domain will be used if possible
- * instead of creating a new one.
- */
- @Override
- protected EditingDomain createEditingDomain() {
- EditingDomain vEditingDomain = null;
-
- if (mSourcePart instanceof IEditingDomainProvider) {
- // Get the editing domain of the source part if possible
- vEditingDomain = (AdapterFactoryEditingDomain) ((IEditingDomainProvider) mSourcePart).getEditingDomain();
-
- // Get the command stack of the editing domain to add a listener on it
- addCommandStackListener(vEditingDomain.getCommandStack());
-
- } else {
- // Call the parent method otherwise to create a default editing domain
- vEditingDomain = super.createEditingDomain();
- }
-
- return vEditingDomain;
- }
-
- /**
- * {@inheritDoc}
- *
- * Overridden to add an action bar contributor without any action able to modify model.
- */
- @Override
- protected ViewActionBarContributor createActionBarContributor() {
- return new NoModifiesActionBarContributor();
- }
-
- /**
- * Initialise the width of the viewer columns, only if their actual size is less than column width constant.
- * Moreover, the column alignment is set to center.
- */
- protected void setColumnsWidthAndAlignment() {
- TreeColumn[] vColummnsArray = getViewer().getTree().getColumns();
-
- for (TreeColumn vColumn : vColummnsArray) {
- vColumn.setAlignment(SWT.CENTER);
-
- if (vColumn.getWidth() < COLUMN_WIDTH) {
- vColumn.setWidth(COLUMN_WIDTH);
- }
- }
- }
-
- /**
- * Add a column in view, and initialise it, to ensure that :
- * <ul>
- * <li>it's editable if needed.</li>
- * <li>it's linked to to right properties.</li>
- * <li>its width is set.</li>
- * </ul>
- *
- * @param pColumnName The column name, used to identify it
- */
- protected void addColumnViewer(final String pColumnName) {
-
- // Get the editable state for the column given
- boolean vIsEditable = isColumnEditable(pColumnName);
-
- // Create a column label provider in function of the target column
- ColumnLabelProvider vColumnLabelProvider = createColumnLabelProvider(pColumnName);
-
- // Get the property id associated to the given column
- String vPropertyId = getAssociatedColumnPropertyID(pColumnName);
-
- // Try to create an editing support if the column is editable,
- // and associated to a property in the model
- if (vIsEditable && StringUtils.isNotEmpty(vPropertyId)) {
-
- // Create an editing support for column which can be modified
- EditingSupport vEditingSupport =
- new ValidatedPropertyEditingSupport(
- getViewer(),
- getPropertySourceProvider(),
- vPropertyId,
- getActionBars().getStatusLineManager());
-
- // Then create the column with this editing support
- createViewerColumn(pColumnName, vColumnLabelProvider, vEditingSupport);
-
- } else {
- // Create a non editable column
- createViewerColumn(pColumnName, vColumnLabelProvider);
- }
-
- // Once that a column has been added, reset the width
- // and alignment of each of them
- setColumnsWidthAndAlignment();
- }
-
- /**
- * Create a column label provider in function of the target column.
- * The label provider may built by default is based on the property id associated
- * to the given column.
- *
- * @param pColumnName The name of the column concerned
- * @return The created column label provider
- */
- protected ColumnLabelProvider createColumnLabelProvider(final String pColumnName) {
- ColumnLabelProvider vColumnLabelProvider = null;
-
- // Get the id of the property linked to this column
- String vPropertyId = getAssociatedColumnPropertyID(pColumnName);
-
- if (StringUtils.isNotEmpty(vPropertyId)) {
- // Create a new label provider for this property
- vColumnLabelProvider = new PropertyColumnLabelProvider(
- getPropertySourceProvider(),
- vPropertyId);
-
- } else {
- // Create a default label provider
- vColumnLabelProvider = new ColumnLabelProvider();
- }
-
- return vColumnLabelProvider;
- }
-
- /**
- * Return a boolean specifying if the column, identified by the name given in parameter
- * is editable or not.
- *
- * Return false by default.
- *
- * @param pColumnName The column name
- * @return <code>true</code> if the column is editable
- */
- protected boolean isColumnEditable(final String pColumnName) {
- return false;
- }
-
- /**
- * {@inheritDoc}
- *
- * In the model pages implementations, the drag and drop actions are disabled, as
- * these pages are made to view to model, not to modify its structure.
- */
- @Override
- protected void addDragSupport() {
- // Nothing to do
- }
-
- /**
- * {@inheritDoc}
- *
- * In the model pages implementations, the drag and drop actions are disabled, as
- * these pages are made to view to model, not to modify its structure.
- */
- @Override
- protected void addDropSupport() {
- // Nothing to do
- }
-
- /**
- * Get the associated property Id for a column whose name is given in parameter.
- *
- * Return an empty String by default.
- *
- * @param pColumnName Column name
- * @return The associated property Id found, or an empty String if no property is associated
- */
- protected String getAssociatedColumnPropertyID(final String pColumnName) {
- return StringUtils.EMPTY;
- }
-
-
- /**
- * {@inheritDoc}
- *
- * This default implementation create a new column for each name returned
- * by the method {@link #getColumnsName()}.
- */
- @Override
- protected void createInitialViewerColumns() {
- // Loop on all the columns name to create a new one for each
- for (String vColumnName : getColumnsName()) {
- // Only the analysis closed column can be edited
- addColumnViewer(vColumnName);
- }
- }
-}
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/view/AbstractModelPageBookView.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/view/AbstractModelPageBookView.java
deleted file mode 100644
index 245def2..0000000
--- a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/view/AbstractModelPageBookView.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.common.ui.view;
-
-import org.eclipse.emf.common.ui.viewer.IViewerProvider;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.part.IPage;
-import org.eclipse.ui.part.MessagePage;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.ui.part.PageBookView;
-import org.polarsys.esf.core.common.ui.CommonUIActivator;
-import org.polarsys.esf.core.common.ui.filter.IFilterPartListener;
-
-/**
- * Abstract base for the views which are looking at the content of an ESF Model
- * opened in any type of editor (Graphical, EMF tree table, etc.).
- *
- * These views are also listening to the changes on the filter to adapt the content
- * of their pages.
- *
- * Moreover, they must implements the interface IEditingDomainProvider to return the editing
- * domain used by the current page. This is mandatory to enable the actions activation with
- * the action bars contributor.
- * To enable the refresh contextual action, the view must provide a viewer, and implements
- * the IViewerProvider interface. The viewer search is delegated to the current page.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public abstract class AbstractModelPageBookView
- extends PageBookView
- implements IFilterPartListener, IEditingDomainProvider, IViewerProvider {
-
- /** Message to show on the default page. */
- private static final String DEFAULT_TEXT = CommonUIActivator.getMessages()
- .getString("AbstractSAModelPageBookView.defaultPage.label"); //$NON-NLS-1$
-
- /**
- * Default constructor.
- */
- public AbstractModelPageBookView() {
- super();
- }
-
- /**
- * {@inheritDoc}
- *
- * The default page displays only a message to warn the user that
- * he must open an editor to link a new page to its content.
- */
- @Override
- protected IPage createDefaultPage(final PageBook pBook) {
-
- // Create the default page, which will contains only an information message
- MessagePage vPage = new MessagePage();
-
- // Initialise the page and create its controls
- initPage(vPage);
- vPage.createControl(pBook);
-
- // Set the default message to the page
- vPage.setMessage(DEFAULT_TEXT);
-
- return vPage;
- }
-
- /**
- * {@inheritDoc}
- *
- * Track only the editors to synchronise the view pages.
- */
- @Override
- protected boolean isImportant(final IWorkbenchPart pPart) {
- // Only cares about editors
- return pPart instanceof IEditorPart;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void doDestroyPage(final IWorkbenchPart pPart, final PageRec pPageRec) {
- // Get the page from the page record
- IPage vPage = pPageRec.page;
-
- // Dispose the page, and the record
- vPage.dispose();
- pPageRec.dispose();
- }
-
- /**
- * {@inheritDoc}
- *
- * Return the active editor for the current page.
- */
- @Override
- protected IWorkbenchPart getBootstrapPart() {
- IWorkbenchPart vBootStrapPart = null;
-
- // Get the current page shown
- IWorkbenchPage vPage = getSite().getPage();
- if (vPage != null) {
- // Get the active editor linked to this page
- vBootStrapPart = vPage.getActiveEditor();
- }
-
- return vBootStrapPart;
- }
-
- /**
- * {@inheritDoc}
- *
- * Treat this event as a part activation.
- * Otherwise, nothing is done by default.
- */
- @Override
- public void partBroughtToTop(final IWorkbenchPart pPart) {
- partActivated(pPart);
- }
-
- /**
- * {@inheritDoc}
- *
- * This method is overridden to register this current page book view as selection provider
- * in the page action bar contributor, to enable the contextual actions.
- *
- * This must be done on each activation, and not only once when the page is initialised,
- * as in this case, the {@link #getEditingDomain()} method will be called only once, and
- * the actions won't be linked to the right editing domain.
- */
- @Override
- public void partActivated(final IWorkbenchPart pPart) {
- // Call the parent method
- super.partActivated(pPart);
-
- // If the current page in a instance of model page, update its action bar contributor
- // to use this view as selection listener
- if (getCurrentPage() instanceof AbstractModelPage) {
- ((AbstractModelPage) getCurrentPage()).updateActionBarContributorActivePart(this);
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * For a page book view, the event treatment is delegated to the current page.
- */
- @Override
- public void filterTextChanged(final String pNewFilterText) {
- IPage vCurrentPage = getCurrentPage();
-
- if (vCurrentPage instanceof AbstractModelPage) {
- ((AbstractModelPage) vCurrentPage).filterTextChanged(pNewFilterText);
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * Return the editing domain of the current page displayed.
- */
- @Override
- public EditingDomain getEditingDomain() {
-
- EditingDomain vEditingDomain = null;
-
- // Delegate the editing domain providing to the current page
- if (getCurrentPage() instanceof IEditingDomainProvider) {
- vEditingDomain = ((IEditingDomainProvider) getCurrentPage()).getEditingDomain();
- }
-
- return vEditingDomain;
- }
-
- /**
- * {@inheritDoc}
- *
- * Return the viewer current page displayed if possible, null otherwise.
- */
- @Override
- public Viewer getViewer() {
-
- Viewer vViewer = null;
-
- // Delegate the viewer providing to the current page
- if (getCurrentPage() instanceof IViewerProvider) {
- vViewer = ((IViewerProvider) getCurrentPage()).getViewer();
- }
-
- return vViewer;
- }
-}
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/view/AbstractPage.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/view/AbstractPage.java
deleted file mode 100644
index ed847ee..0000000
--- a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/view/AbstractPage.java
+++ /dev/null
@@ -1,1189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.common.ui.view;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.EventObject;
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.emf.common.command.BasicCommandStack;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CommandStack;
-import org.eclipse.emf.common.command.CommandStackListener;
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.common.ui.viewer.IViewerProvider;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain.EditingDomainProvider;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator;
-import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
-import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter;
-import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
-import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter;
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
-import org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.part.IPageSite;
-import org.eclipse.ui.part.Page;
-import org.eclipse.ui.views.properties.IPropertySourceProvider;
-import org.polarsys.esf.core.common.ui.CommonUIActivator;
-import org.polarsys.esf.core.common.ui.actions.ViewActionBarContributor;
-import org.polarsys.esf.core.common.ui.constants.ImageConstants;
-import org.polarsys.esf.core.common.ui.filter.AbstractFilter;
-import org.polarsys.esf.core.common.ui.filter.NamePropertyFilter;
-import org.polarsys.esf.core.common.ui.view.properties.PropertySourceProvider;
-
-/**
- * Abstract base of all the Pages to use in a PageBookView,
- * with the filters, the editing domain mechanisms, etc.
- *
- * This abstract page implement the following interfaces :
- * - IEditingDomainProvider : to allow other classes to access to its editing domain
- * - IMenuListener : to be warned when a menu is about to show
- * - IViewerProvider : to allow other classes to access to its viewer
- * - IFiltrePageListener : to enable the filter mechanisms
- *
- * NB : This kind of page doesn't manage a link with the Properties view, nor a save action
- * as its behaviour is to be dependent of an opened editor. Thus, it's the editor
- * selection with is displayed in the Properties view, and the dirty state is also managed
- * by the editor.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public abstract class AbstractPage
- extends Page
- implements IEditingDomainProvider, IMenuListener, IViewerProvider {
-
- /** The pop-up menu id. */
- private static final String POP_UP_ID = "#PopUp"; //$NON-NLS-1$
-
- /** The additions menu section id. */
- private static final String ADDITIONS_SEPARATOR_ID = "additions"; //$NON-NLS-1$
-
- /** The adapter factory used to provide the views of the model elements. */
- private ComposedAdapterFactory mComposedAdapterFactory = null;
-
- /** The editing domain used to track all the changes to the model elements, if this view is editable. */
- private EditingDomain mEditingDomain = null;
-
- /**
- * The command stack listener to plug to the command stack of the used editing domain,
- * to be warned the changes happend.
- */
- private CommandStackListener mCommandStackListener = new CommandStackListener() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void commandStackChanged(final EventObject pEvent) {
- AbstractPage.this.getSite().getShell().getDisplay().asyncExec(new Runnable() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- handleCommandStackChanged(((CommandStack) pEvent.getSource()).getMostRecentCommand());
- }
- });
- }
- };
-
- /** The label provider used in the viewer. */
- private IBaseLabelProvider mLabelProvider = null;
-
- /** The content provider used in the viewer. */
- private IContentProvider mContentProvider = null;
-
- /** The property source provider used in the viewer. */
- private IPropertySourceProvider mPropertySourceProvider = null;
-
- /** The view action bar contributor. */
- private ViewActionBarContributor mActionBarContributor = null;
-
- /** The viewer used in this page. */
- private StructuredViewer mViewer = null;
-
- /** Flag which indicates if this view is in read only mode. */
- private boolean mReadOnlyMode = true;
-
- /**
- * Constructor used to specify if the view is read only or not.
- *
- * @param pReadOnlyMode <code>true</code> if this view is in read only mode, <code>false</code> otherwise
- */
- public AbstractPage(final boolean pReadOnlyMode) {
- super();
- mReadOnlyMode = pReadOnlyMode;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void dispose() {
-
- // Remove the potential listener on the command stack used
- // This is mandatory as the command stack may not be in this instance context only
- if (mEditingDomain != null && mEditingDomain.getCommandStack() != null) {
- mEditingDomain.getCommandStack().removeCommandStackListener(mCommandStackListener);
- }
-
- if (mLabelProvider != null) {
- mLabelProvider.dispose();
- mLabelProvider = null;
- }
-
- if (mContentProvider != null) {
- mContentProvider.dispose();
- mContentProvider = null;
- }
-
- if (mComposedAdapterFactory != null) {
- mComposedAdapterFactory.dispose();
- mComposedAdapterFactory = null;
- }
-
- if (mActionBarContributor != null) {
- // Unlink the potential active part registered in the
- // action bar contributor and dispose it
- mActionBarContributor.setActivePart(null);
- mActionBarContributor.dispose();
- mActionBarContributor = null;
- }
-
- super.dispose();
- }
-
- /**
- * @return <code>true</code> if the view is in read only mode, <code>false</code> otherwise.
- */
- public boolean isReadOnlyMode() {
- return mReadOnlyMode;
- }
-
- /**
- * Initialise the editing domain for this page.
- *
- * The default implementation create a new adapter factory, and
- * a new editing domain for this page instance by calling : {@link AbstractPage#createAdapterFactory()} and
- * {@link AbstractPage#createEditingDomain()}
- */
- protected void initializeEditingDomain() {
- mComposedAdapterFactory = createAdapterFactory();
- mEditingDomain = createEditingDomain();
- }
-
- /**
- * Create and return an instance of {@link ComposedAdapterFactory} and initialise it with the adapter factories.
- *
- * @see #getAdapterFactories()
- * @return The created {@link ComposedAdapterFactory}
- */
- protected ComposedAdapterFactory createAdapterFactory() {
- // Create an adapter factory that yields the needed item providers
- final ComposedAdapterFactory vComposedAdapterFactory = new ComposedAdapterFactory();
-
- // Loop on the adapter factories to add each one to the composed adapter factory
- for (final Class<? extends AdapterFactory> vAdapterFactory : getAdapterFactories()) {
- try {
- vComposedAdapterFactory.addAdapterFactory(vAdapterFactory.newInstance());
- } catch (final InstantiationException e) {
- CommonUIActivator.INSTANCE.log(e);
- } catch (final IllegalAccessException e) {
- CommonUIActivator.INSTANCE.log(e);
- }
- }
-
- return vComposedAdapterFactory;
- }
-
- /**
- * Return the adapter factories that will be added to the composed adapter factory
- * used by this page.
- *
- * @return Adapter factories to add to the composed adapter factory
- */
- protected abstract Collection<Class<? extends AdapterFactory>> getAdapterFactories();
-
- /**
- * This sets the selection into the active viewer.
- *
- * @param pSelections The selection elements to set
- *
- */
- protected void setSelectionToViewer(final Collection<?> pSelections) {
- // Check if this selection is valid
- if (pSelections != null && !pSelections.isEmpty()) {
-
- // Use a runnable in an UI thread to update the viewer selection
- getSite().getShell().getDisplay().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- // Try to select the items in the current content viewer
- if (mViewer != null) {
- mViewer.setSelection(new StructuredSelection(pSelections.toArray()), true);
- }
- }
- });
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * This returns the editing domain as required by the {@link IEditingDomainProvider} interface.
- * This is important to implement several mechanisms as the Commands, etc.
- *
- * @return The current editing domain used
- */
- @Override
- public EditingDomain getEditingDomain() {
- return mEditingDomain;
- }
-
- /**
- * Create and return an instance of {@link AdapterFactoryEditingDomain}.
- *
- * This base implementation creates a default editing domain and associate it to a new {@link CommandStack}, and to
- * the resource set returned by the {@link #getResourceSet()} if it's not null. Otherwise, it uses a new resource
- * set.
- *
- * @return The created instance of {@link EditingDomain}
- */
- protected EditingDomain createEditingDomain() {
-
- AdapterFactoryEditingDomain vEditingDomain = null;
-
- // Create a default command stack
- final CommandStack vCommandStack = createCommandStack();
-
- // Get the resource set used by this page
- final ResourceSet vResourceSet = getResourceSet();
-
- if (vResourceSet != null) {
- // A resource set is known, use it to create the editing domain
- vEditingDomain = new AdapterFactoryEditingDomain(getAdapterFactory(), vCommandStack, vResourceSet);
- vEditingDomain.setResourceToReadOnlyMap(new HashMap<Resource, Boolean>());
-
- } else {
- // A resource set is not known, create the editing domain with a new resource set
- vEditingDomain = new AdapterFactoryEditingDomain(
- getAdapterFactory(),
- vCommandStack,
- new HashMap<Resource, Boolean>());
- }
-
- return vEditingDomain;
- }
-
- /**
- * Create and return a default command stack, which allow to react to its changes
- * using the {@link AbstractPage#handleCommandStackChanged(Command)} method.
- *
- * @return The command stack created
- */
- protected BasicCommandStack createCommandStack() {
- // Create the command stack
- final BasicCommandStack vCommandStack = new BasicCommandStack();
-
- // Add the listener which will notify this page when commands are executed
- addCommandStackListener(vCommandStack);
-
- return vCommandStack;
- }
-
- /**
- * Add a custom listener to the given command stack.
- * This listener is used to allow to this page to react to a change in the command stack.
- *
- * @param pCommandStack The command stack to listen
- */
- protected void addCommandStackListener(final CommandStack pCommandStack) {
- // Add a listener on the command stack to warn the page when something changed
- pCommandStack.addCommandStackListener(mCommandStackListener);
- }
-
- /**
- * Remove the custom listener to the given command stack.
- * This is mandatory to dispose correctly the page.
- *
- * @param pCommandStack The command stack to stop to listen
- */
- protected void removeCommandStackListener(final CommandStack pCommandStack) {
- // Remove the potential listener on the command stack
- pCommandStack.removeCommandStackListener(mCommandStackListener);
- }
-
- /**
- * This method is called when the command stack is changed, to allow the
- * page to react. By default, this will simply select the objects
- * affected by the command in the viewer.
- *
- * @param pMostRecentCommand The most recent command
- */
- protected void handleCommandStackChanged(final Command pMostRecentCommand) {
- if (pMostRecentCommand != null) {
- // Try to select the affected objects
- setSelectionToViewer(pMostRecentCommand.getAffectedObjects());
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * Returns the viewer as required by the {@link IViewerProvider} interface.
- * It can be any kind of viewer (tree, table, etc.).
- *
- * @return The viewer of this page
- */
- @Override
- public Viewer getViewer() {
- return mViewer;
- }
-
- /**
- * {@inheritDoc}
- *
- * By default, return this page viewer control.
- */
- @Override
- public Control getControl() {
- return getViewer().getControl();
- }
-
- /**
- * Creates a default context menu and set it to the viewer.
- */
- protected void addContextMenu() {
- // Create a default context menu
- final MenuManager vContextMenuManager = new MenuManager();
- vContextMenuManager.add(new Separator(ADDITIONS_SEPARATOR_ID));
- vContextMenuManager.setRemoveAllWhenShown(true);
-
- // Register this page instance as menu listener to ensure
- // that it will be warn when the menu is opened
- vContextMenuManager.addMenuListener(this);
-
- // Create a context menu in the new menu manager, and link it to the viewer
- final Menu vMenu = vContextMenuManager.createContextMenu(mViewer.getControl());
- mViewer.getControl().setMenu(vMenu);
-
- // Register the context menu to the viewer selection
- getSite().registerContextMenu(POP_UP_ID, vContextMenuManager, new UnwrappingSelectionProvider(mViewer));
- }
-
- /**
- * Add a drag support to the viewer.
- */
- protected void addDragSupport() {
- final int vDndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
- final Transfer[] vTransfersArray = new Transfer[] {LocalTransfer.getInstance()};
-
- mViewer.addDragSupport(
- vDndOperations,
- vTransfersArray,
- new ViewerDragAdapter(mViewer));
- }
-
- /**
- * Add a drop support to the viewer.
- */
- protected void addDropSupport() {
- final int vDndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
- final Transfer[] vTransfersArray = new Transfer[] {LocalTransfer.getInstance()};
-
- mViewer.addDropSupport(
- vDndOperations,
- vTransfersArray,
- new EditingDomainViewerDropAdapter(mEditingDomain, mViewer));
- }
-
- /**
- * Return the adapter factory content provider to associate to the viewer.
- * If no content provider is known, create a default one.
- *
- * @return Return the content provider to associate to the viewer
- */
- protected IContentProvider getContentProvider() {
- if (mContentProvider == null) {
- // Create a default content provider
- mContentProvider = createContentProvider();
- }
-
- return mContentProvider;
- }
-
- /**
- * Create and return a default content provider.
- * The content provider must call {@link #inputChanged(oldInput,newInput) in the method
- *
- * @return The created content provider
- */
- protected IContentProvider createContentProvider() {
- return new AdapterFactoryContentProvider(getAdapterFactory()) {
-
- /**
- * {@inheritDoc}
- *
- * This method is overridden to be able to manage the arrays as input element.
- */
- @Override
- public Object[] getElements(final Object pInputElement) {
- Object[] vElementsArray = new Object[] {};
-
- // Check if the input element is an array
- if (pInputElement instanceof Object[]) {
- // If the input is an array, loop on each input object in it
- // to get its corresponding elements
- final List<Object> vElementsList = new ArrayList<Object>();
- for (final Object vInputElement : (Object[]) pInputElement) {
- vElementsList.addAll(Arrays.asList(super.getElements(vInputElement)));
- }
-
- // Build the final elements array from the list
- if (!vElementsList.isEmpty()) {
- vElementsArray = vElementsList.toArray(new Object[vElementsList.size()]);
- }
-
- } else {
- // If the input is a single object, get its element by calling the parent method
- vElementsArray = super.getElements(pInputElement);
- }
-
- return vElementsArray;
- }
-
- /**
- * {@inheritDoc}
- *
- * This method is overridden to warn the page instance that its input has changed
- * if the content provider input changes.
- */
- @Override
- public void inputChanged(final Viewer pViewer, final Object pOldInput, final Object pNewInput) {
- // Call the parent method
- super.inputChanged(pViewer, pOldInput, pNewInput);
-
- // Warn the page that its input changed
- AbstractPage.this.inputChanged(pOldInput, pNewInput);
- }
-
- /**
- * {@inheritDoc}
- *
- * This method is overridden to warn the page instance that its input has been disposed.
- */
- @Override
- public void dispose() {
- if (viewer != null) {
- // Set the page input to null
- AbstractPage.this.inputChanged(viewer.getInput(), null);
- }
- super.dispose();
- }
- };
- }
-
- /**
- * Called when the input is changed to attach the {@link IEditingDomainProvider} if needed.
- *
- * @param pOldInput the old input element, or null if the viewer did not previously have an input
- * @param pNewInput the new input element, or null if the viewer does not have an input
- */
- protected void inputChanged(final Object pOldInput, final Object pNewInput) {
- disposeOldInput(pOldInput);
- inputChanged(pNewInput);
- }
-
- /**
- * React to an input change, to link the page content to the new input.
- * If the input is a resource (or an array of resources), attach all the needed adapters to it.
- *
- * @param pNewInput The new input value
- */
- private void inputChanged(final Object pNewInput) {
-
- // Initialise a list of resource to add as input
- List<Resource> vInputResourcesList = new ArrayList<Resource>();
-
- if (pNewInput instanceof Resource) {
- // If the new input is a resource, add it in the list to manage
- vInputResourcesList.add((Resource) pNewInput);
-
- } else if (pNewInput instanceof Object[]) {
- // The input is an array, look in its content for the potential resources
- // to use as input
- for (final Object vInput : (Object[]) pNewInput) {
- if (vInput instanceof Resource) {
- vInputResourcesList.add((Resource) vInput);
- }
- }
- }
-
- // Finally, loop on the resources to add as input
- for (Resource vResource : vInputResourcesList) {
- // Attach all the needed adapters
- attachAdapterForResource(vResource);
-
- // Add the resource to the resource set of the used editing domain
- // but lock its edition if the view is read only, and if the editing
- // domain allows it
- if (mReadOnlyMode && mEditingDomain instanceof AdapterFactoryEditingDomain) {
- // Add the resource in the locked part of the resource set
- ((AdapterFactoryEditingDomain) mEditingDomain).getResourceToReadOnlyMap().put(vResource, Boolean.TRUE);
-
- } else {
- // The view is not in read only, or the editing domain doesn't allow to lock its resource,
- // thus simply add the resource in the resource set
- mEditingDomain.getResourceSet().getResources().add(vResource);
- }
- }
- }
-
- /**
- * Dispose an old input.
- *
- * A custom treatment is applied if the input was a resource or an
- * array of resources, to ensure that all the potential listeners or adapters
- * are also disposed.
- *
- * @param pOldInput The input to dispose
- */
- private void disposeOldInput(final Object pOldInput) {
- if (pOldInput instanceof Resource) {
- // The old input was a resource, detach all the potential adapters
- detachAdapterFromResource((Resource) pOldInput);
-
- } else if (pOldInput instanceof Object[]) {
- // The old input was an array, check if it contains any resource,
- // to detach all the potential adapters
- for (final Object vOldInput : (Object[]) pOldInput) {
- if (vOldInput instanceof Resource) {
- detachAdapterFromResource((Resource) vOldInput);
- }
- }
- }
- }
-
- /**
- * Return the label provider to associate to the viewer.
- * If no label provider is known, create a default one.
- *
- * @return Return the label provider to associate to the viewer
- */
- protected IBaseLabelProvider getLabelProvider() {
- if (mLabelProvider == null) {
- mLabelProvider = createLabelProvider();
- }
- return mLabelProvider;
- }
-
- /**
- * Create and return a default label provider based on the adapter factory.
- *
- * @return The created label provider
- */
- protected IBaseLabelProvider createLabelProvider() {
- return new AdapterFactoryLabelProvider(getAdapterFactory());
- }
-
- /**
- * Set the input of the viewer.
- * This will be done in an UI thread, and will ensure that the viewer is still available.
- *
- * @param pInput The new input to set to the viewer
- */
- protected void setViewerInput(final Object pInput) {
- getSite().getShell().getDisplay().asyncExec(new Runnable() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- if ((mViewer != null) && !mViewer.getControl().isDisposed()) {
- synchronized (mViewer) {
- mViewer.setInput(pInput);
- }
- }
- }
- });
- }
-
- /**
- * Return the initial input of the viewer.
- *
- * @return The initial input of the viewer
- */
- protected abstract Object getInitialInput();
-
- /**
- * Return the resource set to associate to the editing domain.
- *
- * If this method return <code>null</code>, a new resource set will be
- * created by default during the editing domain initialisation.
- *
- * @return The resource set to associate to the editing domain
- */
- protected abstract ResourceSet getResourceSet();
-
- /**
- * Return the property source provider to associate to the viewer.
- * If no property source provider is known, create a default one.
- *
- * @return Return the property source provider to associate to the viewer
- */
- protected IPropertySourceProvider getPropertySourceProvider() {
- if (mPropertySourceProvider == null) {
- mPropertySourceProvider = createPropertySourceProvider();
- }
- return mPropertySourceProvider;
- }
-
- /**
- * Create and return a default property source provider based on the adapter factory.
- *
- * @return The created property source provider
- */
- protected IPropertySourceProvider createPropertySourceProvider() {
- return new PropertySourceProvider(getAdapterFactory());
- }
-
- /**
- * Set the message to the status line manager based on the selection count.
- *
- * @param pSelection The selection to take into account
- */
- protected void updateStatusBar(final ISelection pSelection) {
-
- String vMessage = null;
-
- // Ensure that the selection can be parsed
- if (pSelection instanceof IStructuredSelection) {
-
- // Get the right message, according to the number of elements in the selection
- switch (((IStructuredSelection) pSelection).size()) {
- case 0:
- vMessage = CommonUIActivator.getMessages().getString("AbstractPage.noobjectselected"); //$NON-NLS-1$
- break;
-
- case 1:
- // Get the text corresponding to the selected object
- final String vSelectedObjectText = new AdapterFactoryItemDelegator(mComposedAdapterFactory)
- .getText(((IStructuredSelection) pSelection).getFirstElement());
-
- // Build the message with the text found
- vMessage = CommonUIActivator.getMessages().getString("AbstractPage.oneobjectselected", //$NON-NLS-1$
- new Object[] {vSelectedObjectText});
- break;
-
- default:
- vMessage = CommonUIActivator.getMessages().getString("AbstractPage.multiobjectsselected", //$NON-NLS-1$
- new Object[] {Integer.toString(((IStructuredSelection) pSelection).size())});
- break;
- }
- }
-
- // Finally update the status message
- setStatusLineMessage(vMessage, false);
- }
-
- /**
- * Set the message to the status line manager.
- * It can be treated as an error message or not according to the flag given in parameter.
- *
- * @param pMessage The message to set
- * @param pIsErrorMsg <code>true</code> if the message is an error message, <code>false</code> otherwise
- */
- protected void setStatusLineMessage(final String pMessage, final boolean pIsErrorMsg) {
- // Get the status line manager
- final IStatusLineManager vStatusLineManager = getActionBars().getStatusLineManager();
-
- if (vStatusLineManager != null) {
- // Update the status message, with an error status or not
- if (pIsErrorMsg) {
- vStatusLineManager.setErrorMessage(ImageConstants.ICON_ERROR, pMessage);
- } else {
- vStatusLineManager.setMessage(ImageConstants.ICON_INFO, pMessage);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * This is overridden to help to fill the context menus with contributions from the Edit menu.
- */
- @Override
- public void menuAboutToShow(final IMenuManager pMenuManager) {
- getActionBarContributor().menuAboutToShow(pMenuManager);
- }
-
- /**
- * Returns the action bar contributor for this page.
- * If no contributor is known, create a default one.
- *
- * @return The page action bar contributor
- */
- protected ViewActionBarContributor getActionBarContributor() {
- if (mActionBarContributor == null) {
- mActionBarContributor = createActionBarContributor();
- mActionBarContributor.init(getActionBars(), getSite().getPage());
- }
-
- return mActionBarContributor;
- }
-
- /**
- * Update the action bar contributor of this page to use the given part as
- * selection provider, and if possible also as editing domain provider.
- *
- * This is mandatory to ensure that the contextual actions in the contributor
- * are linked to a selection for their activation and their run.
- *
- * @param pActivePart The part to use as selection provider and potential editing domain
- * provider for the action bar contributor
- */
- public void updateActionBarContributorActivePart(final IWorkbenchPart pActivePart) {
- // Register the new active part
- getActionBarContributor().setActivePart(pActivePart);
-
- // Then update the actions
- getActionBarContributor().update();
- }
-
- /**
- * Create and return a default action bar contributor.
- *
- * @return The created action bar contributor
- */
- protected ViewActionBarContributor createActionBarContributor() {
- return new ViewActionBarContributor();
- }
-
- /**
- * Returns the action bars for this page.
- *
- * @return The {@link IActionBars} of this page
- */
- protected IActionBars getActionBars() {
- return getSite().getActionBars();
- }
-
- /**
- * This returns the composed adapter factory associated to the viewer.
- *
- * @return The composed adapter factory associated to the viewer
- */
- protected ComposedAdapterFactory getAdapterFactory() {
- return mComposedAdapterFactory;
- }
-
- /**
- * Add an editing domain provider adapter to the given resource.
- *
- * @param pResource The resource to treat
- */
- private void attachAdapterForResource(final Resource pResource) {
- // Check if an editing domain provider is already known for this resource
- // in this case, there is nothing to do
- if (getResourceEditingDomainProvider(pResource) == null) {
- // Create a new editing domain provider and add it to the resource
- final EditingDomainProvider vEditingDomainProvider = new EditingDomainProvider(mEditingDomain);
- pResource.eAdapters().add(vEditingDomainProvider);
- }
- }
-
- /**
- * Remove the editing domain provider adapter attach to the resource
- * if it has been added only for this page context.
- *
- * @param pResource The resource to treat
- */
- private void detachAdapterFromResource(final Resource pResource) {
- // Get the editing domain provider linked to the resource
- final IEditingDomainProvider vResourceEditingDomainProvider = getResourceEditingDomainProvider(pResource);
- if (vResourceEditingDomainProvider != null) {
-
- // Check if the resource editing domain is the same editing domain
- // as the one used in the page. In this case, it has been added explicitly
- // for this page and can thus be removed
- if (mEditingDomain.equals(vResourceEditingDomainProvider.getEditingDomain())) {
- pResource.eAdapters().remove(vResourceEditingDomainProvider);
- }
- }
- }
-
- /**
- * Return the editing domain provider of a given resource.
- *
- * @param pResource The resource to treat
- * @return <code>{@link IEditingDomainProvider}</code> found, or null otherwise
- */
- private IEditingDomainProvider getResourceEditingDomainProvider(final Resource pResource) {
- IEditingDomainProvider vEditingDomainProvider = null;
-
- if (pResource != null) {
- // Get the potential existing editing domain provider
- vEditingDomainProvider = (IEditingDomainProvider) EcoreUtil.getExistingAdapter(
- pResource,
- IEditingDomainProvider.class);
- }
-
- return vEditingDomainProvider;
- }
-
- /**
- * {@inheritDoc}
- *
- * Initialises this page with the given page site.
- * <p>
- * This method is automatically called by the workbench shortly after the part is instantiated. It marks the start
- * of the page's life cycle. Clients must not call this method directly.
- * </p>
- *
- * @param pSite The page site
- */
- @Override
- public void init(final IPageSite pSite) {
- // Call the parent method
- super.init(pSite);
-
- // Initialise the editing domain for this page
- initializeEditingDomain();
- }
-
- /**
- * {@inheritDoc}
- *
- * Create the controls for this page, and initialise the viewer of this page.
- *
- * @param pParent The parent control
- */
- @Override
- public void createControl(final Composite pParent) {
- // Initialise the viewer
- initializeViewer(pParent);
-
- // Add the page styles, menus and toolbars
- addStyles();
- addMenuBarActions();
- addToolBarActions();
- }
-
- /**
- * This method is used to add the styles to the page : its context menu,
- * and the mechanisms for the drag & drop, and the filters.
- *
- * User must override this function to add or remove specific styles.
- */
- protected void addStyles() {
- addContextMenu();
- addDragSupport();
- addDropSupport();
- addFilters();
- }
-
- /**
- * Initialise the viewer of this page.
- *
- * @param pParent The parent composite
- */
- protected void initializeViewer(final Composite pParent) {
- // Create the viewer and remember it
- mViewer = createViewer(pParent);
-
- // Set the viewer providers and input
- setViewerProviders();
- setViewerInput(getInitialInput());
-
- // Register the fact that this page site selection is provided by the viewer
- getSite().setSelectionProvider(mViewer);
-
- // Finally, add the listeners (double click, etc.) on the viewer
- addViewerListeners();
- }
-
- /**
- * Set the viewer content and label providers.
- *
- * This default implementation use the methods {@link AbstractPage#getLabelProvider()} and
- * {@link AbstractPage#getContentProvider()} to find the providers to set.
- */
- protected void setViewerProviders() {
- mViewer.setLabelProvider(getLabelProvider());
- mViewer.setContentProvider(getContentProvider());
- }
-
- /**
- * Adds the listeners to the viewer.
- * This default implementation add a selection changed and a double click listeners.
- */
- protected void addViewerListeners() {
- addViewerSelectionChangedListener();
- addViewerDoubleCLickListener();
- }
-
- /**
- * Adds an {@link ISelectionChangedListener} to the viewer.
- */
- protected void addViewerSelectionChangedListener() {
- mViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void selectionChanged(final SelectionChangedEvent pEvent) {
- handleSelectionChanged(pEvent);
- }
- });
- }
-
- /**
- * Adds an {@link IDoubleClickListener} to the viewer.
- */
- protected void addViewerDoubleCLickListener() {
- mViewer.addDoubleClickListener(new IDoubleClickListener() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void doubleClick(final DoubleClickEvent pEvent) {
-
- // Use an asynchronous UI thread to treat the double click event
- mViewer.getControl().getDisplay().asyncExec(new Runnable() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- // Ensure that the viewer is still available
- if (mViewer != null && !mViewer.getControl().isDisposed()) {
- handleDoubleClick(pEvent);
- }
- }
- });
- }
- });
- }
-
- /**
- * Called when a double click is made in the viewer.
- * This method does nothing by default.
- *
- * @param pEvent The {@link DoubleClickEvent}.
- */
- protected void handleDoubleClick(final DoubleClickEvent pEvent) {
- // Nothing to do
- }
-
- /**
- * Called when the selection changed in the viewer.
- * This method update the status bar message by default.
- *
- * @param pEvent The {@link ISelectionChangedListener}.
- */
- protected void handleSelectionChanged(final SelectionChangedEvent pEvent) {
- updateStatusBar(pEvent.getSelection());
- }
-
- /**
- * Create the viewer.
- * This method is abstract as each child will create its own kind of viewer.
- *
- * @param pParent The composite parent
- * @return The created viewer
- */
- protected abstract StructuredViewer createViewer(Composite pParent);
-
- /**
- * Refresh the viewer.
- */
- protected void refreshViewer() {
- // Use an asynchronous UI thread to refresh the viewer
- getSite().getShell().getDisplay().asyncExec(new Runnable() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- // Ensure that the viewer is still available
- if (mViewer != null && !mViewer.getControl().isDisposed()) {
- synchronized (mViewer) {
- mViewer.refresh();
- }
- }
- }
- });
- }
-
- /**
- * {@inheritDoc}
- *
- * Asks this page to take focus within the workbench.
- * Page must assign focus to one of the controls contained in
- * the part's parent composite.
- *
- * In our case, set the focus to the viewer control by default.
- */
- @Override
- public void setFocus() {
- // Ensure that the viewer is still available
- if (mViewer != null && !mViewer.getControl().isDisposed()) {
- mViewer.getControl().setFocus();
- }
- }
-
- /**
- * Add an action in the menu bar.
- *
- * @param pAction The action to add
- */
- protected void addMenuBarAction(final IAction pAction) {
- getActionBars().getMenuManager().add(pAction);
- }
-
- /**
- * Add an action in the tool bar.
- *
- * @param pAction The action to add
- */
- protected void addToolBarAction(final IAction pAction) {
- getActionBars().getToolBarManager().add(pAction);
- }
-
- /**
- * Add a sub-menu to the menu bar.
- *
- * @param pMenuManager The menu manager to add
- */
- protected void addMenuBarSubMenu(final IMenuManager pMenuManager) {
- getActionBars().getMenuManager().add(pMenuManager);
- }
-
- /**
- * Add a separator to the menu bar.
- */
- protected void addMenuBarSeparator() {
- getActionBars().getMenuManager().add(new Separator());
- }
-
- /**
- * Add a separator to the tool bar.
- */
- protected void addToolBarSeparator() {
- getActionBars().getToolBarManager().add(new Separator());
- }
-
- /**
- * Add the filters returned by {@link #getFilters()} to the viewer.
- */
- protected void addFilters() {
- for (AbstractFilter vFilter : getFilters()) {
- mViewer.addFilter(vFilter);
- }
- }
-
- /**
- * Called when the filter text changed, to be able to react.
- *
- * @param pNewFilterText The new filter text to take into account
- */
- public void filterTextChanged(final String pNewFilterText) {
- // Ensure that the viewer is still available
- if (mViewer != null && !mViewer.getControl().isDisposed()) {
-
- // Loop on the registered filters to apply the new text
- for (final ViewerFilter vViewerFilter : mViewer.getFilters()) {
- if (vViewerFilter instanceof AbstractFilter) {
- ((AbstractFilter) vViewerFilter).setFilter(pNewFilterText);
- }
- }
-
- // Finally refresh the viewer content
- refreshViewer();
- }
- }
-
- /**
- * Return the filters that will be associated to the viewer by {@link #addFilters()}.
- * By default, this returns a table of filters containing a new {@link NamePropertyFilter} filter.
- *
- * @return The table of filters to associate to the viewer
- */
- protected AbstractFilter[] getFilters() {
- return new AbstractFilter[] {new NamePropertyFilter()};
- }
-
- /**
- * Add actions to the menu bar.
- *
- * By default, this method doesn't add any actions, it's only update the menu bar. User can override
- * this method to add actions to the menu bar. User can call at the end of the overriding method
- * super {@link #addMenuBarActions()} to update the menu bar.
- */
- protected void addMenuBarActions() {
- getActionBars().getMenuManager().update(true);
- }
-
- /**
- * Add actions to the tool bar.
- *
- * By default, this method doesn't add any actions, it's only update the tool bar. User can override
- * this method to add actions to the tool bar. User can call at the end of the overriding method
- * super {@link #addToolBarActions()} to update the tool bar.
- */
- protected void addToolBarActions() {
- getActionBars().getToolBarManager().update(true);
- }
-}
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/view/AbstractTreePage.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/view/AbstractTreePage.java
deleted file mode 100644
index aa3aca4..0000000
--- a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/view/AbstractTreePage.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.common.ui.view;
-
-import org.apache.commons.lang3.StringUtils;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.EditingSupport;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.TreeViewerColumn;
-import org.eclipse.jface.viewers.ViewerColumn;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.ui.handlers.CollapseAllHandler;
-import org.eclipse.ui.handlers.ExpandAllHandler;
-import org.polarsys.esf.core.common.ui.CommonUIActivator;
-import org.polarsys.esf.core.common.ui.CommonUIActivator.Implementation;
-
-/**
- * Abstract base of all the Pages to use in a PageBookView,
- * and which includes a tree.
- *
- * This implementation doesn't manage the columns in the tree,
- * but it inherits of all the standard mechanisms like the filters, the editing domain mechanisms, etc.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public abstract class AbstractTreePage
- extends AbstractColumnViewerPage {
-
- /**
- * Default constructor, which allows to specify if the viewer must be read only or not.
- *
- * @param pReadOnlyMode <code>true</code> if this view is in read only mode, <code>false</code> otherwise
- */
- public AbstractTreePage(final boolean pReadOnlyMode) {
- super(pReadOnlyMode);
- }
-
- /**
- * Advanced constructor which takes the name of the required column, an array with the optional columns name,
- * and a boolean which specifies if the viewer must be in read only mode or not.
- *
- * The required column will mandatory be visible and can't be hidden.
- *
- * @param pRequiredColumnName The name of the required column name
- * @param pColumnsName The array of optional columns name. This list must not contain the required column name
- * @param pReadOnlyMode <code>true</code> if this view is in read only mode, <code>false</code> otherwise
- */
- public AbstractTreePage(
- final String pRequiredColumnName,
- final String[] pColumnsName,
- final boolean pReadOnlyMode) {
- super(pRequiredColumnName, pColumnsName, pReadOnlyMode);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected TreeViewer createViewer(final Composite pParent) {
- return new TreeViewer(pParent, SWT.MULTI);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public TreeViewer getViewer() {
- return (TreeViewer) super.getViewer();
- }
-
- /**
- * {@inheritDoc}
- *
- * Overridden to expand or collapse the current element on which
- * the double click is performed.
- */
- @Override
- protected void handleDoubleClick(final DoubleClickEvent pEvent) {
- // Get the element on which the double click is performed
- final IStructuredSelection vSelection = (IStructuredSelection) pEvent.getSelection();
- final Object vSelectedeElement = vSelection.getFirstElement();
-
- // If the element is expandable, change is expand state
- if (getViewer().isExpandable(vSelectedeElement)) {
- getViewer().setExpandedState(vSelectedeElement, !getViewer().getExpandedState(vSelectedeElement));
- }
- }
-
- /**
- * Create the expand all action.
- *
- * @return The expand all action created
- */
- protected IAction createExpandAllAction() {
- // Get the action image
- final ImageDescriptor vImageDescriptor =
- CommonUIActivator.getPlugin().getImageRegistry().getDescriptor(
- Implementation.ICON_EXPAND_ALL_KEY);
-
- // Get the action label
- final String vActionLabel =
- CommonUIActivator.getMessages().getString("AbstractTreePage.action.expandall"); //$NON-NLS-1$
-
- // Create the action
- final IAction vExpandAllAction = new Action(vActionLabel, vImageDescriptor) {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- // Prepare the expand action asynchronously, on the UI thread
- AbstractTreePage.this.getSite().getShell().getDisplay().asyncExec(new Runnable() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- // Create the action handler on the viewer
- final ExpandAllHandler vExpandAllHandler =
- new ExpandAllHandler(AbstractTreePage.this.getViewer());
-
- // And finally execute it
- vExpandAllHandler.execute(null);
- }
- });
- }
- };
-
- return vExpandAllAction;
- }
-
- /**
- * Create the collapse all action.
- *
- * @return The collapse all action created
- */
- protected IAction createCollapseAllAction() {
- // Get the action image
- final ImageDescriptor vImageDescriptor =
- CommonUIActivator.getPlugin().getImageRegistry().getDescriptor(
- Implementation.ICON_COLLAPSE_ALL_KEY);
-
- // Get the action label
- final String vActionLabel =
- CommonUIActivator.getMessages().getString("AbstractTreePage.action.collapseall"); //$NON-NLS-1$
-
- // Create the action
- final IAction vCollapseAllAction = new Action(vActionLabel, vImageDescriptor) {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- // Prepare the collapse action asynchronously, on the UI thread
- AbstractTreePage.this.getSite().getShell().getDisplay().asyncExec(new Runnable() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- // Create the action handler on the viewer
- final CollapseAllHandler vCollapseAllHandler =
- new CollapseAllHandler(AbstractTreePage.this.getViewer());
-
- // And finally execute it
- vCollapseAllHandler.execute(null);
- }
- });
- }
- };
-
- return vCollapseAllAction;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setLinesVisible(final boolean pShow) {
- getViewer().getTree().setLinesVisible(pShow);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setHeaderVisible(final boolean pShow) {
- getViewer().getTree().setHeaderVisible(pShow);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean isViewerHeaderInitiallyVisible() {
- return getViewer().getTree().getHeaderVisible();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean isViewerLinesInitiallyVisible() {
- return getViewer().getTree().getLinesVisible();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean hideColumn(final String pColumnName) {
-
- boolean vColumnHidden = false;
-
- // Try to find the column by its name
- final TreeColumn vColumn = getColumn(pColumnName);
-
- // If the column is found, dispose it
- if (vColumn != null) {
- vColumn.dispose();
-
- // Remember that the column was hidden
- vColumnHidden = true;
- }
-
- return vColumnHidden;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean isColumnVisible(final String pColumnName) {
- return getColumn(pColumnName) != null;
- }
-
- /**
- * Find and return an existing column in the tree viewer from its name.
- *
- * @param pColumnName The name of the column to find
- * @return The column found if any, and <code>null</code> otherwise
- */
- protected TreeColumn getColumn(final String pColumnName) {
-
- TreeColumn vColumnFound = null;
-
- // Check if the searched name is valid
- if (StringUtils.isNotEmpty(pColumnName)) {
-
- // Get an iterator on the list of existing columns in the tree viewer
- final TreeColumn[] vColumnsArray = getViewer().getTree().getColumns();
-
- // Loop on the columns array until the column is found
- for (int i = 0; i < vColumnsArray.length && vColumnFound == null; i++) {
- TreeColumn vTreeColumn = vColumnsArray[i];
-
- if (vTreeColumn.getText().equals(pColumnName)) {
- vColumnFound = vTreeColumn;
- }
- }
- }
-
- return vColumnFound;
- }
-
- /**
- * {@inheritDoc}
- *
- * This is customised to add the expand all and collapse all actions.
- */
- @Override
- protected void addToolBarActions() {
- addExpandAllAction();
- addCollapseAllAction();
- super.addToolBarActions();
- }
-
- /**
- * Add to the toolbar the action to expand all the tree content.
- */
- protected void addExpandAllAction() {
- addToolBarAction(createExpandAllAction());
- }
-
- /**
- * Add to the toolbar the action to collapse all the tree content.
- */
- protected void addCollapseAllAction() {
- addToolBarAction(createCollapseAllAction());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected TreeViewerColumn createRequiredViewerColumn() {
- // Nothing to do as this implementation doesn't manage multiple columns
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ViewerColumn createViewerColumn(final String pColumnName) {
- // Nothing to do as this implementation doesn't manage multiple columns
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ViewerColumn createViewerColumn(final String pColumnName, final int pIndex) {
- // Nothing to do as this implementation doesn't manage multiple columns
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ViewerColumn createViewerColumn(
- final String pColumnName,
- final ColumnLabelProvider pColumnLabelProvider) {
- // Nothing to do as this implementation doesn't manage multiple columns
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ViewerColumn createViewerColumn(
- final String pColumnName,
- final ColumnLabelProvider pColumnLabelProvider,
- final EditingSupport pEditingSupport) {
- // Nothing to do as this implementation doesn't manage multiple columns
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected ViewerColumn createViewerColumn(final String pColumnName, final String pPropertyID) {
- // Nothing to do as this implementation doesn't manage multiple columns
- return null;
- }
-
-}
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/view/AbstractTreeTablePage.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/view/AbstractTreeTablePage.java
deleted file mode 100644
index ccb45b4..0000000
--- a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/view/AbstractTreeTablePage.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.common.ui.view;
-
-import org.apache.commons.lang3.StringUtils;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.EditingSupport;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.TreeViewerColumn;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.views.properties.PropertyColumnLabelProvider;
-import org.polarsys.esf.core.common.ui.editingsupport.ValidatedPropertyEditingSupport;
-
-/**
- * Abstract base of all the Pages to use in a PageBookView,
- * and which contains a tree table as viewer.
- *
- * This page inherits of all the standard mechanisms like the filters, the editing domain mechanisms, etc.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public abstract class AbstractTreeTablePage
- extends AbstractTreePage {
-
- /**
- * A constructor that takes the array of columns name to create in the tree table.
- * This constructor is used in the case of adding of the columns visibility action.
- *
- * @param pRequiredColumnName The name of the required column name that can't be hidden
- * @param pColumnsName The column names list. This list must not contain the requiredColumnName
- * @param pReadOnlyMode <code>true</code>if this view is in mode read only <code>false</code> otherwise
- */
- public AbstractTreeTablePage(
- final String pRequiredColumnName,
- final String[] pColumnsName,
- final boolean pReadOnlyMode) {
- super(pRequiredColumnName, pColumnsName, pReadOnlyMode);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected TreeViewerColumn createRequiredViewerColumn() {
- // Get the name of the required column
- String vColumnName = getRequiredColumnName();
-
- // If the name is not valid, set a default empty value
- if (StringUtils.isEmpty(vColumnName)) {
- vColumnName = StringUtils.EMPTY;
- }
-
- // Create the required column at the beginning, and set its width
- final TreeViewerColumn vTreeViewerColumn = createViewerColumn(vColumnName, 0);
- vTreeViewerColumn.getColumn().setWidth(150);
-
- return vTreeViewerColumn;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected TreeViewer createViewer(final Composite pParent) {
-
- // Create a tree viewer allowing multiple selection
- final TreeViewer vTreeViewer = new TreeViewer(pParent, SWT.MULTI | SWT.FULL_SELECTION);
-
- // Set the tree lines and header visible
- // NB : Don't call directly the methods 'setLinesVisible' and 'setHeaderVisible'
- // of this instance as the tree is not already created and initialised
- vTreeViewer.getTree().setLinesVisible(true);
- vTreeViewer.getTree().setHeaderVisible(true);
- return vTreeViewer;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected TreeViewerColumn createViewerColumn(final String pColumnName, final int pIndex) {
-
- // Create a new column at the given index
- final TreeViewerColumn vTreeViewerColumn = new TreeViewerColumn(getViewer(), SWT.LEFT, pIndex);
- vTreeViewerColumn.getColumn().setText(pColumnName);
- vTreeViewerColumn.getColumn().pack();
-
- return vTreeViewerColumn;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected TreeViewerColumn createViewerColumn(final String pColumnName) {
- return createViewerColumn(pColumnName, getViewer().getTree().getColumnCount());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected TreeViewerColumn createViewerColumn(
- final String pColumnName,
- final ColumnLabelProvider pColumnLabelProvider) {
-
- // Create a new column
- final TreeViewerColumn vTreeViewerColumn = createViewerColumn(pColumnName);
-
- // Set the column label provider with the instance given in parameter
- vTreeViewerColumn.setLabelProvider(pColumnLabelProvider);
-
- return vTreeViewerColumn;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected TreeViewerColumn createViewerColumn(
- final String pColumnName,
- final ColumnLabelProvider pColumnLabelProvider,
- final EditingSupport pEditingSupport) {
-
- // Create a new column
- final TreeViewerColumn vTreeViewerColumn = createViewerColumn(pColumnName);
-
- // Set the column label provider and editing support
- // with the instance given in parameter
- vTreeViewerColumn.setLabelProvider(pColumnLabelProvider);
- vTreeViewerColumn.setEditingSupport(pEditingSupport);
- return vTreeViewerColumn;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected TreeViewerColumn createViewerColumn(final String pColumnName, final String pPropertyID) {
-
- // Create a new column
- final TreeViewerColumn vTreeViewerColumn = createViewerColumn(pColumnName);
-
- // Set the column label provider and editing support based on the property whose
- // id is given in parameter
- vTreeViewerColumn.setLabelProvider(new PropertyColumnLabelProvider(getPropertySourceProvider(), pPropertyID));
- vTreeViewerColumn.setEditingSupport(
- new ValidatedPropertyEditingSupport(
- getViewer(),
- getPropertySourceProvider(),
- pPropertyID,
- getActionBars().getStatusLineManager()));
-
- return vTreeViewerColumn;
- }
-}
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/widget/ActiveProjectControlContribution.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/widget/ActiveProjectControlContribution.java
deleted file mode 100644
index 92fa253..0000000
--- a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/widget/ActiveProjectControlContribution.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.common.ui.widget;
-
-import org.apache.commons.lang3.StringUtils;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.common.ui.URIEditorInput;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE.SharedImages;
-import org.eclipse.ui.menus.WorkbenchWindowControlContribution;
-import org.polarsys.esf.core.common.ui.CommonUIActivator;
-
-/**
- * Control contribution used to display the current active project
- * according to the active editor.
- *
- * This is made to ease user work, by displaying directly on which project he is working.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public class ActiveProjectControlContribution
- extends WorkbenchWindowControlContribution
- implements IPartListener {
-
- /** The default label for the active project name. */
- private static final String DEFAULT_PROJECT_NAME = CommonUIActivator.getMessages().getString(
- "ActiveProjectControlContribution.default.projectname"); //$NON-NLS-1$
-
- /** The composite containing all the widgets used to display the active project name. */
- private ActiveProjectComposite mActiveProjectComposite = null;
-
- /** The last editor activated and used to get the active project name. */
- private IEditorPart mActiveEditorPart = null;
-
- /**
- * Default constructor.
- */
- public ActiveProjectControlContribution() {
- // Register this new instance as part listener
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService().addPartListener(this);
- }
-
- /**
- * {@inheritDoc}
- *
- * When the control contribution is disposed, removed it from the part listeners.
- */
- @Override
- public void dispose() {
- // Unregister the instance from the part listeners
- IWorkbenchWindow vWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (vWorkbenchWindow != null) {
- vWorkbenchWindow.getPartService().removePartListener(this);
- }
-
- // Call the parent method
- super.dispose();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected Control createControl(final Composite pParent) {
- // Create a new composite containing all the widgets to display for the active project
- mActiveProjectComposite = new ActiveProjectComposite(pParent);
-
- return mActiveProjectComposite;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void partActivated(final IWorkbenchPart pPart) {
- // Ensure that the activated part is an editor
- if (pPart instanceof IEditorPart) {
-
- // Remember of the active editor
- mActiveEditorPart = (IEditorPart) pPart;
-
- // Get the editor input
- IEditorInput vEditorInput = mActiveEditorPart.getEditorInput();
-
- // Check the type of the editor input to find the file used as input
- IFile vFileInput = null;
- if (vEditorInput instanceof IFileEditorInput) {
- // For a file editor input, get directly the file object
- vFileInput = ((IFileEditorInput) vEditorInput).getFile();
-
- } else if (vEditorInput instanceof URIEditorInput) {
- // For an URI editor input, get the file object by looking for in
- // the workspace content, the file which corresponds to the given URI
-
- // ... Build the file path from the URI
- IPath vFilePath = new Path(((URIEditorInput) vEditorInput).getURI().toPlatformString(true));
-
- // ... Try to find the file from the build path, in the workspace content
- vFileInput = ResourcesPlugin.getWorkspace().getRoot().getFile(vFilePath);
- }
-
- // Finally, if the input file is found, try to get its parent project name
- // to update the controls value
- if (vFileInput != null && vFileInput.getProject() != null) {
- mActiveProjectComposite.updateActiveProjectControls(vFileInput.getProject().getName());
- }
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * Treat this event as a part activation.
- * Otherwise, nothing is done by default.
- */
- @Override
- public void partBroughtToTop(final IWorkbenchPart pPart) {
- partActivated(pPart);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void partClosed(final IWorkbenchPart pPart) {
- // If the last active editor used is the one which is closed,
- // then reset the controls content to the default value
- if (mActiveProjectComposite != null && pPart.equals(mActiveEditorPart)) {
- mActiveProjectComposite.updateActiveProjectControls(null);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void partDeactivated(final IWorkbenchPart pPart) {
- // Nothing to do
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void partOpened(final IWorkbenchPart pPart) {
- // Nothing to do
- }
-
- /**
- * Composite which contains all the widgets used to display the current project.
- */
- private class ActiveProjectComposite
- extends Composite {
-
- /** The preferred width for the composite. */
- private static final int CONTROL_WIDTH = 250;
-
- /** The preferred height for the composite. */
- private static final int CONTROL_HEIGHT = 17;
-
- /** The text used to display the active project name. */
- private Text mActiveProjectNameText = null;
-
- /** The introduction label. */
- private Label mActiveProjectNameLabel = null;
-
- /** The opened project image. */
- private final Image mOpenedProjectImage = PlatformUI.getWorkbench().getSharedImages()
- .getImage(SharedImages.IMG_OBJ_PROJECT);
-
- /** The closed project image. */
- private final Image mClosedProjectImage = PlatformUI.getWorkbench().getSharedImages()
- .getImage(SharedImages.IMG_OBJ_PROJECT_CLOSED);
-
- /**
- * Default constructor.
- *
- * @param pParent The parent composite
- */
- ActiveProjectComposite(final Composite pParent) {
- // Call the parent method
- super(pParent, SWT.FLAT);
-
- // Create all the content of the composite
- createContent(pParent);
- }
-
- /**
- * Create all the widget to include in this composite instance.
- *
- * @param pParent The parent composite
- */
- private void createContent(final Composite pParent) {
- // Prepare and set this instance layout and layout data
- final GridLayout vLayout = new GridLayout();
- vLayout.marginHeight = 0;
- vLayout.marginWidth = 1;
- setLayout(vLayout);
- setFont(pParent.getFont());
-
- // Create a child composite and set its layout and display properties
- final Composite vChildComposite = new Composite(this, SWT.BORDER);
- vChildComposite.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
- final GridLayout vChildLayout = new GridLayout(3, false);
- vChildLayout.marginHeight = 0;
- vChildLayout.marginWidth = 0;
- vChildComposite.setLayout(vChildLayout);
- GridData vGridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
- vGridData.widthHint = CONTROL_WIDTH;
- vChildComposite.setLayoutData(vGridData);
- vChildComposite.setFont(pParent.getFont());
-
- // Create the widgets needed
- createActiveProjectLabel(vChildComposite);
- createActiveProjectText(vChildComposite);
-
- // Update the text and label values with the default text and image
- updateActiveProjectControls(null);
- }
-
- /**
- * Create the active project text.
- *
- * @param pParent The parent composite
- */
- private void createActiveProjectText(final Composite pParent) {
- // Create the text and set its layout
- mActiveProjectNameText = new Text(pParent, SWT.SINGLE | SWT.READ_ONLY);
- GridData vGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
- vGridData.heightHint = CONTROL_HEIGHT;
- mActiveProjectNameText.setLayoutData(vGridData);
-
- // Set the text background
- mActiveProjectNameText.setBackground(pParent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
- }
-
- /**
- * Create the active project label.
- *
- * @param pParent The parent composite
- */
- private void createActiveProjectLabel(final Composite pParent) {
- // Create the label and set its layout
- mActiveProjectNameLabel = new Label(pParent, SWT.NONE);
- mActiveProjectNameLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 0, 0));
-
- // Set the label background
- mActiveProjectNameLabel.setBackground(pParent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
- }
-
- /**
- * Update the active project text message, and the displayed image,
- * according to the given project name.
- *
- * If the given value is <code>null</code> or empty, set the default text
- * and image.
- *
- * @param pProjectName The new project name to display
- */
- private void updateActiveProjectControls(final String pProjectName) {
-
- // Check if the given project name is valid
- if (StringUtils.isNotEmpty(pProjectName)) {
-
- // Update the text value and the label image
- if (mActiveProjectNameText != null) {
- mActiveProjectNameText.setText(pProjectName);
- }
- if (mActiveProjectNameLabel != null) {
- mActiveProjectNameLabel.setImage(mOpenedProjectImage);
- }
-
- } else {
- // The given project name is not valid, set the default values
- // for the text value and the label image
- if (mActiveProjectNameText != null) {
- mActiveProjectNameText.setText(DEFAULT_PROJECT_NAME);
- }
- if (mActiveProjectNameLabel != null) {
- mActiveProjectNameLabel.setImage(mClosedProjectImage);
- }
-
- }
- }
- }
-}
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/widget/listener/ShowHideAdapter.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/widget/listener/ShowHideAdapter.java
deleted file mode 100644
index 2f96735..0000000
--- a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/widget/listener/ShowHideAdapter.java
+++ /dev/null
@@ -1,385 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.common.ui.widget.listener;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
-import org.polarsys.esf.core.common.ui.CommonUIActivator;
-import org.polarsys.esf.core.common.ui.CommonUIActivator.Implementation;
-
-/**
- * Selection listener used to hide / show a composite on action.
- * It can typically be used for an advanced button.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- *
- */
-public class ShowHideAdapter
- extends SelectionAdapter {
-
- /** Default image. */
- public static final Image DEFAULT_SHOW_IMAGE = CommonUIActivator.getPlugin().getImageRegistry()
- .get(Implementation.ICON_ADVANCED_SHOW_KEY);
-
- /** Default image. */
- public static final Image DEFAULT_HIDE_IMAGE = CommonUIActivator.getPlugin().getImageRegistry()
- .get(Implementation.ICON_ADVANCED_HIDE_KEY);
-
- /** Default label. */
- public static final String DEFAULT_SHOW_LABEL =
- CommonUIActivator.getMessages().getString("ShowHideAdapter.default.show"); //$NON-NLS-1$
-
- /** Default label. */
- public static final String DEFAULT_HIDE_LABEL =
- CommonUIActivator.getMessages().getString("ShowHideAdapter.default.hide"); //$NON-NLS-1$
-
- /** Image for advanced button. */
- private Image mShowAdvancedImage = DEFAULT_SHOW_IMAGE;
-
- /** Image for advanced button. */
- private Image mHideAdvancedImage = DEFAULT_HIDE_IMAGE;
-
- /** Label for advanced button. */
- private String mShowAdvancedLabel = DEFAULT_SHOW_LABEL;
-
- /** Label for advanced button. */
- private String mHideAdvancedLabel = DEFAULT_HIDE_LABEL;
-
- /** Memorise last status of composite to hide. */
- private boolean mHidden = false;
-
- /** Composite to hide/show. */
- private Composite mCompositeToToggle = null;
-
- /** Button click to hide/show composite. */
- private Button mToggleButton = null;
-
- /** Map of default values associated to controls. */
- private Map<Control, Object> mDefaultControlsValue = null;
-
- /**
- * Default constructor, with default.
- *
- * @param pAdvancedComposite Composite for which hide/show ability must be implemented
- * @param pButton Button which trigger a switch
- */
- public ShowHideAdapter(final Button pButton, final Composite pAdvancedComposite) {
-
- super();
-
- mCompositeToToggle = pAdvancedComposite;
- mToggleButton = pButton;
-
- // Initialise map of default control values
- snapshotControlStates();
-
- }
-
- /**
- * Refresh (or create) snapshot of control states.
- *
- * This method is automatically call by constructor.
- * External call should only be used if composite to show/hide have a structure modification.
- */
- public void snapshotControlStates() {
- if (mCompositeToToggle != null) {
- mDefaultControlsValue = new HashMap<Control, Object>();
- rememberDefaultValues(mCompositeToToggle);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void widgetSelected(final SelectionEvent pEvent) {
- // Negate the hidden status
- mHidden = !mHidden;
- switchComposite();
- }
-
- /**
- * Switch Composite, based on hidden status.
- */
- private void switchComposite() {
-
- if (mCompositeToToggle != null) {
- // Show / hide composite
- if (mHidden) {
- hideComposite();
- } else {
- showComposite();
- }
- }
-
- }
-
- /**
- * Show composite.
- */
- private void showComposite() {
- mCompositeToToggle.setVisible(true);
- mToggleButton.setText(mHideAdvancedLabel);
- mToggleButton.setImage(mHideAdvancedImage);
-
- resizeButton();
- }
-
- /**
- * Hide composite.
- */
- private void hideComposite() {
- mCompositeToToggle.setVisible(false);
- mToggleButton.setText(mShowAdvancedLabel);
- mToggleButton.setImage(mShowAdvancedImage);
-
- restoreDefaultValues(mCompositeToToggle);
-
- resizeButton();
- }
-
- /**
- * Resize button.
- */
- private void resizeButton() {
- // Compute the button size as the label length can change
- Point vComputedSize = mToggleButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- mToggleButton.setSize(vComputedSize);
- }
-
- /**
- * Construct a map of control / value to be able to restore when main composite is hidden.
- * It is a recursive method.
- *
- * This method must be recall if composite structure changes.
- *
- * @param pComposite The parent in which children are search
- */
- private void rememberDefaultValues(final Composite pComposite) {
-
- // Iterate through all children of this composite
- for (Control vChildrenControl : pComposite.getChildren()) {
- // If this children is itself a composite and have children, explore its children too
- if (vChildrenControl instanceof Composite) {
- Composite vCompositeChildren = (Composite) vChildrenControl;
- if (vCompositeChildren.getChildren().length > 0) {
- rememberDefaultValues(vCompositeChildren);
- }
- } else {
- // Remember default value for this child
- mDefaultControlsValue.put(vChildrenControl, getDefaultValue(vChildrenControl));
- }
- }
-
- }
-
- /**
- * From map constructed before, restore default values for children control of given composite.
- * It is a recursive method.
- *
- * @param pComposite The parent in which children are search
- */
- private void restoreDefaultValues(final Composite pComposite) {
-
- // Iterate through all children of this composite
- for (Control vChildrenControl : pComposite.getChildren()) {
-
- // If this children is itself a composite and have children, explore its children too
- if (vChildrenControl instanceof Composite) {
- Composite vCompositeChildren = (Composite) vChildrenControl;
- if (vCompositeChildren.getChildren().length > 0) {
- restoreDefaultValues(vCompositeChildren);
- }
- } else {
- // Restore value for this child
- Object vDefaultValue = mDefaultControlsValue.get(vChildrenControl);
- if (vDefaultValue != null) {
- restoreDefaultValue(vChildrenControl, vDefaultValue);
- }
- }
- }
- }
-
- /**
- * Restore default value for a specific children control.
- *
- * No control are done on default value parameter, because map construction is internal.
- *
- * This method can be override to offer a more specific approach of how value should be restored.
- *
- * @param pChildrenControl Control for which default value will be restore
- * @param pDefaultValue Default value to restore
- */
- protected void restoreDefaultValue(final Control pChildrenControl, final Object pDefaultValue) {
- if (pChildrenControl instanceof Text) {
- ((Text) pChildrenControl).setText((String) pDefaultValue);
- } else if (pChildrenControl instanceof Button) {
- // For a button, restore selection value. This is a minimal behaviour, not specific. It is because
- // there is no pretty sure solution to define which kind of widget a button is.
- Button vButton = (Button) pChildrenControl;
- vButton.setSelection((Boolean) pDefaultValue);
- }
- }
-
- /**
- * Find default value for a given control.
- * Mean of "default value" is specific to kind of control. For a check box, it will be the selected status for
- * example.
- *
- * This method can be override to offer a more specific approach of how value should be read.
- *
- * @param pChildrenControl Control for which default value is search
- * @return The default value, null if no one found
- */
- protected Object getDefaultValue(final Control pChildrenControl) {
- Object vDefaultValue = null;
-
- if (pChildrenControl instanceof Text) {
- vDefaultValue = ((Text) pChildrenControl).getText();
- } else if (pChildrenControl instanceof Button) {
- // For a button, get selection value. This is a minimal behaviour, totally not specific. It is because
- // there is no pretty sure solution to define which kind of widget a button is.
- Button vButton = (Button) pChildrenControl;
- vDefaultValue = vButton.getSelection();
- }
-
- return vDefaultValue;
- }
-
- /**
- * @return The showAdvancedImage
- */
- public Image getShowAdvancedImage() {
- return mShowAdvancedImage;
- }
-
- /**
- * @param pShowAdvancedImage The showAdvancedImage to set
- */
- public void setShowAdvancedImage(final Image pShowAdvancedImage) {
- mShowAdvancedImage = pShowAdvancedImage;
- }
-
- /**
- * @return The hideAdvancedImage
- */
- public Image getHideAdvancedImage() {
- return mHideAdvancedImage;
- }
-
- /**
- * @param pHideAdvancedImage The hideAdvancedImage to set
- */
- public void setHideAdvancedImage(final Image pHideAdvancedImage) {
- mHideAdvancedImage = pHideAdvancedImage;
- }
-
- /**
- * @return The hidden
- */
- public boolean isHidden() {
- return mHidden;
- }
-
- /**
- * Set hidden status, and switch composite if possible.
- *
- * @param pHidden The hidden to set
- */
- public void setHidden(final boolean pHidden) {
- mHidden = pHidden;
- switchComposite();
- }
-
- /**
- * @return The compositeToToggle
- */
- public Composite getCompositeToToggle() {
- return mCompositeToToggle;
- }
-
- /**
- * @param pCompositeToToggle The compositeToToggle to set
- */
- public void setCompositeToToggle(final Composite pCompositeToToggle) {
- mCompositeToToggle = pCompositeToToggle;
- }
-
- /**
- * @return The toggleButton
- */
- public Button getToggleButton() {
- return mToggleButton;
- }
-
- /**
- * @param pToggleButton The toggleButton to set
- */
- public void setToggleButton(final Button pToggleButton) {
- mToggleButton = pToggleButton;
- }
-
- /**
- * @return The showAdvancedLabel
- */
- public String getShowAdvancedLabel() {
- return mShowAdvancedLabel;
- }
-
- /**
- * @param pShowAdvancedLabel The showAdvancedLabel to set
- */
- public void setShowAdvancedLabel(final String pShowAdvancedLabel) {
- mShowAdvancedLabel = pShowAdvancedLabel;
- }
-
- /**
- * @return The hideAdvancedLabel
- */
- public String getHideAdvancedLabel() {
- return mHideAdvancedLabel;
- }
-
- /**
- * @param pHideAdvancedLabel The hideAdvancedLabel to set
- */
- public void setHideAdvancedLabel(final String pHideAdvancedLabel) {
- mHideAdvancedLabel = pHideAdvancedLabel;
- }
-
- /**
- * @return The defaultControlsValue
- */
- public Map<Control, Object> getDefaultControlsValue() {
- return mDefaultControlsValue;
- }
-
- /**
- * @param pDefaultControlsValue The defaultControlsValue to set
- */
- public void setDefaultControlsValue(final Map<Control, Object> pDefaultControlsValue) {
- mDefaultControlsValue = pDefaultControlsValue;
- }
-
-}
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/wizard/AbstractGenericWizard.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/wizard/AbstractGenericWizard.java
deleted file mode 100644
index c761122..0000000
--- a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/wizard/AbstractGenericWizard.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.common.ui.wizard;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.apache.commons.lang3.StringUtils;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.ui.statushandlers.StatusManager;
-import org.polarsys.esf.core.common.ui.CommonUIActivator;
-import org.polarsys.esf.core.common.ui.job.FocusViewJob;
-
-/**
- * Generic wizard. It handles run of thread and logging, to ensure the same behaviour in all ESF wizards.
- *
- * TODO : add an adapt to ask to subclasses if they can send a project back to centralize the
- * <code>SelectAndRevealResourceJob</code> call.
- *
- * @author $Author: jdumont $
- * @version $Revision: 90 $
- *
- */
-public abstract class AbstractGenericWizard
- extends Wizard {
-
- /** ID for ESF info log. */
- private static final String ID_SA_INFO_LOG = "org.polarsys.esf.view.log"; //$NON-NLS-1$
-
- /** Title for job which focus on info log view after import. */
- private static final String FOCUS_LOG_JOB_LABEL = CommonUIActivator.getMessages().getString(
- "AbstractGenericWizard.refresh.workspace"); //$NON-NLS-1$
-
- /** Constant used to indicate an unknown plugin id. */
- private static final String UNKNOWN_PLUGIN_ID = "unknown"; //$NON-NLS-1$
-
- /** Message show to user when finish is successful. */
- private String mSuccessfulMessage = null;
-
- /** Thread can be cancel (or not). */
- private boolean mCancellable = false;
-
- /**
- * Default constructor.
- *
- * @param pSuccessfulMessage Message show to user when finish is successful.
- * @param pCancellable true means that process launched will offer options to cancel it
- */
- public AbstractGenericWizard(final String pSuccessfulMessage, final boolean pCancellable) {
- super();
- setNeedsProgressMonitor(true);
- mSuccessfulMessage = pSuccessfulMessage;
- mCancellable = pCancellable;
- }
-
- /**
- * Hook offered to gather information from IHM before running action in non UI thread.
- *
- * Default implementation do nothing.
- */
- protected void prepareFinish() {
- }
-
- /**
- * {@inheritDoc}
- *
- * Do a synchronous call (in same thread than wizard) to prepareFinish, then run a IRunnable in a separate thread.
- * This configuration need to get information from IHM in prepareFinish().
- */
- @Override
- public boolean performFinish() {
- prepareFinish();
-
- // Create job
- final IRunnableWithProgress vRunnable = new IRunnableWithProgress() {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run(final IProgressMonitor pMonitor) throws InvocationTargetException, InterruptedException {
-
- // Perform the finish action and wrap the returned status
- // to uniform the returns to display
- IStatus vWrappedStatus = wrapStatus(doFinish(pMonitor));
-
- // Extract the status type to display it correctly
- int vHandleType = extractStatusType(vWrappedStatus);
-
- StatusManager.getManager().handle(vWrappedStatus, vHandleType);
-
- pMonitor.done();
-
- // Show log view
- showFinalView();
- }
- };
-
- // Run job, with no cancel option
- try {
- getContainer().run(true, mCancellable, vRunnable);
-
- } catch (final InvocationTargetException | InterruptedException pException) {
- CommonUIActivator.logError(pException.getMessage(), pException);
- }
-
- // Always return true, as the wizard must not be kept opened even if something goes wrong
- return true;
- }
-
- /**
- * Wrap a given status to uniform how the returns are displayed
- * in the log view. If no status is given, build a default OK status.
- *
- * @see AbstractGenericWizard#buildWrappedStatus(IStatus)
- *
- * @param pStatus A given status or null if no specific return is available
- * @return The wrapped status
- */
- protected IStatus wrapStatus(final IStatus pStatus) {
-
- IStatus vWrappedStatus = null;
-
- // Check the given status
- if (pStatus == null) {
- // No status is given, build a new default OK status
- // to uniform the return in case of success
- vWrappedStatus = new Status(Status.OK, CommonUIActivator.getPlugin().getSymbolicName(), mSuccessfulMessage);
-
- } else {
- // A status is given, thus extract its information if possible
- // to build the wrapped status
- vWrappedStatus = buildWrappedStatus(pStatus);
-
- }
-
- return vWrappedStatus;
- }
-
- /**
- * Build a wrapped status from a one, to uniform how the returns are displayed
- * in the log view. The wrapped status can manage the multi status.
- *
- * @param pStatus A given status, which must not be null
- * @return The wrapped status built
- */
- protected IStatus buildWrappedStatus(final IStatus pStatus) {
- IStatus vWrappedStatus = null;
-
- // Extract the status message, or take the 'successful' message for this
- // action if the status is OK or Info or Warning
- String vStatusMessage = null;
- switch (pStatus.getSeverity()) {
- case IStatus.OK:
- case IStatus.INFO:
- case IStatus.WARNING:
- vStatusMessage = mSuccessfulMessage;
- break;
- default:
- if (StringUtils.isNotEmpty(pStatus.getMessage())) {
- vStatusMessage = pStatus.getMessage();
- }
- break;
-
- }
-
- // Extract the status plugin id, or take the generic
- // plugin if its not given
- String vStatusPlugin = CommonUIActivator.getPlugin().getSymbolicName();
- if (StringUtils.isNotEmpty(pStatus.getPlugin()) && !UNKNOWN_PLUGIN_ID.equals(pStatus.getPlugin())) {
- vStatusPlugin = pStatus.getPlugin();
- }
-
- if (pStatus.isMultiStatus()) {
- // Build a new status to wrap the given multi status, and ensure
- // to always display a uniform return
- vWrappedStatus = new MultiStatus(vStatusPlugin, pStatus.getCode(), vStatusMessage, pStatus.getException());
-
- // Merge the status children to keep all the status stack
- // NB : This will set the multi-status severity according to the children
- // maximum severity
- ((MultiStatus) vWrappedStatus).merge(pStatus);
-
- } else {
- // Build a new status to wrap the given single status, and ensure
- // to always display uniform return
- vWrappedStatus = new Status(pStatus.getSeverity(), vStatusPlugin, vStatusMessage);
- }
-
- return vWrappedStatus;
- }
-
- /**
- * Extract the type of a status to know how it can be added
- * in the status manager. By default it's always a 'LOG', and if
- * the status is an error, add the 'BLOCK' type.
- *
- * @param pStatus The given status from which the type must be extracted, or null
- * @return The status type found
- */
- protected int extractStatusType(final IStatus pStatus) {
-
- // By default, the status is a log
- int vStatusType = StatusManager.LOG;
-
- if ((pStatus != null) && pStatus.matches(Status.ERROR)) {
- // If the status given is an error, add the Block type
- vStatusType |= StatusManager.BLOCK;
- }
-
- return vStatusType;
- }
-
- /**
- * @return The successfulMessage
- */
- protected String getSuccessfulMessage() {
- return mSuccessfulMessage;
- }
-
- /**
- * @param pSuccessfulMessage The successfulMessage to set
- */
- protected void setSuccessfulMessage(final String pSuccessfulMessage) {
- mSuccessfulMessage = pSuccessfulMessage;
- }
-
- /**
- * Show a specific view at the end of the wizard. By default, show log view.
- */
- protected void showFinalView() {
- FocusViewJob vJob = new FocusViewJob(FOCUS_LOG_JOB_LABEL, ID_SA_INFO_LOG);
- vJob.schedule();
- }
-
- /**
- * Do the concrete job for this wizard.
- *
- * Expected behaviour is that the subclass will return an IStatus with error if something goes wrong, or null
- * otherwise.<br/>
- * <br/>
- *
- * <b>Warning</b> : the <code>pMonitor.done()</code> should not be called in implementation, because performFinish()
- * will do it after logging final message.<br/>
- *
- * <b>Warning</b> : the code in this method will be run in a non UI Thread. To get information from UI, do it before
- * in {@link AbstractGenericWizard#prepareFinish()}.
- * If an UI operation is done (like send focus to a specific view), call it in an UIJob.
- *
- * @param pMonitor Monitor used to follow job progression
- * @return an exception if something goes wrong, or null otherwise
- */
- protected abstract IStatus doFinish(IProgressMonitor pMonitor);
-}
diff --git a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/wizard/NotImplementedWizard.java b/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/wizard/NotImplementedWizard.java
deleted file mode 100644
index 44c5632..0000000
--- a/core/org.polarsys.esf.core.common.ui/src/main/java/org/polarsys/esf/core/common/ui/wizard/NotImplementedWizard.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.common.ui.wizard;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.ui.IExportWizard;
-import org.eclipse.ui.IImportWizard;
-import org.eclipse.ui.IWorkbench;
-import org.polarsys.esf.core.common.ui.CommonUIActivator;
-
-/**
- *
- * Wizard "not implemented", used to link with import not implemented yet.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public class NotImplementedWizard
- extends Wizard
- implements IImportWizard, IExportWizard {
-
- /** Title for dialog. */
- private static final String DIALOG_MSG =
- CommonUIActivator.getMessages().getString("NotImplementedWizard.warning.implemented.not.label"); //$NON-NLS-1$
-
- /** Msg for dialog. */
- private static final String DIALOG_TITLE =
- CommonUIActivator.getMessages().getString("NotImplementedWizard.warning.implemented.not.title"); //$NON-NLS-1$
-
- /**
- * Default constructor.
- */
- public NotImplementedWizard() {
- MessageDialog.openInformation(getShell(), DIALOG_TITLE, DIALOG_MSG);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void init(final IWorkbench pWorkbench, final IStructuredSelection pSelection) {
- // Nothing to do here.
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean performFinish() {
- // Nothing to do here.
- return false;
- }
-
-}
diff --git a/core/org.polarsys.esf.core.help/META-INF/MANIFEST.MF b/core/org.polarsys.esf.core.help/META-INF/MANIFEST.MF
index 5139ee9..1184eca 100644
--- a/core/org.polarsys.esf.core.help/META-INF/MANIFEST.MF
+++ b/core/org.polarsys.esf.core.help/META-INF/MANIFEST.MF
@@ -10,4 +10,3 @@
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Bundle-Localization: src/main/resources/properties/plugin
-Export-Package: org.polarsys.esf.core.help.wizard
diff --git a/core/org.polarsys.esf.core.help/src/main/java/org/polarsys/esf/core/help/wizard/AbstractExampleWizard.java b/core/org.polarsys.esf.core.help/src/main/java/org/polarsys/esf/core/help/wizard/AbstractExampleWizard.java
deleted file mode 100644
index 31e838b..0000000
--- a/core/org.polarsys.esf.core.help/src/main/java/org/polarsys/esf/core/help/wizard/AbstractExampleWizard.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.help.wizard;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.osgi.framework.Bundle;
-import org.polarsys.esf.core.common.file.FileTools;
-import org.polarsys.esf.core.common.messages.Messages;
-import org.polarsys.esf.core.common.metamodel.project.ProjectCreator;
-import org.polarsys.esf.core.common.ui.selection.SelectAndRevealResourceJob;
-import org.polarsys.esf.core.common.ui.wizard.AbstractGenericWizard;
-import org.polarsys.esf.core.help.CoreHelpActivator;
-
-/**
- * Abstract class for the example wizard creation.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public abstract class AbstractExampleWizard
- extends AbstractGenericWizard
- implements INewWizard {
-
- /** Message provider. */
- protected static final Messages MESSAGES_PROVIDER = CoreHelpActivator.getMessages();
-
- /** Message for access ESF file error. */
- protected static final String CREATE_FILE_ERROR = MESSAGES_PROVIDER
- .getString("AbstractExampleWizard.library.file.create.error"); //$NON-NLS-1$
-
- /** Title for wizard job. */
- private static final String WIZARD_JOB_TITLE =
- MESSAGES_PROVIDER.getString("AbstractExampleWizard.modeler.job.title"); //$NON-NLS-1$
-
- /** Map of files to add with their directory. */
- private Map<URI, IPath> mAdditionalFilesInfoMap = Collections.emptyMap();
-
- /** Created project. */
- private IProject mProjectExample = null;
-
- /** Name of example project. */
- private String mProjectTitle = null;
-
- /** Name of the model file. */
- private String mSAFile = null;
-
- /** Name of the library file. */
- private String mLibraryFile = null;
-
- /** Relative path for the model file. */
- private String mSAFilePath = null;
-
- /** Relative path for library file. */
- private String mLibraryFilePath = null;
-
-
- /**
- * Default constructor.
- *
- * @param pTitle Title of the example project
- * @param pSourceDirectory URI corresponding to the source example directory
- * @param pSAFile File name of ESF file
- * @param pLibraryFile File name of feared events library file
- * @param pSuccessMessage Message to display when the project creation is successful
- */
- public AbstractExampleWizard(
- final String pTitle,
- final URI pSourceDirectory,
- final String pSAFile,
- final String pLibraryFile,
- final String pSuccessMessage) {
-
- // Call the parent constructor
- super(pSuccessMessage, false);
-
- // Remember of the given parameters
- mProjectTitle = pTitle;
- mSAFile = pSAFile;
- mLibraryFile = pLibraryFile;
-
- mSAFilePath = pSourceDirectory.appendSegment(pSAFile).toString();
- mLibraryFilePath = pSourceDirectory.appendSegment(pLibraryFile).toString();
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void init(final IWorkbench pWorkbench, final IStructuredSelection pSelection) {
- // Nothing to do
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected IStatus doFinish(final IProgressMonitor pMonitor) {
- IStatus vStatus = Status.OK_STATUS;
- pMonitor.beginTask(WIZARD_JOB_TITLE, 6);
-
- // Get ESF file to copy
- try {
- mProjectExample = ProjectCreator.createProject(mProjectTitle);
- pMonitor.worked(1);
-
- // Get location of ESF file in project
- URI vTargetFile = URI.createFileURI(mProjectExample.getFile(mSAFile).getLocation().toOSString());
- URI vSourceFile = getFileURI(mSAFilePath);
- pMonitor.worked(1);
-
- // Copy ESF file in project
- FileTools.copyFile(vSourceFile, vTargetFile);
- pMonitor.worked(1);
-
- // Get library location in project and source to copy
- vTargetFile = URI.createFileURI(mProjectExample.getFile(mLibraryFile).getLocation().toOSString());
- vSourceFile = getFileURI(mLibraryFilePath);
- pMonitor.worked(1);
-
- FileTools.copyFile(vSourceFile, vTargetFile);
- pMonitor.worked(1);
-
- // Add the potential other files included in the example project
- vStatus = addFilesToProject(pMonitor);
- pMonitor.worked(1);
-
- } catch (final IOException | CoreException pException) {
- vStatus = createErrorStatus(CREATE_FILE_ERROR, pException);
- }
-
- // Then run an asynchronous job to show created project
- if (vStatus.isOK()) {
- SelectAndRevealResourceJob vSelectJob = new SelectAndRevealResourceJob(mProjectExample);
- vSelectJob.schedule();
- }
-
- return vStatus;
- }
-
- /**
- * Get the URI to access to a file located in the core help plugin,
- * according to the relative path given in parameter.
- *
- * @param pFilePath File path, relative to the help bundle
- * @return URI to access to the file
- * @throws IOException Thrown when it is impossible to access to the file
- */
- protected final URI getFileURI(final String pFilePath) throws IOException {
- // Get the file using the local bundle
- return getFileURI(CoreHelpActivator.getPlugin().getBundle(), pFilePath);
- }
-
- /**
- * Get the URI to access to a file located in plugin whose bundle is
- * given in parameter. The file is identified with the its path
- * relative to the bundle directory.
- *
- * @param pBundle The bundle containing the file
- * @param pFilePath File path, relative to the given bundle
- * @return URI to access to the file
- * @throws IOException Thrown when it is impossible to access to the file
- */
- protected URI getFileURI(final Bundle pBundle, final String pFilePath) throws IOException {
- URL vURL =
- FileLocator.find(
- pBundle,
- new Path(pFilePath),
- Collections.<String, String> emptyMap());
-
- vURL = FileLocator.toFileURL(vURL);
-
- return URI.createFileURI(vURL.getPath());
- }
-
- /**
- * Make an error Status with message and exception.
- *
- * @param pMessage Message to display in status
- * @param pException Exception to associate with error
- * @return Status to encapsulate message and associated exception
- */
- protected static IStatus createErrorStatus(final String pMessage, final Exception pException) {
- return new Status(
- IStatus.ERROR,
- CoreHelpActivator.getPlugin().getSymbolicName(),
- pMessage,
- pException);
- }
-
- /**
- * Add optional files into the project directory.
- * The default implementation adds the file identified in the map {@link #mAdditionalFilesInfoMap}.
- *
- * @param pMonitor Monitor used to follow the task progress
- * @return An error status if something goes wrong, OK otherwise
- */
- public IStatus addFilesToProject(final IProgressMonitor pMonitor) {
-
- IStatus vStatus = Status.OK_STATUS;
-
- try {
-
- for (Entry<URI, IPath> vAdditionalFilesInfoEntry : mAdditionalFilesInfoMap.entrySet()) {
-
- // Get the entry key, which corresponds to the source file URI
- // and extract from it the source file name decoded
- URI vSourceFile = vAdditionalFilesInfoEntry.getKey();
- String vSourceFileName = URI.decode(vSourceFile.lastSegment());
-
- // Get the entry value, which corresponds to the path of the target directory
- // relative to the created example project
- IPath vTargetDirectoryPath = vAdditionalFilesInfoEntry.getValue();
-
- // Build the target URI of additional files in project, which may be
- // located in the project root, or in a sub folder
- // ... First initiate the path with the project location
- IPath vTargetFilePath = getExampleProject().getLocation();
-
- // ... Then add the target sub folder if needed
- if (!Path.EMPTY.equals(vTargetDirectoryPath)) {
- vTargetFilePath = vTargetFilePath.append(vTargetDirectoryPath);
- }
-
- // ... Add the target file name
- vTargetFilePath = vTargetFilePath.append(vSourceFileName);
-
- // ... Finally build the corresponding URI
- URI vTargetFileURI = URI.createFileURI(vTargetFilePath.toOSString());
-
- // Copy file in project
- FileTools.copyFile(vSourceFile, vTargetFileURI);
- }
-
- } catch (final IOException pException) {
- vStatus = AbstractExampleWizard.createErrorStatus(CREATE_FILE_ERROR, pException);
- }
-
- return vStatus;
- }
-
- /**
- * Return the map containing the information on the
- * additional files to add to the example project.
- *
- * @return The files info map
- */
- public Map<URI, IPath> getAdditionalFileInfoMap() {
- return mAdditionalFilesInfoMap;
- }
-
- /**
- * Set the map containing the information on the
- * additional files to add to the example project.
- *
- * @param pFileInfoMap The file info map to set
- */
- public void setAdditionalFileInfoMap(final Map<URI, IPath> pFileInfoMap) {
- mAdditionalFilesInfoMap = pFileInfoMap;
- }
-
- /**
- * @return The example project created
- */
- public IProject getExampleProject() {
- return mProjectExample;
- }
-}
diff --git a/core/org.polarsys.esf.core.help/src/main/java/org/polarsys/esf/core/help/wizard/impl/CircuitBreakerExampleWizard.java b/core/org.polarsys.esf.core.help/src/main/java/org/polarsys/esf/core/help/wizard/impl/CircuitBreakerExampleWizard.java
deleted file mode 100644
index acfe10e..0000000
--- a/core/org.polarsys.esf.core.help/src/main/java/org/polarsys/esf/core/help/wizard/impl/CircuitBreakerExampleWizard.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.help.wizard.impl;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.common.util.URI;
-import org.polarsys.esf.core.common.messages.Messages;
-import org.polarsys.esf.core.help.CoreHelpActivator;
-import org.polarsys.esf.core.help.wizard.AbstractExampleWizard;
-
-/**
- * Wizard to get ESF project example.
- * This example is CircuitBreaker model.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public class CircuitBreakerExampleWizard
- extends AbstractExampleWizard {
-
- /** Message provider. */
- private static final Messages MESSAGES_PROVIDER = CoreHelpActivator.getMessages();
-
- /** Name of example project. */
- private static final String PROJECT_TITLE = MESSAGES_PROVIDER
- .getString("CircuitBreakerExampleWizard.example.project.title"); //$NON-NLS-1$
-
- /** Message for wizard execution success. */
- private static final String SUCCESSFUL_IMPORT_MESSAGE = MESSAGES_PROVIDER
- .getString("CircuitBreakerExampleWizard.example.job.success"); //$NON-NLS-1$
-
- /** Name of the source model file. */
- private static final String SA_FILE = "Circuit Breaker.sa"; //$NON-NLS-1$
-
- /** Name of the source library file. */
- private static final String LIBRARY_FILE = "Circuit Breaker.fearedevents"; //$NON-NLS-1$
-
- /** Name of the global source examples directory. */
- private static final String EXAMPLES_DIR = "examples"; //$NON-NLS-1$
-
- /** Name of the source Circuit Breaker example directory. */
- private static final String CIRCUITBREAKER_DIR = "Circuit Breaker"; //$NON-NLS-1$
-
- /** Relative path for the directory containing the source example. */
- private static final URI SOURCE_EXAMPLE_DIR =
- URI.createURI(EXAMPLES_DIR).appendSegment(CIRCUITBREAKER_DIR); //$NON-NLS-1$
-
- /** Name of the folder containing the additional UML file. */
- private static final String PAPYRUS_DIR = "Papyrus"; //$NON-NLS-1$
-
- /** Name of the source additional UML file. */
- private static final String UML_FILE = "Circuit Breaker.uml"; //$NON-NLS-1$
-
-
- /**
- * Default constructor.
- */
- public CircuitBreakerExampleWizard() {
-
- super(
- PROJECT_TITLE,
- SOURCE_EXAMPLE_DIR,
- SA_FILE,
- LIBRARY_FILE,
- SUCCESSFUL_IMPORT_MESSAGE);
- }
-
-
- /**
- * {@inheritDoc}
- *
- * Overridden to initialise the additional files map to create with the example.
- * This includes the Papyrus model file.
- *
- * @param pMonitor Monitor used to follow job progression
- * @return An error status if something goes wrong, or OK otherwise
- */
- @Override
- protected IStatus doFinish(final IProgressMonitor pMonitor) {
-
- // Initialise the map with the additional files information
- Map<URI, IPath> vAdditionalFilesInfoMap = new HashMap<URI, IPath>();
-
- try {
- // Add the Papyrus UML file information to the map
- // ... Build the source UML file URI
- String vUMLFileSourcePath =
- new Path(EXAMPLES_DIR).append(CIRCUITBREAKER_DIR)
- .append(PAPYRUS_DIR).append(UML_FILE).toOSString();
- URI vUMLFileSourceURI = getFileURI(vUMLFileSourcePath);
-
- // ... Build the target directory path
- IPath vUMLFileTargetDirectory = new Path(PAPYRUS_DIR);
-
- // ... Then add the information in the map
- vAdditionalFilesInfoMap.put(vUMLFileSourceURI, vUMLFileTargetDirectory);
-
- } catch (final IOException vException) {
- CoreHelpActivator.logError("Error during the additional files search", vException); //$NON-NLS-1$
- }
-
- // Register the built map in this wizard instance
- setAdditionalFileInfoMap(vAdditionalFilesInfoMap);
-
- // Call the parent method to create the example
- return super.doFinish(pMonitor);
- }
-
-}
diff --git a/core/org.polarsys.esf.core.help/src/main/java/org/polarsys/esf/core/help/wizard/impl/RecoveryExampleWizard.java b/core/org.polarsys.esf.core.help/src/main/java/org/polarsys/esf/core/help/wizard/impl/RecoveryExampleWizard.java
deleted file mode 100644
index 4c7a17e..0000000
--- a/core/org.polarsys.esf.core.help/src/main/java/org/polarsys/esf/core/help/wizard/impl/RecoveryExampleWizard.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.help.wizard.impl;
-
-import org.eclipse.emf.common.util.URI;
-import org.polarsys.esf.core.common.messages.Messages;
-import org.polarsys.esf.core.help.CoreHelpActivator;
-import org.polarsys.esf.core.help.wizard.AbstractExampleWizard;
-
-/**
- * Wizard to get ESF project example.
- * This example is Recovery model.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public class RecoveryExampleWizard
- extends AbstractExampleWizard {
-
- /** Message provider. */
- private static final Messages MESSAGES_PROVIDER = CoreHelpActivator.getMessages();
-
- /** Name of example project. */
- private static final String PROJECT_TITLE =
- MESSAGES_PROVIDER.getString("RecoveryExampleWizard.example.project.title"); //$NON-NLS-1$
-
- /** Message for wizard execution success. */
- private static final String SUCCESSFUL_IMPORT_MESSAGE =
- MESSAGES_PROVIDER.getString("RecoveryExampleWizard.example.job.success"); //$NON-NLS-1$
-
- /** Name of the source model file. */
- private static final String SA_FILE = "Recovery.sa"; //$NON-NLS-1$
-
- /** Name of the source library file. */
- private static final String LIBRARY_FILE = "Recovery.fearedevents"; //$NON-NLS-1$
-
- /** Name of the global source examples directory. */
- private static final String EXAMPLES_DIR = "examples"; //$NON-NLS-1$
-
- /** Name of the source Recovery example directory. */
- private static final String RECOVERY_DIR = "Recovery"; //$NON-NLS-1$
-
- /** Relative path for the directory containing the source example. */
- private static final URI SOURCE_EXAMPLE_DIR =
- URI.createURI(EXAMPLES_DIR).appendSegment(RECOVERY_DIR); //$NON-NLS-1$
-
-
- /**
- * Default constructor.
- */
- public RecoveryExampleWizard() {
- super(
- PROJECT_TITLE,
- SOURCE_EXAMPLE_DIR,
- SA_FILE,
- LIBRARY_FILE,
- SUCCESSFUL_IMPORT_MESSAGE);
- }
-}
diff --git a/core/org.polarsys.esf.core.ui/src/main/java/org/polarsys/esf/core/ui/wizards/saproject/ESFProjectWizard.java b/core/org.polarsys.esf.core.ui/src/main/java/org/polarsys/esf/core/ui/wizards/saproject/ESFProjectWizard.java
deleted file mode 100644
index 0ee0b3e..0000000
--- a/core/org.polarsys.esf.core.ui/src/main/java/org/polarsys/esf/core/ui/wizards/saproject/ESFProjectWizard.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.ui.wizards.saproject;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.polarsys.esf.core.common.ui.selection.SelectAndRevealResourceJob;
-import org.polarsys.esf.core.common.ui.wizard.AbstractGenericWizard;
-import org.polarsys.esf.core.ui.CoreUIActivator;
-import org.polarsys.esf.core.ui.CoreUIActivator.Implementation;
-
-/**
- * Define the UI of the wizard used to create new ESF Project.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public class ESFProjectWizard
- extends AbstractGenericWizard
- implements INewWizard {
-
- /** Project creation success message. */
- private static final String PROJECT_CREATION_SUCCESSFUL = CoreUIActivator.getMessages().getString(
- "ESFProjectWizard.task.success"); //$NON-NLS-1$;
-
- /** This is the project creation page of this wizard. */
- private ESFProjectWizardProjectCreationPage mNewProjectCreationPage = null;
-
- /** Remember the selection during initialisation. */
- private IStructuredSelection mSelection = null;
-
- /** Project creation state. */
- private ProjectCreationState mCreationState = null;
-
- /**
- * Constructor for this wizard.
- */
- public ESFProjectWizard() {
- super(PROJECT_CREATION_SUCCESSFUL, false);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final void init(final IWorkbench pWorkbench, final IStructuredSelection pSelection) {
- // Save the selection
- mSelection = pSelection;
-
- // Set the window title
- setWindowTitle(CoreUIActivator.getMessages().getString("ESFProjectWizard.title"));
-
- // Set the default page image
- setDefaultPageImageDescriptor(CoreUIActivator.getPlugin().getImageRegistry()
- .getDescriptor(Implementation.ICON_WIZARD_SA_PROJECT));
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void prepareFinish() {
-
- mCreationState = new ProjectCreationState();
-
- mCreationState.setProjectName(mNewProjectCreationPage.getProjectName());
- mCreationState.setLocationURI(mNewProjectCreationPage.getLocationURI());
- mCreationState.setUseDefault(mNewProjectCreationPage.useDefaults());
- mCreationState.setModelName(mNewProjectCreationPage.getModelName());
- mCreationState.setFearedEventsLibraryName(mNewProjectCreationPage.getFearedEventsLibraryName());
-
- // Get the selected working sets
- mCreationState.setWorkingSetsArray(mNewProjectCreationPage.getSelectedWorkingSets());
- }
-
- /**
- * Create project, then model file, then aird.
- *
- * {@inheritDoc}
- */
- @Override
- protected IStatus doFinish(final IProgressMonitor pMonitor) {
-
- // Execute command with correct state
- ProjectCreationCommand vCommand = new ProjectCreationCommand(mCreationState);
- IStatus vStatus = vCommand.execute(pMonitor);
-
- if (vStatus == null || vStatus.isOK()) {
- SelectAndRevealResourceJob vSelectJob = new SelectAndRevealResourceJob(
- vCommand.getCreatedProject());
- vSelectJob.schedule();
- }
-
- return vStatus;
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final void addPages() {
- // Call the parent method
- super.addPages();
-
- /*
- * Add the pages to create a new ESF project
- */
-
- // Create the page for the project creation
- mNewProjectCreationPage =
- new ESFProjectWizardProjectCreationPage(
- ESFProjectWizardProjectCreationPage.class.getName(),
- mSelection);
-
- // Add the page to the wizard
- addPage(mNewProjectCreationPage);
- }
-}
diff --git a/core/org.polarsys.esf.core.ui/src/main/java/org/polarsys/esf/core/ui/wizards/saproject/ESFProjectWizardProjectCreationPage.java b/core/org.polarsys.esf.core.ui/src/main/java/org/polarsys/esf/core/ui/wizards/saproject/ESFProjectWizardProjectCreationPage.java
deleted file mode 100644
index 8dc7b9b..0000000
--- a/core/org.polarsys.esf.core.ui/src/main/java/org/polarsys/esf/core/ui/wizards/saproject/ESFProjectWizardProjectCreationPage.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.ui.wizards.saproject;
-
-import java.io.File;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
-import org.polarsys.esf.core.common.messages.Messages;
-import org.polarsys.esf.core.common.ui.widget.listener.ShowHideAdapter;
-import org.polarsys.esf.core.ui.CoreUIActivator;
-
-/**
- * This is the page used to create a new ESF project.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- */
-public class ESFProjectWizardProjectCreationPage
- extends WizardNewProjectCreationPage {
-
- /** Messages class. */
- private static final Messages MESSAGES_PROVIDER = CoreUIActivator.getMessages();
-
- /** Page title. */
- private static final String PAGE_TITLE =
- MESSAGES_PROVIDER.getString("ESFProjectWizard.title"); //$NON-NLS-1$
-
- /** Page description. */
- private static final String PAGE_DESCRIPTION =
- MESSAGES_PROVIDER.getString("ESFProjectWizard.page.newproject.description"); //$NON-NLS-1$
-
- /** Label for name field of feared events library parameter. */
- private static final String FEARED_EVENTS_LIBRARY_NAME =
- MESSAGES_PROVIDER.getString("ESFProjectWizard.label.fearedevents.name"); //$NON-NLS-1$
-
- /** Title for feared events library parameters group. */
- private static final String FEARED_EVENTS_LIBRARY_GROUP =
- MESSAGES_PROVIDER.getString("ESFProjectWizard.group.fearedevents"); //$NON-NLS-1$
-
- /** Title for model file parameters group. */
- private static final String MODEL_FILE_GROUP =
- MESSAGES_PROVIDER.getString("ESFProjectWizard.group.modelfile"); //$NON-NLS-1$
-
- /** Label for the model name. */
- private static final String MODEL_NAME_LABEL =
- MESSAGES_PROVIDER.getString("ESFProjectWizard.label.modelname"); //$NON-NLS-1$
-
- /** Error message when the project name is already used by an existing file or folder . */
- private static final String NAME_USED_ERROR_MESSAGE =
- MESSAGES_PROVIDER.getString("ESFProjectWizard.error.nameused"); //$NON-NLS-1$
-
- /** Remember the selection given at the construction. */
- private IStructuredSelection mSelection = null;
-
- /** The text used to give the model name. */
- private Text mTextModelName = null;
-
- /** Text field used to give feared events library name. */
- private Text mFELibraryNameTextField = null;
-
- /**
- * Constructor for this wizard page.
- * Pass in the selection to build this page
- *
- * @param pPageId The page id, must be unique in a wizard
- * @param pSelection The current selection in the workbench
- */
- public ESFProjectWizardProjectCreationPage(final String pPageId, final IStructuredSelection pSelection) {
- // Call the parent constructor
- super(pPageId);
-
- // Remember the selection
- mSelection = pSelection;
-
- // Initialise the page title, description
- setTitle(PAGE_TITLE);
- setDescription(PAGE_DESCRIPTION);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final void createControl(final Composite pParent) {
- // Call the parent method
- super.createControl(pParent);
-
- // Control is created on super. Get it, and add element on it
- Composite vControl = (Composite) getControl();
-
- // Add button to show/hide advance composite and add it to main control
- Button vButton = createShowHideButton(vControl);
-
- // Create the advanced controls, and do not add it to parent now
- Composite vAdvancedComposite = createAdvancedComposite(vControl);
-
- // Associate Button and Adapter. This can not be done in button creation, because button must be add first to
- // parent, and at this time, advanced composite has not been created yet
- ShowHideAdapter vSelectionAdapter = new ShowHideAdapter(vButton, vAdvancedComposite);
- // Start in hidden state
- vSelectionAdapter.setHidden(true);
- vButton.addSelectionListener(vSelectionAdapter);
-
- // Apply the general font
- Dialog.applyDialogFont(getControl());
-
- }
-
- /**
- * Create the Show/Hide advanced button control and push it on parent composite.
- *
- * @param pParent Receiver for the created button
- *
- * @return The created button
- */
- private Button createShowHideButton(final Composite pParent) {
-
- Button vButton = new Button(pParent, SWT.PUSH);
-
- GridData vLayoutData = new GridData();
-
- // Set the button layout data, to align it with the content above
- // NB : The horizontal indent is necessary to align with other components which are
- // included in one more level of composites
- vLayoutData.horizontalIndent = 5;
- vLayoutData.verticalIndent = 5;
-
- vButton.setLayoutData(vLayoutData);
- vButton.setText(ShowHideAdapter.DEFAULT_HIDE_LABEL);
- vButton.setImage(ShowHideAdapter.DEFAULT_HIDE_IMAGE);
-
- return vButton;
- }
-
- /**
- * Create advanced controls and add them to parent.
- *
- * @param pControl Target of created controls
- *
- * @return Composite created with advanced controls
- */
- private Composite createAdvancedComposite(final Composite pControl) {
- // Create a composite to receive advance fields
- Composite vAdvancedComposite = new Composite(pControl, SWT.NULL);
- vAdvancedComposite.setLayout(new GridLayout());
-
- GridData vCompositeLayout = new GridData(GridData.FILL_BOTH);
- vCompositeLayout.horizontalSpan = 2;
- vAdvancedComposite.setLayoutData(vCompositeLayout);
-
- // Create the controls for the model file and model name.
- createControlsModelData(vAdvancedComposite);
-
- // Create the controls for the feared events library name.
- createControlsFearedEventsLibrary(vAdvancedComposite);
-
- // Create the controls used to select a working set
- createWorkingSetGroup(
- vAdvancedComposite,
- mSelection,
- new String[] {"org.eclipse.ui.resourceWorkingSetPage"}); //$NON-NLS-1$
-
- return vAdvancedComposite;
- }
-
- /**
- * Create the controls linked to the model file and model name.
- *
- * @param pParent The parent composite to fill with the new controls
- */
- private void createControlsModelData(final Composite pParent) {
-
- // Create a group which will contain all the controls for the model (file and name).
- Group vGroupModelFile = new Group(pParent, SWT.SHADOW_ETCHED_IN);
- vGroupModelFile.setText(MODEL_FILE_GROUP);
-
- GridLayout vLayout = new GridLayout();
- vLayout.numColumns = 2;
- vGroupModelFile.setLayout(vLayout);
-
- GridData vGridData = new GridData(SWT.FILL, SWT.FILL, true, false);
- vGroupModelFile.setLayoutData(vGridData);
-
- // Create the label for model name
- Label vNameLabel = new Label(vGroupModelFile, SWT.LEFT);
- vNameLabel.setText(MODEL_NAME_LABEL);
- vGridData = new GridData(SWT.FILL, SWT.CENTER, false, false);
- vNameLabel.setLayoutData(vGridData);
-
- // Create the text for the model name
- // No listener on this model name, there is no rule to check.
- mTextModelName = new Text(vGroupModelFile, SWT.SINGLE | SWT.BORDER);
- vGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
- mTextModelName.setLayoutData(vGridData);
-
- }
-
- /**
- * Create the control to set name for feared events library.
- *
- * @param pParent The parent composite to fill with the new controls
- */
- private void createControlsFearedEventsLibrary(final Composite pParent) {
-
- // Create group for feared events library
- Group vFearedEventsGroup = new Group(pParent, SWT.NONE);
-
- // Set position and name for group
- vFearedEventsGroup.setLayout(new GridLayout(2, false));
- vFearedEventsGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- vFearedEventsGroup.setText(FEARED_EVENTS_LIBRARY_GROUP);
-
- Label vLabel = new Label(vFearedEventsGroup, SWT.NONE);
- vLabel.setText(FEARED_EVENTS_LIBRARY_NAME);
-
- mFELibraryNameTextField = new Text(vFearedEventsGroup, SWT.SINGLE | SWT.BORDER);
- mFELibraryNameTextField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- }
-
- /**
- * {@inheritDoc}
- *
- * Overridden to add custom validation steps.
- *
- * Indeed, the project name is verified but not compared to the current workspace
- * content which is not referenced. For example, if there is a folder coming from
- * an old project which has been deleted without deleting its content, the user
- * must be warned.
- */
- @Override
- protected boolean validatePage() {
- // Call the parent method to perform standard validation
- boolean vValid = super.validatePage();
-
- // If the standard validation hasn't identify any error,
- // perform custom validations
- if (vValid) {
-
- // Get the path of the project to create
- // It can be outside the workspace
- IPath vProjectPath = getLocationPath().append(getProjectName());
-
- // Create a java File corresponding to this path and ensure that
- // it doesn't correspond to an existing file or folder
- File vProjectFolder = new File(vProjectPath.toOSString());
- if (vProjectFolder.exists()) {
- // Warn the user
- setErrorMessage(NAME_USED_ERROR_MESSAGE);
- vValid = false;
- }
- }
-
- return vValid;
- }
-
- /**
- * Get model name.
- *
- * @return The name for ESF model, filled by user
- */
- public final String getModelName() {
- return mTextModelName.getText();
- }
-
- /**
- * @return Name of feared events library
- */
- public String getFearedEventsLibraryName() {
- return mFELibraryNameTextField.getText();
- }
-}
diff --git a/core/org.polarsys.esf.core.ui/src/main/java/org/polarsys/esf/core/ui/wizards/saproject/ProjectCreationCommand.java b/core/org.polarsys.esf.core.ui/src/main/java/org/polarsys/esf/core/ui/wizards/saproject/ProjectCreationCommand.java
deleted file mode 100644
index a171821..0000000
--- a/core/org.polarsys.esf.core.ui/src/main/java/org/polarsys/esf/core/ui/wizards/saproject/ProjectCreationCommand.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.ui.wizards.saproject;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.ui.PlatformUI;
-import org.polarsys.esf.core.common.messages.Messages;
-import org.polarsys.esf.core.common.ui.selection.SelectAndRevealResourceJob;
-import org.polarsys.esf.core.ui.CoreUIActivator;
-
-/**
- * This class contains all the methods used to create a new project,
- * from nothing.
- *
- * It has been split from wizard itself to separate the treatment from the UI.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- *
- */
-public class ProjectCreationCommand {
-
- /** Messages provider. */
- private static final Messages MESSAGES_PROVIDER = CoreUIActivator.getMessages();
-
- /** Command creation title. */
- private static final String COMMAND_PROJECT_CREATION =
- MESSAGES_PROVIDER.getString("ProjectCreationCommand.task.label"); //$NON-NLS-1$
-
- /** Project creation state, containing all the parameters for the project creation. */
- private ProjectCreationState mProjectCreationState = null;
-
- /** Keep track of created project to return it. */
- private IProject mCreatedProject = null;
-
- /**
- * Default constructor.
- *
- * @param pState Information used to run project creation
- */
- public ProjectCreationCommand(final ProjectCreationState pState) {
- mProjectCreationState = pState;
- }
-
- /**
- * Do project creation, step by step.
- *
- * @param pMonitor Monitor for display state of project creation
- * @return {@link IStatus#OK} if creation is successful, otherwise {@link IStatus#ERROR}
- */
- public IStatus execute(final IProgressMonitor pMonitor) {
- IStatus vStatus = null;
-
- pMonitor.beginTask(COMMAND_PROJECT_CREATION, 4);
-
- // TODO : Perform project creation ...
-
- // Add to working sets
- if (mProjectCreationState.getWorkingSetsArray().length > 0) {
- // Add the project in the working sets specified
- PlatformUI.getWorkbench().getWorkingSetManager()
- .addToWorkingSets(mCreatedProject, mProjectCreationState.getWorkingSetsArray());
- }
-
- pMonitor.worked(1);
-
- // Then run an asynchronous job to show created project
- if (vStatus == null || vStatus.isOK()) {
- SelectAndRevealResourceJob vJob = new SelectAndRevealResourceJob(mCreatedProject);
- vJob.schedule();
- }
-
- return vStatus;
- }
-
- /**
- * @return The created project. Can be null if project creation failed !
- */
- public IProject getCreatedProject() {
- return mCreatedProject;
- }
-}
diff --git a/core/org.polarsys.esf.core.ui/src/main/java/org/polarsys/esf/core/ui/wizards/saproject/ProjectCreationState.java b/core/org.polarsys.esf.core.ui/src/main/java/org/polarsys/esf/core/ui/wizards/saproject/ProjectCreationState.java
deleted file mode 100644
index 4173db9..0000000
--- a/core/org.polarsys.esf.core.ui/src/main/java/org/polarsys/esf/core/ui/wizards/saproject/ProjectCreationState.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 ALL4TEC & CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * ALL4TEC & CEA LIST - initial API and implementation
- ******************************************************************************/
-package org.polarsys.esf.core.ui.wizards.saproject;
-
-import org.apache.commons.lang3.StringUtils;
-import org.eclipse.ui.IWorkingSet;
-
-/**
- * State pattern used with Project creation wizard.
- *
- * It contains data / information necessary to create a ESF Project.
- *
- * Warning : all fields must be initialised.
- *
- * @author $Author: jdumont $
- * @version $Revision: 83 $
- *
- */
-public class ProjectCreationState {
-
- /** Name of model. */
- private String mModelName = StringUtils.EMPTY;
-
- /** Flag used to detect if default project area creation parameter should be used or not. */
- private boolean mUseDefault = false;
-
- /** Project name. */
- private String mProjectName = StringUtils.EMPTY;
-
- /** Project location URI. */
- private java.net.URI mLocationURI = null;
-
- /** Name of feared events library. */
- private String mFearedEventsLibraryName = null;
-
- /** Array of working set to which project will be added. */
- private IWorkingSet[] mWorkingSetsArray = new IWorkingSet[0];
-
- /**
- * Default constructor.
- */
- public ProjectCreationState() {
- }
-
- /**
- * Return the name of the model specified by the user, or the project
- * name if no specific value has been given.
- *
- * The returned value is not filtered and keep all its potential non alpha numeric characters.
- *
- * @return The model name to use
- */
- public String getModelName() {
- // Get the value specified by the user if any
- String vModelName = mModelName;
-
- // If no specific value is given, use the project name directly
- // NB : Don't filter the non alpha numeric characters
- if (StringUtils.isBlank(vModelName)) {
- vModelName = getProjectName();
- }
-
- return vModelName;
- }
-
- /**
- * @param pModelName The modelName to set
- */
- public void setModelName(final String pModelName) {
- mModelName = pModelName;
- }
-
- /**
- * @return The useDefault
- */
- public boolean isUseDefault() {
- return mUseDefault;
- }
-
- /**
- * @param pUseDefault The useDefault to set
- */
- public void setUseDefault(final boolean pUseDefault) {
- mUseDefault = pUseDefault;
- }
-
- /**
- * Return the name of the project to create.
- *
- * The returned value is not filtered and keep all its potential non alpha numeric characters.
- *
- * @return The project name
- */
- public String getProjectName() {
- return mProjectName;
- }
-
- /**
- * @param pProjectName The projectName to set
- */
- public void setProjectName(final String pProjectName) {
- mProjectName = pProjectName;
- }
-
- /**
- * @return The locationURI
- */
- public java.net.URI getLocationURI() {
- return mLocationURI;
- }
-
- /**
- * @param pLocationURI The locationURI to set
- */
- public void setLocationURI(final java.net.URI pLocationURI) {
- mLocationURI = pLocationURI;
- }
-
- /**
- * @return The workingSetsArray
- */
- public IWorkingSet[] getWorkingSetsArray() {
- return mWorkingSetsArray;
- }
-
- /**
- * @param pWorkingSetsArray The workingSetsArray to set
- */
- public void setWorkingSetsArray(final IWorkingSet[] pWorkingSetsArray) {
- mWorkingSetsArray = pWorkingSetsArray;
- }
-
- /**
- * Return the name of the feared events library specified by the user, or the model
- * name if no specific value has been given.
- *
- * The returned value is not filtered and keep all its potential non alpha numeric characters.
- *
- * @return The feared events library name to use
- */
- public String getFearedEventsLibraryName() {
- // Get the value specified by the user if any
- String vLibraryName = mFearedEventsLibraryName;
-
- // If no specific value is given, use the model name directly
- // NB : Don't filter the non alpha numeric characters
- if (StringUtils.isBlank(vLibraryName)) {
- vLibraryName = getModelName();
- }
-
- return vLibraryName;
- }
-
- /**
- * @param pFearedEventsLibraryName Name of feared events library
- */
- public void setFearedEventsLibraryName(final String pFearedEventsLibraryName) {
- mFearedEventsLibraryName = pFearedEventsLibraryName;
- }
-
-}