diff options
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.modelexplorer/src/org/eclipse')
3 files changed, 231 insertions, 231 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.modelexplorer/src/org/eclipse/papyrus/uml/diagram/modelexplorer/Activator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.modelexplorer/src/org/eclipse/papyrus/uml/diagram/modelexplorer/Activator.java index 2ba58e159ce..ce6cfca72c0 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.modelexplorer/src/org/eclipse/papyrus/uml/diagram/modelexplorer/Activator.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.modelexplorer/src/org/eclipse/papyrus/uml/diagram/modelexplorer/Activator.java @@ -1,71 +1,71 @@ -/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- *
- * 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:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.modelexplorer;
-
-import org.eclipse.papyrus.infra.core.log.LogHelper;
-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.papyrus.uml.diagram.modelexplorer"; //$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- public static LogHelper log;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- log = new LogHelper(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2011 CEA LIST. + * + * + * 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: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.modelexplorer; + +import org.eclipse.papyrus.infra.core.log.LogHelper; +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.papyrus.uml.diagram.modelexplorer"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + public static LogHelper log; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + log = new LogHelper(this); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.modelexplorer/src/org/eclipse/papyrus/uml/diagram/modelexplorer/handler/DiagramViewHandler.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.modelexplorer/src/org/eclipse/papyrus/uml/diagram/modelexplorer/handler/DiagramViewHandler.java index bbba4b88c37..1ebc2bbd28a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.modelexplorer/src/org/eclipse/papyrus/uml/diagram/modelexplorer/handler/DiagramViewHandler.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.modelexplorer/src/org/eclipse/papyrus/uml/diagram/modelexplorer/handler/DiagramViewHandler.java @@ -1,98 +1,98 @@ -/*****************************************************************************
- * Copyright (c) 2010, 2014 CEA LIST and others.
- *
- *
- * 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:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- * Christian W. Damus (CEA) - bug 434635
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.modelexplorer.handler;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.internal.navigator.filters.UpdateActiveExtensionsOperation;
-import org.eclipse.ui.navigator.CommonNavigator;
-import org.eclipse.ui.navigator.CommonViewer;
-import org.eclipse.ui.navigator.INavigatorContentService;
-
-/**
- * This is a class that launches the button load Customization. this code comes
- * from the {@link LoadCustomizationsDialog}
- */
-public class DiagramViewHandler extends AbstractHandler {
-
- /**
- *
- *
- * @return the common navigator
- */
- protected static CommonNavigator getCommonNavigator() {
- IViewPart part = org.eclipse.papyrus.views.modelexplorer.NavigatorUtils.findViewPart(ModelExplorerPageBookView.VIEW_ID);
- // the part is only a book, retrieving correct page
- if (part instanceof ModelExplorerPageBookView) {
- IViewPart page = ((ModelExplorerPageBookView) part).getActiveView();
- if (page instanceof CommonNavigator) {
- return ((CommonNavigator) page);
- }
- }
- return null;
- }
-
- public static final String DIAGRAM_CONTENTS = "org.eclipse.papyrus.views.modelexplorer.DiagramNavigatorContent";
-
- public static final String UML_MODEL_CONTENTS = "org.eclipse.papyrus.views.modelexplorer.UMLnavigatorContent";
-
- /**
- * {@inheritDoc}
- */
- public Object execute(ExecutionEvent event) throws ExecutionException {
- if (getCommonNavigator() == null || getCommonNavigator().getCommonViewer() == null) {
- return null; // The model explorer is not displayed (The editor is closed?)
- }
-
- CommonViewer viewer = getCommonNavigator().getCommonViewer();
-
- String[] newContents = null;
-
- Object trigger = event.getTrigger();
-
- if (trigger instanceof Event) {
- // State based on the widget
- Event triggerEvent = (Event) trigger;
- if (triggerEvent.widget instanceof ToolItem) {
- if (((ToolItem) triggerEvent.widget).getSelection()) {
- newContents = new String[] { DIAGRAM_CONTENTS };
- } else {
- newContents = new String[] { UML_MODEL_CONTENTS };
- }
- }
- }
-
- if (newContents == null) {
- // Revert the current state
- INavigatorContentService navigatorContent = viewer.getNavigatorContentService();
-
- if (navigatorContent.isActive(DIAGRAM_CONTENTS)) {
- newContents = new String[] { UML_MODEL_CONTENTS };
- } else {
- newContents = new String[] { DIAGRAM_CONTENTS };
- }
- }
-
- UpdateActiveExtensionsOperation updateExtensions = new UpdateActiveExtensionsOperation(viewer, newContents);
- updateExtensions.execute(null, null);
-
- return null;
- }
-}
+/***************************************************************************** + * Copyright (c) 2010, 2014 CEA LIST and others. + * + * + * 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: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * Christian W. Damus (CEA) - bug 434635 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.modelexplorer.handler; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.papyrus.views.modelexplorer.ModelExplorerPageBookView; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.ToolItem; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.internal.navigator.filters.UpdateActiveExtensionsOperation; +import org.eclipse.ui.navigator.CommonNavigator; +import org.eclipse.ui.navigator.CommonViewer; +import org.eclipse.ui.navigator.INavigatorContentService; + +/** + * This is a class that launches the button load Customization. this code comes + * from the {@link LoadCustomizationsDialog} + */ +public class DiagramViewHandler extends AbstractHandler { + + /** + * + * + * @return the common navigator + */ + protected static CommonNavigator getCommonNavigator() { + IViewPart part = org.eclipse.papyrus.views.modelexplorer.NavigatorUtils.findViewPart(ModelExplorerPageBookView.VIEW_ID); + // the part is only a book, retrieving correct page + if (part instanceof ModelExplorerPageBookView) { + IViewPart page = ((ModelExplorerPageBookView) part).getActiveView(); + if (page instanceof CommonNavigator) { + return ((CommonNavigator) page); + } + } + return null; + } + + public static final String DIAGRAM_CONTENTS = "org.eclipse.papyrus.views.modelexplorer.DiagramNavigatorContent"; + + public static final String UML_MODEL_CONTENTS = "org.eclipse.papyrus.views.modelexplorer.UMLnavigatorContent"; + + /** + * {@inheritDoc} + */ + public Object execute(ExecutionEvent event) throws ExecutionException { + if (getCommonNavigator() == null || getCommonNavigator().getCommonViewer() == null) { + return null; // The model explorer is not displayed (The editor is closed?) + } + + CommonViewer viewer = getCommonNavigator().getCommonViewer(); + + String[] newContents = null; + + Object trigger = event.getTrigger(); + + if (trigger instanceof Event) { + // State based on the widget + Event triggerEvent = (Event) trigger; + if (triggerEvent.widget instanceof ToolItem) { + if (((ToolItem) triggerEvent.widget).getSelection()) { + newContents = new String[] { DIAGRAM_CONTENTS }; + } else { + newContents = new String[] { UML_MODEL_CONTENTS }; + } + } + } + + if (newContents == null) { + // Revert the current state + INavigatorContentService navigatorContent = viewer.getNavigatorContentService(); + + if (navigatorContent.isActive(DIAGRAM_CONTENTS)) { + newContents = new String[] { UML_MODEL_CONTENTS }; + } else { + newContents = new String[] { DIAGRAM_CONTENTS }; + } + } + + UpdateActiveExtensionsOperation updateExtensions = new UpdateActiveExtensionsOperation(viewer, newContents); + updateExtensions.execute(null, null); + + return null; + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.modelexplorer/src/org/eclipse/papyrus/uml/diagram/modelexplorer/provider/DiagramContentProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.modelexplorer/src/org/eclipse/papyrus/uml/diagram/modelexplorer/provider/DiagramContentProvider.java index bc595c1ec40..a93ef175c5b 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.modelexplorer/src/org/eclipse/papyrus/uml/diagram/modelexplorer/provider/DiagramContentProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.modelexplorer/src/org/eclipse/papyrus/uml/diagram/modelexplorer/provider/DiagramContentProvider.java @@ -1,62 +1,62 @@ -/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- *
- * 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:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.modelexplorer.provider;
-
-import java.util.ArrayList;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.infra.core.resource.ModelUtils;
-import org.eclipse.papyrus.infra.core.sashwindows.di.service.IPageManager;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.ui.emf.providers.MoDiscoContentProvider;
-import org.eclipse.papyrus.uml.diagram.modelexplorer.Activator;
-
-/**
- *
- * this content provider is used to display diagrams and their contents
- *
- */
-@Deprecated
-public class DiagramContentProvider extends MoDiscoContentProvider {
-
- @Override
- public EObject[] getRootElements(Object inputElement) {
-
- try {
- if (!(inputElement instanceof ServicesRegistry)) {
- return null;
- }
-
- ServicesRegistry servicesRegistry = (ServicesRegistry) inputElement;
-
- modelSet = ModelUtils.getModelSetChecked(servicesRegistry);
- pageMngr = servicesRegistry.getService(IPageManager.class);
-
- ArrayList<EObject> result = new ArrayList<EObject>();
- for (int i = 0; i < pageMngr.allPages().size(); i++) {
- if (pageMngr.allPages().get(i) instanceof EObject) {
- result.add((EObject) pageMngr.allPages().get(i));
- }
- }
-
- EObject[] eObject = new EObject[result.size()];
- return result.toArray(eObject);
-
- } catch (Exception e) {
- Activator.log.error(e);
- }
-
- return new EObject[0];
- }
-}
+/***************************************************************************** + * Copyright (c) 2011 CEA LIST. + * + * + * 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: + * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.modelexplorer.provider; + +import java.util.ArrayList; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.infra.core.resource.ModelUtils; +import org.eclipse.papyrus.infra.core.sashwindows.di.service.IPageManager; +import org.eclipse.papyrus.infra.core.services.ServicesRegistry; +import org.eclipse.papyrus.infra.ui.emf.providers.MoDiscoContentProvider; +import org.eclipse.papyrus.uml.diagram.modelexplorer.Activator; + +/** + * + * this content provider is used to display diagrams and their contents + * + */ +@Deprecated +public class DiagramContentProvider extends MoDiscoContentProvider { + + @Override + public EObject[] getRootElements(Object inputElement) { + + try { + if (!(inputElement instanceof ServicesRegistry)) { + return null; + } + + ServicesRegistry servicesRegistry = (ServicesRegistry) inputElement; + + modelSet = ModelUtils.getModelSetChecked(servicesRegistry); + pageMngr = servicesRegistry.getService(IPageManager.class); + + ArrayList<EObject> result = new ArrayList<EObject>(); + for (int i = 0; i < pageMngr.allPages().size(); i++) { + if (pageMngr.allPages().get(i) instanceof EObject) { + result.add((EObject) pageMngr.allPages().get(i)); + } + } + + EObject[] eObject = new EObject[result.size()]; + return result.toArray(eObject); + + } catch (Exception e) { + Activator.log.error(e); + } + + return new EObject[0]; + } +} |