Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src')
-rw-r--r--plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/Activator.java53
-rw-r--r--plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/ColorProvider.java66
-rw-r--r--plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomActionBarContributor.java434
-rw-r--r--plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomEditor.java2019
-rw-r--r--plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomEditorPlugin.java105
-rw-r--r--plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomModelWizard.java639
-rw-r--r--plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomViewer.java445
-rw-r--r--plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/EMFUtil.java363
-rw-r--r--plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/FormStyleSashForm.java143
-rw-r--r--plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/ImageProvider.java770
-rw-r--r--plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/Messages.java122
-rw-r--r--plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/messages.properties97
12 files changed, 5256 insertions, 0 deletions
diff --git a/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/Activator.java b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/Activator.java
new file mode 100644
index 00000000000..6514e1b2a80
--- /dev/null
+++ b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/Activator.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Mia-Software.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.presentation;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/** The activator class controls the plug-in life cycle */
+public class Activator extends AbstractUIPlugin {
+
+ /** The plug-in ID */
+ public static final String PLUGIN_ID = "org.eclipse.emf.facet.custom.metamodel.editor"; //$NON-NLS-1$
+
+ /** The shared instance */
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ // nothing
+ }
+
+ @Override
+ public void start(final BundleContext context) throws Exception {
+ super.start(context);
+ Activator.plugin = this;
+ }
+
+ @Override
+ public void stop(final BundleContext context) throws Exception {
+ Activator.plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return Activator.plugin;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/ColorProvider.java b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/ColorProvider.java
new file mode 100644
index 00000000000..f8ed5741fe2
--- /dev/null
+++ b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/ColorProvider.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Mia-Software.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - initial API and implementation
+ *
+ *******************************************************************************/
+
+package org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.presentation;
+
+import org.eclipse.jface.resource.JFaceColors;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+public final class ColorProvider {
+
+ private static ColorProvider instance;
+
+ public static ColorProvider getInstance() {
+ if (ColorProvider.instance == null) {
+ ColorProvider.instance = new ColorProvider();
+ }
+ return ColorProvider.instance;
+ }
+
+ /** The color used for elements that are empty or not used */
+ private final Color gray;
+ /** The color used for elements that are not part of the first resource */
+ private final Color externalResourceColor;
+ /** The color used for elements that are not in any resource */
+ private final Color nullResourceColor;
+
+ private ColorProvider() {
+ final Display display = Display.getCurrent();
+
+ final RGB rgbGray = new RGB(128, 128, 128);
+ this.gray = new Color(display, rgbGray);
+
+ final RGB rgbBlue = new RGB(0, 0, 255);
+ this.externalResourceColor = new Color(display, rgbBlue);
+
+ final RGB rgbDarkRed = new RGB(192, 0, 0);
+ this.nullResourceColor = new Color(display, rgbDarkRed);
+ }
+
+ public Color getGray() {
+ return this.gray;
+ }
+
+ public Color getExternalResourceColor() {
+ return this.externalResourceColor;
+ }
+
+ public Color getNullResourceColor() {
+ return this.nullResourceColor;
+ }
+
+ public Color getUnresolvedProxyColor() {
+ return JFaceColors.getErrorText(Display.getCurrent());
+ }
+}
diff --git a/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomActionBarContributor.java b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomActionBarContributor.java
new file mode 100644
index 00000000000..d28c76b9de6
--- /dev/null
+++ b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomActionBarContributor.java
@@ -0,0 +1,434 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ */
+package org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.presentation;
+
+import java.util.ArrayList;
+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.ControlAction;
+import org.eclipse.emf.edit.ui.action.CreateChildAction;
+import org.eclipse.emf.edit.ui.action.CreateSiblingAction;
+import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
+import org.eclipse.emf.edit.ui.action.LoadResourceAction;
+import org.eclipse.emf.edit.ui.action.ValidateAction;
+
+import org.eclipse.jface.action.Action;
+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.IMenuListener;
+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.action.SubContributionItem;
+
+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.IEditorPart;
+import org.eclipse.ui.PartInitException;
+
+/**
+ * This is the action bar contributor for the Custom model editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class CustomActionBarContributor
+ extends EditingDomainActionBarContributor
+ implements ISelectionChangedListener {
+ /**
+ * This keeps track of the active editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IEditorPart activeEditorPart;
+
+ /**
+ * This keeps track of the current selection provider.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ISelectionProvider selectionProvider;
+
+ /**
+ * This action opens the Properties view.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IAction showPropertiesViewAction =
+ new Action(CustomEditorPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) {
+ @Override
+ public void run() {
+ try {
+ getPage().showView("org.eclipse.ui.views.PropertySheet");
+ }
+ catch (PartInitException exception) {
+ CustomEditorPlugin.INSTANCE.log(exception);
+ }
+ }
+ };
+
+ /**
+ * This action refreshes the viewer of the current editor if the editor
+ * implements {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IAction refreshViewerAction =
+ new Action(CustomEditorPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) {
+ @Override
+ public boolean isEnabled() {
+ return activeEditorPart instanceof IViewerProvider;
+ }
+
+ @Override
+ public void run() {
+ if (activeEditorPart instanceof IViewerProvider) {
+ Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer();
+ if (viewer != null) {
+ viewer.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.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<IAction> createChildActions;
+
+ /**
+ * This is the menu manager into which menu contribution items should be added for CreateChild actions.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IMenuManager createChildMenuManager;
+
+ /**
+ * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} corresponding to each descriptor
+ * generated for the current selection by the item provider.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<IAction> createSiblingActions;
+
+ /**
+ * This is the menu manager into which menu contribution items should be added for CreateSibling actions.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IMenuManager createSiblingMenuManager;
+
+ /**
+ * This creates an instance of the contributor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public CustomActionBarContributor() {
+ super(ADDITIONS_LAST_STYLE);
+ loadResourceAction = new LoadResourceAction();
+ validateAction = new ValidateAction();
+ controlAction = new ControlAction();
+ }
+
+ /**
+ * This adds Separators for editor additions to the tool bar.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void contributeToToolBar(IToolBarManager toolBarManager) {
+ toolBarManager.add(new Separator("custom-settings"));
+ toolBarManager.add(new Separator("custom-additions"));
+ }
+
+ /**
+ * This adds to the menu bar a menu and some separators for editor additions,
+ * as well as the sub-menus for object creation items.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void contributeToMenu(IMenuManager menuManager) {
+ super.contributeToMenu(menuManager);
+
+ IMenuManager submenuManager = new MenuManager(CustomEditorPlugin.INSTANCE.getString("_UI_CustomEditor_menu"), "org.eclipse.emf.facet.custom.metamodel.v0_2_0.customMenuID");
+ menuManager.insertAfter("additions", submenuManager);
+ submenuManager.add(new Separator("settings"));
+ submenuManager.add(new Separator("actions"));
+ submenuManager.add(new Separator("additions"));
+ submenuManager.add(new Separator("additions-end"));
+
+ // Prepare for CreateChild item addition or removal.
+ //
+ createChildMenuManager = new MenuManager(CustomEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item"));
+ submenuManager.insertBefore("additions", createChildMenuManager);
+
+ // Prepare for CreateSibling item addition or removal.
+ //
+ createSiblingMenuManager = new MenuManager(CustomEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item"));
+ submenuManager.insertBefore("additions", createSiblingMenuManager);
+
+ // Force an update because Eclipse hides empty menus now.
+ //
+ submenuManager.addMenuListener
+ (new IMenuListener() {
+ public void menuAboutToShow(IMenuManager menuManager) {
+ menuManager.updateAll(true);
+ }
+ });
+
+ addGlobalActions(submenuManager);
+ }
+
+ /**
+ * When the active editor changes, this remembers the change and registers with it as a selection provider.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+// @Override
+// public void setActiveEditor(IEditorPart part) {
+// super.setActiveEditor(part);
+// activeEditorPart = part;
+//
+// // Switch to the new selection provider.
+// //
+// if (selectionProvider != null) {
+// selectionProvider.removeSelectionChangedListener(this);
+// }
+// if (part == null) {
+// selectionProvider = null;
+// }
+// else {
+// selectionProvider = part.getSite().getSelectionProvider();
+// selectionProvider.addSelectionChangedListener(this);
+//
+// // Fake a selection changed event to update the menus.
+// //
+// if (selectionProvider.getSelection() != null) {
+// selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()));
+// }
+// }
+// }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener},
+ * handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings
+ * that can be added to the selected object and updating the menus accordingly.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ // Remove any menu items for old selection.
+ //
+ if (createChildMenuManager != null) {
+ depopulateManager(createChildMenuManager, createChildActions);
+ }
+ if (createSiblingMenuManager != null) {
+ depopulateManager(createSiblingMenuManager, createSiblingActions);
+ }
+
+ // Query the new selection for appropriate new child/sibling descriptors
+ //
+ Collection<?> newChildDescriptors = null;
+ Collection<?> newSiblingDescriptors = null;
+
+ ISelection selection = event.getSelection();
+ if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) {
+ Object object = ((IStructuredSelection)selection).getFirstElement();
+
+ EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain();
+
+ newChildDescriptors = domain.getNewChildDescriptors(object, null);
+ newSiblingDescriptors = domain.getNewChildDescriptors(null, object);
+ }
+
+ // Generate actions for selection; populate and redraw the menus.
+ //
+ createChildActions = generateCreateChildActions(newChildDescriptors, selection);
+ createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection);
+
+ if (createChildMenuManager != null) {
+ populateManager(createChildMenuManager, createChildActions, null);
+ createChildMenuManager.update(true);
+ }
+ if (createSiblingMenuManager != null) {
+ populateManager(createSiblingMenuManager, createSiblingActions, null);
+ createSiblingMenuManager.update(true);
+ }
+ }
+
+ /**
+ * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in <code>descriptors</code>,
+ * and returns the collection of these actions.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<IAction> generateCreateChildActions(Collection<?> descriptors, ISelection selection) {
+ Collection<IAction> actions = new ArrayList<IAction>();
+ if (descriptors != null) {
+ for (Object descriptor : descriptors) {
+ actions.add(new CreateChildAction(activeEditorPart, selection, descriptor));
+ }
+ }
+ return actions;
+ }
+
+ /**
+ * This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each object in <code>descriptors</code>,
+ * and returns the collection of these actions.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<IAction> generateCreateSiblingActions(Collection<?> descriptors, ISelection selection) {
+ Collection<IAction> actions = new ArrayList<IAction>();
+ if (descriptors != null) {
+ for (Object descriptor : descriptors) {
+ actions.add(new CreateSiblingAction(activeEditorPart, selection, descriptor));
+ }
+ }
+ return actions;
+ }
+
+ /**
+ * This populates the specified <code>manager</code> with {@link org.eclipse.jface.action.ActionContributionItem}s
+ * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection,
+ * by inserting them before the specified contribution item <code>contributionID</code>.
+ * If <code>contributionID</code> is <code>null</code>, they are simply added.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void populateManager(IContributionManager manager, Collection<? extends IAction> actions, String contributionID) {
+ if (actions != null) {
+ for (IAction action : actions) {
+ if (contributionID != null) {
+ manager.insertBefore(contributionID, action);
+ }
+ else {
+ manager.add(action);
+ }
+ }
+ }
+ }
+
+ /**
+ * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s
+ * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) {
+ if (actions != null) {
+ IContributionItem[] items = manager.getItems();
+ for (int i = 0; i < items.length; i++) {
+ // Look into SubContributionItems
+ //
+ IContributionItem contributionItem = items[i];
+ while (contributionItem instanceof SubContributionItem) {
+ contributionItem = ((SubContributionItem)contributionItem).getInnerItem();
+ }
+
+ // Delete the ActionContributionItems with matching action.
+ //
+ if (contributionItem instanceof ActionContributionItem) {
+ IAction action = ((ActionContributionItem)contributionItem).getAction();
+ if (actions.contains(action)) {
+ manager.remove(contributionItem);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * This populates the pop-up menu before it appears.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void menuAboutToShow(IMenuManager menuManager) {
+ super.menuAboutToShow(menuManager);
+ MenuManager submenuManager = null;
+
+ submenuManager = new MenuManager(CustomEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item"));
+ populateManager(submenuManager, createChildActions, null);
+ menuManager.insertBefore("edit", submenuManager);
+
+ submenuManager = new MenuManager(CustomEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item"));
+ populateManager(submenuManager, createSiblingActions, null);
+ menuManager.insertBefore("edit", submenuManager);
+ }
+
+ /**
+ * This inserts global actions before the "additions-end" separator.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected void addGlobalActions(IMenuManager menuManager) {
+ menuManager.insertAfter("additions-end", new Separator("ui-actions"));
+ menuManager.insertAfter("ui-actions", showPropertiesViewAction);
+
+ refreshViewerAction.setEnabled(refreshViewerAction.isEnabled());
+ menuManager.insertAfter("ui-actions", refreshViewerAction);
+
+ super.addGlobalActions(menuManager);
+ }
+
+ /**
+ * This ensures that a delete action will clean up all references to deleted objects.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected boolean removeAllReferencesOnDelete() {
+ return true;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomEditor.java b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomEditor.java
new file mode 100644
index 00000000000..31a45f7e968
--- /dev/null
+++ b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomEditor.java
@@ -0,0 +1,2019 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ */
+package org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.presentation;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EventObject;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+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.ui.MarkerHelper;
+import org.eclipse.emf.common.ui.URIEditorInput;
+import org.eclipse.emf.common.ui.ViewerPane;
+import org.eclipse.emf.common.ui.editor.ProblemEditorPart;
+import org.eclipse.emf.common.ui.viewer.IViewerProvider;
+import org.eclipse.emf.common.util.BasicDiagnostic;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EParameter;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EValidator;
+import org.eclipse.emf.ecore.EcorePackage;
+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.command.MoveCommand;
+import org.eclipse.emf.edit.command.RemoveCommand;
+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.ReflectiveItemProviderAdapterFactory;
+import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
+import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
+import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor;
+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.emf.edit.ui.util.EditUIMarkerHelper;
+import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage;
+import org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
+import org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.EClassCustomization;
+import org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.FacetCustomization;
+import org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.provider.CustomItemProviderAdapterFactory;
+import org.eclipse.emf.facet.custom.sdk.ui.dialog.ICustomizationDialogFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.EFacetPackage;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.provider.ExtensibleItemProviderAdapterFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.provider.EFacetItemProviderAdapterFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.provider.QueryItemProviderAdapterFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.provider.RuntimeItemProviderAdapterFactory;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.provider.SerializationItemProviderAdapterFactory;
+import org.eclipse.emf.facet.efacet.sdk.ui.dialog.IFacetDialogFactory;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+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.ITreeSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+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.Label;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IFileEditorInput;
+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.dialogs.SaveAsDialog;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Form;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.ide.IGotoMarker;
+import org.eclipse.ui.part.EditorPart;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.views.contentoutline.ContentOutline;
+import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.ui.views.properties.PropertySheet;
+import org.eclipse.ui.views.properties.PropertySheetPage;
+
+
+/**
+ * This is an example of a Custom model editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class CustomEditor
+extends EditorPart
+implements IGotoMarker, ISelectionProvider, IMenuListener, IEditingDomainProvider, IViewerProvider {
+
+ protected Customization mainCustomization;
+
+ protected ComposedAdapterFactory adapterFactory;
+
+ protected CustomViewer customizationViewer;
+
+ /**
+ * Resources that have been changed since last activation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<Resource> changedResources = new ArrayList<Resource>();
+
+ /**
+ * Resources that have been saved.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<Resource> savedResources = new ArrayList<Resource>();
+
+ /**
+ * Resources that have been removed since last activation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<Resource> removedResources = new ArrayList<Resource>();
+
+ /**
+ * This keeps track of the selection of the editor as a whole.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ISelection editorSelection = StructuredSelection.EMPTY;
+
+ /**
+ * This listens to which ever viewer is active.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ISelectionChangedListener selectionChangedListener;
+
+ /**
+ * This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>();
+
+ /**
+ * Controls whether the problem indication should be updated.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean updateProblemIndication = true;
+
+ /**
+ * This is the content outline page's viewer.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected TreeViewer contentOutlineViewer;
+
+ /**
+ * This is a kludge...
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IStatusLineManager contentOutlineStatusLineManager;
+
+ /**
+ * Map to store the diagnostic associated with a resource.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Map<Resource, Diagnostic> resourceToDiagnosticMap = new LinkedHashMap<Resource, Diagnostic>();
+
+ /**
+ * The MarkerHelper is responsible for creating workspace resource markers presented
+ * in Eclipse's Problems View.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected MarkerHelper markerHelper = new EditUIMarkerHelper();
+
+ /**
+ * This is the property sheet page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected PropertySheetPage propertySheetPage;
+
+ /**
+ * This is the content outline page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IContentOutlinePage contentOutlinePage;
+
+ protected Composite buttonsPaneComposite;
+
+ private static final int VERTICAL_SPACE_BETWEEN_BUTTON_GROUPS = 30;
+ private static final int VERTICAL_SPACE_BEFORE_FIRST_BUTTON = 10;
+ public static final String ID = "org.eclipse.emf.facet.infra.browser.custom.editor"; //$NON-NLS-1$
+ private static final int MAIN_FORM_MARGIN_WIDTH = 4;
+ private static final int MAIN_FORM_MARGIN_HEIGHT = 6;
+ private static final int LEFT_PANE_SASH_WEIGHT = 400;
+ private static final int RIGHT_PANE_SASH_WEIGHT = 600;
+
+ private TreeViewer selectionViewer;
+ private Button btnEdit;
+ private Button btnRemove;
+ private Button btnUp;
+ private Button btnDown;
+ private Button cbAppliesToSubinstances;
+ private FormToolkit toolkit;
+ private boolean readOnly;
+
+ protected int listenerCounter = 0;
+
+ private Form fForm;
+ private AdapterFactoryEditingDomain editingDomain;
+
+ public CustomEditor() {
+ super();
+ initializeEditingDomain();
+ }
+
+ /**
+ * This sets up the editing domain for the model editor.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void initializeEditingDomain() {
+ // Create an adapter factory that yields item providers.
+ //
+ adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+ adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new CustomItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new EFacetItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new SerializationItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new ExtensibleItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new QueryItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new RuntimeItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
+
+ // Create the command stack that will notify this editor as commands are executed.
+ //
+ BasicCommandStack commandStack = new BasicCommandStack();
+
+ // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
+ //
+ commandStack.addCommandStackListener
+ (new CommandStackListener() {
+ public void commandStackChanged(final EventObject event) {
+ getSite().getShell().getDisplay().asyncExec
+ (new Runnable() {
+ public void run() {
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ //setDirty(commandStack.isSaveNeeded());
+ // Try to select the affected objects.
+ //
+ Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand();
+ if (mostRecentCommand != null) {
+ setSelectionToViewer(mostRecentCommand.getAffectedObjects());
+ }
+ if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) {
+ propertySheetPage.refresh();
+ }
+ }
+ });
+ }
+ });
+
+ // Create the editing domain with a special command stack.
+ //
+ editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
+ }
+
+ @Override
+ public void init(final IEditorSite site, final IEditorInput input) throws PartInitException {
+ setSite(site);
+ setInputWithNotify(input);
+ setPartName(input.getName());
+ site.setSelectionProvider(this);
+ site.getPage().addPartListener(partListener);
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE);
+ }
+
+ /**
+ * This sets the selection into whichever viewer is active.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setSelectionToViewer(Collection<?> collection) {
+ final Collection<?> theSelection = collection;
+ // Make sure it's okay.
+ //
+ if (theSelection != null && !theSelection.isEmpty()) {
+ Runnable runnable =
+ new Runnable() {
+ public void run() {
+ // Try to select the items in the current content viewer of the editor.
+ //
+ if (selectionViewer != null) {
+ selectionViewer.setSelection(new StructuredSelection(theSelection.toArray()), true);
+ }
+ }
+ };
+ getSite().getShell().getDisplay().asyncExec(runnable);
+ }
+ }
+
+ @Override
+ public void createPartControl(final Composite parent) {
+ java.net.URI locationURI;
+ String fileName = ""; //$NON-NLS-1$
+ final IEditorInput editorInput = getEditorInput();
+ if (editorInput instanceof IFileEditorInput) {
+ final IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput;
+ try {
+ if (fileEditorInput.getFile().exists()) {
+ locationURI = new java.net.URI(URI.createPlatformResourceURI(
+ fileEditorInput.getFile().getFullPath().toString(), true).toString());
+ } else {
+ locationURI = fileEditorInput.getFile().getLocationURI();
+ }
+ } catch (URISyntaxException e) {
+ locationURI = fileEditorInput.getFile().getLocationURI();
+ }
+ fileName = fileEditorInput.getFile().getName();
+ } else if (editorInput instanceof URIEditorInput) {
+ final URIEditorInput uriEditorInput = (URIEditorInput) editorInput;
+ try {
+ locationURI = new java.net.URI(uriEditorInput.getURI().toString());
+ } catch (final URISyntaxException e) {
+ throw new IllegalArgumentException(e);
+ }
+ fileName = new Path(locationURI.getPath()).lastSegment();
+ } else {
+ throw new IllegalStateException("wrong kind of input: " //$NON-NLS-1$
+ + editorInput.getClass().getName());
+ }
+
+ loadResource(org.eclipse.emf.common.util.URI.createURI(locationURI.toString()));
+ setPartName(fileName);
+
+ createContents(parent);
+
+ this.selectionViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(final SelectionChangedEvent event) {
+ if(listenerCounter == 0){
+ ISelection eventSelection = event.getSelection();
+ setSelection(eventSelection);
+ final ITreeSelection selection = (ITreeSelection) CustomEditor.this.selectionViewer
+ .getSelection();
+ listenerCounter++;
+ CustomEditor.this.handleSelectionViewerSelectionChanged(selection.getFirstElement());
+ listenerCounter = 0;
+ CustomEditor.this.customizationViewer.getViewer().getControl()
+ .setRedraw(false);
+ CustomEditor.this.customizationViewer.getViewer().expandAll();
+ CustomEditor.this.customizationViewer.getViewer().getControl()
+ .setRedraw(true);
+ }else {
+ listenerCounter = 0;
+ }
+ }
+ });
+
+ setSelection(selectionViewer == null ? StructuredSelection.EMPTY : selectionViewer.getSelection());
+ }
+
+ public void loadResource(URI resourceURI) {
+ Exception exception = null;
+ Resource resource = null;
+ try {
+ // Load the resource through the editing domain.
+ //
+ resource = editingDomain.getResourceSet().getResource(resourceURI, true);
+ }
+ catch (Exception e) {
+ exception = e;
+ resource = editingDomain.getResourceSet().getResource(resourceURI, false);
+ }
+ this.mainCustomization = (Customization) resource.getContents().get(0);
+ }
+
+ private void createContents(final Composite parent) {
+ this.toolkit = new FormToolkit(parent.getDisplay());
+ this.fForm = this.toolkit.createForm(parent);
+ this.toolkit.decorateFormHeading(this.fForm);
+
+ final FillLayout fillLayout = new FillLayout();
+ fillLayout.marginWidth = CustomEditor.MAIN_FORM_MARGIN_WIDTH;
+ fillLayout.marginHeight = CustomEditor.MAIN_FORM_MARGIN_HEIGHT;
+ this.fForm.getBody().setLayout(fillLayout);
+ createBottomPane(this.fForm.getBody());
+ }
+
+ protected IResourceChangeListener resourceChangeListener =
+ new IResourceChangeListener() {
+
+ public void resourceChanged(IResourceChangeEvent event) {
+ IResourceDelta delta = event.getDelta();
+ try {
+ class ResourceDeltaVisitor implements IResourceDeltaVisitor {
+ protected ResourceSet resourceSet = editingDomain.getResourceSet();
+ protected Collection<Resource> changedResources = new ArrayList<Resource>();
+ protected Collection<Resource> removedResources = new ArrayList<Resource>();
+
+ public boolean visit(IResourceDelta delta) {
+ if (delta.getResource().getType() == IResource.FILE) {
+ if (delta.getKind() == IResourceDelta.REMOVED ||
+ delta.getKind() == IResourceDelta.CHANGED && delta.getFlags() != IResourceDelta.MARKERS) {
+ Resource resource = resourceSet.getResource(URI.createPlatformResourceURI(delta.getFullPath().toString(), true), false);
+ if (resource != null) {
+ if (delta.getKind() == IResourceDelta.REMOVED) {
+ removedResources.add(resource);
+ }
+ else if (!savedResources.remove(resource)) {
+ changedResources.add(resource);
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public Collection<Resource> getChangedResources() {
+ return changedResources;
+ }
+
+ public Collection<Resource> getRemovedResources() {
+ return removedResources;
+ }
+ }
+
+ final ResourceDeltaVisitor visitor = new ResourceDeltaVisitor();
+ delta.accept(visitor);
+
+ if (!visitor.getRemovedResources().isEmpty()) {
+ getSite().getShell().getDisplay().asyncExec
+ (new Runnable() {
+ public void run() {
+ removedResources.addAll(visitor.getRemovedResources());
+ if (!isDirty()) {
+ getSite().getPage().closeEditor(CustomEditor.this, false);
+ }
+ }
+ });
+ }
+
+ if (!visitor.getChangedResources().isEmpty()) {
+ getSite().getShell().getDisplay().asyncExec
+ (new Runnable() {
+ public void run() {
+ changedResources.addAll(visitor.getChangedResources());
+ if (getSite().getPage().getActiveEditor() == CustomEditor.this) {
+ handleActivate();
+ }
+ }
+ });
+ }
+ }
+ catch (CoreException exception) {
+ CustomEditorPlugin.INSTANCE.log(exception);
+ }
+ }
+ };
+
+ private Composite rightPaneComposite;
+
+ private Composite createBottomPane(final Composite parent) {
+ final SashForm sashForm = new FormStyleSashForm(parent, SWT.HORIZONTAL, this.toolkit) {
+ @Override
+ protected void createContents() {
+ createLeftPane(this);
+ createRightPane(this);
+ }
+ };
+
+ sashForm.setWeights(new int[] { CustomEditor.LEFT_PANE_SASH_WEIGHT,
+ CustomEditor.RIGHT_PANE_SASH_WEIGHT
+ });
+ sashForm.setSashWidth(5);
+
+ return sashForm;
+ }
+
+ private void createLeftPane(final Composite parent) {
+
+ ViewerPane viewerPane =
+ new ViewerPane(getSite().getPage(), CustomEditor.this) {
+ @Override
+ public Viewer createViewer(Composite composite) {
+ Tree tree = new Tree(composite, SWT.MULTI);
+ TreeViewer newTreeViewer = new TreeViewer(tree);
+ return newTreeViewer;
+ }
+ };
+ viewerPane.createControl(parent);
+
+ selectionViewer = (TreeViewer)viewerPane.getViewer();
+ selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+
+ selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+ selectionViewer.setInput(editingDomain.getResourceSet());
+ selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
+ viewerPane.setTitle(editingDomain.getResourceSet());
+
+ new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
+
+ createContextMenuFor(selectionViewer);
+ }
+
+ /** Right pane : treeviewer + fixed buttons pane */
+
+ private Composite createRightPane(final Composite parent) {
+ final Section section = this.toolkit.createSection(parent, ExpandableComposite.TITLE_BAR
+ | ExpandableComposite.EXPANDED);
+
+ this.rightPaneComposite = this.toolkit.createComposite(section, SWT.NONE);
+ section.setClient(rightPaneComposite);
+
+ final GridLayout gridLayout = new GridLayout(2, false);
+ gridLayout.marginHeight = 0;
+ gridLayout.marginWidth = 0;
+ rightPaneComposite.setLayout(gridLayout);
+
+ // tree + bottom options
+ final Composite middle = new Composite(rightPaneComposite, SWT.NONE);
+ final GridLayout middleLayout = new GridLayout();
+ middleLayout.marginHeight = 0;
+ middleLayout.marginWidth = 0;
+ middle.setLayout(middleLayout);
+ middle.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ this.customizationViewer = new CustomViewer(middle);
+ this.customizationViewer.getViewer().getControl()
+ .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ final Composite optionsPane = this.toolkit.createComposite(middle);
+ optionsPane.setLayout(new GridLayout());
+ optionsPane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+ this.customizationViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(final SelectionChangedEvent event) {
+ if(listenerCounter == 0){
+ ISelection eventSelection = event.getSelection();
+ setSelection(eventSelection);
+ final ITreeSelection selection = (ITreeSelection) CustomEditor.this.customizationViewer
+ .getSelection();
+ CustomEditor.this.handleCustomzizationViewerSelectionChanged(selection.getFirstElement());
+ listenerCounter++;
+ }else{
+ listenerCounter = 0;
+ }
+ }
+ });
+
+ if (this.readOnly) {
+ this.cbAppliesToSubinstances.setEnabled(false);
+ }
+
+ final GridData customizationViewerGridData = new GridData();
+ customizationViewerGridData.grabExcessHorizontalSpace = true;
+ customizationViewerGridData.grabExcessVerticalSpace = true;
+ customizationViewerGridData.horizontalAlignment = SWT.FILL;
+ customizationViewerGridData.verticalAlignment = SWT.FILL;
+ this.customizationViewer.getViewer().getControl()
+ .setLayoutData(customizationViewerGridData);
+
+ if (!this.readOnly) {
+ createButtonsPane(rightPaneComposite);
+ }
+
+
+ return rightPaneComposite;
+ }
+
+ private void setInputInCustomizationTreeviewer(Facet facet){
+ List<DerivedTypedElement> inputs = new ArrayList<DerivedTypedElement>();
+ inputs.addAll(facet.getFacetOperations());
+ EList<EStructuralFeature> facetElements = facet.getFacetElements();
+ for (EStructuralFeature eStructuralFeature : facetElements) {
+ if(eStructuralFeature instanceof DerivedTypedElement){
+ inputs.add((DerivedTypedElement) eStructuralFeature);
+ }
+ }
+ this.customizationViewer.setInput(inputs);
+ }
+
+ private void handleSelectionViewerSelectionChanged(final Object selectedElement) {
+ if (selectedElement instanceof EClassCustomization || selectedElement instanceof FacetCustomization) {
+ final Facet facet = (Facet) selectedElement;
+
+
+ setInputInCustomizationTreeviewer(facet);
+ buttonsPaneComposite.dispose();
+ createButtonsPaneWhenFacetIsSelected(rightPaneComposite);
+ rightPaneComposite.layout();
+ }else if(selectedElement instanceof Customization){
+ buttonsPaneComposite.dispose();
+ createButtonsPaneWhenCustomizationIsSelected(rightPaneComposite);
+ rightPaneComposite.layout();
+ }
+ else if(selectedElement instanceof DerivedTypedElement){
+ buttonsPaneComposite.dispose();
+ createButtonsPaneWhenDerivedIsSelected(rightPaneComposite);
+ rightPaneComposite.layout();
+
+
+ //Update customViewer input
+ DerivedTypedElement derivedTypeElement = (DerivedTypedElement)selectedElement;
+ Facet facet = (Facet)derivedTypeElement.eContainer();
+ List<DerivedTypedElement> inputs = new ArrayList<DerivedTypedElement>();
+ inputs.addAll(facet.getFacetOperations());
+ EList<EStructuralFeature> facetElements = facet.getFacetElements();
+ for (EStructuralFeature eStructuralFeature : facetElements) {
+ if(eStructuralFeature instanceof DerivedTypedElement){
+ inputs.add((DerivedTypedElement) eStructuralFeature);
+ }
+ }
+ this.customizationViewer.setInput(inputs);
+ this.customizationViewer.getViewer().setSelection(getSelection(), true);
+
+
+ }
+ }
+
+ private void handleCustomzizationViewerSelectionChanged(final Object selectedElement) {
+ setSelection(this.customizationViewer.getViewer().getSelection());
+
+ if (selectedElement instanceof FacetOperation|| selectedElement instanceof FacetElement) {
+ buttonsPaneComposite.dispose();
+ createButtonsPaneWhenDerivedIsSelected(rightPaneComposite);
+ rightPaneComposite.layout();
+ }
+ }
+
+ private void btnEditClicked() {
+ if (this.readOnly) {
+ return;
+ }
+ final Object selectedElement = getSelection();
+ if(selectedElement instanceof TreeSelection){
+ final Object selectedObject = ((TreeSelection)selectedElement).getFirstElement();
+ if(selectedObject != null){
+ if (selectedObject instanceof Facet) {
+ IFacetDialogFactory.INSTANCE.openEditFacetDialog();
+ }else if(selectedObject instanceof FacetAttribute){
+ IFacetDialogFactory.INSTANCE.openEditFacetAttributeDialog();
+ }else if(selectedObject instanceof FacetOperation){
+ IFacetDialogFactory.INSTANCE.openEditFacetOperationDialog();
+ }else if(selectedObject instanceof FacetReference){
+ IFacetDialogFactory.INSTANCE.openEditFacetReferenceDialog();
+ }else if(selectedObject instanceof DerivedTypedElement){
+ IFacetDialogFactory.INSTANCE.openEditFacetOperationParameterDialog();
+ }else if(selectedObject instanceof Customization){
+ ICustomizationDialogFactory.DEFAULT.openAddCustomizationPropertyDialog(getSite().getShell().getDisplay(), editingDomain);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void doSave(final IProgressMonitor monitor) {
+ // Save only resources that have actually changed.
+ //
+ final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
+ saveOptions.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 operation =
+ new WorkspaceModifyOperation() {
+ // This is the method that gets invoked when the operation runs.
+ //
+ @Override
+ public void execute(IProgressMonitor monitor) {
+ // Save the resources to the file system.
+ //
+ boolean first = true;
+ for (Resource resource : editingDomain.getResourceSet().getResources()) {
+ if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) {
+ try {
+ long timeStamp = resource.getTimeStamp();
+ resource.save(saveOptions);
+ if (resource.getTimeStamp() != timeStamp) {
+ savedResources.add(resource);
+ }
+ }
+ catch (Exception exception) {
+ resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
+ }
+ first = false;
+ }
+ }
+ }
+ };
+
+ updateProblemIndication = false;
+ try {
+ // This runs the options, and shows progress.
+ //
+ new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);
+
+ // Refresh the necessary state.
+ //
+ ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ }
+ catch (Exception exception) {
+ // Something went wrong that shouldn't.
+ //
+ CustomEditorPlugin.INSTANCE.log(exception);
+ }
+ updateProblemIndication = true;
+ updateProblemIndication();
+ }
+
+ /**
+ * 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.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean isPersisted(Resource resource) {
+ boolean result = false;
+ try {
+ InputStream stream = editingDomain.getResourceSet().getURIConverter().createInputStream(resource.getURI());
+ if (stream != null) {
+ result = true;
+ stream.close();
+ }
+ }
+ catch (IOException e) {
+ // Ignore
+ }
+ return result;
+ }
+
+ /**
+ * This accesses a cached version of the content outliner.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IContentOutlinePage getContentOutlinePage() {
+ if (contentOutlinePage == null) {
+ // The content outline is just a tree.
+ //
+ class MyContentOutlinePage extends ContentOutlinePage {
+ @Override
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+ contentOutlineViewer = getTreeViewer();
+ contentOutlineViewer.addSelectionChangedListener(this);
+
+ // Set up the tree viewer.
+ //
+ contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
+ contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
+ contentOutlineViewer.setInput(editingDomain.getResourceSet());
+
+ // Make sure our popups work.
+ //
+ createContextMenuFor(contentOutlineViewer);
+
+ if (!editingDomain.getResourceSet().getResources().isEmpty()) {
+ // Select the root object in the view.
+ //
+ contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
+ }
+ }
+
+ @Override
+ public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) {
+ super.makeContributions(menuManager, toolBarManager, statusLineManager);
+ contentOutlineStatusLineManager = statusLineManager;
+ }
+
+ @Override
+ public void setActionBars(IActionBars actionBars) {
+ super.setActionBars(actionBars);
+ getActionBarContributor().shareGlobalActions(this, actionBars);
+ }
+ }
+
+ contentOutlinePage = new MyContentOutlinePage();
+
+ // Listen to selection so that we can handle it is a special way.
+ //
+ contentOutlinePage.addSelectionChangedListener
+ (new ISelectionChangedListener() {
+ // This ensures that we handle selections correctly.
+ //
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleContentOutlineSelection(event.getSelection());
+ }
+ });
+ }
+
+ return contentOutlinePage;
+ }
+
+ /**
+ * This accesses a cached version of the property sheet.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IPropertySheetPage getPropertySheetPage() {
+ if (propertySheetPage == null) {
+ propertySheetPage =
+ new ExtendedPropertySheetPage(editingDomain) {
+ @Override
+ public void setSelectionToViewer(List<?> selection) {
+ CustomEditor.this.setSelectionToViewer(selection);
+ CustomEditor.this.setFocus();
+ }
+
+ @Override
+ public void setActionBars(IActionBars actionBars) {
+ super.setActionBars(actionBars);
+ getActionBarContributor().shareGlobalActions(this, actionBars);
+ }
+ };
+ propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory));
+ }
+
+ return propertySheetPage;
+ }
+
+ /**
+ * This is how the framework determines which interfaces we implement.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Object getAdapter(Class key) {
+ if (key.equals(IContentOutlinePage.class)) {
+ return showOutlineView() ? getContentOutlinePage() : null;
+ }
+ else if (key.equals(IPropertySheetPage.class)) {
+ return getPropertySheetPage();
+ }
+ else if (key.equals(IGotoMarker.class)) {
+ return this;
+ }
+ else {
+ return super.getAdapter(key);
+ }
+ }
+
+ /**
+ * Returns whether the outline view should be presented to the user.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean showOutlineView() {
+ return true;
+ }
+
+ /**
+ * This deals with how we want selection in the outliner to affect the other views.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void handleContentOutlineSelection(ISelection selection) {
+ if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
+ Iterator<?> selectedElements = ((IStructuredSelection)selection).iterator();
+ if (selectedElements.hasNext()) {
+ // Get the first selected element.
+ //
+ Object selectedElement = selectedElements.next();
+
+ // If it's the selection viewer, then we want it to select the same selection as this selection.
+ //
+ ArrayList<Object> selectionList = new ArrayList<Object>();
+ selectionList.add(selectedElement);
+ while (selectedElements.hasNext()) {
+ selectionList.add(selectedElements.next());
+ }
+
+ // Set the selection to the widget.
+ //
+ selectionViewer.setSelection(new StructuredSelection(selectionList));
+
+ }
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void doSaveAs(URI uri, IEditorInput editorInput) {
+ (editingDomain.getResourceSet().getResources().get(0)).setURI(uri);
+ setInputWithNotify(editorInput);
+ setPartName(editorInput.getName());
+ IProgressMonitor progressMonitor =
+ getActionBars().getStatusLineManager() != null ?
+ getActionBars().getStatusLineManager().getProgressMonitor() :
+ new NullProgressMonitor();
+ doSave(progressMonitor);
+ }
+ //
+ /**
+ * This is for implementing {@link IEditorPart} and simply tests the command stack.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean isDirty() {
+ return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded();
+ }
+
+ @Override
+ public boolean isSaveAsAllowed() {
+ return false;
+ }
+ //
+ @Override
+ public void setFocus() {
+ // nothing
+ }
+
+ @Override
+ public void dispose() {
+ updateProblemIndication = false;
+
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener);
+
+ getSite().getPage().removePartListener(partListener);
+
+ adapterFactory.dispose();
+
+ if (getActionBarContributor().getActiveEditor() == this) {
+ getActionBarContributor().setActiveEditor(null);
+ }
+
+ if (propertySheetPage != null) {
+ propertySheetPage.dispose();
+ }
+
+ if (contentOutlinePage != null) {
+ contentOutlinePage.dispose();
+ }
+
+ super.dispose();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void gotoMarker(IMarker marker) {
+ try {
+ if (marker.getType().equals(EValidator.MARKER)) {
+ String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
+ if (uriAttribute != null) {
+ URI uri = URI.createURI(uriAttribute);
+ EObject eObject = editingDomain.getResourceSet().getEObject(uri, true);
+ if (eObject != null) {
+ setSelectionToViewer(Collections.singleton(editingDomain.getWrapper(eObject)));
+ }
+ }
+ }
+ }
+ catch (CoreException exception) {
+ CustomEditorPlugin.INSTANCE.log(exception);
+ }
+ }
+ //
+ private final IPartListener partListener =
+ new IPartListener() {
+ public void partActivated(IWorkbenchPart p) {
+ if (p instanceof ContentOutline) {
+ if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) {
+ getActionBarContributor().setActiveEditor(CustomEditor.this);
+
+ if (selectionChangedListener == null) {
+ // Create the listener on demand.
+ //
+ selectionChangedListener =
+ new ISelectionChangedListener() {
+ // This just notifies those things that are affected by the section.
+ //
+ public void selectionChanged(SelectionChangedEvent selectionChangedEvent) {
+ setSelection(selectionChangedEvent.getSelection());
+ }
+ };
+ }
+ setSelection(selectionViewer == null ? StructuredSelection.EMPTY : selectionViewer.getSelection());
+ }
+ }
+ else if (p instanceof PropertySheet) {
+ if (((PropertySheet)p).getCurrentPage() == propertySheetPage) {
+ getActionBarContributor().setActiveEditor(CustomEditor.this);
+ handleActivate();
+ }
+ }
+ else if (p == CustomEditor.this) {
+ handleActivate();
+ if (selectionChangedListener == null) {
+ // Create the listener on demand.
+ //
+ selectionChangedListener =
+ new ISelectionChangedListener() {
+ // This just notifies those things that are affected by the section.
+ //
+ public void selectionChanged(SelectionChangedEvent selectionChangedEvent) {
+ setSelection(selectionChangedEvent.getSelection());
+ }
+ };
+ }
+ selectionViewer.addSelectionChangedListener(selectionChangedListener);
+ setSelection(selectionViewer.getSelection());
+ }
+ }
+ public void partBroughtToTop(IWorkbenchPart p) {
+ // Ignore.
+ }
+ public void partClosed(IWorkbenchPart p) {
+ // Ignore.
+ }
+ public void partDeactivated(IWorkbenchPart p) {
+ // Ignore.
+ }
+ public void partOpened(IWorkbenchPart p) {
+ // Ignore.
+ }
+ };
+
+ private Button btnAddFacetSet;
+
+ private Button btnAddFacet;
+
+ private Button btnAddEClassCustom;
+
+ private Button btnAddFacetCustom;
+
+ private Button btnAddFacetAttr;
+
+ private Button btnAddFacetRef;
+
+ private Button btnAddFacetOp;
+
+ private Button btnAddFacetParam;
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to return this editor's overall selection.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ISelection getSelection() {
+ return editorSelection;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EditingDomainActionBarContributor getActionBarContributor() {
+ return (EditingDomainActionBarContributor)getEditorSite().getActionBarContributor();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IActionBars getActionBars() {
+ return getActionBarContributor().getActionBars();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setStatusLineManager(ISelection selection) {
+ IStatusLineManager statusLineManager = selectionViewer != null && selectionViewer == contentOutlineViewer ?
+ contentOutlineStatusLineManager : getActionBars().getStatusLineManager();
+
+ if (statusLineManager != null) {
+ if (selection instanceof IStructuredSelection) {
+ Collection<?> collection = ((IStructuredSelection)selection).toList();
+ switch (collection.size()) {
+ case 0: {
+ statusLineManager.setMessage(getString("_UI_NoObjectSelected"));
+ break;
+ }
+ case 1: {
+ String text = new AdapterFactoryItemDelegator(adapterFactory).getText(collection.iterator().next());
+ statusLineManager.setMessage(getString("_UI_SingleObjectSelected", text));
+ break;
+ }
+ default: {
+ statusLineManager.setMessage(getString("_UI_MultiObjectSelected", Integer.toString(collection.size())));
+ break;
+ }
+ }
+ }
+ else {
+ statusLineManager.setMessage("");
+ }
+ }
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection.
+ * Calling this result will notify the listeners.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setSelection(ISelection selection) {
+ editorSelection = selection;
+
+ for (ISelectionChangedListener listener : selectionChangedListeners) {
+ listener.selectionChanged(new SelectionChangedEvent(this, selection));
+ }
+ setStatusLineManager(selection);
+ }
+
+ /**
+ * Returns a diagnostic describing the errors and warnings listed in the resource
+ * and the specified exception (if any).
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) {
+ if (!resource.getErrors().isEmpty() || !resource.getWarnings().isEmpty()) {
+ BasicDiagnostic basicDiagnostic =
+ new BasicDiagnostic
+ (Diagnostic.ERROR,
+ "org.eclipse.emf.facet.custom.metamodel.editor",
+ 0,
+ getString("_UI_CreateModelError_message", resource.getURI()),
+ new Object [] { exception == null ? (Object)resource : exception });
+ basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true));
+ return basicDiagnostic;
+ }
+ else if (exception != null) {
+ return
+ new BasicDiagnostic
+ (Diagnostic.ERROR,
+ "org.eclipse.emf.facet.custom.metamodel.editor",
+ 0,
+ getString("_UI_CreateModelError_message", resource.getURI()),
+ new Object[] { exception });
+ }
+ else {
+ return Diagnostic.OK_INSTANCE;
+ }
+ }
+
+ /**
+ * Handles activation of the editor or it's associated views.
+ */
+ protected void handleActivate() {
+ // Recompute the read only state.
+ //
+ if (editingDomain.getResourceToReadOnlyMap() != null) {
+ editingDomain.getResourceToReadOnlyMap().clear();
+
+ // Refresh any actions that may become enabled or disabled.
+ //
+ setSelection(getSelection());
+ }
+
+ if (!removedResources.isEmpty()) {
+ if (handleDirtyConflict()) {
+ getSite().getPage().closeEditor(CustomEditor.this, false);
+ }
+ else {
+ removedResources.clear();
+ changedResources.clear();
+ savedResources.clear();
+ }
+ }
+ else if (!changedResources.isEmpty()) {
+ changedResources.removeAll(savedResources);
+ handleChangedResources();
+ changedResources.clear();
+ savedResources.clear();
+ }
+ }
+
+ /** Shows a dialog that asks if conflicting changes should be discarded. */
+ protected boolean handleDirtyConflict() {
+ return MessageDialog.openQuestion(getSite().getShell(),
+ "CustomEditor_fileConflict",
+ "CustomEditor_conflictingUnsavedChanges");
+ }
+
+ /**
+ * Updates the problems indication with the information described in the specified diagnostic.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void updateProblemIndication() {
+ if (updateProblemIndication) {
+ BasicDiagnostic diagnostic =
+ new BasicDiagnostic
+ (Diagnostic.OK,
+ "org.eclipse.emf.facet.custom.metamodel.editor",
+ 0,
+ null,
+ new Object [] { editingDomain.getResourceSet() });
+ for (Diagnostic childDiagnostic : resourceToDiagnosticMap.values()) {
+ if (childDiagnostic.getSeverity() != Diagnostic.OK) {
+ diagnostic.add(childDiagnostic);
+ }
+ }
+
+ if (diagnostic.getSeverity() != Diagnostic.OK) {
+ ProblemEditorPart problemEditorPart = new ProblemEditorPart();
+ problemEditorPart.setDiagnostic(diagnostic);
+ problemEditorPart.setMarkerHelper(markerHelper);
+ }
+
+ if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
+ markerHelper.deleteMarkers(editingDomain.getResourceSet());
+ if (diagnostic.getSeverity() != Diagnostic.OK) {
+ try {
+ markerHelper.createMarkers(diagnostic);
+ }
+ catch (CoreException exception) {
+ CustomEditorPlugin.INSTANCE.log(exception);
+ }
+ }
+ }
+ }
+ }
+
+ /** Handles what to do with changed resources on activation. */
+ protected void handleChangedResources() {
+ if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) {
+ if (isDirty()) {
+ changedResources.addAll(editingDomain.getResourceSet().getResources());
+ }
+ editingDomain.getCommandStack().flush();
+
+ updateProblemIndication = false;
+ for (Resource resource : changedResources) {
+ if (resource.isLoaded()) {
+ resource.unload();
+ try {
+ resource.load(Collections.EMPTY_MAP);
+ }
+ catch (IOException exception) {
+ if (!resourceToDiagnosticMap.containsKey(resource)) {
+ resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
+ }
+ }
+ }
+ }
+
+ if (AdapterFactoryEditingDomain.isStale(editorSelection)) {
+ setSelection(StructuredSelection.EMPTY);
+ }
+
+ updateProblemIndication = true;
+ updateProblemIndication();
+ }
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ selectionChangedListeners.add(listener);
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ selectionChangedListeners.remove(listener);
+ }
+
+ /**
+ * This looks up a string in the plugin's plugin.properties file.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static String getString(String key) {
+ return CustomEditorPlugin.INSTANCE.getString(key);
+ }
+
+ /**
+ * This looks up a string in plugin.properties, making a substitution.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static String getString(String key, Object s1) {
+ return CustomEditorPlugin.INSTANCE.getString(key, new Object [] { s1 });
+ }
+
+ /**
+ * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void createContextMenuFor(StructuredViewer viewer) {
+ MenuManager contextMenu = new MenuManager("#PopUp");
+ contextMenu.add(new Separator("additions"));
+ contextMenu.setRemoveAllWhenShown(true);
+ contextMenu.addMenuListener(this);
+ Menu menu= contextMenu.createContextMenu(viewer.getControl());
+ viewer.getControl().setMenu(menu);
+ getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));
+
+ int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
+ Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance() };
+ viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
+ viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
+ }
+
+ /**
+ * This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions from the Edit menu.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void menuAboutToShow(IMenuManager menuManager) {
+ ((IMenuListener)getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager);
+ }
+
+ private Object buttonsGridData() {
+ final GridData buttonsGridData = new GridData();
+ buttonsGridData.grabExcessHorizontalSpace = true;
+ buttonsGridData.grabExcessVerticalSpace = false;
+ buttonsGridData.horizontalAlignment = SWT.FILL;
+ buttonsGridData.verticalAlignment = SWT.FILL;
+ return buttonsGridData;
+ }
+
+ private Composite createButtonsPane(final Composite parent){
+ return createButtonsPaneWhenCustomizationIsSelected(parent);
+ }
+
+ private Composite createButtonsPaneWhenCustomizationIsSelected(final Composite parent) {
+ this.buttonsPaneComposite = new Composite(parent, SWT.NONE);
+ final GridData buttonsPaneGridData = new GridData();
+ buttonsPaneGridData.grabExcessHorizontalSpace = false;
+ buttonsPaneGridData.grabExcessVerticalSpace = true;
+ buttonsPaneGridData.horizontalAlignment = SWT.FILL;
+ buttonsPaneGridData.verticalAlignment = SWT.FILL;
+ buttonsPaneComposite.setLayoutData(buttonsPaneGridData);
+
+ buttonsPaneComposite.setLayout(new GridLayout());
+
+ final Composite spacer1 = new Composite(buttonsPaneComposite, SWT.NONE);
+ final GridData spacer1GridData = new GridData();
+ spacer1GridData.heightHint = CustomEditor.VERTICAL_SPACE_BEFORE_FIRST_BUTTON;
+ spacer1.setLayoutData(spacer1GridData);
+
+ final Composite spacer2 = new Composite(buttonsPaneComposite, SWT.NONE);
+ final GridData spacer2GridData = new GridData();
+ spacer2GridData.heightHint = CustomEditor.VERTICAL_SPACE_BETWEEN_BUTTON_GROUPS;
+ spacer2.setLayoutData(spacer2GridData);
+
+ final Label lblConditions = new Label(buttonsPaneComposite, SWT.NONE);
+ lblConditions.setText("add");
+
+ this.btnAddFacetSet = new Button(buttonsPaneComposite, SWT.PUSH);
+ this.btnAddFacetSet.setText("FacetSet");
+ this.btnAddFacetSet.setLayoutData(buttonsGridData());
+ this.btnAddFacetSet.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ btnAddFacetSetClicked();
+ }
+ });
+
+ this.btnAddFacet = new Button(buttonsPaneComposite, SWT.PUSH);
+ this.btnAddFacet.setText("Facet");
+ this.btnAddFacet.setLayoutData(buttonsGridData());
+ this.btnAddFacet.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ btnAddFacetClicked();
+ }
+ });
+
+ this.btnAddEClassCustom = new Button(buttonsPaneComposite, SWT.PUSH);
+ this.btnAddEClassCustom.setText("EClassCustom");
+ this.btnAddEClassCustom.setLayoutData(buttonsGridData());
+ this.btnAddEClassCustom.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ btnAddECLassCustomClicked();
+ }
+ });
+
+ this.btnAddFacetCustom = new Button(buttonsPaneComposite, SWT.PUSH);
+ this.btnAddFacetCustom.setText("FacetCustom");
+ this.btnAddFacetCustom.setLayoutData(buttonsGridData());
+ this.btnAddFacetCustom.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ btnAddFacetCustomClicked();
+ }
+ });
+
+ return buttonsPaneComposite;
+ }
+
+ protected void btnRemoveClicked() {
+ if (this.readOnly) {
+ return;
+ }
+ final TreeSelection selectedElement = (TreeSelection)getSelection();
+ final Object selectedObject = selectedElement.getFirstElement();
+ if (selectedObject instanceof EObject) {
+ final EObject eObject = (EObject) selectedObject;
+ final EObject eContainer = eObject.eContainer();
+
+ if(eContainer instanceof Customization){
+
+ Command command = RemoveCommand.create(this.editingDomain,
+ eContainer,
+ EcorePackage.eINSTANCE.getEPackage_EClassifiers(),
+ eObject);
+ this.editingDomain.getCommandStack().execute(command);
+ //refresh();
+ }else if(eContainer instanceof Facet){
+ if(selectedObject instanceof FacetOperation){
+ Command command = RemoveCommand.create(this.editingDomain,
+ eContainer,
+ EFacetPackage.eINSTANCE.getFacet_FacetOperations(),
+ eObject);
+ this.editingDomain.getCommandStack().execute(command);
+
+ setInputInCustomizationTreeviewer((Facet)eContainer);
+ this.customizationViewer.getViewer().refresh();
+
+ }else if(selectedObject instanceof FacetAttribute || selectedObject instanceof FacetReference){
+ Command command = RemoveCommand.create(this.editingDomain,
+ eContainer,
+ EFacetPackage.eINSTANCE.getFacet_FacetElements(),
+ eObject);
+ this.editingDomain.getCommandStack().execute(command);
+
+ setInputInCustomizationTreeviewer((Facet)eContainer);
+ this.customizationViewer.getViewer().refresh();
+ }
+ }else if(eContainer instanceof FacetOperation){
+ Command command = RemoveCommand.create(this.editingDomain,
+ eContainer,
+ EcorePackage.eINSTANCE.getEOperation_EParameters(),
+ eObject);
+ this.editingDomain.getCommandStack().execute(command);
+
+ setInputInCustomizationTreeviewer((Facet)eContainer);
+ this.customizationViewer.getViewer().refresh();
+
+ }
+
+ }
+ }
+
+ protected void btnDownClicked() {
+ if (this.readOnly) {
+ return;
+ }
+ final TreeSelection selectedElement = (TreeSelection)getSelection();
+ final Object selectedObject = selectedElement.getFirstElement();
+ if (selectedObject instanceof EObject) {
+ final EObject eObject = (EObject) selectedObject;
+ final EObject eContainer = eObject.eContainer();
+
+ if(eContainer instanceof Customization){
+ EList<EClassifier>list = ((Customization)eContainer).getEClassifiers();
+ final int index = list.indexOf(eObject);
+ if (index + 1 < list.size()) {
+ Command command = MoveCommand.create(this.editingDomain,
+ eContainer,
+ EcorePackage.eINSTANCE.getEPackage_EClassifiers(),
+ list.get(index), index + 1);
+ this.editingDomain.getCommandStack().execute(command);
+ }
+ //refresh();
+ }else if(eContainer instanceof Facet){
+ if(selectedObject instanceof FacetOperation){
+ EList<FacetOperation>list = ((Facet)eContainer).getFacetOperations();
+ final int index = list.indexOf(eObject);
+ if (index + 1 < list.size()) {
+ Command command = MoveCommand.create(this.editingDomain,
+ eContainer,
+ EFacetPackage.eINSTANCE.getFacet_FacetOperations(),
+ list.get(index), index + 1);
+ this.editingDomain.getCommandStack().execute(command);
+
+ setInputInCustomizationTreeviewer((Facet)eContainer);
+ this.customizationViewer.getViewer().refresh();
+ }
+ }else if(selectedObject instanceof FacetAttribute || selectedObject instanceof FacetReference){
+ EList<EStructuralFeature>list = ((Facet)eContainer).getFacetElements();
+ final int index = list.indexOf(eObject);
+ if (index + 1 < list.size()) {
+ Command command = MoveCommand.create(this.editingDomain,
+ eContainer,
+ EFacetPackage.eINSTANCE.getFacet_FacetElements(),
+ list.get(index), index + 1);
+ this.editingDomain.getCommandStack().execute(command);
+
+ setInputInCustomizationTreeviewer((Facet)eContainer);
+ this.customizationViewer.getViewer().refresh();
+ }
+ }
+ }else if(eContainer instanceof FacetOperation){
+ EList<EParameter>list = ((FacetOperation)eContainer).getEParameters();
+ final int index = list.indexOf(eObject);
+ if (index + 1 < list.size()) {
+ Command command = MoveCommand.create(this.editingDomain,
+ eContainer,
+ EcorePackage.eINSTANCE.getEOperation_EParameters(),
+ list.get(index), index + 1);
+ this.editingDomain.getCommandStack().execute(command);
+
+ setInputInCustomizationTreeviewer((Facet)eContainer);
+ this.customizationViewer.getViewer().refresh();
+ }
+ }
+
+ }
+ }
+
+ protected void btnUpClicked() {
+ if (this.readOnly) {
+ return;
+ }
+ final TreeSelection selectedElement = (TreeSelection)getSelection();
+ final Object selectedObject = selectedElement.getFirstElement();
+ if (selectedObject instanceof EObject) {
+ final EObject eObject = (EObject) selectedObject;
+ final EObject eContainer = eObject.eContainer();
+
+ if(eContainer instanceof Customization){
+ EList<EClassifier>list = ((Customization)eContainer).getEClassifiers();
+ final int index = list.indexOf(eObject);
+ if (index - 1 >= 0) {
+ Command command = MoveCommand.create(this.editingDomain,
+ eContainer,
+ EcorePackage.eINSTANCE.getEPackage_EClassifiers(),
+ list.get(index), index - 1);
+ this.editingDomain.getCommandStack().execute(command);
+ }
+ //refresh();
+ }else if(eContainer instanceof Facet){
+ if(selectedObject instanceof FacetOperation){
+ EList<FacetOperation>list = ((Facet)eContainer).getFacetOperations();
+ final int index = list.indexOf(eObject);
+ if (index - 1 >= 0) {
+ Command command = MoveCommand.create(this.editingDomain,
+ eContainer,
+ EFacetPackage.eINSTANCE.getFacet_FacetOperations(),
+ list.get(index), index - 1);
+ this.editingDomain.getCommandStack().execute(command);
+
+ setInputInCustomizationTreeviewer((Facet)eContainer);
+ this.customizationViewer.getViewer().refresh();
+ }
+ }else if(selectedObject instanceof FacetAttribute || selectedObject instanceof FacetReference){
+ EList<EStructuralFeature>list = ((Facet)eContainer).getFacetElements();
+ final int index = list.indexOf(eObject);
+ if (index - 1 >= 0) {
+ Command command = MoveCommand.create(this.editingDomain,
+ eContainer,
+ EFacetPackage.eINSTANCE.getFacet_FacetElements(),
+ list.get(index), index - 1);
+ this.editingDomain.getCommandStack().execute(command);
+
+ setInputInCustomizationTreeviewer((Facet)eContainer);
+ this.customizationViewer.getViewer().refresh();
+ }
+ }
+ }else if(eContainer instanceof FacetOperation){
+ EList<EParameter>list = ((FacetOperation)eContainer).getEParameters();
+ final int index = list.indexOf(eObject);
+ if (index - 1 >= 0) {
+ Command command = MoveCommand.create(this.editingDomain,
+ eContainer,
+ EcorePackage.eINSTANCE.getEOperation_EParameters(),
+ list.get(index), index - 1);
+ this.editingDomain.getCommandStack().execute(command);
+
+ setInputInCustomizationTreeviewer((Facet)eContainer);
+ this.customizationViewer.getViewer().refresh();
+ }
+ }
+
+ }
+
+ }
+
+ protected void btnAddFacetCustomClicked() {
+ if (this.readOnly) {
+ return;
+ }
+ final Object selectedElement = getSelection();
+ if (((TreeSelection)selectedElement).getFirstElement() instanceof Customization) {
+ ICustomizationDialogFactory.DEFAULT.openCreateFacetCustomizationDialog(getSite().getShell().getDisplay(), editingDomain);
+ }
+
+ }
+
+ protected void btnAddECLassCustomClicked() {
+ if (this.readOnly) {
+ return;
+ }
+ final Object selectedElement = getSelection();
+ if (((TreeSelection)selectedElement).getFirstElement() instanceof Customization) {
+ ICustomizationDialogFactory.DEFAULT.openCreateEClassCustomizationDialog(getSite().getShell().getDisplay(), editingDomain);
+ }
+
+ }
+
+ protected void btnAddFacetClicked() {
+ if (this.readOnly) {
+ return;
+ }
+ final Object selectedElement = getSelection();
+ if (((TreeSelection)selectedElement).getFirstElement() instanceof Customization) {
+ IFacetDialogFactory.INSTANCE.openCreateFacetInFacetSetDialog();
+ }
+ }
+
+ protected void btnAddFacetSetClicked() {
+ if (this.readOnly) {
+ return;
+ }
+ final Object selectedElement = getSelection();
+ if (((TreeSelection)selectedElement).getFirstElement() instanceof Customization) {
+ IFacetDialogFactory.INSTANCE.openCreateFacetSetInFacetSetDialog();
+ }
+ }
+
+ private Composite createButtonsPaneWhenFacetIsSelected(final Composite parent) {
+ this.buttonsPaneComposite = new Composite(parent, SWT.NONE);
+ final GridData buttonsPaneGridData = new GridData();
+ buttonsPaneGridData.grabExcessHorizontalSpace = false;
+ buttonsPaneGridData.grabExcessVerticalSpace = true;
+ buttonsPaneGridData.horizontalAlignment = SWT.FILL;
+ buttonsPaneGridData.verticalAlignment = SWT.FILL;
+ buttonsPaneComposite.setLayoutData(buttonsPaneGridData);
+
+ buttonsPaneComposite.setLayout(new GridLayout());
+
+ final Composite spacer1 = new Composite(buttonsPaneComposite, SWT.NONE);
+ final GridData spacer1GridData = new GridData();
+ spacer1GridData.heightHint = CustomEditor.VERTICAL_SPACE_BEFORE_FIRST_BUTTON;
+ spacer1.setLayoutData(spacer1GridData);
+
+ final Composite spacer2 = new Composite(buttonsPaneComposite, SWT.NONE);
+ final GridData spacer2GridData = new GridData();
+ spacer2GridData.heightHint = CustomEditor.VERTICAL_SPACE_BETWEEN_BUTTON_GROUPS;
+ spacer2.setLayoutData(spacer2GridData);
+
+ final Label lblConditions = new Label(buttonsPaneComposite, SWT.NONE);
+ lblConditions.setText("add");
+
+ this.btnAddFacetAttr = new Button(buttonsPaneComposite, SWT.PUSH);
+ this.btnAddFacetAttr.setText("Facet Attribute");
+ this.btnAddFacetAttr.setLayoutData(buttonsGridData());
+ this.btnAddFacetAttr.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ btnAddFacetAttributeClicked();
+ }
+ });
+
+ this.btnAddFacetRef = new Button(buttonsPaneComposite, SWT.PUSH);
+ this.btnAddFacetRef.setText("Facet Reference");
+ this.btnAddFacetRef.setLayoutData(buttonsGridData());
+ this.btnAddFacetRef.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ btnAddFacetReferenceClicked();
+ }
+ });
+
+ this.btnAddFacetOp = new Button(buttonsPaneComposite, SWT.PUSH);
+ this.btnAddFacetOp.setText("Facet Operation");
+ this.btnAddFacetOp.setLayoutData(buttonsGridData());
+ this.btnAddFacetOp.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ btnAddFacetOperationClicked();
+ }
+ });
+
+ final Composite spacer3 = new Composite(buttonsPaneComposite, SWT.NONE);
+ final GridData spacer3GridData = new GridData();
+ spacer3GridData.heightHint = CustomEditor.VERTICAL_SPACE_BETWEEN_BUTTON_GROUPS;
+ spacer3.setLayoutData(spacer2GridData);
+
+ final Label lblEditions = new Label(buttonsPaneComposite, SWT.NONE);
+ lblEditions.setText("edit");
+
+ this.btnEdit = new Button(buttonsPaneComposite, SWT.PUSH);
+ this.btnEdit.setText(CustomEditorPlugin.INSTANCE.getString("CustomizationEditor_edit"));
+ this.btnEdit.setLayoutData(buttonsGridData());
+ this.btnEdit.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ btnEditClicked();
+ }
+ });
+
+ this.btnRemove = new Button(buttonsPaneComposite, SWT.PUSH);
+ this.btnRemove.setText(CustomEditorPlugin.INSTANCE.getString("CustomizationEditor_remove"));
+ this.btnRemove.setLayoutData(buttonsGridData());
+ this.btnRemove.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ btnRemoveClicked();
+ }
+ });
+
+ this.btnUp = new Button(buttonsPaneComposite, SWT.PUSH);
+ this.btnUp.setText(CustomEditorPlugin.INSTANCE.getString("CustomizationEditor_up"));
+ this.btnUp.setLayoutData(buttonsGridData());
+ this.btnUp.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ btnUpClicked();
+ }
+ });
+
+ this.btnDown = new Button(buttonsPaneComposite, SWT.PUSH);
+ this.btnDown.setText(CustomEditorPlugin.INSTANCE.getString("CustomizationEditor_down"));
+ this.btnDown.setLayoutData(buttonsGridData());
+ this.btnDown.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ btnDownClicked();
+ }
+ });
+
+ return buttonsPaneComposite;
+ }
+
+ protected void btnAddFacetOperationClicked() {
+ if (this.readOnly) {
+ return;
+ }
+ final Object selectedElement = getSelection();
+ if (((TreeSelection)selectedElement).getFirstElement() instanceof Facet) {
+ IFacetDialogFactory.INSTANCE.openAddOperationInFacetDialog();
+ }
+
+ }
+
+ protected void btnAddFacetReferenceClicked() {
+ if (this.readOnly) {
+ return;
+ }
+ final Object selectedElement = getSelection();
+ if (((TreeSelection)selectedElement).getFirstElement() instanceof Facet) {
+ IFacetDialogFactory.INSTANCE.openAddReferenceInFacetDialog();
+ }
+ }
+
+ protected void btnAddFacetAttributeClicked() {
+ if (this.readOnly) {
+ return;
+ }
+ final Object selectedElement = getSelection();
+ if (((TreeSelection)selectedElement).getFirstElement() instanceof Facet) {
+ IFacetDialogFactory.INSTANCE.openAddAttributeInFacetDialog();
+ }
+ }
+
+ private Composite createButtonsPaneWhenDerivedIsSelected(final Composite parent) {
+ this.buttonsPaneComposite = new Composite(parent, SWT.NONE);
+ final GridData buttonsPaneGridData = new GridData();
+ buttonsPaneGridData.grabExcessHorizontalSpace = false;
+ buttonsPaneGridData.grabExcessVerticalSpace = true;
+ buttonsPaneGridData.horizontalAlignment = SWT.FILL;
+ buttonsPaneGridData.verticalAlignment = SWT.FILL;
+ buttonsPaneComposite.setLayoutData(buttonsPaneGridData);
+
+ buttonsPaneComposite.setLayout(new GridLayout());
+
+ final Composite spacer1 = new Composite(buttonsPaneComposite, SWT.NONE);
+ final GridData spacer1GridData = new GridData();
+ spacer1GridData.heightHint = CustomEditor.VERTICAL_SPACE_BEFORE_FIRST_BUTTON;
+ spacer1.setLayoutData(spacer1GridData);
+
+ final Composite spacer2 = new Composite(buttonsPaneComposite, SWT.NONE);
+ final GridData spacer2GridData = new GridData();
+ spacer2GridData.heightHint = CustomEditor.VERTICAL_SPACE_BETWEEN_BUTTON_GROUPS;
+ spacer2.setLayoutData(spacer2GridData);
+
+ final Label lblConditions = new Label(buttonsPaneComposite, SWT.NONE);
+ lblConditions.setText("add");
+
+ this.btnAddFacetParam = new Button(buttonsPaneComposite, SWT.PUSH);
+ this.btnAddFacetParam.setText("Parameter");
+ this.btnAddFacetParam.setLayoutData(buttonsGridData());
+ this.btnAddFacetParam.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ btnAddParameterClicked();
+ }
+ });
+
+ if(!(((TreeSelection)getSelection()).getFirstElement() instanceof FacetOperation)){
+ this.btnAddFacetParam.setEnabled(false);
+ }else{
+ this.btnAddFacetParam.setEnabled(true);
+ }
+
+ final Composite spacer3 = new Composite(buttonsPaneComposite, SWT.NONE);
+ final GridData spacer3GridData = new GridData();
+ spacer3GridData.heightHint = CustomEditor.VERTICAL_SPACE_BETWEEN_BUTTON_GROUPS;
+ spacer3.setLayoutData(spacer2GridData);
+
+ final Label lblEditions = new Label(buttonsPaneComposite, SWT.NONE);
+ lblEditions.setText("edit");
+
+ this.btnEdit = new Button(buttonsPaneComposite, SWT.PUSH);
+ this.btnEdit.setText(CustomEditorPlugin.INSTANCE.getString("CustomizationEditor_edit"));
+ this.btnEdit.setLayoutData(buttonsGridData());
+ this.btnEdit.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ btnEditClicked();
+ }
+ });
+
+ this.btnRemove = new Button(buttonsPaneComposite, SWT.PUSH);
+ this.btnRemove.setText(CustomEditorPlugin.INSTANCE.getString("CustomizationEditor_remove"));
+ this.btnRemove.setLayoutData(buttonsGridData());
+ this.btnRemove.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ btnRemoveClicked();
+ }
+ });
+
+ this.btnUp = new Button(buttonsPaneComposite, SWT.PUSH);
+ this.btnUp.setText(CustomEditorPlugin.INSTANCE.getString("CustomizationEditor_up"));
+ this.btnUp.setLayoutData(buttonsGridData());
+ this.btnUp.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ btnUpClicked();
+ }
+ });
+
+ this.btnDown = new Button(buttonsPaneComposite, SWT.PUSH);
+ this.btnDown.setText(CustomEditorPlugin.INSTANCE.getString("CustomizationEditor_down"));
+ this.btnDown.setLayoutData(buttonsGridData());
+ this.btnDown.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(final SelectionEvent e) {
+ btnDownClicked();
+ }
+ });
+
+ return buttonsPaneComposite;
+ }
+
+ protected void btnAddParameterClicked() {
+ if (this.readOnly) {
+ return;
+ }
+ final Object selectedElement = getSelection();
+ if(selectedElement instanceof TreeSelection){
+ final Object selectedObject = ((TreeSelection)selectedElement).getFirstElement();
+ if (selectedObject instanceof FacetOperation) {
+ IFacetDialogFactory.INSTANCE.openAddParameterInOperationDialog();
+ }
+ }
+ }
+
+ public EditingDomain getEditingDomain() {
+ return editingDomain;
+ }
+
+ public Viewer getViewer() {
+ return selectionViewer;
+ }
+
+ /**
+ * This also changes the editor's input.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void doSaveAs() {
+ SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell());
+ saveAsDialog.open();
+ IPath path = saveAsDialog.getResult();
+ if (path != null) {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ if (file != null) {
+ doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true), new FileEditorInput(file));
+ }
+ }
+ }
+
+}
diff --git a/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomEditorPlugin.java b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomEditorPlugin.java
new file mode 100644
index 00000000000..1ef937d2ed9
--- /dev/null
+++ b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomEditorPlugin.java
@@ -0,0 +1,105 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ */
+package org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.presentation;
+
+import org.eclipse.emf.common.EMFPlugin;
+
+import org.eclipse.emf.common.ui.EclipseUIPlugin;
+
+import org.eclipse.emf.common.util.ResourceLocator;
+
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.provider.Efacet2EditPlugin;
+
+/**
+ * This is the central singleton for the Custom editor plugin.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public final class CustomEditorPlugin extends EMFPlugin {
+ /**
+ * Keep track of the singleton.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final CustomEditorPlugin INSTANCE = new CustomEditorPlugin();
+
+ /**
+ * Keep track of the singleton.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static Implementation plugin;
+
+ /**
+ * Create the instance.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public CustomEditorPlugin() {
+ super
+ (new ResourceLocator [] {
+ Efacet2EditPlugin.INSTANCE,
+ });
+ }
+
+ /**
+ * Returns the singleton instance of the Eclipse plugin.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the singleton instance.
+ * @generated
+ */
+ @Override
+ public ResourceLocator getPluginResourceLocator() {
+ return plugin;
+ }
+
+ /**
+ * Returns the singleton instance of the Eclipse plugin.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the singleton instance.
+ * @generated
+ */
+ public static Implementation getPlugin() {
+ return plugin;
+ }
+
+ /**
+ * The actual implementation of the Eclipse <b>Plugin</b>.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static class Implementation extends EclipseUIPlugin {
+ /**
+ * Creates an instance.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Implementation() {
+ super();
+
+ // Remember the static instance.
+ //
+ plugin = this;
+ }
+ }
+
+}
diff --git a/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomModelWizard.java b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomModelWizard.java
new file mode 100644
index 00000000000..09135352270
--- /dev/null
+++ b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomModelWizard.java
@@ -0,0 +1,639 @@
+/**
+ * Copyright (c) 2011 Mia-Software.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
+ * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
+ */
+package org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.presentation;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.StringTokenizer;
+
+import org.eclipse.emf.common.CommonPlugin;
+
+import org.eclipse.emf.common.util.URI;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.emf.ecore.xmi.XMLResource;
+
+import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+
+import org.eclipse.swt.SWT;
+
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.ModifyEvent;
+
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.ISetSelectionTarget;
+
+import org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.CustomFactory;
+import org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.CustomPackage;
+import org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.provider.CustomEditPlugin;
+
+
+import org.eclipse.core.runtime.Path;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+
+
+/**
+ * This is a simple wizard for creating a new model file.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class CustomModelWizard extends Wizard implements INewWizard {
+ /**
+ * The supported extensions for created files.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final List<String> FILE_EXTENSIONS =
+ Collections.unmodifiableList(Arrays.asList(CustomEditorPlugin.INSTANCE.getString("_UI_CustomEditorFilenameExtensions").split("\\s*,\\s*")));
+
+ /**
+ * A formatted list of supported file extensions, suitable for display.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String FORMATTED_FILE_EXTENSIONS =
+ CustomEditorPlugin.INSTANCE.getString("_UI_CustomEditorFilenameExtensions").replaceAll("\\s*,\\s*", ", ");
+
+ /**
+ * This caches an instance of the model package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected CustomPackage customPackage = CustomPackage.eINSTANCE;
+
+ /**
+ * This caches an instance of the model factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected CustomFactory customFactory = customPackage.getCustomFactory();
+
+ /**
+ * This is the file creation page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected CustomModelWizardNewFileCreationPage newFileCreationPage;
+
+ /**
+ * This is the initial object creation page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected CustomModelWizardInitialObjectCreationPage initialObjectCreationPage;
+
+ /**
+ * Remember the selection during initialization for populating the default container.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IStructuredSelection selection;
+
+ /**
+ * Remember the workbench during initialization.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected IWorkbench workbench;
+
+ /**
+ * Caches the names of the types that can be created as the root object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected List<String> initialObjectNames;
+
+ /**
+ * This just records the information.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.workbench = workbench;
+ this.selection = selection;
+ setWindowTitle(CustomEditorPlugin.INSTANCE.getString("_UI_Wizard_label"));
+ setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE.getImageDescriptor(CustomEditorPlugin.INSTANCE.getImage("full/wizban/NewCustom")));
+ }
+
+ /**
+ * Returns the names of the types that can be created as the root object.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<String> getInitialObjectNames() {
+ if (initialObjectNames == null) {
+ initialObjectNames = new ArrayList<String>();
+ for (EClassifier eClassifier : customPackage.getEClassifiers()) {
+ if (eClassifier instanceof EClass) {
+ EClass eClass = (EClass)eClassifier;
+ if (!eClass.isAbstract()) {
+ initialObjectNames.add(eClass.getName());
+ }
+ }
+ }
+ Collections.sort(initialObjectNames, CommonPlugin.INSTANCE.getComparator());
+ }
+ return initialObjectNames;
+ }
+
+ /**
+ * Create a new model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected EObject createInitialModel() {
+ EClass eClass = (EClass)customPackage.getEClassifier(initialObjectCreationPage.getInitialObjectName());
+ EObject rootObject = customFactory.create(eClass);
+ return rootObject;
+ }
+
+ /**
+ * Do the work after everything is specified.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public boolean performFinish() {
+ try {
+ // Remember the file.
+ //
+ final IFile modelFile = getModelFile();
+
+ // Do the work within an operation.
+ //
+ WorkspaceModifyOperation operation =
+ new WorkspaceModifyOperation() {
+ @Override
+ protected void execute(IProgressMonitor progressMonitor) {
+ try {
+ // Create a resource set
+ //
+ ResourceSet resourceSet = new ResourceSetImpl();
+
+ // Get the URI of the model file.
+ //
+ URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true);
+
+ // Create a resource for this file.
+ //
+ Resource resource = resourceSet.createResource(fileURI);
+
+ // Add the initial model object to the contents.
+ //
+ EObject rootObject = createInitialModel();
+ if (rootObject != null) {
+ resource.getContents().add(rootObject);
+ }
+
+ // Save the contents of the resource to the file system.
+ //
+ Map<Object, Object> options = new HashMap<Object, Object>();
+ options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding());
+ resource.save(options);
+ }
+ catch (Exception exception) {
+ CustomEditorPlugin.INSTANCE.log(exception);
+ }
+ finally {
+ progressMonitor.done();
+ }
+ }
+ };
+
+ getContainer().run(false, false, operation);
+
+ // Select the new file resource in the current view.
+ //
+ IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+ IWorkbenchPage page = workbenchWindow.getActivePage();
+ final IWorkbenchPart activePart = page.getActivePart();
+ if (activePart instanceof ISetSelectionTarget) {
+ final ISelection targetSelection = new StructuredSelection(modelFile);
+ getShell().getDisplay().asyncExec
+ (new Runnable() {
+ public void run() {
+ ((ISetSelectionTarget)activePart).selectReveal(targetSelection);
+ }
+ });
+ }
+
+ // Open an editor on the new file.
+ //
+ try {
+ page.openEditor
+ (new FileEditorInput(modelFile),
+ workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId());
+ }
+ catch (PartInitException exception) {
+ MessageDialog.openError(workbenchWindow.getShell(), CustomEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage());
+ return false;
+ }
+
+ return true;
+ }
+ catch (Exception exception) {
+ CustomEditorPlugin.INSTANCE.log(exception);
+ return false;
+ }
+ }
+
+ /**
+ * This is the one page of the wizard.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public class CustomModelWizardNewFileCreationPage extends WizardNewFileCreationPage {
+ /**
+ * Pass in the selection.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public CustomModelWizardNewFileCreationPage(String pageId, IStructuredSelection selection) {
+ super(pageId, selection);
+ }
+
+ /**
+ * The framework calls this to see if the file is correct.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ protected boolean validatePage() {
+ if (super.validatePage()) {
+ String extension = new Path(getFileName()).getFileExtension();
+ if (extension == null || !FILE_EXTENSIONS.contains(extension)) {
+ String key = FILE_EXTENSIONS.size() > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension";
+ setErrorMessage(CustomEditorPlugin.INSTANCE.getString(key, new Object [] { FORMATTED_FILE_EXTENSIONS }));
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IFile getModelFile() {
+ return ResourcesPlugin.getWorkspace().getRoot().getFile(getContainerFullPath().append(getFileName()));
+ }
+ }
+
+ /**
+ * This is the page where the type of object to create is selected.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public class CustomModelWizardInitialObjectCreationPage extends WizardPage {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Combo initialObjectField;
+
+ /**
+ * @generated
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ */
+ protected List<String> encodings;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Combo encodingField;
+
+ /**
+ * Pass in the selection.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public CustomModelWizardInitialObjectCreationPage(String pageId) {
+ super(pageId);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ {
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.verticalSpacing = 12;
+ composite.setLayout(layout);
+
+ GridData data = new GridData();
+ data.verticalAlignment = GridData.FILL;
+ data.grabExcessVerticalSpace = true;
+ data.horizontalAlignment = GridData.FILL;
+ composite.setLayoutData(data);
+ }
+
+ Label containerLabel = new Label(composite, SWT.LEFT);
+ {
+ containerLabel.setText(CustomEditorPlugin.INSTANCE.getString("_UI_ModelObject"));
+
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ containerLabel.setLayoutData(data);
+ }
+
+ initialObjectField = new Combo(composite, SWT.BORDER);
+ {
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ initialObjectField.setLayoutData(data);
+ }
+
+ for (String objectName : getInitialObjectNames()) {
+ initialObjectField.add(getLabel(objectName));
+ }
+
+ if (initialObjectField.getItemCount() == 1) {
+ initialObjectField.select(0);
+ }
+ initialObjectField.addModifyListener(validator);
+
+ Label encodingLabel = new Label(composite, SWT.LEFT);
+ {
+ encodingLabel.setText(CustomEditorPlugin.INSTANCE.getString("_UI_XMLEncoding"));
+
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ encodingLabel.setLayoutData(data);
+ }
+ encodingField = new Combo(composite, SWT.BORDER);
+ {
+ GridData data = new GridData();
+ data.horizontalAlignment = GridData.FILL;
+ data.grabExcessHorizontalSpace = true;
+ encodingField.setLayoutData(data);
+ }
+
+ for (String encoding : getEncodings()) {
+ encodingField.add(encoding);
+ }
+
+ encodingField.select(0);
+ encodingField.addModifyListener(validator);
+
+ setPageComplete(validatePage());
+ setControl(composite);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected ModifyListener validator =
+ new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ setPageComplete(validatePage());
+ }
+ };
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected boolean validatePage() {
+ return getInitialObjectName() != null && getEncodings().contains(encodingField.getText());
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ if (visible) {
+ if (initialObjectField.getItemCount() == 1) {
+ initialObjectField.clearSelection();
+ encodingField.setFocus();
+ }
+ else {
+ encodingField.clearSelection();
+ initialObjectField.setFocus();
+ }
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getInitialObjectName() {
+ String label = initialObjectField.getText();
+
+ for (String name : getInitialObjectNames()) {
+ if (getLabel(name).equals(label)) {
+ return name;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getEncoding() {
+ return encodingField.getText();
+ }
+
+ /**
+ * Returns the label for the specified type name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected String getLabel(String typeName) {
+ try {
+ return CustomEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type");
+ }
+ catch(MissingResourceException mre) {
+ CustomEditorPlugin.INSTANCE.log(mre);
+ }
+ return typeName;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected Collection<String> getEncodings() {
+ if (encodings == null) {
+ encodings = new ArrayList<String>();
+ for (StringTokenizer stringTokenizer = new StringTokenizer(CustomEditorPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens(); ) {
+ encodings.add(stringTokenizer.nextToken());
+ }
+ }
+ return encodings;
+ }
+ }
+
+ /**
+ * The framework calls this to create the contents of the wizard.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ @Override
+ public void addPages() {
+ // Create a page, set the title, and the initial model file name.
+ //
+ newFileCreationPage = new CustomModelWizardNewFileCreationPage("Whatever", selection);
+ newFileCreationPage.setTitle(CustomEditorPlugin.INSTANCE.getString("_UI_CustomModelWizard_label"));
+ newFileCreationPage.setDescription(CustomEditorPlugin.INSTANCE.getString("_UI_CustomModelWizard_description"));
+ newFileCreationPage.setFileName(CustomEditorPlugin.INSTANCE.getString("_UI_CustomEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0));
+ addPage(newFileCreationPage);
+
+ // Try and get the resource selection to determine a current directory for the file dialog.
+ //
+ if (selection != null && !selection.isEmpty()) {
+ // Get the resource...
+ //
+ Object selectedElement = selection.iterator().next();
+ if (selectedElement instanceof IResource) {
+ // Get the resource parent, if its a file.
+ //
+ IResource selectedResource = (IResource)selectedElement;
+ if (selectedResource.getType() == IResource.FILE) {
+ selectedResource = selectedResource.getParent();
+ }
+
+ // This gives us a directory...
+ //
+ if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
+ // Set this for the container.
+ //
+ newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());
+
+ // Make up a unique new name here.
+ //
+ String defaultModelBaseFilename = CustomEditorPlugin.INSTANCE.getString("_UI_CustomEditorFilenameDefaultBase");
+ String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0);
+ String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension;
+ for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) {
+ modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension;
+ }
+ newFileCreationPage.setFileName(modelFilename);
+ }
+ }
+ }
+ initialObjectCreationPage = new CustomModelWizardInitialObjectCreationPage("Whatever2");
+ initialObjectCreationPage.setTitle(CustomEditorPlugin.INSTANCE.getString("_UI_CustomModelWizard_label"));
+ initialObjectCreationPage.setDescription(CustomEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description"));
+ addPage(initialObjectCreationPage);
+ }
+
+ /**
+ * Get the file from the page.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public IFile getModelFile() {
+ return newFileCreationPage.getModelFile();
+ }
+
+}
diff --git a/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomViewer.java b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomViewer.java
new file mode 100644
index 00000000000..bebfabfb479
--- /dev/null
+++ b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/CustomViewer.java
@@ -0,0 +1,445 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Mia-Software.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.presentation;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.naming.event.ObjectChangeListener;
+
+import org.eclipse.emf.common.util.BasicEList;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EParameter;
+import org.eclipse.emf.ecore.util.EObjectContainmentEList;
+import org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementCase;
+import org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementSwitchQuery;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetElement;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.EObjectLiteralQuery;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.FalseLiteralQuery;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.FloatLiteralQuery;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.IntegerLiteralQuery;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.IsOneOfQuery;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.NavigationQuery;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.NullLiteralQuery;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.OperationCallQuery;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.StringLiteralQuery;
+import org.eclipse.emf.facet.efacet.metamodel.v0_2_0.efacet.query.TrueLiteralQuery;
+import org.eclipse.emf.facet.query.java.core.IJavaQuery2;
+import org.eclipse.emf.facet.query.java.metamodel.v0_2_0.javaquery.JavaQuery;
+import org.eclipse.emf.facet.query.ocl.metamodel.oclquery.OclQuery;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StyledCellLabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.TreeViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ * Displays the current customizations for a given {@link CustomView}, which is
+ * the input of the viewer
+ */
+public class CustomViewer {
+
+ private static final int VALUE_COLUMN_WIDTH = 200;
+ private static final int TYPE_COLUMN_WIDTH = 200;
+ private static final int FEATURE_COLUMN_WIDTH = 200;
+ private final TreeViewer treeViewer;
+
+ //Customization
+ private static final String TOP_LEFT_OVERLAY_ICON_PATH = "topLeftOverlay";
+ private static final String TOP_MIDDLE_OVERLAY_ICON_PATH = "topMiddleOverlay";
+ private static final String TOP_RIGHT_OVERLAY_ICON_PATH = "topRightOverlay";
+ private static final String MIDDLE_LEFT_OVERLAY_ICON_PATH = "middleLeftOverlay";
+ private static final String MIDDLE_RIGHT_OVERLAY_ICON_PATH = "middleRightOverlay";
+ private static final String BOTTOM_LEFT_OVERLAY_ICON_PATH = "bottomLeftOverlay";
+ private static final String BOTTOM_MIDDLE_OVERLAY_ICON_PATH = "bottomMiddleOverlay";
+ private static final String BOTTOM_RIGHT_OVERLAY_ICON_PATH = "bottomRightOverlay";
+ private static final String CUSTOMIZATION_LABEL = "label";
+ private static final String CUSTOMIZATION_IMAGE = "image";
+ private static final String CUSTOMIZATION_FOREGROUND = "foreground";
+ private static final String CUSTOMIZATION_BACKGROUND = "background";
+ private static final String FONT_NAME = "fontName";
+ private static final String FONT_SIZE = "fontSize";
+ private static final String FONT_BOLD = "isBold";
+ private static final String FONT_ITALIC = "isItalic";
+ private static final String FONT_UNDERLINE = "isUnderlined";
+ private static final String FONT_STRUKETHROUGH = "isStruckthrough";
+
+ public CustomViewer(final Composite parent) {
+ this.treeViewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER
+ | SWT.SINGLE | SWT.FULL_SELECTION);
+ this.treeViewer.getTree().setHeaderVisible(true);
+
+ final TreeViewerColumn featureColumn = new TreeViewerColumn(this.treeViewer, SWT.LEFT);
+ featureColumn.getColumn().setText("feature column");
+ featureColumn.getColumn().setWidth(CustomViewer.FEATURE_COLUMN_WIDTH);
+ final TreeViewerColumn typeColumn = new TreeViewerColumn(this.treeViewer, SWT.LEFT);
+ typeColumn.getColumn().setText("feature type");
+ typeColumn.getColumn().setWidth(CustomViewer.TYPE_COLUMN_WIDTH);
+ final TreeViewerColumn valueColumn = new TreeViewerColumn(this.treeViewer, SWT.LEFT);
+ valueColumn.getColumn().setText("feature value");
+ valueColumn.getColumn().setWidth(CustomViewer.VALUE_COLUMN_WIDTH);
+
+ this.treeViewer.setContentProvider(new CustomViewerContentProvider());
+
+ // for sorting purposes
+ this.treeViewer.setLabelProvider(new FeatureLabelProvider());
+ this.treeViewer.setComparator(new ViewerComparator() {
+ @Override
+ public int compare(final Viewer viewer, final Object e1, final Object e2) {
+ // do not sort value cases
+ if (e1 instanceof FacetOperation) {
+ return 0;
+ }
+ return super.compare(viewer, e1, e2);
+ }
+ });
+
+ featureColumn.setLabelProvider(new FeatureLabelProvider());
+ typeColumn.setLabelProvider(new TypeLabelProvider());
+ valueColumn.setLabelProvider(new ValueLabelProvider());
+
+ this.treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(final SelectionChangedEvent event) {
+ // for selection text color
+ CustomViewer.this.treeViewer.refresh();
+ }
+ });
+ }
+
+ public void setInput(final Object input) {
+ this.treeViewer.setInput(input);
+ }
+
+ protected class CustomViewerContentProvider implements ITreeContentProvider {
+ public Object[] getElements(final Object inputElement) {
+ final List facetOperations = new ArrayList<FacetOperation>();
+ if (inputElement instanceof FacetOperation) {
+ final FacetOperation facetOperation = (FacetOperation) inputElement;
+ facetOperations.add(facetOperation);
+ }
+ if(inputElement instanceof FacetElement){
+ final FacetElement facetElement = (FacetElement)inputElement;
+ facetOperations.add(facetElement);
+ }
+ if(inputElement instanceof List){
+ for (Object object : (List)inputElement) {
+ if(object instanceof DerivedTypedElement){
+ facetOperations.add(object);
+ }
+ }
+ }
+ return facetOperations.toArray();
+ }
+
+ public Object[] getChildren(final Object parentElement) {
+
+ if (parentElement instanceof FacetOperation) {
+ final FacetOperation facetOperation = (FacetOperation) parentElement;
+ final EList<EParameter> parameters = new BasicEList<EParameter>();
+ parameters.addAll(facetOperation.getEParameters());
+ return parameters.toArray();
+ }
+
+ return new Object[0];
+ }
+
+ public Object getParent(final Object element) {
+ if (element instanceof EParameter) {
+ final EParameter eParameter = (EParameter) element;
+ return eParameter.getEOperation();
+ }
+ return null;
+ }
+
+ public boolean hasChildren(final Object element) {
+ if (element instanceof FacetOperation) {
+ final FacetOperation facetOperation = (FacetOperation) element;
+ return !facetOperation.getEParameters().isEmpty();
+ }
+ return false;
+ }
+
+ public void dispose() {
+ // nothing
+ }
+
+ public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {
+ // nothing
+ }
+ }
+
+ protected class FeatureLabelProvider extends ColumnLabelProvider {
+
+ @Override
+ public String getText(final Object element) {
+ if (element instanceof DerivedTypedElement) {
+ final DerivedTypedElement facetElement = (DerivedTypedElement) element;
+ return facetElement.getName() ;
+ }else if (element instanceof ParameterValue){
+ final ParameterValue parameterValue = (ParameterValue) element;
+ return parameterValue.getParameter().getName();
+ }else if (element instanceof EParameter){
+ final EParameter parameterValue = (EParameter) element;
+ return parameterValue.getName();
+ }
+ return element.toString();
+ }
+
+ @Override
+ public Font getFont(final Object element) {
+ return null;
+ }
+
+ }
+
+ protected class ValueLabelProvider extends ColumnLabelProvider {
+
+ /** Images in use */
+ private final HashMap<String, Image> images = new HashMap<String, Image>();
+
+ public ValueLabelProvider() {
+ super();
+ }
+
+ public String getText(final Object element) {
+
+ if(element instanceof DerivedTypedElement){
+ DerivedTypedElement derivedTypedElement = (DerivedTypedElement)element;
+ Query query = derivedTypedElement.getQuery();
+ if(query != null){
+ if(query instanceof StringLiteralQuery){
+ StringLiteralQuery stringQuery = (StringLiteralQuery)query;
+ return stringQuery.getValue();
+ }else if(query instanceof TrueLiteralQuery){
+ return "true";
+ }else if(query instanceof FalseLiteralQuery){
+ return "false";
+ }else if(query instanceof NullLiteralQuery){
+ return "null";
+ }else if(query instanceof OperationCallQuery){
+ OperationCallQuery operationCallQuery = (OperationCallQuery)query;
+ return operationCallQuery.toString();
+ }else if(query instanceof JavaQuery){
+ JavaQuery javaQuery = (JavaQuery)query;
+ String qualifiedName = javaQuery.getImplementationClassName();
+ String[] path = qualifiedName.split("\\.");
+ return path[path.length -1];
+ }else if (query instanceof OclQuery){
+ OclQuery oclQuery = (OclQuery)query;
+ return oclQuery.getOclExpression();
+ }else if (query instanceof NavigationQuery){
+ NavigationQuery navigationQuery = (NavigationQuery)query;
+ return navigationQuery.getPath().toString();
+ }else if (query instanceof IsOneOfQuery){
+ IsOneOfQuery isOneOfQuery = (IsOneOfQuery)query;
+ return isOneOfQuery.getExpectedEObjects().toString();
+ }else if (query instanceof IntegerLiteralQuery){
+ IntegerLiteralQuery integerQuery = (IntegerLiteralQuery)query;
+ return String.valueOf(integerQuery.getValue());
+ }else if (query instanceof FloatLiteralQuery){
+ FloatLiteralQuery floatQuery = (FloatLiteralQuery)query;
+ return String.valueOf(floatQuery.getValue());
+ }else if (query instanceof EObjectLiteralQuery){
+ EObjectLiteralQuery eObjectQuery = (EObjectLiteralQuery)query;
+ return eObjectQuery.getElement().eClass().getName();
+ }else if(query instanceof ETypedElementSwitchQuery){
+ ETypedElementSwitchQuery switchQuery = (ETypedElementSwitchQuery)query;
+ EList<ETypedElementCase> list = switchQuery.getCases();
+ List listResult = new ArrayList<String>();
+ for (ETypedElementCase object : list) {
+ if(object.getCase() != null){
+ listResult.add(object.getCase().getName());
+ }
+ }
+ return listResult.toString();
+ }
+ }
+ }else if(element instanceof EParameter){
+ EParameter parameterValue = (EParameter)element;
+ return "";
+ //return parameterValue.getName();
+ }
+ return "N/A";
+ }
+
+ public Image getImage(final Object element) {
+ return null;
+ }
+
+ @Override
+ public void dispose() {
+ for (final Image image : this.images.values()) {
+ image.dispose();
+ }
+ super.dispose();
+ }
+
+ @Override
+ public void update(final ViewerCell cell) {
+ // for a color static value => display color
+ final Object element = cell.getElement();
+
+ // gray if not customized
+ boolean gray = false;
+ if (element instanceof FacetOperation) {
+ final FacetOperation customViewFeature = (FacetOperation) element;
+ //if (customViewFeature.getDefaultValue() == null) {
+ // gray = true;
+ //}
+ }
+
+ // red if unresolved query
+ boolean unresolved = false;
+ if (element instanceof DerivedTypedElement) {
+ final DerivedTypedElement derivedTypedElement = (DerivedTypedElement) element;
+ final Query query = derivedTypedElement.getQuery();
+ if (query == null || !EMFUtil.tryResolve(query)) {
+ unresolved = true;
+ }
+ }
+
+ if (unresolved) {
+ final String text = getText(element);
+ cell.setText(text);
+ cell.setImage(ImageProvider.getInstance().getErrorIcon());
+ super.update(cell);
+ } else {
+ cell.setImage(getImage(element));
+ super.update(cell);
+ }
+ }
+ }
+
+ protected class TypeLabelProvider extends ColumnLabelProvider{
+
+ @Override
+ public String getText(final Object element) {
+ if (element instanceof DerivedTypedElement) {
+ final DerivedTypedElement facetElement = (DerivedTypedElement) element;
+ if(facetElement instanceof FacetAttribute || facetElement instanceof FacetReference){
+ return facetElement.getEType().getName();
+ }else{
+ DerivedTypedElement override = facetElement.getOverride();
+ if( override != null){
+ return override.getName();
+ }else{
+ return ("N/A");
+ }
+ }
+ } else if( element instanceof EParameter){
+ final EParameter eParameter = (EParameter) element;
+ return eParameter.getEType().getName();
+ }
+
+ return element.toString();
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof DerivedTypedElement) {
+ final DerivedTypedElement facetElement = (DerivedTypedElement) element;
+ if(facetElement instanceof FacetAttribute || facetElement instanceof FacetReference){
+ return ImageProvider.getInstance().getAttributeIcon();
+ }else{
+ DerivedTypedElement override = facetElement.getOverride();
+ if( override != null){
+ String overrideName = override.getName();
+ if(CustomViewer.TOP_LEFT_OVERLAY_ICON_PATH.equals(overrideName)){
+ return ImageProvider.getInstance().getTopLeftOverlayIcon();
+ }else if(CustomViewer.TOP_MIDDLE_OVERLAY_ICON_PATH.equals(overrideName)){
+ return ImageProvider.getInstance().getTopMiddleOverlayIcon();
+ }else if(CustomViewer.TOP_RIGHT_OVERLAY_ICON_PATH.equals(overrideName)){
+ return ImageProvider.getInstance().getTopRightOverlayIcon();
+ }else if(CustomViewer.MIDDLE_LEFT_OVERLAY_ICON_PATH.equals(overrideName)){
+ return ImageProvider.getInstance().getMiddleLeftOverlayIcon();
+ }else if(CustomViewer.MIDDLE_RIGHT_OVERLAY_ICON_PATH.equals(overrideName)){
+ return ImageProvider.getInstance().getMiddleRightOverlayIcon();
+ }else if(CustomViewer.BOTTOM_LEFT_OVERLAY_ICON_PATH.equals(overrideName)){
+ return ImageProvider.getInstance().getBottomLeftOverlayIcon();
+ }else if(CustomViewer.BOTTOM_MIDDLE_OVERLAY_ICON_PATH.equals(overrideName)){
+ return ImageProvider.getInstance().getBottomMiddleOverlayIcon();
+ }else if(CustomViewer.BOTTOM_RIGHT_OVERLAY_ICON_PATH.equals(overrideName)){
+ return ImageProvider.getInstance().getBottomRightOverlayIcon();
+ }else if(CustomViewer.CUSTOMIZATION_LABEL.equals(overrideName)){
+ return ImageProvider.getInstance().getCustomizationLabelIcon();
+ }else if(CustomViewer.CUSTOMIZATION_IMAGE.equals(overrideName)){
+ return ImageProvider.getInstance().getCustomizationImageIcon();
+ }else if(CustomViewer.CUSTOMIZATION_FOREGROUND.equals(overrideName)){
+ return ImageProvider.getInstance().getCustomizationColorIcon();
+ }else if(CustomViewer.CUSTOMIZATION_BACKGROUND.equals(overrideName)){
+ return ImageProvider.getInstance().getCustomizationColorIcon();
+ }else if(CustomViewer.FONT_NAME.equals(overrideName)){
+ return ImageProvider.getInstance().getFontNameIcon();
+ }else if(CustomViewer.FONT_SIZE.equals(overrideName)){
+ return ImageProvider.getInstance().getFontSizeIcon();
+ }else if(CustomViewer.FONT_BOLD.equals(overrideName)){
+ return ImageProvider.getInstance().getIsBoldIcon();
+ }else if(CustomViewer.FONT_ITALIC.equals(overrideName)){
+ return ImageProvider.getInstance().getIsItalicIcon();
+ }else if(CustomViewer.FONT_UNDERLINE.equals(overrideName)){
+ return ImageProvider.getInstance().getIsUnderlinedIcon();
+ }else if(CustomViewer.FONT_STRUKETHROUGH.equals(overrideName)){
+ return ImageProvider.getInstance().getIsStrukethroughIcon();
+ }
+ }
+ }
+ }
+ return super.getImage(element);
+ }
+ }
+
+ public void refresh() {
+ if (!this.treeViewer.getTree().isDisposed()) {
+ try {
+ this.treeViewer.getTree().setRedraw(false);
+ this.treeViewer.refresh();
+ } finally {
+ this.treeViewer.getTree().setRedraw(true);
+ }
+ }
+ }
+
+ public void addSelectionChangedListener(final ISelectionChangedListener selectionChangedListener) {
+ this.treeViewer.addSelectionChangedListener(selectionChangedListener);
+ }
+
+ public ISelection getSelection() {
+ return this.treeViewer.getSelection();
+ }
+
+ public TreeViewer getViewer() {
+ return this.treeViewer;
+ }
+}
diff --git a/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/EMFUtil.java b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/EMFUtil.java
new file mode 100644
index 00000000000..4796e3ef682
--- /dev/null
+++ b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/EMFUtil.java
@@ -0,0 +1,363 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 Mia-Software.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.presentation;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.ENamedElement;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+/** Utility functions related to EMF */
+public class EMFUtil {
+
+ /**
+ * @return whether the given EObject is in the first resource of its
+ * resource set
+ */
+ public static boolean isInFirstResource(final EObject eObject) {
+ final Resource resource = eObject.eResource();
+ if (resource == null) {
+ return false;
+ }
+ final ResourceSet resourceSet = resource.getResourceSet();
+ if (resourceSet == null) {
+ return false;
+ }
+ final EList<Resource> resources = resourceSet.getResources();
+ if (resources.size() > 0) {
+ if (resourceSet.getResources().get(0) == resource) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Search for instances of the given EClass
+ *
+ * @param eClass
+ * the EClass of the elements that are looked for
+ * @param resource
+ * the resource to search in
+ * @return elements that are instances of the given EClass
+ */
+ public Collection<EObject> findInstancesOf(final EClass eClass, final Resource resource) {
+ final ArrayList<EObject> instances = new ArrayList<EObject>();
+ final TreeIterator<EObject> allContents = resource.getAllContents();
+ while (allContents.hasNext()) {
+ final EObject eObject = allContents.next();
+ if (eObject.eClass() == eClass) {
+ instances.add(eObject);
+ }
+ }
+ return instances;
+ }
+
+ /**
+ * Find and return all the metaclasses of the given resource set.
+ *
+ * @return a list of all the metaclasses of elements contained in the
+ * resource set, and metaclasses in resources in which metaclasses
+ * of elements in the resource set have been found
+ */
+// public static Set<EClass> findAllClasses(final Set<Resource> browsedResources) {
+// // TODO: try to read from PackageRegistry?
+// // resourceSet.getPackageRegistry().keySet()
+//
+// // TODO: find EClasses in EPackages
+//
+// /*
+// * the list of metaclasses is a tree set so that it is always sorted and
+// * each class is guaranteed to appear at most once.
+// */
+// final TreeSet<EClass> classes = new TreeSet<EClass>(new Comparator<EClass>() {
+// public int compare(final EClass c1, final EClass c2) {
+// return ModelUtils.getMetaclassQualifiedName(c1).compareTo(
+// ModelUtils.getMetaclassQualifiedName(c2));
+// }
+// });
+//
+// /** The resources, in a HashSet to get constant time access */
+// final HashSet<Resource> resources = new HashSet<Resource>();
+// /**
+// * Resources that were discovered outside of the resource set, and which
+// * contain metaclasses used in the model
+// */
+// final ArrayList<Resource> newResources = new ArrayList<Resource>();
+//
+// resources.addAll(browsedResources);
+//
+// for (final Resource resource : browsedResources) {
+// final TreeIterator<EObject> allContents = resource.getAllContents();
+// while (allContents.hasNext()) {
+// final EObject eObject = allContents.next();
+// if (eObject instanceof EClass) {
+// final EClass eClass = (EClass) eObject;
+// classes.add(eClass);
+// } else {
+// // EPackage ePackage = eObject.eClass().getEPackage();
+// // System.out.println("package : " + ePackage.getNsURI());
+//
+// final EClass eClass = eObject.eClass();
+// if (eClass != null) {
+// // make sure all model elements have their metaclass in
+// // the list
+// classes.add(eClass);
+//
+// // if we discovered a new resource, then memorize it
+// final Resource res = eClass.eResource();
+// if (res != null && !resources.contains(res)) {
+// resources.add(res);
+// newResources.add(res);
+// }
+// }
+// }
+// }
+// }
+//
+// /*
+// * Now, add the classes that reside in resources that we discovered and
+// * are not part of the resource set. For example, the UML models have
+// * metaclasses in 'http://www.eclipse.org/uml2/2.1.0/UML', which is not
+// * in the resource set.
+// */
+// addAll(classes, newResources);
+// newResources.clear();
+//
+// final ArrayList<EClass> newClasses = new ArrayList<EClass>();
+//
+// for (final EClass eClass : classes) {
+// final EList<EClass> allSuperTypes = eClass.getEAllSuperTypes();
+// for (final EClass superclass : allSuperTypes) {
+// newClasses.add(superclass);
+//
+// // if we discovered a new resource, then memorize it
+// final Resource resource = superclass.eResource();
+// if (resource != null && !resources.contains(resource)) {
+// resources.add(resource);
+// newResources.add(resource);
+// }
+// }
+// }
+//
+// for (final EClass eClass : newClasses) {
+// classes.add(eClass);
+// }
+//
+// // add classes in newly discovered resources (again)
+// addAll(classes, newResources);
+//
+// // for (Resource resource : resources) {
+// // System.out.println(resource.getURI().toString());
+// // }
+//
+// return classes;
+// }
+
+ /**
+ * Add all the classes in <code>resources</code> to the <code>classes</code>
+ * set
+ */
+ private static void addAll(final Set<EClass> classes, final List<Resource> resources) {
+ for (final Resource resource : resources) {
+ final TreeIterator<EObject> allContents = resource.getAllContents();
+ while (allContents.hasNext()) {
+ final EObject eObject = allContents.next();
+ if (eObject instanceof EClass) {
+ final EClass eClass = (EClass) eObject;
+ classes.add(eClass);
+ }
+ }
+ }
+ }
+
+ /**
+ * Find the most specific metaclass that is common to all of the given
+ * elements.
+ *
+ * @return the common metaclass or <code>null</code> if none was found
+ */
+ public static EClass findCommonClass(final List<EObject> elements) {
+ // FIXME this algorithm can make a choice about a branch early and not
+ // find
+ // a solution, when a solution does exist
+ EClass eClass = null;
+ for (final EObject element : elements) {
+ final EClass elementEClass = element.eClass();
+ if (eClass == null) {
+ eClass = elementEClass;
+ } else {
+ if (eClass.isSuperTypeOf(elementEClass)) {
+ continue;
+ } else if (elementEClass.isSuperTypeOf(eClass)) {
+ eClass = elementEClass;
+ } else {
+ // elements are on two different branches
+ // try to find a common metaclass
+ eClass = findSuperType(eClass, elementEClass);
+ if (eClass == null) {
+ return null;
+ }
+ }
+ }
+ }
+ return eClass;
+ }
+
+ /**
+ * Find the first superclass of <code>eClass</code> that is a superclass of
+ * <code>element</code>
+ */
+ private static EClass findSuperType(final EClass eClass, final EClass element) {
+ // do a breadth-first search (with a bottom-up tree)
+ final LinkedList<EClass> breadthFirstList = new LinkedList<EClass>();
+ breadthFirstList.addFirst(eClass);
+
+ while (!breadthFirstList.isEmpty()) {
+ final EClass candidateClass = breadthFirstList.poll();
+
+ if (candidateClass.isSuperTypeOf(element)) {
+ return candidateClass;
+ }
+
+ // add all the direct super-types of this class
+ for (final EClass supertype : candidateClass.getESuperTypes()) {
+ breadthFirstList.addLast(supertype);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Try to resolve the given proxy.
+ *
+ * @return whether the proxy could be resolved
+ */
+ public static boolean tryResolve(final EObject eObject) {
+ final EObject resolved = EcoreUtil.resolve(eObject, (EObject) null);
+ return !resolved.eIsProxy();
+ }
+
+ /** @return the proxy URI for the given EObject or an empty String if none */
+ public static String proxyURI(final EObject eObject) {
+ final URI eProxyURI = ((InternalEObject) eObject).eProxyURI();
+ if (eProxyURI == null) {
+ return ""; //$NON-NLS-1$
+ }
+ return eProxyURI.toString();
+ }
+
+ public static <T extends ENamedElement> T findElementWithName(final String name,
+ final EList<T> elements) {
+ for (T element : elements) {
+ if (name.equals(element.getName())) {
+ return element;
+ }
+ }
+ return null;
+ }
+
+// public static EClass findMetaclassWithName(final String metaclassFullyQualifiedName,
+// final List<EClass> metaclasses) {
+// for (EClass eClass : metaclasses) {
+// if (metaclassFullyQualifiedName.equals(ModelUtils.getMetaclassQualifiedName(eClass))) {
+// return eClass;
+// }
+// }
+// return null;
+// }
+
+ /**
+ * @return the name of the package in the package registry with this nsURI,
+ * or <code>null</code> if not found
+ */
+ public static String getMetamodelName(final String nsURI) {
+ if (nsURI != null) {
+ final EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(nsURI);
+ if (ePackage != null) {
+ final String name = ePackage.getName();
+ if (name != null) {
+ return name;
+ }
+ }
+
+ final URI uri = URI.createURI(nsURI);
+ final String lastSegment = uri.lastSegment();
+ if (lastSegment != null) {
+ return lastSegment;
+ }
+ }
+ return null;
+ }
+
+ /** @return the list of {@link EClass}es found in the following resource */
+ public static List<EClass> getMetaclasses(final Resource metamodel) {
+ final List<EClass> metaclasses = new ArrayList<EClass>();
+ final TreeIterator<EObject> allContents = metamodel.getAllContents();
+ while (allContents.hasNext()) {
+ final EObject eObject = allContents.next();
+ if (eObject instanceof EClass) {
+ final EClass eClass = (EClass) eObject;
+ metaclasses.add(eClass);
+ }
+ }
+ return metaclasses;
+ }
+
+ /**
+ * Find the {@link EObject} with the given URI in the given
+ * {@link ResourceSet}
+ *
+ * @return the element or <code>null</code> if no element was found with
+ * this URI in the given {@link ResourceSet}
+ */
+ public static EObject findElementByURI(final String uriFragment, final ResourceSet resourceSet) {
+ EList<Resource> resources = resourceSet.getResources();
+ for (Resource resource : resources) {
+ EObject eObject = resource.getEObject(uriFragment);
+ if (eObject != null) {
+ return eObject;
+ }
+ }
+
+ // Resource resource;
+ // resource.
+ // TreeIterator<Notifier> allContents = resourceSet.getAllContents();
+ // while (allContents.hasNext()) {
+ // Notifier notifier = allContents.next();
+ // if (notifier instanceof EObject) {
+ // EObject eObject = (EObject) notifier;
+ // if (uri.equals(EcoreUtil.getURI(eObject))) {
+ // return eObject;
+ // }
+ // }
+ // }
+ return null;
+ }
+
+}
diff --git a/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/FormStyleSashForm.java b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/FormStyleSashForm.java
new file mode 100644
index 00000000000..7d7d6192cce
--- /dev/null
+++ b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/FormStyleSashForm.java
@@ -0,0 +1,143 @@
+package org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.presentation;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.emf.facet.util.core.Logger;
+import org.eclipse.emf.facet.util.core.internal.Activator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Sash;
+import org.eclipse.ui.forms.FormColors;
+import org.eclipse.ui.forms.IFormColors;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/** Adapted from {@link org.eclipse.ui.forms.MasterDetailsBlock} */
+public abstract class FormStyleSashForm extends SashForm {
+ private final ArrayList<Sash> fSashes = new ArrayList<Sash>();
+ private final FormToolkit formToolkit;
+ private int minWidth = 0;
+
+ private final Listener fListener = new Listener() {
+ public void handleEvent(final Event e) {
+ switch (e.type) {
+ case SWT.MouseEnter:
+ e.widget.setData("hover", Boolean.TRUE); //$NON-NLS-1$
+ ((Control) e.widget).redraw();
+ break;
+ case SWT.MouseExit:
+ e.widget.setData("hover", null); //$NON-NLS-1$
+ ((Control) e.widget).redraw();
+ break;
+ case SWT.Paint:
+ onSashPaint(e);
+ break;
+ case SWT.Resize:
+ hookSashListeners();
+ break;
+ case SWT.Selection:
+ if (e.x < FormStyleSashForm.this.minWidth) {
+ e.x = FormStyleSashForm.this.minWidth;
+ }
+ break;
+ default:
+ Logger.logWarning("Unhandled event", Activator.getDefault()); //$NON-NLS-1$
+ }
+ }
+ };
+
+ public FormStyleSashForm(final Composite parent, final int style, final FormToolkit formToolkit) {
+ super(parent, style);
+ this.formToolkit = formToolkit;
+ formToolkit.adapt(this, false, false);
+ createContents();
+ hookListeners();
+ }
+
+ public void setMinWidth(final int minWidth) {
+ this.minWidth = minWidth;
+ }
+
+ protected abstract void createContents();
+
+ private void hookListeners() {
+ final Listener listener = this.fListener;
+ for (final Control child : getChildren()) {
+ if (!(child instanceof Sash)) {
+ child.addListener(SWT.Resize, listener);
+ }
+ }
+ }
+
+ @Override
+ public void layout(final boolean changed) {
+ super.layout(changed);
+ hookSashListeners();
+ }
+
+ @Override
+ public void layout(final Control[] children) {
+ super.layout(children);
+ hookSashListeners();
+ }
+
+ void hookSashListeners() {
+ purgeSashes();
+ try {
+ final Sash[] allSashes = getSashes();
+ for (final Sash sash : allSashes) {
+ if (this.fSashes.contains(sash)) {
+ continue;
+ }
+ sash.addListener(SWT.Paint, this.fListener);
+ sash.addListener(SWT.MouseEnter, this.fListener);
+ sash.addListener(SWT.MouseExit, this.fListener);
+ sash.addListener(SWT.Selection, this.fListener);
+ this.fSashes.add(sash);
+ }
+ } catch (final Exception e) {
+ Logger.logError(e, Activator.getDefault());
+ }
+ }
+
+ private Sash[] getSashes() {
+ try {
+ final Field sashesField = SashForm.class.getDeclaredField("sashes"); //$NON-NLS-1$
+ sashesField.setAccessible(true);
+ final Sash[] allSashes = (Sash[]) sashesField.get(this);
+ return allSashes;
+ } catch (final Exception e) {
+ Logger.logError(e, Activator.getDefault());
+ return new Sash[0];
+ }
+ }
+
+ private void purgeSashes() {
+ for (final Iterator<Sash> iter = this.fSashes.iterator(); iter.hasNext();) {
+ final Sash sash = iter.next();
+ if (sash.isDisposed()) {
+ iter.remove();
+ }
+ }
+ }
+
+ void onSashPaint(final Event e) {
+ final Sash sash = (Sash) e.widget;
+ final FormColors colors = this.formToolkit.getColors();
+ final GC gc = e.gc;
+ final Boolean hover = (Boolean) sash.getData("hover"); //$NON-NLS-1$
+ if (hover != null) {
+ gc.setBackground(colors.getColor(IFormColors.TB_BG));
+ gc.setForeground(colors.getColor(IFormColors.TB_BORDER));
+ final Point size = sash.getSize();
+ gc.fillRectangle(0, 0, size.x, size.y);
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/ImageProvider.java b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/ImageProvider.java
new file mode 100644
index 00000000000..9c1903fe925
--- /dev/null
+++ b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/ImageProvider.java
@@ -0,0 +1,770 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 Mia-Software.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - initial API and implementation
+ * Vincent Lorenzo (CEA-LIST) - bug 341238 - We need to be able to specify which column have to be hidden/visible using the customization mechanism
+ *******************************************************************************/
+
+package org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.presentation;
+
+import java.net.URL;
+
+import org.eclipse.emf.facet.util.core.Logger;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+/** A singleton image provider, which caches image descriptors */
+public final class ImageProvider {
+
+ private ImageProvider() {
+ // This class must only be instantiated by getInstance().
+ }
+
+ private static ImageProvider instance;
+
+ public static ImageProvider getInstance() {
+ if (ImageProvider.instance == null) {
+ ImageProvider.instance = new ImageProvider();
+ }
+ return ImageProvider.instance;
+ }
+
+ private Image linkIcon = null;
+ private Image linkUniDirIcon = null;
+ private Image linkFacetIcon = null;
+ private Image aggregIcon = null;
+ private Image aggregUniDirIcon = null;
+ private Image invAggregIcon = null;
+
+ private Image emptyLinksIcon = null;
+ // private Image sortInstancesIcon = null;
+ private Image sortLinksIcon = null;
+ private Image sortLinksByTypeIcon = null;
+ // private Image sortNumericallyIcon = null;
+ private Image showDerivedLinksIcon = null;
+ private Image showFullQualifiedNamesIcon = null;
+ private Image showMultiplicityIcon = null;
+ private Image showOppositeLinksIcon = null;
+
+ private Image rangeIcon = null;
+ private Image containerIcon = null;
+ // private Image emptyMetaclassesIcon = null;
+ private Image packageIcon = null;
+ // private Image derivedInstancesIcon = null;
+ // private Image derivationTreeIcon = null;
+ private Image attributeIcon = null;
+ private Image attributeFacetIcon = null;
+ private Image emptyAttributeIcon = null;
+ private Image orderingIcon = null;
+ private Image linkTypeIcon = null;
+
+ private Image facetIcon = null;
+ private Image viewMenuIcon = null;
+
+ private ImageDescriptor increaseFontSizeIcon = null;
+ private ImageDescriptor decreaseFontSizeIcon = null;
+ private ImageDescriptor restoreFontSizeIcon = null;
+
+ private Image hideEmptyColumnsIcon = null;
+ private Image commonColumnsIcon = null;
+ private Image eClassIcon = null;
+ private Image operationIcon = null;
+ private Image predicateIcon = null;
+ private Image emffacetIcon = null;
+ private Image featureIcon = null;
+ private Image errorIcon = null;
+ private Image queryIcon = null;
+ private Image uiCustomIcon = null;
+ private Image grayedUiCustomIcon=null;
+ private Image uriIcon = null;
+
+ private Image shortcutIcon = null;
+
+ private Image topLeftOverlay = null;
+ private Image topMiddleOverlay = null;
+ private Image topRightOverlay = null;
+ private Image middleLeftOverlay = null;
+ private Image middleRightOverlay = null;
+ private Image bottomLeftOverlay = null;
+ private Image bottomMiddleOverlay = null;
+ private Image bottomRightOverlay = null;
+ private Image customizationLabel = null;
+ private Image customizationImage = null;
+ private Image rgb = null;
+ private Image fontName = null;
+ private Image fontSize = null;
+ private Image isBold = null;
+ private Image isItalic = null;
+ private Image isUnderlined = null;
+ private Image isStruckthrough = null;
+
+
+ private static final String LINK_ICON_PATH = "/icons/full/ctool16/link.gif"; //$NON-NLS-1$
+ private static final String LINK_UNIDIR_ICON_PATH = "/icons/full/ctool16/link_unidir.gif"; //$NON-NLS-1$
+ private static final String LINK_FACET_ICON_PATH = "/icons/full/ctool16/link_unidir_facet.gif"; //$NON-NLS-1$
+ private static final String AGGREG_ICON_PATH = "/icons/full/ctool16/aggreg.gif"; //$NON-NLS-1$
+ private static final String AGGREG_UNIDIR_ICON_PATH = "/icons/full/ctool16/aggreg_unidir.gif"; //$NON-NLS-1$
+ private static final String INV_AGGREG_ICON_PATH = "/icons/full/ctool16/inv_aggreg.gif"; //$NON-NLS-1$
+ private static final String EMPTY_LINKS_ICON_PATH = "/icons/full/ctool16/empty_links.gif"; //$NON-NLS-1$
+ private static final String SORT_INSTANCES_ICON_PATH = "/icons/full/ctool16/sort.gif"; //$NON-NLS-1$
+ private static final String SORT_LINKS_ICON_PATH = "/icons/full/ctool16/sort_links.gif"; //$NON-NLS-1$
+ private static final String SORT_LINKS_BY_TYPE_ICON_PATH = "/icons/full/ctool16/sort_links_by_type.gif"; //$NON-NLS-1$
+ private static final String SORT_NUMERICALLY_ICON_PATH = "/icons/full/ctool16/sort_num.gif"; //$NON-NLS-1$
+ private static final String SHOW_DERIVED_LINKS_ICON_PATH = "/icons/full/ctool16/derived.gif"; //$NON-NLS-1$
+ private static final String SHOW_FULL_QUALIFIED_NAMES_ICON_PATH = "/icons/full/ctool16/full_name.gif"; //$NON-NLS-1$
+ private static final String RANGE_ICON_PATH = "/icons/full/ctool16/range.gif"; //$NON-NLS-1$
+ private static final String SHOW_MULTIPLICITY_ICON_PATH = "/icons/full/ctool16/multiplicity.gif"; //$NON-NLS-1$
+ private static final String SHOW_OPPOSITE_LINKS_ICON_PATH = "/icons/full/ctool16/opposite_links.gif"; //$NON-NLS-1$
+ private static final String CONTAINER_ICON_PATH = "/icons/full/ctool16/container.gif"; //$NON-NLS-1$
+ private static final String EMPTY_METACLASSES_ICON_PATH = "/icons/full/ctool16/zero.gif"; //$NON-NLS-1$
+ private static final String PACKAGE_ICON_PATH = "/icons/full/ctool16/package.gif"; //$NON-NLS-1$
+ private static final String DERIVED_INSTANCES_ICON_PATH = "/icons/full/ctool16/derived_instances.gif"; //$NON-NLS-1$
+ private static final String DERIVATION_TREE_ICON_PATH = "/icons/full/ctool16/derivation_tree.gif"; //$NON-NLS-1$
+ private static final String ATTRIBUTE_ICON_PATH = "/icons/full/ctool16/attributes.gif"; //$NON-NLS-1$
+ private static final String ATTRIBUTE_FACET_ICON_PATH = "/icons/full/ctool16/attribute_facet.gif"; //$NON-NLS-1$
+ private static final String EMPTY_ATTRIBUTE_ICON_PATH = "/icons/full/ctool16/empty_attributes.gif"; //$NON-NLS-1$
+ private static final String INCREASE_FONT_SIZE_ICON_PATH = "/icons/full/ctool16/increase_font_size.gif"; //$NON-NLS-1$
+ private static final String DECREASE_FONT_SIZE_ICON_PATH = "/icons/full/ctool16/decrease_font_size.gif"; //$NON-NLS-1$
+ private static final String RESTORE_FONT_SIZE_ICON_PATH = "/icons/full/ctool16/restore_font_size.gif"; //$NON-NLS-1$
+ private static final String HIDE_EMPTY_COLUMNS_ICON_PATH = "/icons/full/ctool16/non-zero.gif"; //$NON-NLS-1$
+ private static final String COMMON_COLUMNS_ICON_PATH = "/icons/full/ctool16/common_columns.gif"; //$NON-NLS-1$
+ private static final String ORDERING_ICON_PATH = "/icons/full/ctool16/ordering.gif"; //$NON-NLS-1$
+ private static final String ECLASS_ICON_PATH = "/icons/full/ctool16/eClass.gif"; //$NON-NLS-1$
+ private static final String OPERATION_ICON_PATH = "/icons/full/ctool16/operation.gif"; //$NON-NLS-1$
+ private static final String PREDICATE_ICON_PATH = "/icons/full/ctool16/predicate.gif"; //$NON-NLS-1$
+ private static final String EMFFACET_ICON_PATH = "icons/logoEmfFacetMini.gif"; //$NON-NLS-1$
+ private static final String FEATURE_ICON_PATH = "icons/full/ctool16/feature.gif"; //$NON-NLS-1$
+ private static final String ERROR_ICON_PATH = "icons/error.gif"; //$NON-NLS-1$
+ private static final String FACET_ICON_PATH = "icons/Facet.gif"; //$NON-NLS-1$
+ private static final String ADD_UI_CUSTOM_ICON_PATH = "icons/full/ctool16/addUiCustom.gif"; //$NON-NLS-1$
+ private static final String VIEW_MENU_ICON_PATH = "icons/full/ctool16/view_menu.gif"; //$NON-NLS-1$
+ private static final String LINK_TYPE_ICON_PATH = "icons/full/ctool16/link_type.gif"; //$NON-NLS-1$
+ private static final String QUERY_ICON_PATH = "icons/query.png"; //$NON-NLS-1$
+ private static final String ELEMENT_IDS_ICON_PATH = "/icons/full/ctool16/element_id.gif"; //$NON-NLS-1$
+ private static final String URI_ICON_PATH = "/icons/full/ctool16/uri.gif"; //$NON-NLS-1$
+ private static final String COLLAPSE_ALL_ICON_PATH = "/icons/full/ctool16/collapseall.gif"; //$NON-NLS-1$
+ private static final String SHORTCUT_ICON_PATH = "/icons/shortcut.png"; //$NON-NLS-1$
+
+ //Customization
+ private static final String TOP_LEFT_OVERLAY_ICON_PATH = "/icons/full/ctool16/topLeftOverlay.png";
+ private static final String TOP_MIDDLE_OVERLAY_ICON_PATH = "/icons/full/ctool16/topMiddleOverlay.png";
+ private static final String TOP_RIGHT_OVERLAY_ICON_PATH = "/icons/full/ctool16/topRightOverlay.png";
+ private static final String MIDDLE_LEFT_OVERLAY_ICON_PATH = "/icons/full/ctool16/middleLeftOverlay.png";
+ private static final String MIDDLE_RIGHT_OVERLAY_ICON_PATH = "/icons/full/ctool16/middleRightOverlay.png";
+ private static final String BOTTOM_LEFT_OVERLAY_ICON_PATH = "/icons/full/ctool16/bottomLeftOverlay.png";
+ private static final String BOTTOM_MIDDLE_OVERLAY_ICON_PATH = "/icons/full/ctool16/bottomMiddleOverlay.png";
+ private static final String BOTTOM_RIGHT_OVERLAY_ICON_PATH = "/icons/full/ctool16/bottomRightOverlay.png";
+ private static final String LABEL_CUSTOMIZATION = "/icons/full/ctool16/customizationLabel.png";
+ private static final String IMAGE_CUSTOMIZATION = "/icons/full/ctool16/imageCustomization.png";
+ private static final String RGB_CUSTOMIZATION = "/icons/full/ctool16/rgb.png";
+ private static final String FONT_NAME = "/icons/full/ctool16/fontName.png"; //$NON-NLS-1$
+ private static final String FONT_SIZE = "/icons/full/ctool16/fontSize.png"; //$NON-NLS-1$
+ private static final String IS_BOLD = "/icons/full/ctool16/fontBold.png"; //$NON-NLS-1$
+ private static final String IS_ITALIC = "/icons/full/ctool16/fontItalic.bmp"; //$NON-NLS-1$
+ private static final String IS_UNDERLINED = "/icons/full/ctool16/fontUnderline.bmp"; //$NON-NLS-1$
+ private static final String IS_STRUCKTHROUGH = "/icons/full/ctool16/fontStrukethrough.bmp"; //$NON-NLS-1$
+
+ /**
+ * Create an image descriptor from a resource
+ *
+ * @param resourcePath
+ * the path of the resource (in the bundle)
+ * @return the image descriptor
+ */
+ private ImageDescriptor createImageDescriptor(final String resourcePath) {
+ final URL url = Activator.getDefault().getBundle().getResource(resourcePath);
+ if (url == null) {
+ Logger.logError(NLS.bind("Resource not found: {0}", //$NON-NLS-1$
+ resourcePath), Activator.getDefault());
+ return ImageDescriptor.getMissingImageDescriptor();
+ }
+ return ImageDescriptor.createFromURL(url);
+ }
+
+ /** Return the icon representing a bidirectional link */
+ public Image getLinkIcon() {
+ if (this.linkIcon == null) {
+ this.linkIcon = createImageDescriptor(ImageProvider.LINK_ICON_PATH).createImage();
+ }
+ return this.linkIcon;
+ }
+
+ /** Return the icon representing an unidirectional link */
+ public Image getUnidirectionalLinkIcon() {
+ if (this.linkUniDirIcon == null) {
+ this.linkUniDirIcon = createImageDescriptor(ImageProvider.LINK_UNIDIR_ICON_PATH)
+ .createImage();
+ }
+ return this.linkUniDirIcon;
+ }
+
+ /** Return the icon representing a facet reference */
+ public Image getFacetLinkIcon() {
+ if (this.linkFacetIcon == null) {
+ this.linkFacetIcon = createImageDescriptor(ImageProvider.LINK_FACET_ICON_PATH)
+ .createImage();
+ }
+ return this.linkFacetIcon;
+ }
+
+ /** Return the icon representing a composition link */
+ public Image getAggregIcon() {
+ if (this.aggregIcon == null) {
+ this.aggregIcon = createImageDescriptor(ImageProvider.AGGREG_ICON_PATH).createImage();
+ }
+ return this.aggregIcon;
+ }
+
+ /** Return the icon representing an unidirectional composition link */
+ public Image getUnidirectionalAggregIcon() {
+ if (this.aggregUniDirIcon == null) {
+ this.aggregUniDirIcon = createImageDescriptor(ImageProvider.AGGREG_UNIDIR_ICON_PATH)
+ .createImage();
+ }
+ return this.aggregUniDirIcon;
+ }
+
+ /** Return the icon representing a reverse composition link */
+ public Image getInvAggregIcon() {
+ if (this.invAggregIcon == null) {
+ this.invAggregIcon = createImageDescriptor(ImageProvider.INV_AGGREG_ICON_PATH)
+ .createImage();
+ }
+ return this.invAggregIcon;
+ }
+
+ /** Return the icon representing empty links */
+ public Image getEmptyLinksIcon() {
+ if (this.emptyLinksIcon == null) {
+ this.emptyLinksIcon = createImageDescriptor(ImageProvider.EMPTY_LINKS_ICON_PATH)
+ .createImage();
+ }
+ return this.emptyLinksIcon;
+ }
+
+ /** Return the icon representing empty links */
+ public ImageDescriptor getEmptyLinksImageDescriptor() {
+ return createImageDescriptor(ImageProvider.EMPTY_LINKS_ICON_PATH);
+ }
+
+ /** Return the icon representing sorting of instances */
+ public ImageDescriptor getSortInstancesIcon() {
+ return createImageDescriptor(ImageProvider.SORT_INSTANCES_ICON_PATH);
+ }
+
+ /** Return the icon representing sorting of links */
+ public Image getSortLinksIcon() {
+ if (this.sortLinksIcon == null) {
+ this.sortLinksIcon = createImageDescriptor(ImageProvider.SORT_LINKS_ICON_PATH)
+ .createImage();
+ }
+ return this.sortLinksIcon;
+ }
+
+ /** Return the icon representing sorting of links */
+ public ImageDescriptor getSortLinksImageDescriptor() {
+ return createImageDescriptor(ImageProvider.SORT_LINKS_ICON_PATH);
+ }
+
+ /** Return the icon representing sorting of links by type */
+ public Image getSortLinksByTypeIcon() {
+ if (this.sortLinksByTypeIcon == null) {
+ this.sortLinksByTypeIcon = createImageDescriptor(
+ ImageProvider.SORT_LINKS_BY_TYPE_ICON_PATH).createImage();
+ }
+ return this.sortLinksByTypeIcon;
+ }
+
+ /** Return the icon representing sorting of links by type */
+ public ImageDescriptor getSortLinksByTypeImageDescriptor() {
+ return createImageDescriptor(ImageProvider.SORT_LINKS_BY_TYPE_ICON_PATH);
+ }
+
+ /** Return the icon representing sorting numerically */
+ public ImageDescriptor getSortNumericallyIcon() {
+ return createImageDescriptor(ImageProvider.SORT_NUMERICALLY_ICON_PATH);
+ }
+
+ /** Return the icon representing derived links */
+ public Image getShowDerivedLinksIcon() {
+ if (this.showDerivedLinksIcon == null) {
+ this.showDerivedLinksIcon = createImageDescriptor(
+ ImageProvider.SHOW_DERIVED_LINKS_ICON_PATH).createImage();
+ }
+ return this.showDerivedLinksIcon;
+ }
+
+ /** Return the icon representing derived links */
+ public ImageDescriptor getShowDerivedLinksImageDescriptor() {
+ return createImageDescriptor(ImageProvider.SHOW_DERIVED_LINKS_ICON_PATH);
+ }
+
+ /** Return the icon representing full qualified names */
+ public Image getShowFullQualifiedNamesIcon() {
+ if (this.showFullQualifiedNamesIcon == null) {
+ this.showFullQualifiedNamesIcon = createImageDescriptor(
+ ImageProvider.SHOW_FULL_QUALIFIED_NAMES_ICON_PATH).createImage();
+ }
+ return this.showFullQualifiedNamesIcon;
+ }
+
+ /** Return the icon representing full qualified names */
+ public ImageDescriptor getShowFullQualifiedNamesImageDescriptor() {
+ return createImageDescriptor(ImageProvider.SHOW_FULL_QUALIFIED_NAMES_ICON_PATH);
+ }
+
+ /** Return the icon representing a range */
+ public Image getRangeIcon() {
+ if (this.rangeIcon == null) {
+ this.rangeIcon = createImageDescriptor(ImageProvider.RANGE_ICON_PATH).createImage();
+ }
+ return this.rangeIcon;
+ }
+
+ /** Return the multiplicity icon */
+ public Image getShowMultiplicityIcon() {
+ if (this.showMultiplicityIcon == null) {
+ this.showMultiplicityIcon = createImageDescriptor(
+ ImageProvider.SHOW_MULTIPLICITY_ICON_PATH).createImage();
+ }
+ return this.showMultiplicityIcon;
+ }
+
+ /** Return the multiplicity icon */
+ public ImageDescriptor getShowMultiplicityImageDescriptor() {
+ return createImageDescriptor(ImageProvider.SHOW_MULTIPLICITY_ICON_PATH);
+ }
+
+ /** Return the "opposite links" icon */
+ public Image getShowOppositeLinksIcon() {
+ if (this.showOppositeLinksIcon == null) {
+ this.showOppositeLinksIcon = createImageDescriptor(
+ ImageProvider.SHOW_OPPOSITE_LINKS_ICON_PATH).createImage();
+ }
+ return this.showOppositeLinksIcon;
+ }
+
+ /** Return the "opposite links" icon */
+ public ImageDescriptor getShowOppositeLinksImageDescriptor() {
+ return createImageDescriptor(ImageProvider.SHOW_OPPOSITE_LINKS_ICON_PATH);
+ }
+
+ /** Return the "container" icon */
+ public Image getContainerIcon() {
+ if (this.containerIcon == null) {
+ this.containerIcon = createImageDescriptor(ImageProvider.CONTAINER_ICON_PATH)
+ .createImage();
+ }
+ return this.containerIcon;
+ }
+
+ /** Return the "container" icon */
+ public ImageDescriptor getContainerImageDescriptor() {
+ return createImageDescriptor(ImageProvider.CONTAINER_ICON_PATH);
+ }
+
+ /** Return the "show empty metaclasses" icon */
+ public ImageDescriptor getShowEmptyMetaclassesIcon() {
+ return createImageDescriptor(ImageProvider.EMPTY_METACLASSES_ICON_PATH);
+ }
+
+ /** Return the "package" icon */
+ public Image getPackageIcon() {
+ if (this.packageIcon == null) {
+ this.packageIcon = createImageDescriptor(ImageProvider.PACKAGE_ICON_PATH).createImage();
+ }
+ return this.packageIcon;
+ }
+
+ /** Return the "package" icon */
+ public ImageDescriptor getPackageImageDescriptor() {
+ return createImageDescriptor(ImageProvider.PACKAGE_ICON_PATH);
+ }
+
+ // /** Return the "derived instances" icon */
+ // public Image getDerivedInstancesIcon() {
+ // if (this.derivedInstancesIcon == null) {
+ // this.derivedInstancesIcon = createImageDescriptor(
+ // ImageProvider.DERIVED_INSTANCES_ICON_PATH).createImage();
+ // }
+ // return this.derivedInstancesIcon;
+ // }
+
+ /** Return the "derived instances" icon */
+ public ImageDescriptor getDerivedInstancesImageDescriptor() {
+ return createImageDescriptor(ImageProvider.DERIVED_INSTANCES_ICON_PATH);
+ }
+
+ /** Return the "derivation tree" icon */
+ public ImageDescriptor getDerivationTreeIcon() {
+ return createImageDescriptor(ImageProvider.DERIVATION_TREE_ICON_PATH);
+ }
+
+ /** Return the "attribute" icon */
+ public Image getAttributeIcon() {
+ if (this.attributeIcon == null) {
+ this.attributeIcon = createImageDescriptor(ImageProvider.ATTRIBUTE_ICON_PATH)
+ .createImage();
+ }
+ return this.attributeIcon;
+ }
+
+ /** Return the "attribute" icon */
+ public ImageDescriptor getAttributeImageDescriptor() {
+ return createImageDescriptor(ImageProvider.ATTRIBUTE_ICON_PATH);
+ }
+
+ /** Return the "facet attribute" icon */
+ public Image getFacetAttributeIcon() {
+ if (this.attributeFacetIcon == null) {
+ this.attributeFacetIcon = createImageDescriptor(ImageProvider.ATTRIBUTE_FACET_ICON_PATH)
+ .createImage();
+ }
+ return this.attributeFacetIcon;
+ }
+
+ /** Return the "empty attributes" icon */
+ public Image getEmptyAttributeIcon() {
+ if (this.emptyAttributeIcon == null) {
+ this.emptyAttributeIcon = createImageDescriptor(ImageProvider.EMPTY_ATTRIBUTE_ICON_PATH)
+ .createImage();
+ }
+ return this.emptyAttributeIcon;
+ }
+
+ /** Return the "empty attributes" icon */
+ public ImageDescriptor getEmptyAttributeImageDescriptor() {
+ return createImageDescriptor(ImageProvider.EMPTY_ATTRIBUTE_ICON_PATH);
+ }
+
+ /** Return the "increase font size" icon */
+ public ImageDescriptor getIncreaseFontSizeIcon() {
+ if (this.increaseFontSizeIcon == null) {
+ this.increaseFontSizeIcon = createImageDescriptor(ImageProvider.INCREASE_FONT_SIZE_ICON_PATH);
+ }
+ return this.increaseFontSizeIcon;
+ }
+
+ /** Return the "decrease font size" icon */
+ public ImageDescriptor getDecreaseFontSizeIcon() {
+ if (this.decreaseFontSizeIcon == null) {
+ this.decreaseFontSizeIcon = createImageDescriptor(ImageProvider.DECREASE_FONT_SIZE_ICON_PATH);
+ }
+ return this.decreaseFontSizeIcon;
+ }
+
+ /** Return the "restore font size" icon */
+ public ImageDescriptor getRestoreFontSizeIcon() {
+ if (this.restoreFontSizeIcon == null) {
+ this.restoreFontSizeIcon = createImageDescriptor(ImageProvider.RESTORE_FONT_SIZE_ICON_PATH);
+ }
+ return this.restoreFontSizeIcon;
+ }
+
+ /** Return the "hide empty columns" icon */
+ public Image getHideEmptyColumnsIcon() {
+ if (this.hideEmptyColumnsIcon == null) {
+ this.hideEmptyColumnsIcon = createImageDescriptor(
+ ImageProvider.HIDE_EMPTY_COLUMNS_ICON_PATH).createImage();
+ }
+ return this.hideEmptyColumnsIcon;
+ }
+
+ /** Return the "common columns" icon */
+ public Image getCommonColumnsIcon() {
+ if (this.commonColumnsIcon == null) {
+ this.commonColumnsIcon = createImageDescriptor(ImageProvider.COMMON_COLUMNS_ICON_PATH)
+ .createImage();
+ }
+ return this.commonColumnsIcon;
+ }
+
+ /** Return the "ordering" icon */
+ public Image getOrderingIcon() {
+ if (this.orderingIcon == null) {
+ this.orderingIcon = createImageDescriptor(ImageProvider.ORDERING_ICON_PATH)
+ .createImage();
+ }
+ return this.orderingIcon;
+ }
+
+ /** Return the "ordering" icon */
+ public ImageDescriptor getOrderingImageDescriptor() {
+ return createImageDescriptor(ImageProvider.ORDERING_ICON_PATH);
+ }
+
+ /** Return the "eClass" icon */
+ public Image getEClassIcon() {
+ if (this.eClassIcon == null) {
+ this.eClassIcon = createImageDescriptor(ImageProvider.ECLASS_ICON_PATH).createImage();
+ }
+ return this.eClassIcon;
+ }
+
+ /** Return the "operation" icon */
+ public Image getOperationIcon() {
+ if (this.operationIcon == null) {
+ this.operationIcon = createImageDescriptor(ImageProvider.OPERATION_ICON_PATH)
+ .createImage();
+ }
+ return this.operationIcon;
+ }
+
+ /** Return the "predicate" icon */
+ public Image getPredicateIcon() {
+ if (this.predicateIcon == null) {
+ this.predicateIcon = createImageDescriptor(ImageProvider.PREDICATE_ICON_PATH)
+ .createImage();
+ }
+ return this.predicateIcon;
+ }
+
+ /** Return the "EmfFacet" icon */
+ public Image getEmfFacetIcon() {
+ if (this.emffacetIcon == null) {
+ this.emffacetIcon = createImageDescriptor(ImageProvider.EMFFACET_ICON_PATH).createImage();
+ }
+ return this.emffacetIcon;
+ }
+
+ /** Return an icon representing the concept of "feature" */
+ public Image getFeatureIcon() {
+ if (this.featureIcon == null) {
+ this.featureIcon = createImageDescriptor(ImageProvider.FEATURE_ICON_PATH).createImage();
+ }
+ return this.featureIcon;
+ }
+
+ /** Return an icon descriptor representing the concept of "feature" */
+ public ImageDescriptor getFeatureIconDescriptor() {
+ return createImageDescriptor(ImageProvider.FEATURE_ICON_PATH);
+ }
+
+ /** Return an icon descriptor representing the concept of "facet" */
+ public ImageDescriptor getFacetIconDescriptor() {
+ return createImageDescriptor(ImageProvider.FACET_ICON_PATH);
+ }
+
+ /** Return an icon descriptor representing the concept of "facet" */
+ public Image getFacetIcon() {
+ if (this.facetIcon == null) {
+ this.facetIcon = createImageDescriptor(ImageProvider.FACET_ICON_PATH).createImage();
+ }
+ return this.facetIcon;
+ }
+
+ /** Return an icon descriptor for "uiCustom" */
+ public ImageDescriptor getAddUiCustomIconDescriptor() {
+ return createImageDescriptor(ImageProvider.ADD_UI_CUSTOM_ICON_PATH);
+ }
+
+ /** Return an icon for "uiCustom" */
+ public Image getUiCustomIcon() {
+ if (this.uiCustomIcon == null) {
+ this.uiCustomIcon = createImageDescriptor(ImageProvider.ADD_UI_CUSTOM_ICON_PATH)
+ .createImage();
+ }
+ return this.uiCustomIcon;
+ }
+
+ /**Return the grayed image for "uiCustom*/
+ public Image getGrayedUiCustomIcon(){
+ if(this.grayedUiCustomIcon==null){
+ this.grayedUiCustomIcon = new Image(Display.getCurrent(), getUiCustomIcon(), SWT.IMAGE_GRAY);
+ }
+ return this.grayedUiCustomIcon;
+ }
+
+ /** Return the "error" icon */
+ public Image getErrorIcon() {
+ if (this.errorIcon == null) {
+ this.errorIcon = createImageDescriptor(ImageProvider.ERROR_ICON_PATH).createImage();
+ }
+ return this.errorIcon;
+ }
+
+ /** Return the toolbar menu icon */
+ public Image getViewMenuIcon() {
+ if (this.viewMenuIcon == null) {
+ this.viewMenuIcon = createImageDescriptor(ImageProvider.VIEW_MENU_ICON_PATH)
+ .createImage();
+ }
+ return this.viewMenuIcon;
+ }
+
+ /** Return the query menu icon */
+ public Image getQueryIcon() {
+ if (this.queryIcon == null) {
+ this.queryIcon = createImageDescriptor(ImageProvider.QUERY_ICON_PATH).createImage();
+ }
+ return this.queryIcon;
+ }
+
+ /** Return the link type icon */
+ public Image getLinkTypeIcon() {
+ if (this.linkTypeIcon == null) {
+ this.linkTypeIcon = createImageDescriptor(ImageProvider.LINK_TYPE_ICON_PATH)
+ .createImage();
+ }
+ return this.linkTypeIcon;
+ }
+
+ /** Return the link type icon descriptor */
+ public ImageDescriptor getLinkTypeIconDescriptor() {
+ return createImageDescriptor(ImageProvider.LINK_TYPE_ICON_PATH);
+ }
+
+ /** Return the "element ID" icon descriptor */
+ public ImageDescriptor getShowElementIDsDescriptor() {
+ return createImageDescriptor(ImageProvider.ELEMENT_IDS_ICON_PATH);
+ }
+
+ public ImageDescriptor getShowURIDescriptor() {
+ return createImageDescriptor(ImageProvider.URI_ICON_PATH);
+ }
+
+ public Image getURIIcon() {
+ if (this.uriIcon == null) {
+ this.uriIcon = createImageDescriptor(ImageProvider.URI_ICON_PATH).createImage();
+ }
+ return this.uriIcon;
+ }
+
+ public ImageDescriptor getCollapseAllDescriptor() {
+ return createImageDescriptor(ImageProvider.COLLAPSE_ALL_ICON_PATH);
+ }
+
+ public Image getShortcutIcon() {
+ if (this.shortcutIcon == null) {
+ this.shortcutIcon = createImageDescriptor(ImageProvider.SHORTCUT_ICON_PATH).createImage();
+ }
+ return this.shortcutIcon;
+ }
+
+ public Image getTopLeftOverlayIcon() {
+ if (this.topLeftOverlay == null) {
+ this.topLeftOverlay = createImageDescriptor(ImageProvider.TOP_LEFT_OVERLAY_ICON_PATH).createImage();
+ }
+ return this.topLeftOverlay;
+ }
+
+ public Image getTopMiddleOverlayIcon() {
+ if (this.topMiddleOverlay == null) {
+ this.topMiddleOverlay = createImageDescriptor(ImageProvider.TOP_MIDDLE_OVERLAY_ICON_PATH).createImage();
+ }
+ return this.topMiddleOverlay;
+ }
+
+ public Image getTopRightOverlayIcon() {
+ if (this.topRightOverlay == null) {
+ this.topRightOverlay = createImageDescriptor(ImageProvider.TOP_RIGHT_OVERLAY_ICON_PATH).createImage();
+ }
+ return this.topRightOverlay;
+ }
+
+ public Image getMiddleLeftOverlayIcon() {
+ if (this.middleLeftOverlay == null) {
+ this.middleLeftOverlay = createImageDescriptor(ImageProvider.MIDDLE_LEFT_OVERLAY_ICON_PATH).createImage();
+ }
+ return this.middleLeftOverlay;
+ }
+
+ public Image getMiddleRightOverlayIcon() {
+ if (this.middleRightOverlay == null) {
+ this.middleRightOverlay = createImageDescriptor(ImageProvider.MIDDLE_RIGHT_OVERLAY_ICON_PATH).createImage();
+ }
+ return this.middleRightOverlay;
+ }
+
+ public Image getBottomLeftOverlayIcon() {
+ if (this.bottomLeftOverlay == null) {
+ this.bottomLeftOverlay = createImageDescriptor(ImageProvider.BOTTOM_LEFT_OVERLAY_ICON_PATH).createImage();
+ }
+ return this.bottomLeftOverlay;
+ }
+
+ public Image getBottomMiddleOverlayIcon() {
+ if (this.bottomMiddleOverlay == null) {
+ this.bottomMiddleOverlay = createImageDescriptor(ImageProvider.BOTTOM_MIDDLE_OVERLAY_ICON_PATH).createImage();
+ }
+ return this.bottomMiddleOverlay;
+ }
+
+ public Image getBottomRightOverlayIcon() {
+ if (this.bottomRightOverlay == null) {
+ this.bottomRightOverlay = createImageDescriptor(ImageProvider.BOTTOM_RIGHT_OVERLAY_ICON_PATH).createImage();
+ }
+ return this.bottomRightOverlay;
+ }
+
+ public Image getCustomizationLabelIcon() {
+ if (this.customizationLabel == null) {
+ this.customizationLabel = createImageDescriptor(ImageProvider.LABEL_CUSTOMIZATION).createImage();
+ }
+ return this.customizationLabel;
+ }
+
+ public Image getCustomizationImageIcon() {
+ if (this.customizationImage == null) {
+ this.customizationImage = createImageDescriptor(ImageProvider.IMAGE_CUSTOMIZATION).createImage();
+ }
+ return this.customizationImage;
+ }
+
+ public Image getCustomizationColorIcon() {
+ if (this.rgb == null) {
+ this.rgb = createImageDescriptor(ImageProvider.RGB_CUSTOMIZATION).createImage();
+ }
+ return this.rgb;
+ }
+
+ public Image getFontNameIcon() {
+ if (this.fontName == null) {
+ this.fontName = createImageDescriptor(ImageProvider.FONT_NAME).createImage();
+ }
+ return this.fontName;
+ }
+
+ public Image getFontSizeIcon() {
+ if (this.fontSize == null) {
+ this.fontSize = createImageDescriptor(ImageProvider.FONT_SIZE).createImage();
+ }
+ return this.fontSize;
+ }
+
+ public Image getIsBoldIcon() {
+ if (this.isBold == null) {
+ this.isBold = createImageDescriptor(ImageProvider.IS_BOLD).createImage();
+ }
+ return this.isBold;
+ }
+
+ public Image getIsItalicIcon() {
+ if (this.isItalic == null) {
+ this.isItalic = createImageDescriptor(ImageProvider.IS_ITALIC).createImage();
+ }
+ return this.isItalic;
+ }
+
+ public Image getIsUnderlinedIcon() {
+ if (this.isUnderlined == null) {
+ this.isUnderlined = createImageDescriptor(ImageProvider.IS_UNDERLINED).createImage();
+ }
+ return this.isUnderlined;
+ }
+
+ public Image getIsStrukethroughIcon() {
+ if (this.isStruckthrough == null) {
+ this.isStruckthrough = createImageDescriptor(ImageProvider.IS_STRUCKTHROUGH).createImage();
+ }
+ return this.isStruckthrough;
+ }
+}
diff --git a/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/Messages.java b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/Messages.java
new file mode 100644
index 00000000000..80167d3deca
--- /dev/null
+++ b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/Messages.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Mia-Software.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Nicolas Bros (Mia-Software) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.facet.custom.metamodel.v0_2_0.custom.presentation;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.emf.facet.custom.metamodel.editor.messages"; //$NON-NLS-1$
+
+ public static String CustomizationEditor_add;
+ public static String CustomizationEditor_appliesToSubInstances;
+ public static String CustomizationEditor_bold;
+ public static String CustomizationEditor_btnOpenElementSelectionDialogText;
+ public static String CustomizationEditor_btnOpenFontDialogText;
+ public static String CustomizationEditor_btnProperties;
+ public static String CustomizationEditor_btnTooltipViewErrors;
+ public static String CustomizationEditor_cannotFindMetamodel;
+
+ public static String CustomizationEditor_changeProperties;
+ public static String CustomizationEditor_collapseLink;
+
+ public static String CustomizationEditor_conditions;
+
+ public static String CustomizationEditor_conflictingUnsavedChanges;
+ public static String CustomizationEditor_customizationsWillBeDeleted;
+
+ public static String CustomizationEditor_customViewFor;
+ public static String CustomizationEditor_down;
+ public static String CustomizationEditor_edit;
+ public static String CustomizationEditor_editFeatureValue;
+ public static String CustomizationEditor_error;
+ public static String CustomizationEditor_errorLoadingResource;
+
+ public static String CustomizationEditor_fileConflict;
+ public static String CustomizationEditor_hideMetaclassName;
+ public static String CustomizationEditor_iconSelection;
+ public static String CustomizationEditor_invalidSelection;
+ public static String CustomizationEditor_italic;
+ public static String CustomizationEditor_missingQuery;
+ public static String CustomizationEditor_missingQuerySet;
+ public static String CustomizationEditor_nonExistingQuery;
+ public static String CustomizationEditor_nonExistingQuerySet;
+ public static String CustomizationEditor_notFileSelected;
+ public static String CustomizationEditor_promptCleanCustomizations;
+ public static String CustomizationEditor_readonly;
+ public static String CustomizationEditor_remove;
+
+ public static String CustomizationEditor_removeIrrelevantCustomizations;
+
+ public static String CustomizationEditor_resetDefaults;
+ public static String CustomizationEditor_sectionName_customizations;
+ public static String CustomizationEditor_sectionName_types;
+ public static String CustomizationEditor_selectAnIcon;
+ public static String CustomizationEditor_strikethrough;
+ public static String CustomizationEditor_text;
+ public static String CustomizationEditor_Title_cleanCustomization;
+ public static String CustomizationEditor_underlined;
+ public static String CustomizationEditor_unknown;
+ public static String CustomizationEditor_up;
+ public static String CustomizationEditor_visible;
+ public static String CustomizationEditor_metaclassVisible;
+ public static String CustomizationEditor_youChangedMetamodel;
+ public static String CustomizationPropertiesDialog_customizationProperties;
+ public static String CustomizationPropertiesDialog_metamodel;
+ public static String CustomizationPropertiesDialog_metamodelMustBeSelected;
+ public static String CustomizationPropertiesDialog_noMetamodelSelected;
+ public static String CustomizationPropertiesDialog_querySets;
+ public static String CustomizationViewer_backgroundColor;
+
+ public static String CustomizationViewer_collapseLink;
+ public static String CustomizationViewer_defaultValue;
+ public static String CustomizationViewer_feature;
+ public static String CustomizationViewer_hideMetaclassName;
+ public static String CustomizationViewer_typeIcon;
+ public static String CustomizationViewer_isBold;
+ public static String CustomizationViewer_isItalic;
+ public static String CustomizationViewer_isStruckthrough;
+ public static String CustomizationViewer_isUnderlined;
+ public static String CustomizationViewer_isVisible;
+ public static String CustomizationViewer_label;
+ public static String CustomizationViewer_instanceIcon;
+ public static String CustomizationViewer_overlayIcon;
+ public static String CustomizationViewer_textColor;
+ public static String CustomizationViewer_textFontName;
+ public static String CustomizationViewer_value;
+ public static String CustomizationViewer_metaclassVisible;
+ public static String ErrorsDialog_diagnosticMessage;
+ public static String ErrorsDialog_errors;
+ public static String MetaclassViewToolBar_showDerivedLinks;
+ public static String MetaclassViewToolBar_showFullQualifiedNames;
+ public static String MetaclassViewToolBar_showMultiplicity;
+ public static String MetaclassViewToolBar_sortLinks;
+ public static String MetaclassViewToolBar_sortLinksByType;
+ public static String EditFeatureValueDialog_conditionQueryMustBeSelected;
+ public static String EditFeatureValueDialog_defaultValue;
+ public static String EditFeatureValueDialog_editFeatureValue;
+ public static String EditFeatureValueDialog_featureValue;
+ public static String EditFeatureValueDialog_noConditionQuerySelected;
+ public static String EditFeatureValueDialog_noQuerySelected;
+ public static String EditFeatureValueDialog_queryForCondition;
+ public static String EditFeatureValueDialog_queryMustBeSelected;
+ public static String EditFeatureValueDialog_queryValue;
+ public static String EditFeatureValueDialog_staticValue;
+ public static String EditFeatureValueDialog_type;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(Messages.BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ // not instantiable
+ }
+}
diff --git a/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/messages.properties b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/messages.properties
new file mode 100644
index 00000000000..e213977eea5
--- /dev/null
+++ b/plugins/facet/editor/org.eclipse.emf.facet.custom.metamodel.editor/src/org/eclipse/emf/facet/custom/metamodel/v0_2_0/custom/presentation/messages.properties
@@ -0,0 +1,97 @@
+###############################################################################
+# Copyright (c) 2009, 2010 Mia-Software.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Nicolas Bros (Mia-Software) - initial API and implementation
+###############################################################################
+CustomizationEditor_add=&Add...
+CustomizationEditor_appliesToSubInstances=Applies to &Sub-Instances
+CustomizationEditor_bold=Bold
+CustomizationEditor_btnOpenElementSelectionDialogText=...
+CustomizationEditor_btnOpenFontDialogText=...
+CustomizationEditor_btnProperties=&Properties
+CustomizationEditor_btnTooltipViewErrors=View errors
+CustomizationEditor_cannotFindMetamodel=Couldn't find metamodel with URI "{0}"
+CustomizationEditor_changeProperties=Change Properties
+CustomizationEditor_collapseLink=Collapse link
+CustomizationEditor_conditions=Conditions :
+CustomizationEditor_conflictingUnsavedChanges=There are unsaved changes that conflict with changes made outside the editor. Do you wish to discard this editor's changes?
+CustomizationEditor_customizationsWillBeDeleted=All the customizations for metaclass "{0}" will be deleted. Are you sure?
+CustomizationEditor_customViewFor=custom view for "{0}" ({1})
+CustomizationEditor_down=&Down
+CustomizationEditor_edit=&Edit...
+CustomizationEditor_editFeatureValue=Edit feature &value...
+CustomizationEditor_error=Error
+CustomizationEditor_errorLoadingResource=Error loading resource. See log for more information.
+CustomizationEditor_fileConflict=File Conflict
+CustomizationEditor_hideMetaclassName=Hide metaclass name
+CustomizationEditor_iconSelection=Icon selection
+CustomizationEditor_invalidSelection=Invalid selection
+CustomizationEditor_italic=Italic
+CustomizationEditor_missingQuery=Couldn't find Query named "{0}" in query set "{1}".
+CustomizationEditor_missingQuerySet=Couldn't find Query Set named "{0}".
+CustomizationEditor_nonExistingQuery=Non-existing Query
+CustomizationEditor_nonExistingQuerySet=Non-existing Query Set
+CustomizationEditor_notFileSelected=You haven't selected a file
+CustomizationEditor_promptCleanCustomizations=Do you want to remove customizations that don't correspond to the new metamodel?
+CustomizationEditor_readonly=READONLY
+CustomizationEditor_remove=&Remove
+CustomizationEditor_removeIrrelevantCustomizations=Remove Irrelevant Customizations
+CustomizationEditor_resetDefaults=Reset Defaults
+CustomizationEditor_sectionName_customizations=Customizations
+CustomizationEditor_sectionName_types=Types
+CustomizationEditor_selectAnIcon=Select an icon:
+CustomizationEditor_strikethrough=Strikethrough
+CustomizationEditor_text=Text
+CustomizationEditor_Title_cleanCustomization=Clean customization
+CustomizationEditor_underlined=Underlined
+CustomizationEditor_unknown=<unknown>
+CustomizationEditor_up=&Up
+CustomizationEditor_visible=Visible
+CustomizationEditor_metaclassVisible=Visible in Types Panel
+CustomizationEditor_youChangedMetamodel=You have changed the metamodel.\n
+CustomizationPropertiesDialog_customizationProperties=Customization Properties
+CustomizationPropertiesDialog_metamodel=Metamodel
+CustomizationPropertiesDialog_metamodelMustBeSelected=A metamodel must be selected
+CustomizationPropertiesDialog_noMetamodelSelected=No metamodel selected
+CustomizationPropertiesDialog_querySets=Query Sets
+CustomizationViewer_backgroundColor=Background Color
+CustomizationViewer_collapseLink=Collapse Link
+CustomizationViewer_defaultValue=<default value>
+CustomizationViewer_feature=Feature
+CustomizationViewer_hideMetaclassName=Hide Metaclass Name
+CustomizationViewer_typeIcon=Type Icon
+CustomizationViewer_isBold=Is Bold
+CustomizationViewer_isItalic=Is Italic
+CustomizationViewer_isStruckthrough=Is Struckthrough
+CustomizationViewer_isUnderlined=Is Underlined
+CustomizationViewer_isVisible=Is Visible
+CustomizationViewer_metaclassVisible=Visible in Types Panel
+CustomizationViewer_label=Label
+CustomizationViewer_instanceIcon=Instance Icon
+CustomizationViewer_overlayIcon=Overlay Icon
+CustomizationViewer_textColor=Text Color
+CustomizationViewer_textFontName=Text Font Name
+CustomizationViewer_value=Value
+ErrorsDialog_diagnosticMessage={0}\nin: {1}\nline: {2} column: {3}
+ErrorsDialog_errors=Errors
+MetaclassViewToolBar_showDerivedLinks=Show Derived Links
+MetaclassViewToolBar_showFullQualifiedNames=Show Full Qualified Names
+MetaclassViewToolBar_showMultiplicity=Show Multiplicity
+MetaclassViewToolBar_sortLinks=Sort Links
+MetaclassViewToolBar_sortLinksByType=Sort Links by Type
+EditFeatureValueDialog_conditionQueryMustBeSelected=A condition query must be selected
+EditFeatureValueDialog_defaultValue=Default value
+EditFeatureValueDialog_editFeatureValue=Edit Feature Value
+EditFeatureValueDialog_featureValue=Feature value
+EditFeatureValueDialog_noConditionQuerySelected=No condition query selected
+EditFeatureValueDialog_noQuerySelected=No query selected
+EditFeatureValueDialog_queryForCondition=Query for condition
+EditFeatureValueDialog_queryMustBeSelected=A query must be selected
+EditFeatureValueDialog_queryValue=Value computed by a query
+EditFeatureValueDialog_staticValue=Static value
+EditFeatureValueDialog_type=Type

Back to the top