summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Maggi2014-05-07 11:06:30 (EDT)
committerCamille Letavernier2014-05-15 04:59:59 (EDT)
commit7236353467d7e25aaa919dbad2c73f3adc07da31 (patch)
tree7be0ffe3b44ae56266aa7d0f70672120b9f26a74
parent9b2d887216b5d51b2af149ff0de5f6f62563f54c (diff)
downloadorg.eclipse.papyrus-7236353467d7e25aaa919dbad2c73f3adc07da31.zip
org.eclipse.papyrus-7236353467d7e25aaa919dbad2c73f3adc07da31.tar.gz
org.eclipse.papyrus-7236353467d7e25aaa919dbad2c73f3adc07da31.tar.bz2
Clean - Remove deprecated references to SashModel.MODEL_FILE_EXTENSIONrefs/changes/47/26147/2
Change-Id: Ibee1048c9472c9b6a64f3d09fdf95fbd12a3af72 Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
-rw-r--r--tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/DiagramUtils.java241
-rw-r--r--tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/PapyrusProjectUtils.java164
2 files changed, 201 insertions, 204 deletions
diff --git a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/DiagramUtils.java b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/DiagramUtils.java
index d86a002..1e0fa14 100644
--- a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/DiagramUtils.java
+++ b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/DiagramUtils.java
@@ -1,122 +1,119 @@
-/*****************************************************************************
- * Copyright (c) 2014 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:
- * CEA LIST - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.junit.utils;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.Shape;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
-import org.eclipse.papyrus.infra.core.resource.AbstractBaseModel;
-import org.eclipse.papyrus.infra.core.resource.IModel;
-import org.eclipse.papyrus.infra.core.resource.ModelSet;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.uml2.uml.NamedElement;
-import org.junit.Assert;
-
-/**
- * Utility class for diagrams
- */
-public class DiagramUtils {
-
- public static IGraphicalEditPart findEditPartforView(IMultiDiagramEditor papyrusEditor, View view, Class<? extends EditPart> editPartClass) {
- DiagramEditPart diagramEditPart = findDiagramEditPart(papyrusEditor);
- Object part = diagramEditPart.getViewer().getEditPartRegistry().get(view);
- Assert.assertNotNull("Cannot find the edit part", part);
- Assert.assertNotNull("part has not the right class", editPartClass.isAssignableFrom(part.getClass()));
- return (IGraphicalEditPart) part;
- }
-
- public static DiagramEditPart findDiagramEditPart(IMultiDiagramEditor papyrusEditor) {
- DiagramEditPart diagramEditPart = (DiagramEditPart) papyrusEditor.getAdapter(DiagramEditPart.class);
- Assert.assertNotNull("Cannot find the Diagram edit part", diagramEditPart);
- return diagramEditPart;
- }
-
- /**
- * Search and returns the first view in the specified container view with the given name
- *
- * @param container
- * the view container of the searched view
- * @param elementName
- * the name of the element represented by the search view
- * @return the found view or <code>null</code> if none was found
- */
- public static Shape findShape(View container, String elementName) {
- for (Object viewObject : container.getChildren()) {
- View view = (View) viewObject;
- if (view instanceof Shape && view.getElement() instanceof NamedElement) {
- NamedElement element = (NamedElement) view.getElement();
- if (elementName.equals(element.getName())) {
- return (Shape) view;
- }
- }
- }
-
- // Assert.fail("Cannot find the view associated to " + elementName);
- return null;
- }
-
- /**
- * Returns the int corresponding to the given tuple
- *
- * @param red
- * @param green
- * @param blue
- * @return
- */
- public static int rgb(int red, int green, int blue) {
- return red | green << 8 | blue << 16;
- }
-
- public static RGB integerToRGB(int value) {
- int blue = value & 255;
- int green = (value >> 8) & 255;
- int red = (value >> 16) & 255;
- return new RGB(red, green, blue);
- }
-
- public static String integerToRGBString(int value) {
- RGB rgb = integerToRGB(value);
- return rgb.toString();
-
- }
-
- public static Diagram getNotationDiagram(ModelSet modelSet, String string) {
- IModel notationModel = modelSet.getModel(NotationModel.MODEL_ID);
-
- AbstractBaseModel notationBaseModel = null;
- if (notationModel instanceof AbstractBaseModel) {
- notationBaseModel = (AbstractBaseModel) notationModel;
- } else {
- Assert.fail("notation model is not an abstract base model");
- return null;
- }
- Assert.assertTrue("notation resource contains nothing", notationBaseModel.getResource().getContents().size() >= 1);
- for (EObject object : notationBaseModel.getResource().getContents()) {
- if (object instanceof Diagram && string.equals(((Diagram) object).getName())) {
- return (Diagram) object;
- }
- }
- return null;
- }
-
-
-
-}
+/*****************************************************************************
+ * Copyright (c) 2014 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.junit.utils;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Shape;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.infra.core.resource.AbstractBaseModel;
+import org.eclipse.papyrus.infra.core.resource.IModel;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.uml2.uml.NamedElement;
+import org.junit.Assert;
+
+/**
+ * Utility class for diagrams
+ */
+public class DiagramUtils {
+
+ public static IGraphicalEditPart findEditPartforView(IMultiDiagramEditor papyrusEditor, View view, Class<? extends EditPart> editPartClass) {
+ DiagramEditPart diagramEditPart = findDiagramEditPart(papyrusEditor);
+ Object part = diagramEditPart.getViewer().getEditPartRegistry().get(view);
+ Assert.assertNotNull("Cannot find the edit part", part);
+ Assert.assertNotNull("part has not the right class", editPartClass.isAssignableFrom(part.getClass()));
+ return (IGraphicalEditPart) part;
+ }
+
+ public static DiagramEditPart findDiagramEditPart(IMultiDiagramEditor papyrusEditor) {
+ DiagramEditPart diagramEditPart = (DiagramEditPart) papyrusEditor.getAdapter(DiagramEditPart.class);
+ Assert.assertNotNull("Cannot find the Diagram edit part", diagramEditPart);
+ return diagramEditPart;
+ }
+
+ /**
+ * Search and returns the first view in the specified container view with the given name
+ *
+ * @param container
+ * the view container of the searched view
+ * @param elementName
+ * the name of the element represented by the search view
+ * @return the found view or <code>null</code> if none was found
+ */
+ public static Shape findShape(View container, String elementName) {
+ for (Object viewObject : container.getChildren()) {
+ View view = (View) viewObject;
+ if (view instanceof Shape && view.getElement() instanceof NamedElement) {
+ NamedElement element = (NamedElement) view.getElement();
+ if (elementName.equals(element.getName())) {
+ return (Shape) view;
+ }
+ }
+ }
+
+ // Assert.fail("Cannot find the view associated to " + elementName);
+ return null;
+ }
+
+ /**
+ * Returns the int corresponding to the given tuple
+ *
+ * @param red
+ * @param green
+ * @param blue
+ * @return
+ */
+ public static int rgb(int red, int green, int blue) {
+ return red | green << 8 | blue << 16;
+ }
+
+ public static RGB integerToRGB(int value) {
+ int blue = value & 255;
+ int green = (value >> 8) & 255;
+ int red = (value >> 16) & 255;
+ return new RGB(red, green, blue);
+ }
+
+ public static String integerToRGBString(int value) {
+ RGB rgb = integerToRGB(value);
+ return rgb.toString();
+
+ }
+
+ public static Diagram getNotationDiagram(ModelSet modelSet, String string) {
+ IModel notationModel = modelSet.getModel(NotationModel.MODEL_ID);
+
+ AbstractBaseModel notationBaseModel = null;
+ if (notationModel instanceof AbstractBaseModel) {
+ notationBaseModel = (AbstractBaseModel) notationModel;
+ } else {
+ Assert.fail("notation model is not an abstract base model"); //$NON-NLS-1$
+ return null;
+ }
+ Assert.assertTrue("notation resource contains nothing", notationBaseModel.getResource().getContents().size() >= 1); //$NON-NLS-1$
+ for (EObject object : notationBaseModel.getResource().getContents()) {
+ if (object instanceof Diagram && string.equals(((Diagram) object).getName())) {
+ return (Diagram) object;
+ }
+ }
+ return null;
+ }
+
+
+
+}
diff --git a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/PapyrusProjectUtils.java b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/PapyrusProjectUtils.java
index 10bdf5a..d920584 100644
--- a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/PapyrusProjectUtils.java
+++ b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/PapyrusProjectUtils.java
@@ -1,82 +1,82 @@
-/*****************************************************************************
- * Copyright (c) 2012 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:
- * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.junit.utils;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.papyrus.infra.core.resource.sasheditor.SashModel;
-import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel;
-import org.eclipse.papyrus.uml.tools.model.UmlModel;
-import org.junit.Assert;
-import org.osgi.framework.Bundle;
-
-public class PapyrusProjectUtils {
-
- private PapyrusProjectUtils() {
- //to prevent instanciation
- }
-
- /**
- *
- * @param project
- * @param bundle
- * @param sourcePath
- * should be something like /model/
- * @param fileRootName
- * @throws IOException
- * @throws CoreException
- */
- public static final IFile copyPapyrusModel(final IProject project, final Bundle bundle, final String sourcePath, final String fileRootName) throws CoreException, IOException {
-
- String diSourcePath = sourcePath + fileRootName + "." + SashModel.MODEL_FILE_EXTENSION;
- String notationSourcePath = sourcePath + fileRootName + "." + NotationModel.NOTATION_FILE_EXTENSION;
- String umlSourcePath = sourcePath + fileRootName + "." + UmlModel.UML_FILE_EXTENSION;
-
- final IFile emptyModel_di = copyIFile(diSourcePath, bundle, project, fileRootName + "." + SashModel.MODEL_FILE_EXTENSION);
- copyIFile(notationSourcePath, bundle, project, fileRootName + "." + NotationModel.NOTATION_FILE_EXTENSION);
- copyIFile(umlSourcePath, bundle, project, fileRootName + "." + UmlModel.UML_FILE_EXTENSION);
-
- return emptyModel_di;
- }
-
- public static IFile copyIFile(String sourcePath, Bundle sourceBundle, IProject targetProject, String targetFileName) throws CoreException, IOException {
- final IFile createdFile = targetProject.getFile(targetFileName);
- if(createdFile.getParent() instanceof IFolder) {
- createRecursiveFolder((IFolder)createdFile.getParent());
- }
- URL bundleResource = sourceBundle.getResource(sourcePath);
- Assert.assertNotNull("Cannot find bundle resource: " + sourcePath, bundleResource);
- InputStream bundleResourceStream = bundleResource.openStream();
- createdFile.create(bundleResourceStream, true, new NullProgressMonitor());
- return createdFile;
- }
-
- public static void createRecursiveFolder(IFolder folderToCreate) throws CoreException {
- if(folderToCreate.exists()) {
- return;
- }
-
- if(folderToCreate.getParent() instanceof IFolder) {
- createRecursiveFolder((IFolder)folderToCreate.getParent());
- }
- folderToCreate.create(true, true, new NullProgressMonitor());
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2012 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:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.junit.utils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel;
+import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel;
+import org.eclipse.papyrus.uml.tools.model.UmlModel;
+import org.junit.Assert;
+import org.osgi.framework.Bundle;
+
+public class PapyrusProjectUtils {
+
+ private PapyrusProjectUtils() {
+ //to prevent instanciation
+ }
+
+ /**
+ *
+ * @param project
+ * @param bundle
+ * @param sourcePath
+ * should be something like /model/
+ * @param fileRootName
+ * @throws IOException
+ * @throws CoreException
+ */
+ public static final IFile copyPapyrusModel(final IProject project, final Bundle bundle, final String sourcePath, final String fileRootName) throws CoreException, IOException {
+
+ String diSourcePath = sourcePath + fileRootName + "." + DiModel.MODEL_FILE_EXTENSION;
+ String notationSourcePath = sourcePath + fileRootName + "." + NotationModel.NOTATION_FILE_EXTENSION;
+ String umlSourcePath = sourcePath + fileRootName + "." + UmlModel.UML_FILE_EXTENSION;
+
+ final IFile emptyModel_di = copyIFile(diSourcePath, bundle, project, fileRootName + "." + DiModel.MODEL_FILE_EXTENSION);
+ copyIFile(notationSourcePath, bundle, project, fileRootName + "." + NotationModel.NOTATION_FILE_EXTENSION);
+ copyIFile(umlSourcePath, bundle, project, fileRootName + "." + UmlModel.UML_FILE_EXTENSION);
+
+ return emptyModel_di;
+ }
+
+ public static IFile copyIFile(String sourcePath, Bundle sourceBundle, IProject targetProject, String targetFileName) throws CoreException, IOException {
+ final IFile createdFile = targetProject.getFile(targetFileName);
+ if(createdFile.getParent() instanceof IFolder) {
+ createRecursiveFolder((IFolder)createdFile.getParent());
+ }
+ URL bundleResource = sourceBundle.getResource(sourcePath);
+ Assert.assertNotNull("Cannot find bundle resource: " + sourcePath, bundleResource);
+ InputStream bundleResourceStream = bundleResource.openStream();
+ createdFile.create(bundleResourceStream, true, new NullProgressMonitor());
+ return createdFile;
+ }
+
+ public static void createRecursiveFolder(IFolder folderToCreate) throws CoreException {
+ if(folderToCreate.exists()) {
+ return;
+ }
+
+ if(folderToCreate.getParent() instanceof IFolder) {
+ createRecursiveFolder((IFolder)folderToCreate.getParent());
+ }
+ folderToCreate.create(true, true, new NullProgressMonitor());
+ }
+}