Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-11-23 10:52:23 +0000
committercletavernie2012-11-23 10:52:23 +0000
commit6424abf6e7e922c90a56eec84fd3f9b2de9dfae5 (patch)
tree8d3239a03710422cba8493b4dbe9ee2bb9aeda71 /plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src
parentc7ed19562dfcf443385c0213765c98ffc841409f (diff)
downloadorg.eclipse.papyrus-6424abf6e7e922c90a56eec84fd3f9b2de9dfae5.tar.gz
org.eclipse.papyrus-6424abf6e7e922c90a56eec84fd3f9b2de9dfae5.tar.xz
org.eclipse.papyrus-6424abf6e7e922c90a56eec84fd3f9b2de9dfae5.zip
391945: [Refactoring] Part 2: Refactoring on Kepler (0.10)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=391945
Diffstat (limited to 'plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/Activator.java4
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/CreateDiagramWithNavigationHandler.java24
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/utils/MultiDiagramDialog.java163
3 files changed, 24 insertions, 167 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/Activator.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/Activator.java
index e900603edc5..4f62d238078 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/Activator.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/Activator.java
@@ -12,6 +12,7 @@
*/
package org.eclipse.papyrus.infra.gmfdiag.navigation;
+import org.eclipse.papyrus.infra.core.log.LogHelper;
import org.eclipse.papyrus.infra.gmfdiag.navigation.preference.NavigationPreferenceInitializer;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
@@ -27,6 +28,8 @@ public class Activator extends AbstractUIPlugin {
// The shared instance
private static Activator plugin;
+ public static LogHelper log;
+
/**
* The constructor
*/
@@ -43,6 +46,7 @@ public class Activator extends AbstractUIPlugin {
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
+ log = new LogHelper(this);
NavigationPreferenceInitializer preferenceInitializer = new NavigationPreferenceInitializer();
preferenceInitializer.initializeDefaultPreferences();
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/CreateDiagramWithNavigationHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/CreateDiagramWithNavigationHandler.java
index 1d8e7bde33b..3f06d81d76b 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/CreateDiagramWithNavigationHandler.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/CreateDiagramWithNavigationHandler.java
@@ -29,8 +29,11 @@ import org.eclipse.papyrus.commands.ICreationCommand;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.core.extension.commands.ICreationCondition;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
-import org.eclipse.papyrus.infra.core.utils.EditorUtils;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
import org.eclipse.papyrus.infra.emf.utils.BusinessModelResolver;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForHandlers;
import org.eclipse.papyrus.infra.widgets.toolbox.dialog.InformationDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
@@ -64,12 +67,19 @@ public abstract class CreateDiagramWithNavigationHandler extends AbstractHandler
public Object execute(ExecutionEvent event) throws ExecutionException {
NavigableElement navElement = getNavigableElementWhereToCreateDiagram();
+ ServicesRegistry registry;
+ try {
+ registry = ServiceUtilsForHandlers.getInstance().getServiceRegistry(event);
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ return null;
+ }
if(navElement == null) {
InformationDialog dialog = new InformationDialog(Display.getCurrent().getActiveShell(), "Impossible diagram creation", "It is not possible to create this diagram on the selected element.", null, null, SWT.OK, MessageDialog.WARNING, new String[]{ IDialogConstants.OK_LABEL });
dialog.open();
} else {
- createDiagram(navElement);
+ createDiagram(navElement, registry);
}
return null;
}
@@ -98,8 +108,14 @@ public abstract class CreateDiagramWithNavigationHandler extends AbstractHandler
return null;
}
- private void createDiagram(NavigableElement navElement) {
- ModelSet modelSet = EditorUtils.getDiResourceSet();
+ private void createDiagram(NavigableElement navElement, ServicesRegistry registry) {
+ ModelSet modelSet;
+ try {
+ modelSet = ServiceUtils.getInstance().getModelSet(registry);
+ } catch (ServiceException ex) {
+ Activator.log.error(ex);
+ return;
+ }
if(navElement != null && modelSet != null) {
try {
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/utils/MultiDiagramDialog.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/utils/MultiDiagramDialog.java
deleted file mode 100644
index 417190b7159..00000000000
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.navigation/src/org/eclipse/papyrus/infra/gmfdiag/navigation/utils/MultiDiagramDialog.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 AtoS
- * 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:
- * Anass RADOUANI (AtoS)
- *******************************************************************************/
-
-package org.eclipse.papyrus.infra.gmfdiag.navigation.utils;
-
-import java.util.List;
-
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageMngr;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.utils.EditorUtils;
-import org.eclipse.papyrus.views.modelexplorer.MoDiscoLabelProvider;
-import org.eclipse.swt.SWT;
-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.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-
-/**
- * This class Provide a dialog filled with a list of reachable diagrams
- *
- * @author aradouan
- *
- */
-public class MultiDiagramDialog extends Dialog {
-
- private List<Diagram> diagrams;
-
- private Composite dialogComposite;
-
- protected int selectedDiagram;
-
- private Table table;
-
- private TableViewer list;
-
- public int getSelectedDiagram() {
- return selectedDiagram;
- }
-
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(Messages.MultiDiagramDialog_0);
- }
-
- public MultiDiagramDialog(Shell parentShell, List<Diagram> diagrams) {
- super(parentShell);
- this.diagrams = diagrams;
- setShellStyle(getShellStyle() | SWT.RESIZE);
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- dialogComposite = (Composite)super.createDialogArea(parent);
- parent.setLayout(new GridLayout());
- dialogComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- createDialogComposite();
- createDialogContents(dialogComposite);
- hookListeners();
- loadData();
- defaultSelection();
-
- return dialogComposite;
- }
-
- private void createDialogContents(Composite parent) {
- dialogComposite.setLayout(new GridLayout(1, false));
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new FillLayout(SWT.HORIZONTAL));
- composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
-
- Label lblDiagrams = new Label(composite, SWT.NONE);
- lblDiagrams.setText(Messages.MultiDiagramDialog_1);
-
- Composite composite_1 = new Composite(parent, SWT.NONE);
- composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
- composite_1.setLayout(new GridLayout(1, false));
-
- list = new TableViewer(composite_1, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
- list.setUseHashlookup(true);
- table = list.getTable();
- table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
- list.setLabelProvider(new MoDiscoLabelProvider());
- list.setContentProvider(new IStructuredContentProvider() {
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- public void dispose() {
- }
-
- public Object[] getElements(Object inputElement) {
- if(inputElement instanceof List) {
- return ((List)inputElement).toArray();
- } else {
- return new Object[]{ inputElement };
- }
- }
- });
- }
-
- private void createDialogComposite() {
- GridData dialogLayoutData = new GridData(GridData.FILL_BOTH);
- dialogComposite.setLayoutData(dialogLayoutData);
-
- }
-
- private void hookListeners() {
- table.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- MultiDiagramDialog.this.selectedDiagram = table.getSelectionIndex();
- }
-
- });
- }
-
- private void loadData() {
- list.setInput(diagrams);
- }
-
- private void defaultSelection() {
- boolean found = false;
- IPageMngr pageMngr;
- try {
- pageMngr = EditorUtils.getServiceRegistry().getService(IPageMngr.class);
-
- for(Diagram diagram : diagrams) {
- if(pageMngr.isOpen(diagram)) {
- table.select(diagrams.indexOf(diagram));
- found = true;
- break;
- }
- }
- } catch (ServiceException e) {
- e.printStackTrace();
- }
-
- if(!found) {
- table.select(0);
- }
- }
-}

Back to the top