diff options
Diffstat (limited to 'plugins/uml/org.eclipse.papyrus.uml.profile')
53 files changed, 31 insertions, 9116 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/META-INF/MANIFEST.MF b/plugins/uml/org.eclipse.papyrus.uml.profile/META-INF/MANIFEST.MF index 65d60ea8a23..97e86488e5a 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/META-INF/MANIFEST.MF +++ b/plugins/uml/org.eclipse.papyrus.uml.profile/META-INF/MANIFEST.MF @@ -1,27 +1,21 @@ Manifest-Version: 1.0
Require-Bundle: org.eclipse.uml2.uml.editor,
- org.eclipse.papyrus.uml.extensionpoints;bundle-version="0.9.0",
- org.eclipse.gmf.runtime.diagram.ui.properties;bundle-version="1.1.0",
org.eclipse.emf.facet.infra.browser.uicore;bundle-version="0.1.0",
org.eclipse.papyrus.infra.core;bundle-version="0.9.0",
- org.eclipse.papyrus.uml.tools.utils;bundle-version="0.9.0"
+ org.eclipse.papyrus.uml.tools.utils;bundle-version="0.9.0",
+ org.eclipse.core.runtime;bundle-version="3.8.0",
+ org.eclipse.emf.transaction;bundle-version="1.4.0",
+ org.eclipse.papyrus.uml.extensionpoints;bundle-version="0.9.0",
+ org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.200"
Export-Package: org.eclipse.papyrus.uml.profile,
org.eclipse.papyrus.uml.profile.constraints,
org.eclipse.papyrus.uml.profile.definition,
- org.eclipse.papyrus.uml.profile.filter,
org.eclipse.papyrus.uml.profile.preference,
org.eclipse.papyrus.uml.profile.structure,
org.eclipse.papyrus.uml.profile.tree,
org.eclipse.papyrus.uml.profile.tree.objects,
- org.eclipse.papyrus.uml.profile.ui.actions,
- org.eclipse.papyrus.uml.profile.ui.compositeforview,
- org.eclipse.papyrus.uml.profile.ui.compositesformodel,
org.eclipse.papyrus.uml.profile.ui.dialogs,
org.eclipse.papyrus.uml.profile.ui.items,
- org.eclipse.papyrus.uml.profile.ui.listeners,
- org.eclipse.papyrus.uml.profile.ui.panels,
- org.eclipse.papyrus.uml.profile.ui.section,
- org.eclipse.papyrus.uml.profile.ui.views,
org.eclipse.papyrus.uml.profile.utils,
org.eclipse.papyrus.uml.profile.wizard
Bundle-Vendor: %providerName
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/plugin.xml b/plugins/uml/org.eclipse.papyrus.uml.profile/plugin.xml index 436cadb0382..f36bfd8e4af 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/plugin.xml +++ b/plugins/uml/org.eclipse.papyrus.uml.profile/plugin.xml @@ -6,7 +6,7 @@ <constraintProvider
cache="true">
<package
- namespaceUri="http://www.eclipse.org/uml2/2.1.0/UML">
+ namespaceUri="http://www.eclipse.org/uml2/4.0.0/UML">
</package>
<constraints
categories="org.eclipse.papyrus.infra.services.validation.CategoryID/UMLProfile">
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/filter/AppliedProfileSectionFilter.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/filter/AppliedProfileSectionFilter.java deleted file mode 100644 index 6e48cbc8b7c..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/filter/AppliedProfileSectionFilter.java +++ /dev/null @@ -1,66 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.filter;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.properties.filters.ShapeEditPartPropertySectionFilter;
-import org.eclipse.uml2.uml.Package;
-
-public class AppliedProfileSectionFilter extends ShapeEditPartPropertySectionFilter {
-
- public boolean select(Object object) {
- if(object instanceof ShapeEditPart) {
- if(((ShapeEditPart)object).resolveSemanticElement() != null && ((ShapeEditPart)object).resolveSemanticElement() instanceof org.eclipse.uml2.uml.Package) {
- return true;
- }
- } else if(object instanceof DiagramEditPart) {
- DiagramEditPart diagramEditPart = (DiagramEditPart)object;
- if(diagramEditPart.resolveSemanticElement() != null && diagramEditPart.resolveSemanticElement() instanceof org.eclipse.uml2.uml.Package) {
- return true;
- }
-
-
- }
- EObject eobject=resolveSemanticObject(object);
- if(eobject!=null && eobject instanceof Package) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Resolve semantic element
- *
- * @param object
- * the object to resolve
- * @return <code>null</code> or the semantic element associated to the specified object
- */
- private EObject resolveSemanticObject(Object object) {
- if (object instanceof EObject) {
- return (EObject) object;
- } else if (object instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable) object;
- if (adaptable.getAdapter(EObject.class) != null) {
- return (EObject) adaptable.getAdapter(EObject.class);
- }
- }
- return null;
- }
-
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/filter/AppliedStereotypeSectionFilter.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/filter/AppliedStereotypeSectionFilter.java deleted file mode 100644 index 81cca93f62f..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/filter/AppliedStereotypeSectionFilter.java +++ /dev/null @@ -1,73 +0,0 @@ -/*******************************************************************************
- * Copyright (c) 2009 Obeo.
- * 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:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.papyrus.uml.profile.filter;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.properties.filters.ShapeEditPartPropertySectionFilter;
-import org.eclipse.uml2.uml.Element;
-
-/**
- * This filter is used to check if stereotypes are applicable on the selected Element.
- *
- * @author <a href="mailto:jerome.benois@obeo.fr">Jerome Benois</a>
- */
-public class AppliedStereotypeSectionFilter extends ShapeEditPartPropertySectionFilter {
-
- public boolean select(Object object) {
- if(object instanceof ShapeEditPart) {
- if(((ShapeEditPart)object).resolveSemanticElement() != null && ((ShapeEditPart)object).resolveSemanticElement() instanceof org.eclipse.uml2.uml.Element) {
- return true;
- }
- } else if(object instanceof ConnectionNodeEditPart) {
- if(((ConnectionNodeEditPart)object).resolveSemanticElement() instanceof org.eclipse.uml2.uml.Element) {
- return true;
- }
- } else if(object instanceof CompartmentEditPart) {
- if(((CompartmentEditPart)object).resolveSemanticElement() instanceof org.eclipse.uml2.uml.Element) {
- return true;
- }
- } else if(object instanceof DiagramEditPart) {
- DiagramEditPart diagramEditPart = (DiagramEditPart)object;
- if(diagramEditPart.resolveSemanticElement() != null && diagramEditPart.resolveSemanticElement() instanceof Element) {
- return true;
- }
- }
- EObject eobject=resolveSemanticObject(object);
- if(eobject!=null && eobject instanceof Element) {
- return true;
- }
- return false;
- }
-
- /**
- * Resolve semantic element
- *
- * @param object
- * the object to resolve
- * @return <code>null</code> or the semantic element associated to the specified object
- */
- private EObject resolveSemanticObject(Object object) {
- if (object instanceof EObject) {
- return (EObject) object;
- } else if (object instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable) object;
- if (adaptable.getAdapter(EObject.class) != null) {
- return (EObject) adaptable.getAdapter(EObject.class);
- }
- }
- return null;
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/filter/CompartmentEditPartPropertySectionFilter.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/filter/CompartmentEditPartPropertySectionFilter.java deleted file mode 100644 index c73b2a09a2b..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/filter/CompartmentEditPartPropertySectionFilter.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************
- * Copyright (c) 2009 IBM Corporation 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:
- * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - initial API and implementation
- ****************************************************************************/
-
-package org.eclipse.papyrus.uml.profile.filter;
-
-import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
-import org.eclipse.jface.viewers.IFilter;
-
-/**
- * Filter to display a property section if the selection is a compartment edit part.
- */
-public class CompartmentEditPartPropertySectionFilter implements IFilter {
-
- /**
- * {@inheritDoc}
- */
- public boolean select(Object object) {
- if(object instanceof CompartmentEditPart)
- return true;
-
- return false;
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/AbstractPackageImportAction.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/AbstractPackageImportAction.java deleted file mode 100644 index f91328809b5..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/AbstractPackageImportAction.java +++ /dev/null @@ -1,108 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- * Ansgar Radermacher (CEA LIST) Ansgar.Radermacher@cea.fr - minor modifications
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.actions;
-
-import org.eclipse.emf.common.command.CommandStack;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.transaction.util.TransactionUtil;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.uml2.common.edit.command.ChangeCommand;
-import org.eclipse.uml2.uml.Package;
-
-/**
- * Abstract command for all package import for registered elements actions
- */
-public abstract class AbstractPackageImportAction extends AbstractViewActionDelegate {
-
- /** current selection */
- protected Package selectedElement;
-
- /** stored instance of the command */
- protected ChangeCommand command;
-
- @Override
- public void init(IViewPart view) {
- super.init(view);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Package getSelectedElement() {
- return selectedElement;
- }
-
- /**
- * Returns <code>true</code> if the element is a Package
- *
- * @param element
- * the element to test
- * @return <code>true</code> if the element is a Package
- */
- @Override
- protected boolean isSelectableElement(Object element) {
- return (element instanceof Package);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setSelectedElement(Object selectedElement) {
- if(selectedElement instanceof Package) {
- this.selectedElement = (Package)selectedElement;
- }
- else {
- this.selectedElement = null;
- }
- }
-
- /**
- * Returns <code>true</code> if the action can be executed
- *
- * @return <code>true</code> if the action can be executed
- */
- public boolean canExecute() {
- if (selectedElement != null) {
- EditingDomain editingDomain = TransactionUtil.getEditingDomain(selectedElement);
- return getCommand(editingDomain).canExecute();
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run(IAction action) {
- if (selectedElement != null) {
- EditingDomain editingDomain = TransactionUtil.getEditingDomain(selectedElement);
- CommandStack stack = editingDomain.getCommandStack ();
- stack.execute (getCommand(editingDomain));
- }
- }
-
- /**
- * returns the command that is executed by this action.
- *
- * @param domain
- * EMF editing domain used by the command
- * @return the command that is executed by this action
- */
- public abstract ChangeCommand getCommand(EditingDomain domain);
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/AbstractViewActionDelegate.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/AbstractViewActionDelegate.java deleted file mode 100644 index 9c18040619f..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/AbstractViewActionDelegate.java +++ /dev/null @@ -1,108 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 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: - * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation - * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.profile.ui.actions; - -import java.util.Iterator; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IViewActionDelegate; -import org.eclipse.ui.IViewPart; -import org.eclipse.uml2.uml.Element; - -/** - * Action delegate default implementation for this plugin. Is is based on a - * selection of a {@link Element}. - */ -public abstract class AbstractViewActionDelegate implements IViewActionDelegate { - - /** current selection */ - protected Element selectedElement; - - /** - * {@inheritDoc} - */ - public void init(IViewPart view) { - } - - /** - * {@inheritDoc} - */ - public abstract void run(IAction action); - - /** - * Returns <code>true</code> if the element is a selectableElement, i.e. if the action - * should be enabled - * - * @param element - * the element to test - * @return <code>true</code> if the element can be selected - */ - protected boolean isSelectableElement(Object o) { - return (o instanceof Element); - } - - /** - * {@inheritDoc} - */ - public void selectionChanged(IAction action, ISelection selection) { - IStructuredSelection structSelection = null; - if(selection instanceof IStructuredSelection) { - structSelection = (IStructuredSelection)selection; - // iterate the selection to update the selected element - @SuppressWarnings("unchecked") - Iterator<Object> it = structSelection.iterator(); - while(it.hasNext()) { - Object o = (Object)it.next(); - if (o instanceof IAdaptable) { - EObject eObject = (EObject) ((IAdaptable) o) - .getAdapter(EObject.class); - if (eObject != null) { - setSelectedElement(eObject); - } - } - if(isSelectableElement(o)) { - setSelectedElement(o); - return; - } - } - } - } - - /** - * Sets the current selected element - * - * @param selectedElement - * the new selected element - */ - protected void setSelectedElement(Object selectedElement) { - if( selectedElement instanceof Element){ - this.selectedElement = (Element)selectedElement; - } - } - - /** - * Returns current selected element - * - * @return current selected element may be null - */ - protected Element getSelectedElement() { - return selectedElement; - } - -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/ImportFromFile.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/ImportFromFile.java deleted file mode 100644 index 2e460e6d31c..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/ImportFromFile.java +++ /dev/null @@ -1,134 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 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: - * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation - * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.profile.ui.actions; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.jface.window.Window; -import org.eclipse.papyrus.uml.extensionpoints.utils.Util; -import org.eclipse.papyrus.uml.profile.ui.dialogs.PackageImportTreeSelectionDialog; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.ResourceSelectionDialog; -import org.eclipse.uml2.common.edit.command.ChangeCommand; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.PackageImport; -import org.eclipse.uml2.uml.UMLFactory; - -/** - * The Class ImportFromFile. - */ -public class ImportFromFile extends AbstractPackageImportAction { - - /** - * returns the command that is executed by this action. - * - * @param domain - * EMF editing domain used by the command - * @return the command that is executed by this action - */ - @Override - public ChangeCommand getCommand(EditingDomain domain) { - if(command == null) { - command = new ImportFromFileCommand(domain); - } - return command; - } - - /** - * Specific {@link ChangeCommand} that imports libraries from repository - */ - public class ImportFromFileCommand extends ChangeCommand { - - /** - * Creates a new ImportLibraryFromRepositoryCommand - * - * @param editingDomain - * editing domain that manages the changed objects - * @param runnable - * process that executes the modifications - * @param label - * the label of the command - * @param description - * description of the command - */ - public ImportFromFileCommand(EditingDomain editingDomain) { - super(editingDomain, new Runnable() { - - public void run() { - - // Retrieve shell instance - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - - // Start selection dialog - ResourceSelectionDialog chooseLib = new ResourceSelectionDialog(shell, ResourcesPlugin.getWorkspace().getRoot(), "Select Registered ModelLibrary"); - - chooseLib.open(); - - // User selection - Object[] selection = chooseLib.getResult(); - - if(selection == null) { // Cancel was selected - return; - } - - ResourceSet resourceSet = Util.getResourceSet(selectedElement); - // Parse selection and add ModelLibrary files - for(int i = 0; i < selection.length; i++) { - - if(selection[i] instanceof IFile) { - - IFile currentFile = (IFile)selection[i]; - - URI modelUri = URI.createURI("platform:/resource" + currentFile.getFullPath()); - Resource modelResource = resourceSet.getResource(modelUri, true); - - PackageImportTreeSelectionDialog eisd = new PackageImportTreeSelectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), ((Package)modelResource.getContents() - .get(0))); - int ret = eisd.open(); - - if(ret == Window.OK) { - ArrayList result = eisd.getResult(); - Iterator resultIter = result.iterator(); - while(resultIter.hasNext()) { - Element element = (Element)resultIter.next(); - PackageImport ei = UMLFactory.eINSTANCE.createPackageImport(); - ei.setImportedPackage((Package)element); - ((Package)selectedElement).getPackageImports().add(ei); - } - } - - /* - * Element root = (Element) modelResource.getContents().get(0); - * - * // Import model library Package libToImport = (Package) root; // create import package PackageImport pi = - * UMLFactory.eINSTANCE.createPackageImport(); - * pi.setImportedPackage(libToImport); ((Package) selectedElement).getPackageImports().add(pi); - */ - } - } - } - }, "Import Libraries", "Import Libraries from Workspace"); - } - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/ImportLibrariesFromRepositoryAction.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/ImportLibrariesFromRepositoryAction.java deleted file mode 100644 index bac57d49d37..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/ImportLibrariesFromRepositoryAction.java +++ /dev/null @@ -1,188 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 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: - * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation - * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.profile.ui.actions; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.window.Window; -import org.eclipse.papyrus.uml.extensionpoints.library.FilteredRegisteredLibrariesSelectionDialog; -import org.eclipse.papyrus.uml.extensionpoints.library.RegisteredLibrary; -import org.eclipse.papyrus.uml.extensionpoints.utils.Util; -import org.eclipse.papyrus.uml.profile.ui.dialogs.PackageImportTreeSelectionDialog; -import org.eclipse.papyrus.uml.tools.utils.PackageUtil; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.uml2.common.edit.command.ChangeCommand; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.PackageImport; -import org.eclipse.uml2.uml.UMLFactory; - -/** - * Action that imports a library from the library registry - * - * @see RegisteredLibrary - */ -public class ImportLibrariesFromRepositoryAction extends AbstractPackageImportAction { - - /** - * returns the command that is executed by this action. - * - * @param domain - * EMF editing domain used by the command - * @return the command that is executed by this action - */ - @Override - public ChangeCommand getCommand(EditingDomain domain) { - if(command == null) { - command = new ImportLibraryFromRepositoryCommand(domain); - } - return command; - } - - /** - * Apply the result of the dialog, i.e. it adds package imports to libraries - * - * @param librariesToImport - * the array of Libraries to import - */ - protected void importLibraries(RegisteredLibrary[] librariesToImport) { - // retrieve the current resource set - ResourceSet resourceSet = Util.getResourceSet(selectedElement); - - for(int i = 0; i < librariesToImport.length; i++) { - RegisteredLibrary currentLibrary = (librariesToImport[i]); - URI modelUri = currentLibrary.uri; - - Resource modelResource = resourceSet.getResource(modelUri, true); - PackageImportTreeSelectionDialog eisd = new PackageImportTreeSelectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), - ((Package)modelResource.getContents().get(0))); - int ret = eisd.open(); - - if(ret == Window.OK) { - ArrayList result = eisd.getResult(); - Iterator resultIter = result.iterator(); - while(resultIter.hasNext()) { - Element element = (Element)resultIter.next(); - PackageImport ei = UMLFactory.eINSTANCE.createPackageImport(); - ei.setImportedPackage((Package)element); - getSelectedElement().getPackageImports().add(ei); - } - } - } - } - - /** - * Returns the array of available libraries for the currently selected package. - * <p> - * It returns all registered libraries except the already imported ones. - * </p> - * - * @return the array of available libraries for the currently selected package - */ - protected RegisteredLibrary[] getAvailableLibraries() { - List<RegisteredLibrary> libraries = new ArrayList<RegisteredLibrary>(); - RegisteredLibrary[] allLibraries = RegisteredLibrary.getRegisteredLibraries(); - for(int i = 0; i < allLibraries.length; i++) { - RegisteredLibrary registeredLibrary = allLibraries[i]; - List<String> importedPackageNames = PackageUtil.getImportedPackagesNames(getSelectedElement()); - if(!(importedPackageNames.contains(registeredLibrary.getName()))) { - libraries.add(registeredLibrary); - } - } - return libraries.toArray(new RegisteredLibrary[libraries.size()]); - } - - /** - * Returns the array of already selected libraries for the currently selected package. - * <p> - * It returns all already imported libraries. - * </p> - * - * @return the array of already selected libraries for the currently selected package - */ - protected Collection<RegisteredLibrary> getImportedLibraries() { - List<RegisteredLibrary> libraries = new ArrayList<RegisteredLibrary>(); - RegisteredLibrary[] allLibraries = RegisteredLibrary.getRegisteredLibraries(); - for(int i = 0; i < allLibraries.length; i++) { - RegisteredLibrary registeredLibrary = allLibraries[i]; - List<String> importedPackageNames = PackageUtil.getImportedPackagesNames(getSelectedElement()); - // problem: name of library might be different from name of top-level package - if(importedPackageNames.contains(registeredLibrary.getName())) { - libraries.add(registeredLibrary); - } - } - return libraries; - } - - /** - * Specific {@link ChangeCommand} that imports libraries from repository - */ - public class ImportLibraryFromRepositoryCommand extends ChangeCommand { - - /** - * Creates a new ImportLibraryFromRepositoryCommand - * - * @param editingDomain - * editing domain that manages the changed objects - * @param runnable - * process that executes the modifications - * @param label - * the label of the command - * @param description - * description of the command - */ - public ImportLibraryFromRepositoryCommand(EditingDomain editingDomain) { - super(editingDomain, new Runnable() { - - public void run() { - // Retrieve shell instance - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - - // get the set of registered libraries available - RegisteredLibrary[] allLibraries = RegisteredLibrary.getRegisteredLibraries(); - - // Open Registered ModelLibrary selection dialog - FilteredRegisteredLibrariesSelectionDialog dialog = - new FilteredRegisteredLibrariesSelectionDialog(shell, true, - allLibraries, getImportedLibraries()); - dialog.open(); - if(Dialog.OK == dialog.getReturnCode()) { - // get the result, which is the set of libraries to import - List<Object> librariesToImport = Arrays.asList(dialog.getResult()); - importLibraries(librariesToImport.toArray(new RegisteredLibrary[librariesToImport.size()])); - } - } - }, "Import Libraries", "Import Libraries from Repository"); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean canExecute() { - return (getSelectedElement() != null); - } - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/ImportProfileAction.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/ImportProfileAction.java deleted file mode 100644 index aaaf4f6699b..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/ImportProfileAction.java +++ /dev/null @@ -1,190 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2009-2010 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.uml.profile.ui.actions;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.uml.extensionpoints.profile.FilteredRegisteredProfilesAsLibrarySelectionDialog;
-import org.eclipse.papyrus.uml.extensionpoints.profile.RegisteredProfile;
-import org.eclipse.papyrus.uml.extensionpoints.utils.Util;
-import org.eclipse.papyrus.uml.profile.ui.dialogs.ProfileTreeSelectionDialog;
-import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.uml2.common.edit.command.ChangeCommand;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.PackageImport;
-import org.eclipse.uml2.uml.UMLFactory;
-
-
-/**
- *
- * This action allows to import registered profiles like the Standard UML Profile
- *
- */
-public class ImportProfileAction extends AbstractPackageImportAction {
-
- /**
- *
- * @see org.eclipse.papyrus.uml.profile.ui.actions.AbstractPackageImportAction#getCommand(org.eclipse.emf.edit.domain.EditingDomain)
- *
- * @param domain
- * @return
- */
- @Override
- public ChangeCommand getCommand(EditingDomain domain) {
- if(command == null) {
- command = new ImportProfileCommand(domain);
- }
- getAvailableProfiles();
- return command;
- }
-
- /**
- * Returns the list of the profiles which are already imported
- *
- * @return
- * the list of the profiles which are already imported
- */
- protected Collection<RegisteredProfile> getImportedProfiles() {
- List<RegisteredProfile> profiles = new ArrayList<RegisteredProfile>();
- RegisteredProfile[] allLibraries = RegisteredProfile.getRegisteredProfiles();
- for(int i = 0; i < allLibraries.length; i++) {
- RegisteredProfile registeredProfile = allLibraries[i];
- List<String> importedPackageNames = PackageUtil.getImportedPackagesNames(getSelectedElement());
- // problem: name of library might be different from name of top-level package
- if(importedPackageNames.contains(registeredProfile.getName())) {
- profiles.add(registeredProfile);
- }
- }
- return profiles;
- }
-
- /**
- * Import the profiles in the model.
- *
- * @param profilesToImport
- * the profiles to import
- */
- protected void importProfiles(RegisteredProfile[] profilesToImport) {
-
- // retrieve the current resource set
- ResourceSet resourceSet = Util.getResourceSet(selectedElement);
-
- for(int i = 0; i < profilesToImport.length; i++) {
- RegisteredProfile currentLibrary = (profilesToImport[i]);
- URI modelUri = currentLibrary.uri;
-
- Resource modelResource = resourceSet.getResource(modelUri, true);
- // PackageImportTreeSelectionDialog dialog = new PackageImportTreeSelectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), ((Package)modelResource.getContents().get(0)));
- ProfileTreeSelectionDialog dialog = new ProfileTreeSelectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), ((Package)modelResource.getContents().get(0)));
- int ret = dialog.open();
-
- if(ret == Window.OK) {
- ArrayList<?> result = dialog.getResult();
- Iterator<?> resultIter = result.iterator();
- while(resultIter.hasNext()) {
- Element element = (Element)resultIter.next();
- PackageImport ei = UMLFactory.eINSTANCE.createPackageImport();
- ei.setImportedPackage((Package)element);
-
- //we import only once an element :
- List<Package> importedPackages = getSelectedElement().getImportedPackages();
- if(!importedPackages.contains(element)) {
- getSelectedElement().getPackageImports().add(ei);
- }
- }
- }
- }
- }
-
- /**
- * Return the available profiles
- *
- * @return
- * the available profiles
- */
- protected Object getAvailableProfiles() {
- List<RegisteredProfile> profiles = new ArrayList<RegisteredProfile>();
- RegisteredProfile[] allProfiles = org.eclipse.papyrus.uml.extensionpoints.profile.RegisteredProfile.getRegisteredProfiles();
- for(int i = 0; i < allProfiles.length; i++) {
- RegisteredProfile registeredProfile = allProfiles[i];
- List<String> importedPackageNames = PackageUtil.getImportedPackagesNames(getSelectedElement());
- if(!(importedPackageNames.contains(registeredProfile.getName()))) {
- profiles.add(registeredProfile);
- }
- }
- return profiles.toArray(new RegisteredProfile[profiles.size()]);
- }
-
- /**
- *
- * The command to import profiles in the the model
- *
- */
- public class ImportProfileCommand extends ChangeCommand {
-
- /**
- *
- * Constructor.
- *
- * @param editingDomain
- * the editing domain
- */
- public ImportProfileCommand(EditingDomain editingDomain) {
- super(editingDomain, new Runnable() {
-
- public void run() {
- // Retrieve shell instance
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
-
- // get the set of registered libraries available
- RegisteredProfile[] allProfiles = RegisteredProfile.getRegisteredProfiles();
-
- // Open Registered ModelLibrary selection dialog
- FilteredRegisteredProfilesAsLibrarySelectionDialog dialog = new FilteredRegisteredProfilesAsLibrarySelectionDialog(shell, true, allProfiles, getImportedProfiles());
- dialog.open();
- if(Dialog.OK == dialog.getReturnCode()) {
- // get the result, which is the set of libraries to import
- List<Object> profilesToImport = Arrays.asList(dialog.getResult());
- importProfiles(profilesToImport.toArray(new RegisteredProfile[profilesToImport.size()]));
- }
- }
- }, "Import Profile", "Import Profile from Registred Profiles");
- }
-
- /**
- *
- * @see org.eclipse.emf.common.command.AbstractCommand#canExecute()
- *
- * @return
- */
- @Override
- public boolean canExecute() {
- return (getSelectedElement() != null);
- }
-
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/ImportProfilesAsLibraryFromRepositoryAction.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/ImportProfilesAsLibraryFromRepositoryAction.java deleted file mode 100644 index cd6d44a108d..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/ImportProfilesAsLibraryFromRepositoryAction.java +++ /dev/null @@ -1,185 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 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: - * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation - * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.profile.ui.actions; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.window.Window; -import org.eclipse.papyrus.uml.extensionpoints.profile.FilteredRegisteredProfilesAsLibrarySelectionDialog; -import org.eclipse.papyrus.uml.extensionpoints.profile.RegisteredProfile; -import org.eclipse.papyrus.uml.extensionpoints.utils.Util; -import org.eclipse.papyrus.uml.profile.ui.dialogs.PackageImportTreeSelectionDialog; -import org.eclipse.papyrus.uml.tools.utils.PackageUtil; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.uml2.common.edit.command.ChangeCommand; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.PackageImport; -import org.eclipse.uml2.uml.UMLFactory; - -/** - * Action that imports a profile as a library from the profiles registry - * - * @see RegisteredProfile - */ -public class ImportProfilesAsLibraryFromRepositoryAction extends AbstractPackageImportAction { - - /** - * returns the command that is executed by this action. - * - * @param domain - * EMF editing domain used by the command - * @return the command that is executed by this action - */ - @Override - public ChangeCommand getCommand(EditingDomain domain) { - if(command == null) { - command = new ImportProfilesAsLibraryFromRepositoryCommand(domain); - } - return command; - } - - /** - * Apply the result of the dialog, i.e. it adds package imports to libraries - * - * @param librariesToImport - * the array of Libraries to import - */ - protected void importProfiles(RegisteredProfile[] profilesToImport) { - // retrieve the current resource set - ResourceSet resourceSet = Util.getResourceSet(selectedElement); - - for(int i = 0; i < profilesToImport.length; i++) { - RegisteredProfile currentProfile = (profilesToImport[i]); - URI modelUri = currentProfile.uri; - - Resource modelResource = resourceSet.getResource(modelUri, true); - PackageImportTreeSelectionDialog eisd = new PackageImportTreeSelectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), - ((Package)modelResource.getContents().get(0))); - int ret = eisd.open(); - - if(ret == Window.OK) { - ArrayList result = eisd.getResult(); - Iterator resultIter = result.iterator(); - while(resultIter.hasNext()) { - Element element = (Element)resultIter.next(); - PackageImport ei = UMLFactory.eINSTANCE.createPackageImport(); - ei.setImportedPackage((Package)element); - getSelectedElement().getPackageImports().add(ei); - } - } - } - } - - /** - * Returns the array of available profiles for the currently selected package. - * <p> - * It returns all registered profiles except the already imported ones. - * </p> - * - * @return the array of available profiles for the currently selected package - */ - protected RegisteredProfile[] getAvailableProfiles() { - List<RegisteredProfile> profiles = new ArrayList<RegisteredProfile>(); - RegisteredProfile[] allprofiles = RegisteredProfile.getRegisteredProfiles(); - for(int i = 0; i < allprofiles.length; i++) { - RegisteredProfile registeredProfile = allprofiles[i]; - List<String> importedPackageNames = PackageUtil.getImportedPackagesNames(getSelectedElement()); - if(!(importedPackageNames.contains(registeredProfile.getName()))) { - profiles.add(registeredProfile); - } - } - return profiles.toArray(new RegisteredProfile[profiles.size()]); - } - - /** - * Returns the array of already selected profiles for the currently selected package. - * <p> - * It returns all already imported profiles. - * </p> - * - * @return the array of already selected profiles for the currently selected package - */ - protected Collection<RegisteredProfile> getImportedProfiles() { - List<RegisteredProfile> profiles = new ArrayList<RegisteredProfile>(); - RegisteredProfile[] allProfiles = RegisteredProfile.getRegisteredProfiles(); - for(int i = 0; i < allProfiles.length; i++) { - RegisteredProfile registeredProfile = allProfiles[i]; - List<String> importedPackageNames = PackageUtil.getImportedPackagesNames(getSelectedElement()); - if(importedPackageNames.contains(registeredProfile.getName())) { - profiles.add(registeredProfile); - } - } - return profiles; - } - - /** - * Specific {@link ChangeCommand} that imports profiles as libraries from repository - */ - public class ImportProfilesAsLibraryFromRepositoryCommand extends ChangeCommand { - - /** - * Creates a new ImportProfilesAsLibraryFromRepositoryCommand - * - * @param editingDomain - * editing domain that manages the changed objects - * @param runnable - * process that executes the modifications - * @param label - * the label of the command - * @param description - * description of the command - */ - public ImportProfilesAsLibraryFromRepositoryCommand(EditingDomain editingDomain) { - super(editingDomain, new Runnable() { - - public void run() { - // Retrieve shell instance - Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - - // get the set of registered profiles available - RegisteredProfile[] allProfiles = RegisteredProfile.getRegisteredProfiles(); - - // Open Registered ModelLibrary selection dialog - FilteredRegisteredProfilesAsLibrarySelectionDialog dialog = new FilteredRegisteredProfilesAsLibrarySelectionDialog(shell, true, allProfiles, getImportedProfiles()); - dialog.open(); - if(Dialog.OK == dialog.getReturnCode()) { - // get the result, which is the set of libraries to import - List<Object> profilesToImport = Arrays.asList(dialog.getResult()); - importProfiles(profilesToImport.toArray(new RegisteredProfile[profilesToImport.size()])); - } - } - }, "Import Profiles as libraries", "Import Profiles as libraries from Repository"); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean canExecute() { - return (getSelectedElement() != null); - } - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/ReApplyProfiles.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/ReApplyProfiles.java deleted file mode 100644 index c7593f5c0b9..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/actions/ReApplyProfiles.java +++ /dev/null @@ -1,66 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 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: - * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation - * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.profile.ui.actions; - -import java.util.Iterator; - -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.jface.action.IAction; -import org.eclipse.ui.IViewPart; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.Profile; - -// TODO: Auto-generated Javadoc -/** - * The Class ImportFromFile. - */ -public class ReApplyProfiles extends AbstractViewActionDelegate { - - /** - * {@inheritDoc} - */ - @Override - public void init(IViewPart view) { - // do nothing particular - } - - /** - * Run. - * - * @param action - * the action - */ - @Override - public void run(IAction action) { - - if(selectedElement == null) { // Cancel was selected - return; - } - - if(selectedElement instanceof Package) { - Package pack = (Package)selectedElement; - Iterator<Profile> profilesIt = pack.getAllAppliedProfiles().iterator(); - while(profilesIt.hasNext()) { - Profile prof = profilesIt.next(); - EPackage ep = prof.getDefinition(); - pack.applyProfile(prof); - ep = prof.getDefinition(); - } - } else { - IllegalArgumentException e = new IllegalArgumentException("Selected element should be a profile."); - e.printStackTrace(); - } - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/AppearanceForAppliedStereotypeComposite.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/AppearanceForAppliedStereotypeComposite.java deleted file mode 100644 index efcee6c4427..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/AppearanceForAppliedStereotypeComposite.java +++ /dev/null @@ -1,747 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 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: - * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation - * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.profile.ui.compositeforview; - -import org.eclipse.emf.ecore.EModelElement; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.jface.resource.JFaceColors; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.papyrus.infra.core.utils.EditorUtils; -import org.eclipse.papyrus.uml.profile.Activator; -import org.eclipse.papyrus.uml.profile.ImageManager; -import org.eclipse.papyrus.uml.profile.tree.DisplayedProfileElementLabelProvider; -import org.eclipse.papyrus.uml.profile.tree.objects.AppliedStereotypePropertyTreeObject; -import org.eclipse.papyrus.uml.profile.tree.objects.AppliedStereotypeTreeObject; -import org.eclipse.papyrus.uml.tools.utils.UMLUtil; -import org.eclipse.papyrus.uml.tools.utils.ui.helper.AppliedStereotypeHelper; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.layout.FormLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.Property; -import org.eclipse.uml2.uml.Stereotype; - -/** - * The Class AppearanceStereotypeComposite manages the display of stereotype properties from appearance tab. - * - * when {@link TreeViewer#setSelection(ISelection)} runs the code could be changed - */ -public class AppearanceForAppliedStereotypeComposite extends org.eclipse.papyrus.uml.profile.ui.compositeforview.AppliedStereotypeDisplayComposite implements IViewComposite { - - DisplayedProfileElementLabelProvider displayedProfileElementLabelProvider = new DisplayedProfileElementLabelProvider(); - - /** - * Listener for the Display Button Specific behavior is implemented in {@link DecoratedTreeComposite#downButtonPressed()}. - * - * @author Chokri Mraidha - */ - private class DisplayButtonListener implements MouseListener { - - /** - * Mouse double click. - * - * @param e - * the e - */ - public void mouseDoubleClick(MouseEvent e) { - // do nothing - } - - /** - * Mouse down. - * - * @param e - * the e - */ - public void mouseDown(MouseEvent e) { - // do nothing - } - - /** - * Mouse up. - * - * @param e - * the e - */ - public void mouseUp(MouseEvent e) { - boolean withQualifiedName = false; - if(e.getSource().equals(displayButtonQN)) { - withQualifiedName = true; - } - TreeItem[] selectedTreeItems = getTree().getSelection(); - displayButtonPressed(withQualifiedName); - // Keep selection - if(!getTree().isDisposed()) { - getTree().setSelection(selectedTreeItems); - } - - } - } - - /** - * The diagram element. - */ - protected EModelElement diagramElement = null; - - /** - * button that displays the element. - */ - protected Button displayButton; - - /** - * button that displays the element. - */ - protected Button displayButtonQN; - - /** - * Listener for the display button. - */ - protected MouseListener displayButtonListener; - - /** - * The selection. - */ - protected ISelection selection; - - /** - * The Constructor. - * - * @param parent - * the parent - */ - public AppearanceForAppliedStereotypeComposite(Composite parent) { - super(parent); - this.setBackground(JFaceColors.getBannerBackground(parent.getDisplay())); - this.displayButtonListener = new DisplayButtonListener(); - } - - /** - * - * {@inheritDoc} - */ - public Composite createContent(Composite parent, TabbedPropertySheetWidgetFactory factory) { - super.createContent(parent, factory); - - FormData data; - displayButton = factory.createButton(this, "", SWT.PUSH); - displayButton.setVisible(true); - displayButton.setImage(ImageManager.IMG_DISPLAY); - displayButton.setToolTipText("Display selected stereotype for the element in the diagram"); - data = new FormData(); - // data.top = new FormAttachment(addButton, ITabbedPropertyConstants.HSPACE); - data.top = new FormAttachment(0, 0); - data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE); - displayButton.setLayoutData(data); - displayButton.addMouseListener(displayButtonListener); - - // button for qualifiedName - displayButtonQN = factory.createButton(this, "", SWT.PUSH); - displayButtonQN.setVisible(true); - displayButtonQN.setImage(ImageManager.IMG_CONSOLEVIEW_WITH_QN); - displayButtonQN.setToolTipText("Display selected stereotypes with their qualified name for the element in the diagram"); - data = new FormData(); - // data.top = new FormAttachment(addButton, ITabbedPropertyConstants.HSPACE); - data.top = new FormAttachment(0, 0); - data.right = new FormAttachment(displayButton, -ITabbedPropertyConstants.HSPACE); - displayButtonQN.setLayoutData(data); - displayButtonQN.addMouseListener(displayButtonListener); - - // Create label - label = factory.createCLabel(this, name + ":", SWT.NONE); - label.setLayout(new FormLayout()); - data = new FormData(); - data.left = new FormAttachment(0, ITabbedPropertyConstants.HSPACE); - data.right = new FormAttachment(displayButtonQN, -ITabbedPropertyConstants.HSPACE - 30); - data.top = new FormAttachment(0, 0); - label.setLayoutData(data); - - // Create and place Table - treeViewer.setLabelProvider(displayedProfileElementLabelProvider); - tree = treeViewer.getTree(); - tree.setLayout(new FormLayout()); - tree.setVisible(true); - - data = new FormData(SWT.DEFAULT, 50); - data.top = new FormAttachment(displayButton, ITabbedPropertyConstants.VSPACE); - data.left = new FormAttachment(0, ITabbedPropertyConstants.HSPACE); - data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE); - data.bottom = new FormAttachment(100, -ITabbedPropertyConstants.VSPACE); - - tree.setLayoutData(data); - - // Replace label and content providers in treeViewers - treeViewer.setContentProvider(new ProfileElementWithDisplayContentProvider(diagramElement)); - // treeViewer.setLabelProvider(new ProfileElementWithDisplayLabelProvider()); - - refresh(); - return this; - } - - /** - * Display button pressed. - */ - public void displayButtonPressed(boolean withQualifiedName) { - // If nothing selected : abort - if(getTree().getSelection().length < 1) { - return; - } - - // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline) - if(getDiagramElement() == null) { - return; - } - - TreeItem[] treeSelection = getTree().getSelection(); - for(int i = 0; i < treeSelection.length; i++) { - // stereotypesTree.getSelection()[0] - if(treeSelection[i].getData() instanceof AppliedStereotypeTreeObject) { - Stereotype stereo = ((AppliedStereotypeTreeObject)treeSelection[i].getData()).getStereotype(); - - if(treeSelection[i].getImage().equals(ImageManager.IMG_STEREOTYPE)) { - displayStereotype(stereo); - treeSelection[i].setImage(ImageManager.IMG_STEREOTYPEDISPLAYED); - if(withQualifiedName) { - displayStereotypeWithQN(stereo); - - treeSelection[i].setImage(ImageManager.DISPLAYED_STEREOTYPE_QN); - } - - } else { - // if we remove the stereotype we have to remove its properties also - removeDisplayStereotype(stereo); - treeSelection[i].setImage(ImageManager.IMG_STEREOTYPE); - } - } - - else if(treeSelection[i].getData() instanceof AppliedStereotypePropertyTreeObject) { - Property prop = ((AppliedStereotypePropertyTreeObject)treeSelection[i].getData()).getProperty(); - - if(treeSelection[i].getImage().equals(ImageManager.IMG_DISPLAYEDPROPERTY)) { - // removeStereotypePropertyDisplay(prop, ((StereotypeTreeObject) (treeSelection[i].getParentItem().getData())).getStereotype()); - removeStereotypeProperty(((AppliedStereotypeTreeObject)(treeSelection[i].getParentItem().getData())).getStereotype(), ((AppliedStereotypePropertyTreeObject)treeSelection[i] - .getData()).getProperty()); - treeSelection[i].setImage(ImageManager.IMG_PROPERTY); - } - - else { - // if the stereotype owning the property we want to display is not displayed, we display it! - if(!isInStereotypeDisplay(((AppliedStereotypeTreeObject)(treeSelection[i].getParentItem().getData())).getStereotype())) { - displayStereotype(((AppliedStereotypeTreeObject)(treeSelection[i].getParentItem().getData())).getStereotype()); - } - addStereotypePropertyDisplay(prop, ((AppliedStereotypeTreeObject)(treeSelection[i].getParentItem().getData())).getStereotype()); - treeSelection[i].setImage(ImageManager.IMG_DISPLAYEDPROPERTY); - } - } - - } - - } - - protected void addStereotypePropertyDisplay(final Property prop, final Stereotype stereotype) { - // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline) - if(diagramElement == null) { - return; - } - try { - - getDomain().runExclusive(new Runnable() { - - public void run() { - - Display.getCurrent().asyncExec(new Runnable() { - - public void run() { - - String appliedStereotypeListToAdd = stereotype.getQualifiedName() + "." + prop.getName(); - RecordingCommand command = AppliedStereotypeHelper.getAddAppliedStereotypePropertiesCommand(getDomain(), diagramElement, appliedStereotypeListToAdd); - getDomain().getCommandStack().execute(command); - // refresh(); - } - }); - } - }); - - } catch (Exception e) { - Activator.logException(e); - } - - } - - /** - * {@inheritDoc} - */ - public void disposeListeners() { - if(displayButton != null && !displayButton.isDisposed()) - displayButton.removeMouseListener(displayButtonListener); - } - - /** - * returns the selected DiagramElement. - * - * @return the diagram element - */ - public EModelElement getDiagramElement() { - return diagramElement; - } - - public TransactionalEditingDomain getDomain() { - return EditorUtils.getTransactionalEditingDomain(); - } - - /** - * {@inheritDoc} - */ - public Element getSelected() { - Object input = ((IStructuredSelection)selection).getFirstElement(); - return UMLUtil.resolveUMLElement(input); - } - - - /** - * {@inheritDoc} - */ - protected Boolean isInStereotypeDisplay(Stereotype st) { - // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline) - if(getDiagramElement() == null) { - return false; - } - String stereotypeList = AppliedStereotypeHelper.getStereotypesToDisplay(getDiagramElement()); - if(stereotypeList.contains(st.getQualifiedName())) { - return true; - } - return false; - } - - /** - * {@inheritDoc} - */ - public void refresh() { - if(diagramElement != null) { - displayedProfileElementLabelProvider.setDisplayedStereotype(AppliedStereotypeHelper.getStereotypesToDisplay(diagramElement)); - displayedProfileElementLabelProvider.setDisplayedStereotypeWithQN(AppliedStereotypeHelper.getStereotypesQNToDisplay(diagramElement)); - displayedProfileElementLabelProvider.setDisplayedProperty(AppliedStereotypeHelper.getAppliedStereotypesPropertiesToDisplay(diagramElement)); - } - super.refresh(); - if((diagramElement == null) && (!displayButton.isDisposed())) { - displayButton.setEnabled(false); - displayButton.setToolTipText("Stereotypes can only be displayed for elements with graphical representation. " + "Currently edited element is a non graphical element. " - + "(example: an element selected in the outline is not a graphical element)"); - } else { - // button should be enabled only if a stereotype is selected, but it requires a listener on the tree selection - displayButton.setEnabled(true); - displayButton.setToolTipText("Display selected stereotype for the currently selected element in the diagram"); - } - } - - /** - * {@inheritDoc} - */ - protected void removeStereotypeDisplay(Stereotype st) { - // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline) - if(diagramElement == null) { - return; - } - String presentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind(diagramElement); - RecordingCommand command = AppliedStereotypeHelper.getRemoveAppliedStereotypeCommand(getDomain(), diagramElement, st.getQualifiedName(), presentationKind); - getDomain().getCommandStack().execute(command); - - } - - /** - * {@inheritDoc} - */ - public void selectionChanged(SelectionChangedEvent event) { - if(event == null) { - return; - } - } - - /** Stereotype display operations **********************/ - - /** - * Sets the diagram element. - * - * @param diagramElement - * the diagram element - */ - public void setDiagramElement(EModelElement diagramElement) { - this.diagramElement = diagramElement; - ((ProfileElementWithDisplayContentProvider)treeViewer.getContentProvider()).setDiagramElement(diagramElement); - } - - /** - * Sets the selection. - * - * @param selection - * the selection - */ - public void setSelection(ISelection selection) { - this.selection = selection; - } - - // /** - // * {@inheritDoc} - // */ - // protected void buildStereotypeDisplay(EList appliedStereotypes) { - // // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline) - // if (getDiagramElement() == null) { - // return; - // } - // - // EList propList = getDiagramElement().getProperty(); - // - // // temporary list to avoid concurrent access to propList - // ArrayList tempPropList = new ArrayList(); - // - // // list containing stereotype display properties of the current graphElement - // ArrayList<com.cea.papyrus.diagraminterchange2.di2.Property> stereoDiplayList = new ArrayList<com.cea.papyrus.diagraminterchange2.di2.Property>(); - // - // // copy propList to tempPropList - // for (int i = 0; i < propList.size(); i++) { - // tempPropList.add(propList.get(i)); - // } - // - // // build stereoDiplayList and remove stereotype display properties form propList - // Iterator<com.cea.papyrus.diagraminterchange2.di2.Property> iter = tempPropList.iterator(); - // while (iter.hasNext()) { - // com.cea.papyrus.diagraminterchange2.di2.Property prop = iter.next(); - // if (prop.getKey().equals(ModelerHelper.PROPERTY_STEREOTYPE_DISPLAY)) { - // stereoDiplayList.add(prop); - // propList.remove(prop); - // } - // } - // - // // add stereotype display properties in the appropriate order - // Iterator<Stereotype> stereoIter = appliedStereotypes.iterator(); - // while (stereoIter.hasNext()) { - // String stereoName = stereoIter.next().getQualifiedName(); - // Iterator<com.cea.papyrus.diagraminterchange2.di2.Property> propIter = stereoDiplayList.iterator(); - // while (propIter.hasNext()) { - // com.cea.papyrus.diagraminterchange2.di2.Property prop = propIter.next(); - // if (prop.getValue().equals(stereoName)) { - // propList.add(prop); - // } - // } - // } - // } - // - // /** Stereotype properties values display operations **********************/ - // - // /** - // * Adds a stereotype property to the list of properties to display for a diagram element. - // * - // * @param owner - // * the owner - // * @param prop - // * the stereotype property to add - // */ - // private void addStereotypePropertyDisplay(Property prop, Stereotype owner) { - // // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline) - // if (getDiagramElement() == null) { - // return; - // } - // - // // property to add creation - // com.cea.papyrus.diagraminterchange2.di2.Property property = Di2Factory.eINSTANCE.createProperty(); - // property.setKey(ModelerHelper.PROPERTY_STEREOTYPE_PROPERTY_VALUES_DISPLAY); - // property.setValue(owner.getQualifiedName() + "::" + prop.getName()); - // - // // add the property - // getDiagramElement().getProperty().add(property); - // - // // command creation: display stereotype properties in active diagram - // Command command = new StereotypePropertiesDisplayCreateCommand(getSelectedEditPart(), getDiagramElement(), (DiagramElement) getDiagramElement().getContainer()); - // CommandStack stack = CommandStackUtils.getCommandStack(); - // - // Assert.isNotNull(stack, "Impossible to adapt current editor into a CommandStackUtils"); - // stack.execute(command); - // - // } - // - // /** - // * Removes a stereotype property from the list of properties to display for a diagram element. - // * - // * @param owner - // * the owner - // * @param property - // * the stereotype property to remove - // */ - // protected void removeStereotypePropertyDisplay(Property property, Stereotype owner) { - // // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline) - // if (getDiagramElement() == null) { - // return; - // } - // - // EList propList = getDiagramElement().getProperty(); - // ArrayList<com.cea.papyrus.diagraminterchange2.di2.Property> tempPropList = new ArrayList<com.cea.papyrus.diagraminterchange2.di2.Property>(); - // for (int i = 0; i < propList.size(); i++) { - // tempPropList.add(i, ((com.cea.papyrus.diagraminterchange2.di2.Property) propList.get(i))); - // } - // - // Iterator iter = tempPropList.iterator(); - // - // while (iter.hasNext()) { - // com.cea.papyrus.diagraminterchange2.di2.Property prop = (com.cea.papyrus.diagraminterchange2.di2.Property) iter.next(); - // if (prop.getKey().equals(ModelerHelper.PROPERTY_STEREOTYPE_PROPERTY_VALUES_DISPLAY)) { - // if (prop.getValue().equals(owner.getQualifiedName() + "::" + property.getName())) { - // propList.remove(prop); - // } - // } - // } - // - // // count the number of stereotype properties to display - // Iterator<com.cea.papyrus.diagraminterchange2.di2.Property> iterProp = getDiagramElement().getProperty().iterator(); - // int count = 0; - // while (iterProp.hasNext()) { - // com.cea.papyrus.diagraminterchange2.di2.Property diProp = iterProp.next(); - // if (diProp.getKey().equals(ModelerHelper.PROPERTY_STEREOTYPE_PROPERTY_VALUES_DISPLAY)) { - // count++; - // } - // } - // - // if (count == 0) { - // Command command; - // - // CommandStack stack = CommandStackUtils.getCommandStack(); - // - // command = DiagramElementDeleteCommandFactory.eINSTANCE.createCommand((GraphNode) LookForElement.getSemanticChildWithoutUmlSemanticAndNoContent(getDiagramElement())); - // - // Assert.isNotNull(stack, "Impossible to adapt current editor into a CommandStackUtils"); - // stack.execute(command); - // } - // } - // - // /** - // * Checks wether the stereotype property is in the display list or not. - // * - // * @param owner - // * the owner - // * @param property - // * to check out - // * - // * @return true if the stereotype property is in the display list, false otherwise - // */ - // private Boolean isInStereoPropertyDisplay(Property property, Stereotype owner) { - // // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline) - // if (getDiagramElement() == null) { - // return false; - // } - // - // EList propList = getDiagramElement().getProperty(); - // Iterator iter = propList.iterator(); - // while (iter.hasNext()) { - // com.cea.papyrus.diagraminterchange2.di2.Property prop = (com.cea.papyrus.diagraminterchange2.di2.Property) iter.next(); - // if (prop.getKey().equals(ModelerHelper.PROPERTY_STEREOTYPE_PROPERTY_VALUES_DISPLAY)) { - // if (prop.getValue().equals(owner.getQualifiedName() + "::" + property.getName())) { - // return true; - // } - // } - // } - // return false; - // } - // - // /** - // * {@inheritDoc} - // */ - // protected void removeStereotypePropertiesDisplay(Stereotype stereotype) { - // Iterator<Property> stereoPropIter = stereotype.getAllAttributes().iterator(); - // while (stereoPropIter.hasNext()) { - // Property currentProp = stereoPropIter.next(); - // if (isInStereoPropertyDisplay(currentProp, stereotype)) { - // removeStereotypePropertyDisplay(currentProp, stereotype); - // } - // } - // } - - /** - * Display the stereotype once it is applied - * - * @param st - * the stereotype to add - */ - protected void displayStereotype(final Stereotype st) { - // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline) - if(diagramElement == null) { - return; - } - try { - - getDomain().runExclusive(new Runnable() { - - public void run() { - - Display.getCurrent().asyncExec(new Runnable() { - - public void run() { - String presentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind(diagramElement); - RecordingCommand command = AppliedStereotypeHelper.getAddAppliedStereotypeCommand(getDomain(), diagramElement, st.getQualifiedName(), presentationKind); - getDomain().getCommandStack().execute(command); - // refresh(); - } - }); - } - }); - - } catch (Exception e) { - Activator.logException(e); - } - - } - - protected void removeStereotypeProperty(final Stereotype st, final Property property) { - // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline) - if(diagramElement == null) { - return; - } - try { - - getDomain().runExclusive(new Runnable() { - - public void run() { - - Display.getCurrent().asyncExec(new Runnable() { - - public void run() { - String stringToRemove = st.getQualifiedName() + "." + property.getName(); - RecordingCommand command = AppliedStereotypeHelper.getRemoveAppliedStereotypePropertiesCommand(getDomain(), diagramElement, stringToRemove); - getDomain().getCommandStack().execute(command); - // refresh(); - } - }); - } - }); - - } catch (Exception e) { - Activator.logException(e); - } - - } - - /** - * Display the stereotype once it is applied - * - * @param st - * the stereotype to add - */ - protected void displayStereotypeProperties(final Stereotype st) { - // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline) - if(diagramElement == null) { - return; - } - try { - - getDomain().runExclusive(new Runnable() { - - public void run() { - - Display.getCurrent().asyncExec(new Runnable() { - - public void run() { - String presentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind(diagramElement); - RecordingCommand command = AppliedStereotypeHelper.getAddAppliedStereotypeCommand(getDomain(), diagramElement, st.getQualifiedName(), presentationKind); - getDomain().getCommandStack().execute(command); - // refresh(); - } - }); - } - }); - - } catch (Exception e) { - Activator.logException(e); - } - - } - - /** - * Display the stereotype once it is applied - * - * @param st - * the stereotype to add - */ - protected void displayStereotypeWithQN(final Stereotype st) { - // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline) - if(diagramElement == null) { - return; - } - try { - - getDomain().runExclusive(new Runnable() { - - public void run() { - - Display.getCurrent().asyncExec(new Runnable() { - - public void run() { - RecordingCommand command = AppliedStereotypeHelper.getAddAppliedStereotypeToDisplayWithQNCommand(getDomain(), diagramElement, st.getQualifiedName()); - getDomain().getCommandStack().execute(command); - // refresh(); - } - }); - } - }); - - } catch (Exception e) { - Activator.logException(e); - } - - } - - /** - * Remove a stereotype from the list of stereotypes to display. - * - * @param st - * the stereotype to remove - */ - protected void removeDisplayStereotype(final Stereotype st) { - // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline) - if(diagramElement == null) { - return; - } - try { - getDomain().runExclusive(new Runnable() { - - public void run() { - - Display.getCurrent().asyncExec(new Runnable() { - - public void run() { - String presentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind(diagramElement); - RecordingCommand command = AppliedStereotypeHelper.getRemoveAppliedStereotypeCommand(getDomain(), diagramElement, st.getQualifiedName(), presentationKind); - - getDomain().getCommandStack().execute(command); - // refresh(); - } - }); - } - }); - } catch (Exception e) { - Activator.logException(e); - } - - } - -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/AppliedProfileCompositeWithView.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/AppliedProfileCompositeWithView.java deleted file mode 100644 index 7354ad6a67e..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/AppliedProfileCompositeWithView.java +++ /dev/null @@ -1,220 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.compositeforview;
-
-import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.jface.resource.JFaceColors;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
-import org.eclipse.uml2.uml.Profile;
-
-//TODO: Auto-generated Javadoc
-/**
- * The Class ProfileComposite to apply or unapply profile only on model element withou view.
- */
-public class AppliedProfileCompositeWithView extends org.eclipse.papyrus.uml.profile.ui.compositesformodel.AppliedProfileCompositeOnModel implements IViewComposite {
-
- /**
- * The Constructor.
- *
- * @param parent
- * the parent
- * @param factory
- * the factory
- */
- public AppliedProfileCompositeWithView(Composite parent, TabbedPropertySheetWidgetFactory factory) {
- super(parent, factory);
- this.setBackground(JFaceColors.getBannerBackground(parent.getDisplay()));
- }
-
- /**
- * Adds the reg button pressed.
- */
- @Override
- protected void registeredProfileButtonPressed() {
- super.registeredProfileButtonPressed();
- }
-
- /**
- * Rem button pressed.
- */
- @Override
- protected void unapplyProfileButtonPressed() {
- // refreshGraphicalStereotypesdisplay((Profile) getProfiles().getData(getProfiles().getItem(getProfiles().getSelectionIndex())));
- removeProfileDisplaying();
- super.unapplyProfileButtonPressed();
- synchroniseGraphicalStereotypesdisplay();
- }
-
- /**
- * Adds the button pressed.
- */
- @Override
- protected void applyProfileButtonPressed() {
- super.applyProfileButtonPressed();
- // refreshGraphicalStereotypesdisplay(super.profiletoApply);
- synchroniseGraphicalStereotypesdisplay();
- }
-
- /**
- * Refresh graphical stereotypesdisplay.
- */
- protected void synchroniseGraphicalStereotypesdisplay() {
-
- // /* profile to unapply */
- // // Profile profileToUnapply = (Profile) getProfiles().getData(getProfiles().getItem(getProfiles().getSelectionIndex()));
- // /** update stereotype display list ************************************/
- // // set of uml elements of the package
- // Set<Element> umlElements = PackageUtil.getAllNestedElements((org.eclipse.uml2.uml.Package) getSelected());
- // // add the package to this set
- // umlElements.add(getSelected());
- //
- // // set of diagrams
- // Iterator<Diagram> diagramIter = modelManager.getDiagrams().iterator();
- //
- // // set of graphElements associated to uml elements that are nested
- // // in the package we unapply the profile from
- // ArrayList<GraphElement> filteredGraphElements = new ArrayList<GraphElement>();
- //
- // while (diagramIter.hasNext()) {
- // Diagram diag = diagramIter.next();
- //
- // // list of graphElements of a diagram
- // ArrayList<GraphElement> diagramGraphElements = new ArrayList<GraphElement>();
- // diagramGraphElements = LookForElement.getAllGraphElements(diag, diagramGraphElements);
- //
- // // filter diagramsGraphElements in order to hold graphElements associated to uml elements
- // // of the package which we unapply profile from
- // Iterator<GraphElement> geIter = diagramGraphElements.iterator();
- // while (geIter.hasNext()) {
- // GraphElement ge = geIter.next();
- //
- // // if the diagram element property list is empty, it has not have any stereotype
- // if (ge.getProperty().size() != 0) {
- // if (umlElements.contains(((Uml1SemanticModelBridge) ge.getSemanticModel()).getElement())) {
- // filteredGraphElements.add(ge);
- // }
- // }
- // }
- // }
- //
- // // look for each stereotyped graphElement
- // Iterator<GraphElement> stereotypedGE = filteredGraphElements.iterator();
- // while (stereotypedGE.hasNext()) {
- // GraphElement stGE = stereotypedGE.next();
- // // tempProp contains list of property element of a stereotyped GraphElement
- // ArrayList tempProp = new ArrayList();
- // EList tpList = stGE.getProperty();
- // for (int i = 0; i < tpList.size(); i++) {
- // tempProp.add(tpList.get(i));
- // }
- //
- // Iterator propIter = tempProp.iterator();
- // while (propIter.hasNext()) {
- // com.cea.papyrus.diagraminterchange2.di2.Property prop = (com.cea.papyrus.diagraminterchange2.di2.Property) propIter.next();
- // // This is a Property to display a stereotype?
- // if (prop.getKey().equals(ModelerHelper.PROPERTY_STEREOTYPE_DISPLAY)) {
- // String stName = prop.getValue();
- // // test if the stereotype is not applied
- // if (((Uml1SemanticModelBridge) stGE.getSemanticModel()).getElement().getAppliedStereotype(stName) == null) {
- // stGE.getProperty().remove(prop);
- // }
- // }
- // // remove properties
- // if (prop.getKey().equals(ModelerHelper.PROPERTY_STEREOTYPE_PROPERTY_VALUES_DISPLAY)) {
- // String propName = prop.getValue();
- // // stereotype name
- // String stereoName = propName.substring(0, propName.lastIndexOf("::"));
- // // test if the stereotype is applied
- // if (((Uml1SemanticModelBridge) stGE.getSemanticModel()).getElement().getAppliedStereotype(stereoName) == null) {
- // stGE.getProperty().remove(prop);
- // } else {
- // Stereotype stereo = ((Uml1SemanticModelBridge) stGE.getSemanticModel()).getElement().getAppliedStereotype(stereoName);
- // String simplePropName = propName.replaceAll(stereoName + "::", "");
- // Iterator iterPro = stereo.getAllAttributes().iterator();
- // boolean found = false;
- // while (iterPro.hasNext()) {
- // org.eclipse.uml2.uml.Property tmpProperty = (org.eclipse.uml2.uml.Property) iterPro.next();
- // if (tmpProperty.getName().equals(simplePropName)) {
- // found = true;
- // }
- // }
- //
- // if (found == false) {
- // stGE.getProperty().remove(prop);
- // }
- // }
- // /***** Remove properties display if there is no more properties to display after unapplying this profile *****/
- // // count the number of stereotype properties to display
- // Iterator<com.cea.papyrus.diagraminterchange2.di2.Property> iterProp = stGE.getProperty().iterator();
- // int count = 0;
- // while (iterProp.hasNext()) {
- // com.cea.papyrus.diagraminterchange2.di2.Property diProp = iterProp.next();
- // if (diProp.getKey().equals(ModelerHelper.PROPERTY_STEREOTYPE_PROPERTY_VALUES_DISPLAY)) {
- // count++;
- // }
- // }
- //
- // // is there some properties to display?
- // if (count == 0) {
- // org.eclipse.gef.commands.Command command = DiagramElementDeleteCommandFactory.eINSTANCE.createCommand((GraphNode) LookForElement
- // .getSemanticChildWithoutUmlSemanticAndNoContent(stGE));
- //
- // // getCommandStack
- // CommandStack stack = CommandStackUtils.getCommandStack();
- //
- // Assert.isNotNull(stack, "Impossible to adapt current editor into a CommandStackUtils");
- // stack.execute(command);
- //
- // /*************************************************************************************************************/
- //
- // }
- // }
- // }
- // }
- }
-
- public void removeProfileDisplaying() {
- // Retrieve indices of selected profiles to unapply
- int[] selectionIndices = getProfiles().getSelectionIndices();
- if((selectionIndices == null) || (selectionIndices.length == 0)) {
- return;
- }
-
- // Parse selection
- for(int i = 0; i < selectionIndices.length; i++) {
- int currentIndex = selectionIndices[i];
- // Remove TAG_PROFILE_CHANGED when it exists
- String itemName = getProfiles().getItem(currentIndex).replace(TAG_PROFILE_CHANGED, "");
- Profile profileToUnapply = (Profile)getProfiles().getData(itemName);
- // set of diagrams
- // Iterator<Diagram> diagramIter = modelManager.getDiagrams().iterator();
- // while (diagramIter.hasNext()) {
- // ArrayList found = LookForElement.lookForGraphElement(profileToUnapply, diagramIter.next(), new ArrayList());
- // Iterator founditer = found.iterator();
- // while (founditer.hasNext()) {
- // Command cmd = DiagramElementDeleteCommandFactory.eINSTANCE.createCommand((GraphElement) founditer.next());
- // CommandStackUtils.getCommandStack().execute(cmd);
- // }
- // }
- }
-
- }
-
- public void setDiagramElement(EModelElement diagramElement) {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/AppliedStereotypeCompositeWithView.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/AppliedStereotypeCompositeWithView.java deleted file mode 100644 index ce77687786f..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/AppliedStereotypeCompositeWithView.java +++ /dev/null @@ -1,242 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.compositeforview;
-
-import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.jface.resource.JFaceColors;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.papyrus.uml.profile.tree.objects.AppliedStereotypePropertyTreeObject;
-import org.eclipse.papyrus.uml.tools.utils.ui.helper.AppliedStereotypeHelper;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * This Composite allows displaying applied stereotypes from the model, but allows also displaying it in the associated view.
- */
-public class AppliedStereotypeCompositeWithView extends org.eclipse.papyrus.uml.profile.ui.compositesformodel.AppliedStereotypeCompositeOnModel implements IViewComposite {
-
- /**
- * The selection.
- */
- protected ISelection selection;
-
- /**
- * The property composite.
- */
- protected AppliedStereotypePropertyCompositeWithView propertyComposite;
-
- private EModelElement diagramElement;
-
- /**
- * The Constructor.
- *
- * @param parent
- * the parent
- */
- public AppliedStereotypeCompositeWithView(Composite parent) {
- super(parent);
- this.setBackground(JFaceColors.getBannerBackground(parent.getDisplay()));
- }
-
- /**
- * Creates the content.
- *
- * @param parent
- * the parent
- * @param factory
- * the factory
- *
- * @return the composite
- */
- @Override
- public Composite createContent(Composite parent, TabbedPropertySheetWidgetFactory factory) {
- super.createContent(parent, factory);
-
- // Replace label and content providers in treeViewers
- treeViewer.setContentProvider(new ProfileElementWithDisplayContentProvider(diagramElement));
- treeViewer.setLabelProvider(new ProfileElementWithDisplayLabelProvider());
-
- refresh();
- return this;
- }
-
- /**
- * Sets the selection.
- *
- * @param selection
- * the selection
- */
- public void setSelection(ISelection selection) {
- this.selection = selection;
- }
-
- /**
- * Sets the diagram element.
- *
- * @param diagramElement
- * the diagram element
- */
- public void setDiagramElement(EModelElement diagramElement) {
- this.diagramElement = diagramElement;
- ((ProfileElementWithDisplayContentProvider)treeViewer.getContentProvider()).setDiagramElement(diagramElement);
- }
-
- /**
- * Sets the property composite associated to this stereotype composite
- *
- * @param propertyComposite
- * the composite associated to this stereotype composite used for stereotype property display.
- */
- public void setPropertyComposite(AppliedStereotypePropertyCompositeWithView propertyComposite) {
- this.propertyComposite = propertyComposite;
- }
-
- /**
- * Gets the selected.
- *
- * @return the selected
- * @deprecated
- */
- @Override
- public Element getSelected() {
- return getElement();
- }
-
- /**
- * Adds the button pressed.
- */
- @Override
- public void addButtonPressed() {
- super.addButtonPressed();
- }
-
- /**
- * Display the stereotype once it is applied
- *
- * @param st
- * the stereotype to add
- */
- @Override
- public void applyStereotype(final Element elt, final Stereotype st) {
- super.applyStereotype(elt, st);
- // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline)
- if(diagramElement == null) {
- return;
- }
- try {
-
- getDomain().runExclusive(new Runnable() {
-
- public void run() {
-
- Display.getCurrent().asyncExec(new Runnable() {
-
- public void run() {
-
- String presentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind(diagramElement);
- RecordingCommand command = AppliedStereotypeHelper.getAddAppliedStereotypeCommand(getDomain(), diagramElement, st.getQualifiedName(), presentationKind);
- getDomain().getCommandStack().execute(command);
- }
- });
- }
- });
-
- } catch (Exception e) {
- e.printStackTrace ();
- }
-
- }
-
- /**
- * Remove a stereotype from the list of stereotypes to display.
- *
- * @param st
- * the stereotype to remove
- */
- @Override
- protected void unapplyStereotype(final Element elt, final Stereotype st) {
- super.unapplyStereotype(elt, st);
- // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline)
- if(diagramElement == null) {
- return;
- }
- try {
- getDomain().runExclusive(new Runnable() {
-
- public void run() {
-
- Display.getCurrent().asyncExec(new Runnable() {
-
- public void run() {
- String presentationKind = AppliedStereotypeHelper.getAppliedStereotypePresentationKind(diagramElement);
- RecordingCommand command = AppliedStereotypeHelper.getRemoveAppliedStereotypeCommand(getDomain(), diagramElement, st.getQualifiedName(), presentationKind);
-
- getDomain().getCommandStack().execute(command);
- }
- });
- }
- });
- } catch (Exception e) {
- e.printStackTrace ();
- }
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.cea.papyrus.profile.ui.composites.StereotypeComposite#removeButtonPressed()
- */
- @Override
- public void removeButtonPressed() {
- superRemoveButton();
- }
-
- /**
- * Calls super method
- */
- private void superRemoveButton() {
- super.removeButtonPressed();
- }
-
- /**
- * Selection changed.
- *
- * @param event
- * the event
- */
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- if(event == null) {
- propertyComposite.setInput(null);
- return;
- }
-
- IStructuredSelection structSelection = (IStructuredSelection)event.getSelection();
- Object selection = structSelection.getFirstElement();
-
- if(selection instanceof AppliedStereotypePropertyTreeObject) {
- propertyComposite.setInput((AppliedStereotypePropertyTreeObject)selection);
- } else {
- propertyComposite.setInput(null);
- }
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/AppliedStereotypeDisplayComposite.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/AppliedStereotypeDisplayComposite.java deleted file mode 100644 index 2eaf3ffc1a8..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/AppliedStereotypeDisplayComposite.java +++ /dev/null @@ -1,169 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 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: - * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation - * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.profile.ui.compositeforview; - -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.papyrus.uml.profile.Activator; -import org.eclipse.papyrus.uml.profile.preference.ProfilePreferenceConstants; -import org.eclipse.papyrus.uml.profile.tree.ProfileElementContentProvider; -import org.eclipse.papyrus.uml.profile.tree.ProfileElementLabelProvider; -import org.eclipse.papyrus.uml.profile.tree.ProfileElementTreeViewerFilter; -import org.eclipse.papyrus.uml.profile.tree.objects.AppliedStereotypePropertyTreeObject; -import org.eclipse.papyrus.uml.profile.tree.objects.StereotypedElementTreeObject; -import org.eclipse.papyrus.uml.profile.ui.compositesformodel.AppearanceDecoratedTreeComposite; -import org.eclipse.papyrus.uml.profile.ui.panels.AppliedStereotypePanel; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory; -import org.eclipse.uml2.uml.Element; - -/** - * The Class StereotypeComposite. - */ -public class AppliedStereotypeDisplayComposite extends AppearanceDecoratedTreeComposite implements ISelectionChangedListener { - - // the parent panel instance - /** - * The parent panel. - */ - private AppliedStereotypePanel parentPanel; - - // GUI related declarations - /** - * The label. - */ - protected CLabel label; - - /** - * The default constructor. - * - * @param style - * the style of this panel - * @param parent - * the parent Composite for this panel - */ - public AppliedStereotypeDisplayComposite(AppliedStereotypePanel parent) { - super(parent, SWT.NONE, "Applied stereotypes", true); - - parentPanel = parent; - } - - /** - * - * - * @param parent - */ - public AppliedStereotypeDisplayComposite(Composite parent) { - super(parent, SWT.NONE, "Applied stereotypes", true); - } - - /** - * - * - * @param factory - * @param parent - * - * @return - */ - @Override - public Composite createContent(Composite parent, TabbedPropertySheetWidgetFactory factory) { - super.createContent(parent, factory); - createStereotypesTree(); - - return this; - } - - /** - * Gets the selected. - * - * @return Returns the selected element. - */ - public Element getSelected() { - return parentPanel.getSelected(); - } - - /** - * Gets the tree. - * - * @return the tree - */ - public Tree getTree() { - return treeViewer.getTree(); - } - - /** - * Sets the input. - * - * @param element - * the element - */ - public void setInput(StereotypedElementTreeObject element) { - treeViewer.setInput(element); - // boolean toto = Activator.getDefault().getPreferenceStore().getBoolean(ProfilePreferenceConstants.EXPAND_STERETOYPES_TREE); - if(Activator.getDefault().getPreferenceStore().getBoolean(ProfilePreferenceConstants.EXPAND_STEREOTYPES_TREE)) { - treeViewer.expandAll(); - } - } - - /** - * Refresh the content of applied the applied stereotype tree. - */ - @Override - public void refresh() { - - if(treeViewer.getTree() != null && !(treeViewer.getTree().isDisposed())) { - treeViewer.refresh(); - } - } - - /** - * Creates the stereotypes tree. - * - * @return the tree of applied stereotypes and properties - */ - private void createStereotypesTree() { - // Tree viewer shows applied stereotypes - treeViewer.setContentProvider(new ProfileElementContentProvider()); - treeViewer.setLabelProvider(new ProfileElementLabelProvider()); - treeViewer.addFilter(new ProfileElementTreeViewerFilter()); - treeViewer.addSelectionChangedListener(this); - } - - /** - * - * - * @param event - */ - public void selectionChanged(SelectionChangedEvent event) { - if(parentPanel != null) { - if(event == null) { - parentPanel.setSelectedProperty(null); - return; - } - - IStructuredSelection structSelection = (IStructuredSelection)event.getSelection(); - Object selection = structSelection.getFirstElement(); - if(selection instanceof AppliedStereotypePropertyTreeObject) { - parentPanel.setSelectedProperty((AppliedStereotypePropertyTreeObject)selection); - } else { - parentPanel.setSelectedProperty(null); - } - } - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/AppliedStereotypePropertyCompositeWithView.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/AppliedStereotypePropertyCompositeWithView.java deleted file mode 100644 index e435918b88b..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/AppliedStereotypePropertyCompositeWithView.java +++ /dev/null @@ -1,164 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.compositeforview;
-
-import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.jface.resource.JFaceColors;
-import org.eclipse.papyrus.uml.tools.utils.ui.helper.AppliedStereotypeHelper;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-// TODO: Auto-generated Javadoc
-/**
- * The Class PropertyComposite.
- */
-public class AppliedStereotypePropertyCompositeWithView extends org.eclipse.papyrus.uml.profile.ui.compositesformodel.PropertyComposite implements IViewComposite {
-
- /**
- * the current view
- */
- protected EModelElement currentView;
-
- /**
- * The stereotype composite.
- */
- protected AppliedStereotypeCompositeWithView stereotypeComposite;
-
- /**
- * The Constructor.
- *
- * @param stereotypeComposite
- * the stereotype composite
- * @param parent
- * the parent
- */
- public AppliedStereotypePropertyCompositeWithView(Composite parent, AppliedStereotypeCompositeWithView stereotypeComposite) {
- super(parent);
-
- this.setBackground(JFaceColors.getBannerBackground(parent.getDisplay()));
- this.stereotypeComposite = stereotypeComposite;
- }
-
- /**
- * Touch model.
- *
- *
- */
- protected void touchModel() {
-
- // CommandSupport.exec ("update stereotype", /* command)
- if (currentView == null) {
- return;
- }
-
- try {
- getDomain().runExclusive(new Runnable() {
-
-
- public void run() {
-
- Display.getCurrent().asyncExec( new Runnable() {
-
- public void run() {
- String localization = AppliedStereotypeHelper.getAppliedStereotypesPropertiesLocalization(currentView);
- RecordingCommand command = AppliedStereotypeHelper.getSetAppliedStereotypePropertiesLocalizationCommand(getDomain(), currentView, localization);
-
- getDomain().getCommandStack().execute(command);
-
- }
- });
-
- }
- });
-
- } catch (Exception e) {
- e.printStackTrace ();
- }
- }
-
- /**
- * Adds the button pressed.
- */
- @Override
- public void addButtonPressed() {
- super.addButtonPressed();
- touchModel();
- stereotypeComposite.refreshTreeViewer ();
- }
-
- /**
- * Removes the button pressed.
- */
- @Override
- public void removeButtonPressed() {
- super.removeButtonPressed();
- touchModel();
- stereotypeComposite.refreshTreeViewer ();
- }
-
- /**
- * Up button pressed.
- */
- @Override
- public void upButtonPressed() {
- super.upButtonPressed();
- touchModel();
- stereotypeComposite.refreshTreeViewer ();
- }
-
- /**
- * Down button pressed.
- */
- @Override
- public void downButtonPressed() {
- super.downButtonPressed();
- touchModel();
- stereotypeComposite.refreshTreeViewer ();
- }
-
- /**
- * Creates the prop tree.
- */
- @Override
- protected void createPropTree() {
- super.createPropTree();
- getTree().addListener(SWT.MouseDoubleClick, new StereotypePropertiesDoubleClickListener (treeViewer, stereotypeComposite, this));
- }
-
- /**
- * Sets the stereotype composite.
- *
- * @param stereotypeComposite
- * the stereotype composite
- */
- public void setStereotypeComposite(AppliedStereotypeCompositeWithView stereotypeComposite) {
- this.stereotypeComposite = stereotypeComposite;
- }
-
- /**
- *
- */
- public void disposeListeners() {
- super.disposeListeners();
- stereotypeComposite.disposeListeners();
- }
-
- public void setDiagramElement(EModelElement diagramElement) {
- this.currentView = diagramElement;
-
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/IViewComposite.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/IViewComposite.java deleted file mode 100644 index c66edc980cb..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/IViewComposite.java +++ /dev/null @@ -1,33 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.compositeforview;
-
-import org.eclipse.emf.ecore.EModelElement;
-
-/**
- * All Composite view has to modify a view
- *
- */
-public interface IViewComposite {
-
- /**
- * Sets the diagram element.
- *
- * @param diagramElement
- * the diagram element
- */
- public void setDiagramElement(EModelElement diagramElement);
-
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/ProfileElementWithDisplayContentProvider.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/ProfileElementWithDisplayContentProvider.java deleted file mode 100644 index b441ed600bf..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/ProfileElementWithDisplayContentProvider.java +++ /dev/null @@ -1,187 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.compositeforview;
-
-import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.papyrus.uml.profile.tree.ProfileElementContentProvider;
-import org.eclipse.papyrus.uml.profile.tree.objects.AppliedStereotypePropertyTreeObject;
-import org.eclipse.papyrus.uml.profile.tree.objects.AppliedStereotypeTreeObject;
-import org.eclipse.papyrus.uml.profile.tree.objects.TreeObject;
-import org.eclipse.uml2.uml.Property;
-import org.eclipse.uml2.uml.Stereotype;
-
-// TODO: Auto-generated Javadoc
-/**
- * The Class ProfileElementWithDisplayContentProvider.
- */
-public class ProfileElementWithDisplayContentProvider extends ProfileElementContentProvider {
-
- /**
- * The diagram element.
- */
- protected EModelElement diagramElement = null;
-
- /**
- * The Constructor.
- *
- * @param _diagramElement
- * the _diagram element
- */
- public ProfileElementWithDisplayContentProvider(EModelElement _diagramElement) {
- super();
- diagramElement = _diagramElement;
- // TODO Auto-generated constructor stub
- }
-
- /**
- * Gets the children.
- *
- * @param parent
- * the parent
- *
- * @return the children
- */
- @Override
- public TreeObject[] getChildren(Object parent) {
- // TODO Auto-generated method stub
- TreeObject[] objects = super.getChildren(parent);
- updateIsDisplay(objects);
-
- return objects;
- }
-
- /**
- * Update is display.
- *
- * @param objects
- * the objects
- */
- private void updateIsDisplay(TreeObject[] objects) {
-
- for(int i = 0; i < objects.length; i++) {
-
- if(objects[i] instanceof AppliedStereotypeTreeObject) {
- AppliedStereotypeTreeObject currentStTO = (AppliedStereotypeTreeObject)objects[i];
- if(isInStereotypeDisplay(currentStTO.getStereotype())) {
- currentStTO.setDisplay(true);
- } else {
- currentStTO.setDisplay(false);
- }
-
- } else if(objects[i] instanceof AppliedStereotypePropertyTreeObject) {
- AppliedStereotypePropertyTreeObject currentPropertyTO = (AppliedStereotypePropertyTreeObject)objects[i];
- AppliedStereotypeTreeObject currentStereotypeTO = (AppliedStereotypeTreeObject)currentPropertyTO.getParent();
- if(isInStereoPropertyDisplay(currentPropertyTO.getProperty(), currentStereotypeTO.getStereotype())) {
- currentPropertyTO.setDisplay(true);
- } else {
- currentPropertyTO.setDisplay(false);
- }
-
- } // else nothing to do
- }
- //
- //
- // // handle display icons
- // TreeItem[] treeItems = getTree().getItems();
- // for(int i=0; i<treeItems.length; i++){
- // if(treeItems[i].getData() instanceof StereotypeTreeObject){
- // if(isInStereotypeDisplay(((StereotypeTreeObject)treeItems[i].getData()).getStereotype())) {
- // treeItems[i].setImage(IMG_DISPLAYED_STEREO);
- // }
- // else {
- // treeItems[i].setImage(ImageManager.IMG_STEREOTYPE);
- // }
- // }
- //
- // // properties display handling
- // TreeItem[] propItems = treeItems[i].getItems();
- // for(int j=0; j<propItems.length; j++){
- // if(propItems[j].getData() instanceof PropertyTreeObject){
- // if(isInStereoPropertyDisplay(((PropertyTreeObject)propItems[j].getData()).getProperty(), ((StereotypeTreeObject)treeItems[i].getData()).getStereotype())) {
- // propItems[j].setImage(IMG_DISPLAYED_STEREO);
- // } else {
- // propItems[j].setImage(ImageManager.IMG_PROPERTY);
- // }
- // }
- // }
- }
-
- /**
- * Checks wether the stereotype property is in the display list or not.
- *
- * @param owner
- * the owner
- * @param property
- * to check out
- *
- * @return true if the stereotype property is in the display list, false otherwise
- */
- private Boolean isInStereoPropertyDisplay(Property property, Stereotype owner) {
- // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline)
- if(diagramElement == null) {
- return false;
- }
-
- // EList propList = diagramElement.getProperty();
- // Iterator iter = propList.iterator();
- // while (iter.hasNext()) {
- // com.cea.papyrus.diagraminterchange2.di2.Property prop = (com.cea.papyrus.diagraminterchange2.di2.Property) iter.next();
- // if (prop.getKey().equals(ModelerHelper.PROPERTY_STEREOTYPE_PROPERTY_VALUES_DISPLAY)) {
- // if (prop.getValue().equals(owner.getQualifiedName() + "::" + property.getName())) {
- // return true;
- // }
- // }
- // }
- return false;
- }
-
- /**
- * Sets the diagram element.
- *
- * @param diagramElement
- * the diagram element
- */
- public void setDiagramElement(EModelElement diagramElement) {
- this.diagramElement = diagramElement;
- }
-
- /**
- * Checks wether the stereotype is in the display list or not.
- *
- * @param st
- * to check out
- *
- * @return true if the stereotype is in the display list, false otherwise
- */
- protected Boolean isInStereotypeDisplay(Stereotype st) {
- // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline)
- if(diagramElement == null) {
- return false;
- }
-
- // EList propList = diagramElement.getProperty();
- // Iterator iter = propList.iterator();
- // while (iter.hasNext()) {
- // com.cea.papyrus.diagraminterchange2.di2.Property prop = (com.cea.papyrus.diagraminterchange2.di2.Property) iter.next();
- // if (prop.getKey().equals(ModelerHelper.PROPERTY_STEREOTYPE_DISPLAY)) {
- // if (prop.getValue().equals(st.getQualifiedName())) {
- // return true;
- // }
- // }
- // }
- return false;
- }
-
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/ProfileElementWithDisplayLabelProvider.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/ProfileElementWithDisplayLabelProvider.java deleted file mode 100644 index 85e49b1cd77..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/ProfileElementWithDisplayLabelProvider.java +++ /dev/null @@ -1,49 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.compositeforview;
-
-import org.eclipse.papyrus.uml.profile.ImageManager;
-import org.eclipse.papyrus.uml.profile.tree.ProfileElementLabelProvider;
-import org.eclipse.papyrus.uml.profile.tree.objects.TreeObject;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * The Class ProfileElementWithDisplayLabelProvider.
- */
-public class ProfileElementWithDisplayLabelProvider extends ProfileElementLabelProvider {
-
- /**
- * Gets the image.
- *
- * @param object
- * the object
- *
- * @return the image
- */
- @Override
- public Image getImage(Object object) {
-
- if(object instanceof TreeObject) {
-
- TreeObject to = (TreeObject)object;
- if(to.isDisplay()) {
- return ImageManager.IMG_STEREOTYPEDISPLAYED;
- }
- }
-
- // else, Default case : no display
- return super.getImage(object);
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/StereotypePropertiesDoubleClickListener.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/StereotypePropertiesDoubleClickListener.java deleted file mode 100644 index 0c7db40fcea..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositeforview/StereotypePropertiesDoubleClickListener.java +++ /dev/null @@ -1,73 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.compositeforview;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.papyrus.uml.profile.ui.listeners.DoubleClickListener;
-import org.eclipse.swt.widgets.TreeItem;
-
-// TODO: Auto-generated Javadoc
-/**
- * The Class StereotypePropertiesDoubleClickListener.
- */
-public class StereotypePropertiesDoubleClickListener extends DoubleClickListener {
-
- /**
- * The stereotype composite.
- */
- protected AppliedStereotypeCompositeWithView stereotypeComposite;
-
- /**
- * The property composite.
- */
- protected AppliedStereotypePropertyCompositeWithView propertyComposite;
-
- /**
- * The Constructor.
- *
- * @param propertyComposite
- * the property composite
- * @param stereotypeComposite
- * the stereotype composite
- * @param treeViewer
- * the tree viewer
- * @param parent
- * the parent
- */
- public StereotypePropertiesDoubleClickListener(TreeViewer treeViewer, AppliedStereotypeCompositeWithView stereotypeComposite,
- AppliedStereotypePropertyCompositeWithView propertyComposite) {
- super();
- this.treeViewer = treeViewer;
- this.stereotypeComposite = stereotypeComposite;
- this.propertyComposite = propertyComposite;
- }
-
- /**
- * Item D clicked.
- *
- * @param item
- * the item
- * @param index
- * the index
- */
- @Override
- protected void itemDClicked(TreeItem item, int index) {
- super.itemDClicked(item, index);
- stereotypeComposite.refreshTreeViewer();
- propertyComposite.itemDClicked();
- propertyComposite.touchModel();
- propertyComposite.refresh();
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositesformodel/AppearanceDecoratedTreeComposite.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositesformodel/AppearanceDecoratedTreeComposite.java deleted file mode 100644 index 06444c8ef20..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositesformodel/AppearanceDecoratedTreeComposite.java +++ /dev/null @@ -1,156 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 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: - * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation - * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.profile.ui.compositesformodel; - -import org.eclipse.gef.commands.CommandStack; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.papyrus.uml.profile.tree.ProfileElementTreeViewer; -import org.eclipse.papyrus.uml.profile.tree.PropertyValueTreeViewer; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.layout.FormLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory; -import org.eclipse.uml2.uml.Element; - -/** - * Base class for appearance stereotype composite - */ -public abstract class AppearanceDecoratedTreeComposite extends Composite implements ISectionComposite { - - // child composites for the table composite - - // /** main composite of this complex composite */ - // protected Composite composite; - /** - * Label above the table. - */ - protected CLabel label; - - /** - * Table that displays a property for the current element. - */ - protected Tree tree; - - /** - * The tree viewer. - */ - protected TreeViewer treeViewer; - - /** - * Element selected in the Papyrus modeler. - */ - protected Element element; - - // Construction parameters for the composite - /** - * text of the label. - */ - protected String name; - - /** - * returns the element that is selected in Papyrus tool, for which properties are displayed in the property section. - * - * @return the element - */ - public Element getElement() { - return element; - } - - /** - * Sets the element that holds property displyed in property section. - * - * @param element - * the element to set - */ - public void setElement(Element element) { - this.element = element; - } - - /** - * Constructor. - * - * @param style - * @param isStereotypeTree - * @param name - * text of the Label on the top left of this composite - * @param parent - */ - public AppearanceDecoratedTreeComposite(Composite parent, int style, String name, boolean isStereotypeTree) { - super(parent, style); - this.name = name; - this.setLayout(new FormLayout()); - - if(isStereotypeTree) { - treeViewer = new ProfileElementTreeViewer(this); - } else { - // Property tree - treeViewer = new PropertyValueTreeViewer(this); - } - } - - /* - * (non-Javadoc) - * - * @see com.cea.papyrus.ui.composites.ISectionComposite#createContent(org.eclipse.swt.widgets.Composite, - * org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory) - */ - /** - * - * - * @param factory - * @param parent - * - * @return - */ - public Composite createContent(Composite parent, TabbedPropertySheetWidgetFactory factory) { - - return this; - } - - /* - * (non-Javadoc) - * - * @see com.cea.papyrus.ui.composites.ISectionComposite#refresh() - */ - /** - * - */ - public void refresh() { - } - - /** - * Returns the CommmandStack of the current editor. - * - * @return the CommmandStack of the current editor - */ - public CommandStack getCommandStack() { - if(getActiveEditor() != null) { - return (CommandStack)getActiveEditor().getAdapter(CommandStack.class); - } - return null; - } - - /** - * Returns the current Editor. - * - * @return the current editor - */ - public IEditorPart getActiveEditor() { - return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositesformodel/AppliedProfileCompositeOnModel.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositesformodel/AppliedProfileCompositeOnModel.java deleted file mode 100644 index c36cda5b40c..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositesformodel/AppliedProfileCompositeOnModel.java +++ /dev/null @@ -1,669 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- * Emilien Perico (Atos Origin) - fix bug on refresh
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.compositesformodel;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.papyrus.infra.core.utils.EditorUtils;
-import org.eclipse.papyrus.uml.profile.Activator;
-import org.eclipse.papyrus.uml.profile.ImageManager;
-import org.eclipse.papyrus.uml.profile.ui.dialogs.FileSelectionFilter;
-import org.eclipse.papyrus.uml.profile.ui.dialogs.Message;
-import org.eclipse.papyrus.uml.profile.ui.dialogs.ProfileTreeSelectionDialog;
-import org.eclipse.papyrus.uml.profile.ui.dialogs.RegisteredProfileSelectionDialog;
-import org.eclipse.papyrus.uml.profile.ui.panels.AppliedProfilePanel;
-import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
-import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
-import org.eclipse.ui.model.WorkbenchContentProvider;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Package;
-import org.eclipse.uml2.uml.PackageImport;
-import org.eclipse.uml2.uml.Profile;
-
-/**
- * The Class ProfileComposite.
- */
-public class AppliedProfileCompositeOnModel extends Composite {
-
- public final static String TAG_PROFILE_CHANGED = " (has changed, consider re-applying profile)";
-
- /**
- * The add registered button.
- */
- private Button addButton, removeButton, addRegisteredButton;
-
- /**
- * Listeners *.
- */
- private MouseListener addButtonListener, removeButtonListener, addRegisteredButtonListener;
-
- /**
- * The applied label.
- */
- private CLabel appliedLabel;
-
- private TransactionalEditingDomain domain;
-
- /**
- * the factory to create elements
- */
- protected TabbedPropertySheetWidgetFactory factory;
-
- /**
- * The profiles.
- */
- private List profiles;
-
- /**
- * profile listener
- */
- private SelectionListener profilesListener;
-
- public Profile profiletoApply;
-
- /**
- * The selected element of the edior : an edit part or element in the outline for example.
- */
- protected ISelection selectedElement;
-
- /**
- * The default constructor.
- *
- * @param style
- * the style of this panel
- * @param parent
- * the parent Composite for this panel
- */
- public AppliedProfileCompositeOnModel(AppliedProfilePanel parent) {
- super(parent, SWT.NONE);
- this.setLayout(new FormLayout());
-
- }
-
- /**
- *
- *
- * @param factory
- * @param parent
- */
- public AppliedProfileCompositeOnModel(Composite parent, TabbedPropertySheetWidgetFactory factory) {
- super(parent, SWT.NONE);
- this.setLayout(new FormLayout());
-
- this.factory = factory;
- }
-
- /**
- * apply profile done in asynchronous thread
- *
- * @param thepackage
- * the package where the profile will be applied
- * @param profile
- * to apply
- * @param withSubProfiles
- * yes if we want to apply all contained subprofiles
- */
- protected void applyProfile(final Package thepackage, final Profile profile, final boolean withSubProfiles) {
- try {
- getDomain().runExclusive(new Runnable() {
-
- public void run() {
-
- Display.getCurrent().asyncExec(new Runnable() {
-
- public void run() {
- getDomain().getCommandStack().execute(new RecordingCommand(domain) {
-
- @Override
- protected void doExecute() {
- PackageUtil.applyProfile(thepackage, profile, withSubProfiles);
- refresh();
- }
- });
- }
- });
- }
- });
- } catch (Exception e) {
- Activator.logException(e, "Unable to apply selected profile.");
- }
-
- }
-
- /**
- * Button action : open a selection dialog box that allow the user to choose profiles to apply.
- */
- protected void applyProfileButtonPressed() {
-
- // Create and open the dialog box
- // ResourceSelectionDialog dialog =
- // new ResourceSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), "Apply Profiles");
-
- ILabelProvider lp = new WorkbenchLabelProvider();
- ITreeContentProvider cp = new WorkbenchContentProvider();
-
- ArrayList<String> filetypes = new ArrayList<String>();
- filetypes.add("uml");
-
- ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), lp, cp);
- dialog.setTitle("Apply Profiles...");
- dialog.setMessage("Choose profiles to apply");
- dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
- dialog.addFilter(new FileSelectionFilter(filetypes));
- dialog.setValidator(new org.eclipse.papyrus.uml.profile.ui.dialogs.FileSelectionValidator());
- dialog.setDoubleClickSelects(true);
- dialog.setHelpAvailable(false);
- dialog.setAllowMultiple(true);
-
- dialog.open();
-
- // If nothing is selected : abort
- if((dialog.getResult() == null) || (dialog.getResult().length < 1)) {
- return;
- }
-
- ArrayList<Package> importedModels = new ArrayList<Package>();
- Package package_ = getSelectedPackage();
-
- for(int i = 0; i < dialog.getResult().length; i++) {
- IFile selectedFile = (IFile)dialog.getResult()[i];
- URI profileUri = URI.createURI("platform:/resource" + selectedFile.getFullPath().toString());
-
- ResourceSet resourceSet = package_.eResource().getResourceSet();
-
- Resource profileResource = resourceSet.getResource(profileUri, true);
-
- if(profileResource.getContents().get(0) instanceof Package) {
- Package importedModel = (Package)profileResource.getContents().get(0);
- importedModels.add(importedModel);
- }
-
- }
-
- if(importedModels.size() > 0) {
- ProfileTreeSelectionDialog profileDialog = new ProfileTreeSelectionDialog(getShell(), importedModels);
-
- profileDialog.open();
- ArrayList<Profile> profilestoApply = profileDialog.getResult();
-
- Message message = new Message("Profile application", "Applying profile...");
- message.open();
- Iterator<Profile> iterator = profilestoApply.iterator();
- while(iterator.hasNext()) {
- applyProfile(package_, iterator.next(), false);
- }
- message.close();
- }
-
- }
-
- /**
- * Creates the button that applies new profiles on selected package.
- */
- private void createApplyProfileButton() {
- FormData data = new FormData();
-
- // Button creation
- addButton = factory.createButton(this, "", SWT.PUSH);
- addButton.setImage(ImageManager.IMG_ADD);
- addButton.setToolTipText("Apply profile...");
- addButton.setVisible(true);
-
- // Button placement
- data.right = new FormAttachment(addRegisteredButton, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
- addButton.setLayoutData(data);
-
- // Button listeners
- addButton.addMouseListener(addButtonListener = new MouseListener() {
-
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- public void mouseDown(MouseEvent e) {
- }
-
- public void mouseUp(MouseEvent e) {
- applyProfileButtonPressed();
- }
-
- });
- }
-
- /**
- *
- */
- public void createContent() {
-
- createLabel();
- createUnapplyProfileButton();
- createRegiteredProfileButton();
- createApplyProfileButton();
-
- profiles = createProfilesList();
- profiles.setVisible(true);
- }
-
- /**
- * Create a label.
- */
- private void createLabel() {
- FormData data = new FormData();
-
- // Label creation
- appliedLabel = factory.createCLabel(this, "Applied profiles:", SWT.NONE);
-
- // Label placement
- data.left = new FormAttachment(0, ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
- appliedLabel.setLayoutData(data);
- }
-
- /**
- * Creates the profiles list.
- *
- * @return the list of applied profiles
- */
- private List createProfilesList() {
- FormData data = new FormData();
-
- // List of applied profiles
- List profiles = new List(this, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER);
-
- // List placement
- data.left = new FormAttachment(0, ITabbedPropertyConstants.HSPACE);
- data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(addButton, ITabbedPropertyConstants.VSPACE);
- data.bottom = new FormAttachment(100, -ITabbedPropertyConstants.VSPACE);
- profiles.setLayoutData(data);
-
- // List listeners
- profiles.addSelectionListener(profilesListener = new SelectionListener() {
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- }
- });
-
- return profiles;
- }
-
- /**
- * Creates the button used to apply a registered (= plugin enclosed) profile to the selected package.
- */
- private void createRegiteredProfileButton() {
- FormData data = new FormData();
-
- // Button creation
- addRegisteredButton = factory.createButton(this, "", SWT.PUSH);
- addRegisteredButton.setImage(ImageManager.IMG_ADDREG);
- addRegisteredButton.setToolTipText("Apply registered profile...");
- addRegisteredButton.setVisible(true);
-
- // Button placement
- data.right = new FormAttachment(removeButton, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
- addRegisteredButton.setLayoutData(data);
-
- // Button listeners
- addRegisteredButton.addMouseListener(addRegisteredButtonListener = new MouseListener() {
-
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- public void mouseDown(MouseEvent e) {
- }
-
- public void mouseUp(MouseEvent e) {
- registeredProfileButtonPressed();
- }
- });
- }
-
- /**
- * Creates a button used to unapply a profile from the selected package.
- */
- private void createUnapplyProfileButton() {
- FormData data = new FormData();
-
- // Button creation
- removeButton = factory.createButton(this, "", SWT.PUSH);
- removeButton.setImage(ImageManager.IMG_DELETE);
- removeButton.setToolTipText("Unapply profiles...");
- removeButton.setVisible(true);
-
- // Button placement
- data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
- removeButton.setLayoutData(data);
-
- // Button listeners
- removeButton.addMouseListener(removeButtonListener = new MouseListener() {
-
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- public void mouseDown(MouseEvent e) {
- }
-
- public void mouseUp(MouseEvent e) {
- unapplyProfileButtonPressed();
- }
- });
- }
-
- /**
- * Dispose listeners.
- */
- public void disposeListeners() {
- if(addButton != null && !addButton.isDisposed()) {
- addButton.removeMouseListener(addButtonListener);
- }
- if(removeButton != null && !removeButton.isDisposed()) {
- removeButton.removeMouseListener(removeButtonListener);
- }
- if(addRegisteredButton != null && !addRegisteredButton.isDisposed()) {
- addRegisteredButton.removeMouseListener(addRegisteredButtonListener);
- }
- if(profiles != null && !profiles.isDisposed()) {
- profiles.removeSelectionListener(profilesListener);
- }
- }
-
- public TransactionalEditingDomain getDomain() {
- return EditorUtils.getTransactionalEditingDomain();
- }
-
- /**
- *
- *
- * @return
- */
- protected List getProfiles() {
- return profiles;
- }
-
- /**
- * Gets the selected package.
- *
- * @return the selected package or null
- */
- public Package getSelectedPackage() {
- Package selectedPackage = null;
- Object input = ((IStructuredSelection)selectedElement).getFirstElement();
- Element element =UMLUtil.resolveUMLElement(input);
- if(element!=null && element instanceof Package ) {
- selectedPackage = (Package)element;
- }
-
- return selectedPackage;
- }
-
- /**
- * Checks if the profile applied has been changed since last application (definition does not match.
- *
- * @param _package
- * on which the profile is applied
- * @param _profile
- * the applied profile
- * @return true if the profile has changed
- */
- private boolean isDirty(Package _package, Profile _profile) {
- boolean isDirty = false;
-
- // Retrieve model resourceSet
- ResourceSet pkge_resourceSet = _package.eResource().getResourceSet();
-
- // Retrieve profile resource
- URI prof_URI = _profile.eResource().getURI();
- Resource modelResource = pkge_resourceSet.getResource(prof_URI, true);
-
- if(modelResource.getContents().get(0) instanceof Profile) {
-
- // ckeck applied profile application definition vs profile definition referenced in file
- Profile profileInFile = (Profile)(modelResource.getContents().get(0));
-
- if(_package.getProfileApplication(_profile) != null) {
- EPackage appliedProfileDefinition = _package.getProfileApplication(_profile).getAppliedDefinition();
- EPackage fileProfileDefinition = null;
-
- // Check profiles qualified names to ensure the correct profiles are compared
- String appliedProfileName = _profile.getQualifiedName();
- String fileProfileName = profileInFile.getQualifiedName();
- if(!appliedProfileName.equals(fileProfileName)) {
-
- // The profile must be a subprofile
- Iterator<Profile> it = PackageUtil.getSubProfiles(profileInFile).iterator();
- while(it.hasNext()) {
- Profile current = it.next();
- fileProfileName = current.getQualifiedName();
- if(fileProfileName.equals(appliedProfileName)) {
- profileInFile = current;
- }
- }
- }
-
- fileProfileDefinition = profileInFile.getDefinition();
-
- if(appliedProfileDefinition != fileProfileDefinition) {
- isDirty = true;
- }
- }
-
- }
-
- return isDirty;
- }
-
- /**
- * refresh the composite
- */
- public void refresh() {
- Package currentPackage = getSelectedPackage();
- if(currentPackage != null && !profiles.isDisposed()) {
- profiles.removeAll();
- EList<Profile> appliedProfiles = currentPackage.getAllAppliedProfiles();
- for(int i = 0; i < appliedProfiles.size(); i++) {
- Profile currentProfile = appliedProfiles.get(i);
- String currentName = currentProfile.getQualifiedName();
-
- if(currentName == null) {
- Activator.getDefault().getLog().log(new Status(IStatus.WARNING, Activator.PLUGIN_ID, "Warning a profile applied on " + currentPackage.getName() + " could not be found : \n\t" + currentProfile.toString()));
- } else if(isDirty(currentPackage, currentProfile)) {
- profiles.add(currentName + TAG_PROFILE_CHANGED);
- profiles.setData(currentName, currentProfile);
- } else {
- profiles.add(currentName);
- profiles.setData(currentName, currentProfile);
- }
- }
- }
- }
-
- /**
- * Button action : open the dialog box for registered profile selection.
- */
- protected void registeredProfileButtonPressed() {
- RegisteredProfileSelectionDialog profileSelectionDialog = new RegisteredProfileSelectionDialog(getShell(), getSelectedPackage());
- java.util.List<Profile> profilestoApply = profileSelectionDialog.run();
- Iterator<Profile> iterator = profilestoApply.iterator();
- while(iterator.hasNext()) {
- if(getSelectedPackage() != null) {
- this.applyProfile(getSelectedPackage(), iterator.next(), false);
- }
- }
- }
-
- public void setDomain(TransactionalEditingDomain domain) {
- this.domain = domain;
- }
-
- /**
- * Sets the selection.
- *
- * @param selection
- * the selection
- */
- public void setSelection(ISelection selection) {
- this.selectedElement = selection;
- }
-
- /**
- * unApply profile done in asynchronous thread
- *
- * @param thepackage
- * the package where the profile will be unapplied
- * @param profile
- * to unapply
- */
- protected void unApplyProfile(final Package thepackage, final Profile profile) {
- try {
- getDomain().runExclusive(new Runnable() {
-
- public void run() {
-
- Display.getCurrent().asyncExec(new Runnable() {
-
- public void run() {
- getDomain().getCommandStack().execute(new RecordingCommand(domain) {
-
- @Override
- protected void doExecute() {
- thepackage.unapplyProfile(profile);
- refresh();
- }
- });
- }
- });
- }
- });
- } catch (Exception e) {
- Activator.logException(e);
- }
-
- }
-
- /**
- * Button action : unaply the profiles selected by the user.
- */
- protected void unapplyProfileButtonPressed() {
-
- // Retrieve indices of selected profiles to unapply
- int[] selectionIndices = profiles.getSelectionIndices();
- if((selectionIndices == null) || (selectionIndices.length == 0)) {
- return;
- }
-
- // Parse selection
- for(int i = 0; i < selectionIndices.length; i++) {
-
- int currentIndex = selectionIndices[i];
- // Remove TAG_PROFILE_CHANGED when it exists
- String itemName = profiles.getItem(currentIndex).replace(TAG_PROFILE_CHANGED, "");
- Profile profileToUnapply = (Profile)profiles.getData(itemName);
-
- if(profileToUnapply == null) {
- return;
- }
-
- // Allow removal if profile is applied on current package
- // Not if it is applied from owner package
- EList appliedProfiles = getSelectedPackage().getAppliedProfiles();
- if(appliedProfiles.contains(profileToUnapply)) {
-
- /**********************************************************************/
- /** delete imported model libraries and types related to that profile */
-
- // model libraries handling
- EList importedPackages = getSelectedPackage().getPackageImports();
- Iterator<PackageImport> iterPI = importedPackages.iterator();
- ArrayList importedPackagesToRemove = new ArrayList();
- while(iterPI.hasNext()) {
- PackageImport pi = iterPI.next();
- if(pi.getImportedPackage().getOwner() != null) {
- if(pi.getImportedPackage().getOwner().equals(profileToUnapply)) {
- importedPackagesToRemove.add(pi);
- }
- }
- }
-
- // remove model librairies
- // this has been done here to avoid concurrent modification of importedPackages
- for(int j = 0; j < importedPackagesToRemove.size(); j++) {
- importedPackages.remove(importedPackagesToRemove.get(j));
- }
- }
- unApplyProfile(getSelectedPackage(), profileToUnapply);
- }
-
- }
-
- /**
- * Resolve semantic element
- *
- * @param object
- * the object to resolve
- * @return <code>null</code> or the semantic element associated to the specified object
- */
- private EObject resolveSemanticObject(Object object) {
- if(object instanceof EObject) {
- return (EObject)object;
- } else if(object instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable)object;
- if(adaptable.getAdapter(EObject.class) != null) {
- return (EObject)adaptable.getAdapter(EObject.class);
- }
- }
- return null;
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositesformodel/AppliedStereotypeCompositeOnModel.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositesformodel/AppliedStereotypeCompositeOnModel.java deleted file mode 100644 index cab9dd1d92d..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositesformodel/AppliedStereotypeCompositeOnModel.java +++ /dev/null @@ -1,534 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.compositesformodel;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.NotificationImpl;
-import org.eclipse.emf.common.util.BasicEList;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.papyrus.infra.core.utils.EditorUtils;
-import org.eclipse.papyrus.uml.profile.Activator;
-import org.eclipse.papyrus.uml.profile.preference.ProfilePreferenceConstants;
-import org.eclipse.papyrus.uml.profile.tree.ProfileElementContentProvider;
-import org.eclipse.papyrus.uml.profile.tree.ProfileElementLabelProvider;
-import org.eclipse.papyrus.uml.profile.tree.ProfileElementTreeViewerFilter;
-import org.eclipse.papyrus.uml.profile.tree.objects.AppliedStereotypePropertyTreeObject;
-import org.eclipse.papyrus.uml.profile.tree.objects.AppliedStereotypeTreeObject;
-import org.eclipse.papyrus.uml.profile.tree.objects.StereotypedElementTreeObject;
-import org.eclipse.papyrus.uml.profile.ui.dialogs.ChooseSetStereotypeDialog;
-import org.eclipse.papyrus.uml.profile.ui.panels.AppliedStereotypePanel;
-import org.eclipse.papyrus.uml.profile.utils.Util;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Stereotype;
-
-// TODO: Auto-generated Javadoc
-/**
- * This composite is used to display applied stereotype in the model. It allows applying or desapply a stereotype
- */
-public class AppliedStereotypeCompositeOnModel extends DecoratedTreeComposite implements ISelectionChangedListener {
-
- /**
- * Gets the domain.
- *
- * @return the domain
- */
- public TransactionalEditingDomain getDomain() {
- return EditorUtils.getTransactionalEditingDomain();
- }
-
- /** The panel that display applied stereotypes. */
- private AppliedStereotypePanel appliedStereotypePanel;
-
- /** The label. */
- protected CLabel label;
-
- /**
- * The default constructor.
- *
- * @param parent
- * the parent Composite for this panel
- */
- public AppliedStereotypeCompositeOnModel(AppliedStereotypePanel parent) {
- super(parent, SWT.NONE, "Applied stereotypes", true);
-
- appliedStereotypePanel = parent;
- }
-
- /**
- * create a composite applied stereotype on model.
- *
- * @param parent
- * the parent composite
- */
- public AppliedStereotypeCompositeOnModel(Composite parent) {
- super(parent, SWT.NONE, "Applied stereotypes", true);
- }
-
- /**
- * apply a stereotype on current selected element.
- */
- protected void addAppliedStereotype() {
-
- // Open stereotype selection (may add or remove)
- ChooseSetStereotypeDialog dialog = new ChooseSetStereotypeDialog(this.getShell(), getElement());
- int result = dialog.open();
-
- if(result == ChooseSetStereotypeDialog.OK) {
- // Retrieve selected element
- Element element = getElement();
-
- // compare the 2 lists (present list and future list
- EList<Stereotype> oldStereotypeList = element.getAppliedStereotypes();
- ArrayList<Stereotype> newStereotypeList = dialog.getSelectedElements();
-
- // Keep newStereotype order (will be used at the end of the method)
- EList<Stereotype> newOrderList = new BasicEList<Stereotype>();
- newOrderList.addAll(newStereotypeList);
-
- // If the 2 lists differ, apply the new list of stereotypes
- if(!(newStereotypeList.equals(oldStereotypeList))) {
-
- // Parse old list :
- // if stereotype is in the new list : it is already applied
- // --> don't unapply it
- // --> remove it from new list
- Iterator<Stereotype> it = oldStereotypeList.iterator();
- while(it.hasNext()) {
- Stereotype currentStOld = it.next();
- if(newStereotypeList.contains(currentStOld)) {
- newStereotypeList.remove(currentStOld);
- } else {
- unapplyStereotype(element, currentStOld);
- }
- }
-
- // Already applied stereotype should have been removed
- // apply others
- Iterator<Stereotype> newApplyStereotypes = newStereotypeList.iterator();
- while(newApplyStereotypes.hasNext()) {
- Stereotype currentStereotype = newApplyStereotypes.next();
- applyStereotype(element, currentStereotype);
- }
-
- // Update Stereotype order
- // this.reorderStereotypeApplications(element, newOrderList);
-
- // checkSelection(null);
- selectionChanged(null);
-
- if(appliedStereotypePanel != null) {
- appliedStereotypePanel.refresh();
- }
- }
- }
-
- }
-
- /**
- * Button action : open a selection dialog box that allow the user to choose stereotypes to apply (or unapply).
- */
- @Override
- public void addButtonPressed() {
- addAppliedStereotype();
- }
-
- /**
- *
- * {@inheritDoc}
- */
- @Override
- public Composite createContent(Composite parent, TabbedPropertySheetWidgetFactory factory) {
- super.createContent(parent, factory);
- createStereotypesTree();
-
- removeButton.setToolTipText("Remove stereotype");
- addButton.setToolTipText("Apply stereotype");
-
- return this;
- }
-
- /**
- * Creates the stereotypes tree.
- *
- * @return the tree of applied stereotypes and properties
- */
- private void createStereotypesTree() {
- // Tree viewer shows applied stereotypes
- treeViewer.setContentProvider(new ProfileElementContentProvider());
- treeViewer.setLabelProvider(new ProfileElementLabelProvider());
- treeViewer.addFilter(new ProfileElementTreeViewerFilter());
- treeViewer.addSelectionChangedListener(this);
- }
-
- /**
- * Button action : modify display order of stereotypes (selected elements are pushed down in the list).
- */
- @Override
- public void downButtonPressed() {
- int nbrOfSelection = getTree().getSelectionCount();
- if(nbrOfSelection < 1) {
- return;
- }
-
- TreeItem[] items = getTree().getSelection();
- int indexLast = getTree().indexOf(items[items.length - 1]);
- if(indexLast + 1 >= getElement().getAppliedStereotypes().size()) {
- // do nothing
- return;
- }
-
- for(int i = 0; i < nbrOfSelection; i++) {
- TreeItem item = items[nbrOfSelection - 1 - i];
- if(item.getData() instanceof AppliedStereotypeTreeObject) {
- AppliedStereotypeTreeObject sTO = (AppliedStereotypeTreeObject)item.getData();
- EList stereotypes = new BasicEList();
- stereotypes.addAll(element.getAppliedStereotypes());
-
- int index = stereotypes.indexOf(sTO.getStereotype());
- if((index == -1) || (index >= stereotypes.size() - 1)) {
- // Not found of already on top...
- return;
- }
-
- stereotypes.move(index + 1, sTO.getStereotype());
- this.reorderStereotypeApplications(element, stereotypes);
- }
- }
- }
-
- /**
- * Edits the item.
- *
- * @param item
- * the item
- */
- @Override
- public void editItem(TreeItem item) {
- // do nothing
- }
-
- /**
- * Gets the selected.
- *
- * @return Returns the selected element.
- */
- public Element getSelected() {
- return appliedStereotypePanel.getSelected();
- }
-
- /**
- * Gets the tree.
- *
- * @return the tree
- */
- public Tree getTree() {
- return treeViewer.getTree();
- }
-
- /**
- * Checks if is in stereotype display.
- *
- * @param st
- * the stereotype
- *
- * @return true, if checks if is in stereotype display
- */
- protected Boolean isInStereotypeDisplay(Stereotype st) {
- return false;
- }
-
- /**
- * Redraw the treeViewer while preserving selections and non-collapsed tree elements
- * It is not sufficient to redraw only selected elements as an optimization, since
- * derived stereotype attributes (that are not selected) might change in response to
- * changing other attributes.
- *
- * @param propertyView
- */
- public void refreshTreeViewer () {
- treeViewer.refresh ();
- }
-
- /**
- * Refresh the content of applied the applied stereotype tree.
- */
- @Override
- public void refresh() {
- if(treeViewer.getTree() != null && !(treeViewer.getTree().isDisposed())) {
- treeViewer.setInput(null);
- treeViewer.refresh();
- if(element != null) {
- treeViewer.setInput(new StereotypedElementTreeObject(element));
- }
- StereotypedElementTreeObject rTO = (StereotypedElementTreeObject)treeViewer.getInput();
- if(rTO == null) {
- return;
- }
-
- // If the property is Multivalued show Up - Down
- if((rTO.getChildren() != null) && (rTO.getChildren().length > 1)) {
- upButton.setEnabled(true);
- downButton.setEnabled(true);
- } else {
- upButton.setEnabled(false);
- downButton.setEnabled(false);
- }
-
- if((rTO.getChildren() != null) && (rTO.getChildren().length == 0)) {
- removeButton.setEnabled(false);
- } else {
- removeButton.setEnabled(true);
- }
- }
- }
-
- /**
- * Button action : unapply the stereotypes selected by the user in the stereotype tree.
- */
- @Override
- public void removeButtonPressed() {
- unapplyStereotype();
- }
-
- /**
- * Selection changed.
- *
- * @param event
- * the event
- */
- public void selectionChanged(SelectionChangedEvent event) {
- if(appliedStereotypePanel != null) {
- if(event == null) {
- appliedStereotypePanel.setSelectedProperty(null);
- return;
- }
-
- IStructuredSelection structSelection = (IStructuredSelection)event.getSelection();
- Object selection = structSelection.getFirstElement();
- if(selection instanceof AppliedStereotypePropertyTreeObject) {
- appliedStereotypePanel.setSelectedProperty((AppliedStereotypePropertyTreeObject)selection);
- } else {
- appliedStereotypePanel.setSelectedProperty(null);
- }
-
- }
- }
-
- /**
- * Sets the input.
- *
- * @param element
- * the element
- */
- public void setInput(StereotypedElementTreeObject element) {
- treeViewer.setInput(element);
- if(Activator.getDefault().getPreferenceStore().getBoolean(ProfilePreferenceConstants.EXPAND_STEREOTYPES_TREE)) {
- treeViewer.expandAll();
- }
- }
-
- /**
- * unapply stereotype on current selected element.
- */
- protected void unapplyStereotype() {
- int nbrOfSelection = getTree().getSelectionCount();
- if(nbrOfSelection == 0) {
- return;
- }
-
- for(int i = 0; i < nbrOfSelection; i++) {
- TreeItem item = getTree().getSelection()[i];
- if(item.getData() instanceof AppliedStereotypeTreeObject) {
- AppliedStereotypeTreeObject sTO = (AppliedStereotypeTreeObject)item.getData();
- unapplyStereotype(element, sTO.getStereotype());
- sTO.removeMe();
- }
- }
- if(appliedStereotypePanel != null) {
- appliedStereotypePanel.refresh();
- } else {
- refresh();
- }
- }
-
- /**
- * Button action : modify display order of stereotypes (selected elements are pushed up in the list).
- */
- @Override
- public void upButtonPressed() {
- int nbrOfSelection = getTree().getSelectionCount();
- if(nbrOfSelection < 1) {
- return;
- }
-
- TreeItem[] items = getTree().getSelection();
- int indexFirst = getTree().indexOf(items[0]);
- if(indexFirst == 0) {
- // do nothing
- return;
- }
-
- for(int i = 0; i < nbrOfSelection; i++) {
- TreeItem item = items[i];
- if(item.getData() instanceof AppliedStereotypeTreeObject) {
- AppliedStereotypeTreeObject sTO = (AppliedStereotypeTreeObject)item.getData();
- EList stereotypes = new BasicEList();
- stereotypes.addAll(element.getAppliedStereotypes());
-
- int index = stereotypes.indexOf(sTO.getStereotype());
- if(index < 1) {
- return;
- }
-
- stereotypes.move(index - 1, sTO.getStereotype());
- this.reorderStereotypeApplications(element, stereotypes);
- }
- }
- if(appliedStereotypePanel != null) {
- appliedStereotypePanel.refresh();
- } else {
- refresh();
- }
- }
-
- /**
- * Apply stereotype.
- *
- * @param elt
- * the elt
- * @param st
- * the st
- */
- public void applyStereotype(final Element elt, final Stereotype st) {
- try {
-
- getDomain().runExclusive(new Runnable() {
-
- public void run() {
-
- Display.getCurrent().asyncExec(new Runnable() {
-
- public void run() {
- getDomain().getCommandStack().execute(new RecordingCommand(getDomain()) {
-
- @Override
- protected void doExecute() {
- elt.applyStereotype(st);
- refresh();
- }
- });
- }
- });
- }
- });
-
- } catch (Exception e) {
- System.err.println(e);
- }
-
- }
-
- /**
- * Unapply stereotype.
- *
- * @param elt
- * the uml element
- * @param st
- * the stereotype to unapply
- */
- protected void unapplyStereotype(final Element elt, final Stereotype st) {
- // bugfix: a selected element is not necessary a diagram element (ex: selection in the outline)
- try {
-
- getDomain().runExclusive(new Runnable() {
-
- public void run() {
-
- Display.getCurrent().asyncExec(new Runnable() {
-
- public void run() {
- getDomain().getCommandStack().execute(new RecordingCommand(getDomain()) {
-
- @Override
- protected void doExecute() {
- elt.unapplyStereotype(st);
- elt.eNotify(new NotificationImpl(Notification.SET, true, true, true));
- refresh();
- }
- });
- }
- });
- }
- });
-
- } catch (Exception e) {
- System.err.println(e);
- }
-
- }
-
- /**
- * change the order of applied stereotype
- *
- * @param element
- * the UML element where stereotypes are applied
- * @param stereotypes
- * the lis of applied stereotypes with the wanted order
- */
- public void reorderStereotypeApplications(final Element element, final EList stereotypes) {
- try {
-
- getDomain().runExclusive(new Runnable() {
-
- public void run() {
-
- Display.getCurrent().asyncExec(new Runnable() {
-
- public void run() {
- getDomain().getCommandStack().execute(new RecordingCommand(getDomain()) {
-
- @Override
- protected void doExecute() {
- Util.reorderStereotypeApplications(element, stereotypes);
- refresh();
- }
- });
- }
- });
- }
- });
-
- } catch (Exception e) {
- System.err.println(e);
- }
-
- }
-
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositesformodel/DecoratedTreeComposite.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositesformodel/DecoratedTreeComposite.java deleted file mode 100644 index f0e8cbb1c26..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositesformodel/DecoratedTreeComposite.java +++ /dev/null @@ -1,530 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.compositesformodel;
-
-import org.eclipse.gef.commands.CommandStack;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.papyrus.uml.profile.ImageManager;
-import org.eclipse.papyrus.uml.profile.tree.ProfileElementTreeViewer;
-import org.eclipse.papyrus.uml.profile.tree.PropertyValueTreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
-import org.eclipse.uml2.uml.Element;
-
-
-/**
- * Base class for a complex section composite. This composite has a label, a
- * tree that describes a tree structure, and four buttons on the side of the
- * table to add an element into the tree, remove selected element(s), move up
- * or down the selected element.
- *
- * @author Remi SCHNEKENBURGER
- */
-public abstract class DecoratedTreeComposite extends Composite implements ISectionComposite {
-
- // child composites for the table composite
-
- // /** main composite of this complex composite */
- // protected Composite composite;
- /**
- * Label above the table.
- */
- protected CLabel label;
-
- /**
- * Table that displays a property for the current element.
- */
- protected Tree tree;
-
- /**
- * The tree viewer.
- */
- protected TreeViewer treeViewer;
-
- /**
- * Button that adds an element.
- */
- protected Button addButton;
-
- /**
- * Button that removes an element.
- */
- protected Button removeButton;
-
- /**
- * button that moves the element up.
- */
- protected Button upButton;
-
- /**
- * button that moves the element down.
- */
- protected Button downButton;
-
- // listeners for buttons
- /**
- * Listener for the add button.
- */
- protected MouseListener addButtonlistener;
-
- /**
- * Listener for the delete button.
- */
- protected MouseListener removeButtonlistener;
-
- /**
- * Listener for the up button.
- */
- protected MouseListener upButtonlistener;
-
- /**
- * Listener for the down button.
- */
- protected MouseListener downButtonlistener;
-
- /**
- *
- */
- protected Listener treeListener;
-
- /**
- * Element selected in the Papyrus modeler.
- */
- protected Element element;
-
-
- // Construction parameters for the composite
- /**
- * text of the label.
- */
- protected String name;
-
- /**
- * returns the element that is selected in Papyrus tool, for which
- * properties are displayed in the property section.
- *
- * @return the element
- */
- public Element getElement() {
- return element;
- }
-
- /**
- * Sets the element that holds property displyed in property section.
- *
- * @param element
- * the element to set
- */
- public void setElement(Element element) {
- this.element = element;
- }
-
- /**
- * Constructor.
- *
- * @param style
- * @param isStereotypeTree
- * @param name
- * text of the Label on the top left of this composite
- * @param parent
- */
- public DecoratedTreeComposite(Composite parent, int style, String name, boolean isStereotypeTree) {
- super(parent, style);
- this.name = name;
- this.setLayout(new FormLayout());
-
- this.addButtonlistener = new AddButtonlistener();
- this.removeButtonlistener = new RemoveButtonlistener();
- this.upButtonlistener = new UpButtonlistener();
- this.downButtonlistener = new DownButtonlistener();
-
- if(isStereotypeTree) {
- treeViewer = new ProfileElementTreeViewer(this);
- } else {
- // Property tree
- treeViewer = new PropertyValueTreeViewer(this);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.cea.papyrus.ui.composites.ISectionComposite#createContent(org.eclipse.swt.widgets.Composite,
- * org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory)
- */
- /**
- *
- *
- * @param factory
- * @param parent
- *
- * @return
- */
- public Composite createContent(Composite parent,
- TabbedPropertySheetWidgetFactory factory) {
-
- FormData data;
-
- /////////////////////////////////////////////////////////////////////////////
- // Create and place button vertically on the left side
- // Button : Add Element
- // Button Delete Element
- removeButton = factory.createButton(this, "", SWT.PUSH);
- removeButton.setVisible(true);
- removeButton.setImage(ImageManager.IMG_DELETE);
- removeButton.setToolTipText("Delete selected element(s)");
- data = new FormData();
- data.top = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
- removeButton.setLayoutData(data);
- removeButton.addMouseListener(removeButtonlistener);
-
- addButton = factory.createButton(this, "", SWT.PUSH);
- addButton.setVisible(true);
- addButton.setImage(ImageManager.IMG_ADD);
- addButton.setToolTipText("Add a new element");
-
- data = new FormData();
- data.top = new FormAttachment(0, 0);
- data.right = new FormAttachment(removeButton, -ITabbedPropertyConstants.HSPACE);
- addButton.setLayoutData(data);
- addButton.addMouseListener(addButtonlistener);
-
- // Button Up
- upButton = factory.createButton(this, "", SWT.PUSH);
- upButton.setVisible(true);
- upButton.setImage(ImageManager.IMG_UP);
- upButton.setToolTipText("Up");
-
- data = new FormData();
- data.top = new FormAttachment(0, 0);
- data.right = new FormAttachment(addButton, -ITabbedPropertyConstants.HSPACE);
- upButton.setLayoutData(data);
- upButton.addMouseListener(upButtonlistener);
-
-
- // Button Down
- downButton = factory.createButton(this, "", SWT.PUSH);
- downButton.setVisible(true);
- downButton.setImage(ImageManager.IMG_DOWN);
- downButton.setToolTipText("Down");
-
- data = new FormData();
- data.top = new FormAttachment(0, 0);
- data.right = new FormAttachment(upButton, -ITabbedPropertyConstants.HSPACE);
- downButton.setLayoutData(data);
- downButton.addMouseListener(downButtonlistener);
-
- // Create label
- label = factory.createCLabel(this, name + ":", SWT.NONE);
- label.setLayout(new FormLayout());
- data = new FormData();
- data.left = new FormAttachment(0, ITabbedPropertyConstants.HSPACE);
- data.right = new FormAttachment(downButton, -ITabbedPropertyConstants.HSPACE - 30);
- data.top = new FormAttachment(0, 0);
- label.setLayoutData(data);
-
- /////////////////////////////////////////////////////////////////////////////
- // Create and place Table
- tree = treeViewer.getTree();
- tree.setLayout(new FormLayout());
- tree.setVisible(true);
- tree.addListener(SWT.MouseDoubleClick, treeListener = new EditItemListener());
-
- data = new FormData();
- data.top = new FormAttachment(addButton, ITabbedPropertyConstants.VSPACE);
- data.left = new FormAttachment(0, ITabbedPropertyConstants.HSPACE);
- data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
- data.bottom = new FormAttachment(100, -ITabbedPropertyConstants.VSPACE);
-
- tree.setLayoutData(data);
- return this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.cea.papyrus.ui.composites.ISectionComposite#refresh()
- */
- /**
- *
- */
- public void refresh() {
- }
-
- // /**
- // * Sets the layout data to the main composite of this complex element
- // * @param data the new LayoutData
- // */
- // public void setLayoutData(Object data) {
- // composite.setLayoutData(data);
- // }
- //
- // public Composite getMainComposite() {
- // return composite;
- // }
-
- /**
- * Returns the CommmandStack of the current editor.
- *
- * @return the CommmandStack of the current editor
- */
- public CommandStack getCommandStack() {
- if(getActiveEditor() != null) {
- return (CommandStack)getActiveEditor().getAdapter(CommandStack.class);
- }
- return null;
- }
-
- /**
- * Returns the current Editor.
- *
- * @return the current editor
- */
- public IEditorPart getActiveEditor() {
- return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- }
-
- /**
- * action executed when the add button is pressed.
- */
- public void addButtonPressed() {
- }
-
- /**
- * action executed when the remove button is pressed.
- */
- public abstract void removeButtonPressed();
-
- /**
- * action executed when the up button is pressed.
- */
- public abstract void upButtonPressed();
-
- /**
- * action executed when the down button is pressed.
- */
- public abstract void downButtonPressed();
-
- /**
- * action executed when a table item is edited.
- *
- * @param item
- */
- public abstract void editItem(TreeItem item);
-
- /**
- * Listener for the Add Button
- * Specific behavior is implemented in {@link DecoratedTreeComposite#addButtonPressed()}.
- *
- * @author Remi SCHNEKENBURGER
- */
- private class AddButtonlistener implements MouseListener {
-
- /**
- *
- *
- * @param e
- */
- public void mouseDoubleClick(MouseEvent e) {
- // do nothing
- }
-
- /**
- *
- *
- * @param e
- */
- public void mouseDown(MouseEvent e) {
- // do nothing
- }
-
- /**
- *
- *
- * @param e
- */
- public void mouseUp(MouseEvent e) {
- addButtonPressed();
- refresh();
- }
- }
-
- /**
- * Listener for the Remove Button
- * Specific behavior is implemented in {@link DecoratedTreeComposite#removeButtonPressed()}.
- *
- * @author Remi SCHNEKENBURGER
- */
- private class RemoveButtonlistener implements MouseListener {
-
- /**
- *
- *
- * @param e
- */
- public void mouseDoubleClick(MouseEvent e) {
- // do nothing
- }
-
- /**
- *
- *
- * @param e
- */
- public void mouseDown(MouseEvent e) {
- // do nothing
- }
-
- /**
- *
- *
- * @param e
- */
- public void mouseUp(MouseEvent e) {
- removeButtonPressed();
- refresh();
- }
- }
-
- /**
- * Listener for the Up Button
- * Specific behavior is implemented in {@link DecoratedTreeComposite#upButtonPressed()}.
- *
- * @author Remi SCHNEKENBURGER
- */
- private class UpButtonlistener implements MouseListener {
-
- /**
- *
- *
- * @param e
- */
- public void mouseDoubleClick(MouseEvent e) {
- // do nothing
- }
-
- /**
- *
- *
- * @param e
- */
- public void mouseDown(MouseEvent e) {
- // do nothing
- }
-
- /**
- *
- *
- * @param e
- */
- public void mouseUp(MouseEvent e) {
- TreeItem[] treeItems = tree.getSelection();
- upButtonPressed();
- refresh();
- // Keep selection
- tree.setSelection(treeItems);
- }
- }
-
- /**
- * Listener for the Down Button
- * Specific behavior is implemented in {@link DecoratedTreeComposite#downButtonPressed()}.
- *
- * @author Remi SCHNEKENBURGER
- */
- private class DownButtonlistener implements MouseListener {
-
- /**
- *
- *
- * @param e
- */
- public void mouseDoubleClick(MouseEvent e) {
- // do nothing
- }
-
- /**
- *
- *
- * @param e
- */
- public void mouseDown(MouseEvent e) {
- // do nothing
- }
-
- /**
- *
- *
- * @param e
- */
- public void mouseUp(MouseEvent e) {
- TreeItem[] treeItems = tree.getSelection();
- downButtonPressed();
- refresh();
- // Keep selection
- tree.setSelection(treeItems);
- }
- }
-
- /**
- *
- */
- private class EditItemListener implements Listener {
-
- /**
- *
- *
- * @param event
- */
- public void handleEvent(Event event) {
- if(tree.getSelection().length > 0) {
- TreeItem item = tree.getSelection()[0];
- editItem(item);
- }
- }
- }
-
- /**
- * Dipose listeners.
- */
- public void disposeListeners() {
- if(addButton != null && !addButton.isDisposed())
- addButton.removeMouseListener(addButtonlistener);
- if(removeButton != null && !removeButton.isDisposed())
- removeButton.removeMouseListener(removeButtonlistener);
- if(upButton != null && !upButton.isDisposed())
- upButton.removeMouseListener(upButtonlistener);
- if(downButton != null && !downButton.isDisposed())
- downButton.removeMouseListener(downButtonlistener);
- if(tree != null && !tree.isDisposed())
- tree.removeListener(SWT.MouseDoubleClick, treeListener);
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositesformodel/ISectionComposite.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositesformodel/ISectionComposite.java deleted file mode 100644 index bb21f86352d..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositesformodel/ISectionComposite.java +++ /dev/null @@ -1,43 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.compositesformodel;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
-
-/**
- *
- */
-public interface ISectionComposite {
-
- /**
- * Creates the content of the Section.
- *
- * @param factory
- * the factory used to create the widgets for the section
- * @param parent
- * the parent of the composite for this section
- *
- * @return the top level Composite of this section
- */
- public Composite createContent(Composite parent, TabbedPropertySheetWidgetFactory factory);
-
- /**
- * Refresh the contents of the controls displayed in this section.
- */
- public void refresh();
-
-
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositesformodel/PropertyComposite.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositesformodel/PropertyComposite.java deleted file mode 100644 index 4ac1fd784e4..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/compositesformodel/PropertyComposite.java +++ /dev/null @@ -1,342 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 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: - * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation - * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification - * Ansgar Radermacher (CEA LIST) Ansgar.Radermacher@cea.fr - modification, clean-up - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.profile.ui.compositesformodel; - -import java.util.ArrayList; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.papyrus.infra.core.utils.EditorUtils; -import org.eclipse.papyrus.uml.profile.Message; -import org.eclipse.papyrus.uml.profile.tree.ProfileElementContentProvider; -import org.eclipse.papyrus.uml.profile.tree.ProfileElementLabelProvider; -import org.eclipse.papyrus.uml.profile.tree.objects.AppliedStereotypePropertyTreeObject; -import org.eclipse.papyrus.uml.profile.tree.objects.AppliedStereotypeTreeObject; -import org.eclipse.papyrus.uml.profile.tree.objects.StereotypedElementTreeObject; -import org.eclipse.papyrus.uml.profile.tree.objects.ValueTreeObject; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.Property; -import org.eclipse.uml2.uml.Stereotype; - -/** - * The goal of this composite is make properties of applied stereotype editable see class AppliedStereotypeEditor - */ -public class PropertyComposite extends DecoratedTreeComposite { - - public TransactionalEditingDomain getDomain() { - // used by heir AppliedStereotypePropertyCompositeWithView - return EditorUtils.getTransactionalEditingDomain(); - } - - /** - * Creates a new PropertyComposite. - * - * @param parent - * the composite parent - */ - public PropertyComposite(Composite parent) { - super(parent, SWT.NONE, "Property values", false); - } - - - /* - * (non-Javadoc) - * - * @see com.cea.papyrus.ui.composites.DecoratedTableComposite#createContent(org.eclipse.swt.widgets.Composite, - * org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory) - */ - @Override - public Composite createContent(Composite parent, TabbedPropertySheetWidgetFactory factory) { - super.createContent(parent, factory); - createPropTree(); - - return this; - } - - /** - * Creates the prop tree. - */ - protected void createPropTree() { - - // List of applied profiles - treeViewer.setContentProvider(new ProfileElementContentProvider()); - treeViewer.setLabelProvider(new ProfileElementLabelProvider()); - } - - /** - * Refresh. - */ - @Override - public void refresh() { - - if(treeViewer.getTree() != null && !(treeViewer.getTree().isDisposed())) { - treeViewer.refresh(); - - AppliedStereotypePropertyTreeObject pTO = (AppliedStereotypePropertyTreeObject)treeViewer.getInput(); - if(pTO == null) { - this.setVisible(false); - } else if((pTO.getProperty() != null) && pTO.getProperty().isReadOnly()) { - upButton.setEnabled(false); - downButton.setEnabled(false); - removeButton.setEnabled(false); - addButton.setEnabled(false); - } else { - upButton.setEnabled(true); - downButton.setEnabled(true); - removeButton.setEnabled(true); - addButton.setEnabled(true); - - // If the property is Multivalued show Up - Down - if((pTO.getChildren() != null) && (pTO.getChildren().length > 1)) { - upButton.setEnabled(true); - downButton.setEnabled(true); - } else { - upButton.setEnabled(false); - downButton.setEnabled(false); - } - - if((pTO.getChildren() != null) && (pTO.getChildren().length == pTO.getProperty().getLower())) { - removeButton.setEnabled(false); - } else { - removeButton.setEnabled(true); - } - - if((pTO.getChildren() != null) && (pTO.getChildren().length == pTO.getProperty().getUpper())) { - addButton.setEnabled(false); - } else { - addButton.setEnabled(true); - } - - this.setVisible(true); - } - } - - } - - public void itemDClicked () { - AppliedStereotypePropertyTreeObject pTO = (AppliedStereotypePropertyTreeObject)treeViewer.getInput(); - // re-initialize value tree objects (model is already updated, value in tree object is not) - pTO.reInitChilds(); - } - - /** - * Action triggered when the add button is pressed. - */ - @Override - public void addButtonPressed() { - - // Retrieve selections - AppliedStereotypePropertyTreeObject pTO = (AppliedStereotypePropertyTreeObject)treeViewer.getInput(); - Property property = pTO.getProperty(); - Stereotype selectedSt = ((AppliedStereotypeTreeObject)pTO.getParent()).getStereotype(); - Element selectedElt = ((StereotypedElementTreeObject)pTO.getParent().getParent()).getElement(); - - if((property == null) || (selectedSt == null) || (selectedElt == null)) { - // Nothing selected - return; - } - - // Retrieve property related info - int lower = property.getLower(); - int upper = property.getUpper(); - - // if lower multiplicity is equal to upper multiplicity : cannot add - if(lower == upper && pTO.getValue() != null) { - if (pTO.getValue() instanceof EList) { - @SuppressWarnings("unchecked") - EList<Object> currentValues = (EList<Object>) pTO.getValue (); - if (currentValues.size() >= upper) { - Message.warning("Multiplicity of this property is " + property.getLower() + ".." + property.getUpper() + "\n" + "Impossible to add a new value."); - return; - } - } else { - Message.warning("Multiplicity of this property is " + property.getLower() + ".." + property.getUpper() + "\n" + "Impossible to add a new value."); - return; - } - } - - // Retrieve current value - ArrayList<Object> currentPropertyValues = new ArrayList<Object>(); - Object currentValue = pTO.getValue(); - if (currentValue != null) { - - if(upper == 1) { - currentPropertyValues.add(currentValue); - - } else { // if (upper != 1) { - - @SuppressWarnings("unchecked") - EList<Object> currentValues = (EList<Object>) currentValue; - for(int i = 0; i < currentValues.size(); i++) { - currentPropertyValues.add(currentValues.get(i)); - } - } - } - - if (property.isMultivalued() || (currentPropertyValues.size() < upper)) { - ValueTreeObject.createInstance(pTO, null).editMe (); - } - else { - Message.warning("Upper multiplicity of " + property.getName() + " is " + property.getUpper()); - } - // Update value tree objects - pTO.reInitChilds (); - } - - /** - * Action triggered when the remove button is pressed. - */ - @Override - public void removeButtonPressed() { - int nbrOfSelection = getTree().getSelectionCount(); - if(nbrOfSelection == 0) { - return; - } - - TreeItem[] items = getTree().getSelection(); - for(int i = 0; i < nbrOfSelection; i++) { - ValueTreeObject vTO = (ValueTreeObject) items[i].getData(); - AppliedStereotypePropertyTreeObject pTO = - (AppliedStereotypePropertyTreeObject) treeViewer.getInput(); - Property property = pTO.getProperty(); - - int lower = property.getLower(); - int upper = property.getUpper(); - - // if lower multiplicity is equal to upper multiplicity - if(lower == upper) { - Message.warning("Multiplicity of this property is" + lower + ".." + upper + "\n" + "Impossible to remove a value."); - return; - } - - Object currentVal = pTO.getValue(); - ArrayList<Object> tempValues = new ArrayList<Object>(); - - if (upper != 1) { - @SuppressWarnings("unchecked") - EList<Object> currentValues = (EList<Object>) currentVal; - tempValues.addAll (currentValues); - - if (tempValues.size() > lower) { - tempValues.remove(vTO.getValue()); - } - } - - if(property.isMultivalued()) { - // setPropertiesValue(selectedElt, stereotype, property, tempValues); - pTO.updateValue (tempValues); - } else { - pTO.updateValue (null); - } - - // Update value tree objects - pTO.reInitChilds (); - } - } - - /** - * Action triggered when the up button is pressed. - */ - @Override - public void upButtonPressed() { - int nbrOfSelection = getTree().getSelectionCount(); - if(nbrOfSelection < 1) { - return; - } - - TreeItem[] items = getTree().getSelection(); - int indexFirst = getTree().indexOf(items[0]); - if(indexFirst == 0) { - // do nothing - return; - } - - for(int i = 0; i < nbrOfSelection; i++) { - ValueTreeObject vTO = (ValueTreeObject)items[i].getData(); - int index = getTree().indexOf(items[i]); - vTO.moveMeUp(index); - } - } - - /** - * Action triggered when the down button is pressed. - */ - @Override - public void downButtonPressed() { - int nbrOfSelection = getTree().getSelectionCount(); - if(nbrOfSelection < 1) { - return; - } - - TreeItem[] items = getTree().getSelection(); - // Get last value index - AppliedStereotypePropertyTreeObject pTO = (AppliedStereotypePropertyTreeObject)treeViewer.getInput(); - int indexLastValue = -1; - if(pTO.getChildren() != null) { - indexLastValue = pTO.getChildren().length - 1; - } - // Get last selection index - int indexLastSelection = getTree().indexOf(items[nbrOfSelection - 1]); - if((indexLastValue == -1) || (indexLastSelection == indexLastValue)) { - // do nothing - return; - } - - for(int i = 0; i < nbrOfSelection; i++) { - ValueTreeObject vTO = (ValueTreeObject)items[nbrOfSelection - 1 - i].getData(); - int index = getTree().indexOf(items[nbrOfSelection - 1 - i]); - vTO.moveMeDown(index); - } - } - - /** - * Sets the input. - * - * @param element - * the element - */ - public void setInput(AppliedStereotypePropertyTreeObject element) { - treeViewer.setInput(element); - if (element != null) { - element.reInitChilds (); - } - refresh(); - } - - /** - * Gets the tree. - * - * @return the tree - */ - public Tree getTree() { - return treeViewer.getTree(); - } - - /** - * - * - * @param item - */ - @Override - public void editItem(TreeItem item) { - // do nothing - } -}
\ No newline at end of file diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/ChooseSetAssistedDialog.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/ChooseSetAssistedDialog.java index bc97f942a56..c6127e61e2a 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/ChooseSetAssistedDialog.java +++ b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/ChooseSetAssistedDialog.java @@ -57,6 +57,7 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
@@ -230,9 +231,7 @@ public class ChooseSetAssistedDialog extends Dialog implements IChooseDialog { * @param possibleText
* the possible text
*/
- public ChooseSetAssistedDialog(Shell parentShell,
- String possibleText,
- String selectedText) {
+ public ChooseSetAssistedDialog(Shell parentShell, String possibleText, String selectedText) {
super(parentShell);
// add the resize ability to the window
@@ -270,10 +269,8 @@ public class ChooseSetAssistedDialog extends Dialog implements IChooseDialog { @Override
protected void createButtonsForButtonBar(Composite parent) {
// remove default button = OK (enter pressed)
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
- false);
- createButton(parent, IDialogConstants.CANCEL_ID,
- IDialogConstants.CANCEL_LABEL, false);
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}
/*
@@ -473,9 +470,7 @@ public class ChooseSetAssistedDialog extends Dialog implements IChooseDialog { char[] autoActivationCharacters = null;
int autoActivationDelay = 500;
- ContentProposalAdapter adapter = new ContentProposalAdapter(possibleElementsText,
- new TextContentAdapter(), getContentProposalProvider(),
- keyStroke, autoActivationCharacters);
+ ContentProposalAdapter adapter = new ContentProposalAdapter(possibleElementsText, new TextContentAdapter(), getContentProposalProvider(), keyStroke, autoActivationCharacters);
adapter.setAutoActivationDelay(autoActivationDelay);
// filter proposals as keys are pressed and proposals popup is present
@@ -1144,10 +1139,12 @@ public class ChooseSetAssistedDialog extends Dialog implements IChooseDialog { * the v
*/
public void inputChanged(Viewer v, Object oldInput, Object newInput) {
- if(newInput != null)
+ if(newInput != null) {
((ElementList)newInput).addChangeListener(this);
- if(oldInput != null)
+ }
+ if(oldInput != null) {
((ElementList)oldInput).removeChangeListener(this);
+ }
}
/*
@@ -1243,10 +1240,12 @@ public class ChooseSetAssistedDialog extends Dialog implements IChooseDialog { * the v
*/
public void inputChanged(Viewer v, Object oldInput, Object newInput) {
- if(newInput != null)
+ if(newInput != null) {
((ElementList)newInput).addChangeListener(this);
- if(oldInput != null)
+ }
+ if(oldInput != null) {
((ElementList)oldInput).removeChangeListener(this);
+ }
}
/*
@@ -1363,8 +1362,7 @@ public class ChooseSetAssistedDialog extends Dialog implements IChooseDialog { * @throws InterruptedException
* @throws InvocationTargetException
*/
- public synchronized final void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
+ public synchronized final void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
final InvocationTargetException[] iteHolder = new InvocationTargetException[1];
try {
IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/ChooseSetDialog.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/ChooseSetDialog.java deleted file mode 100644 index 8dd97411f5c..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/ChooseSetDialog.java +++ /dev/null @@ -1,638 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.dialogs;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.papyrus.uml.profile.FontManager;
-import org.eclipse.papyrus.uml.profile.ImageManager;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants;
-
-
-// TODO: Auto-generated Javadoc
-/**
- * Generic dialog that allows user to add/remove items to an element.
- *
- * @author Patrick Tessier, Remi Schnekenburger
- */
-public class ChooseSetDialog extends Dialog implements IChooseDialog {
-
- /**
- * The combo.
- */
- protected Combo combo;
-
- /**
- * The element list.
- */
- protected String[] elementList = { "test", "test1", "test2" };
-
- /**
- * The name field.
- */
- protected Text nameField;
-
- /**
- * The announce.
- */
- protected String announce = "Choose your element";
-
- /**
- * The Constant channel.
- */
- protected static final int channel = 19;
-
- /**
- * The value.
- */
- protected Object value = null;
-
- /**
- * The possible element list.
- */
- protected List possibleElementList;
-
- /**
- * The selected element list.
- */
- protected List selectedElementList;
-
- /**
- * The add button.
- */
- protected Button addButton;
-
- /**
- * The delete button.
- */
- protected Button deleteButton;
-
- /**
- * The possible set text.
- */
- protected Label possibleSetText;
-
- /**
- * The selected element text.
- */
- protected Label selectedElementText;
-
- /**
- * The possible text.
- */
- protected String possibleText = "Choose Element";
-
- /**
- * The selected text.
- */
- protected String selectedText = "Selected Element";
-
- /**
- * The add button listener.
- */
- protected MouseListener addButtonListener = null;
-
- /**
- * The delete button listener.
- */
- protected MouseListener deleteButtonListener = null;
-
- /**
- * The up button.
- */
- protected Button upButton;
-
- /**
- * The bottom button.
- */
- protected Button bottomButton;
-
- /**
- * The up button listener.
- */
- protected MouseListener upButtonListener = null;
-
- /**
- * The bottom button listener.
- */
- protected MouseListener bottomButtonListener = null;
-
- /**
- * The Constant IMG_UP_ARROW.
- */
- private static final Image IMG_UP_ARROW = ImageManager.IMG_UP;
-
- /**
- * The Constant IMG_DOWN_ARROW.
- */
- private static final Image IMG_DOWN_ARROW = ImageManager.IMG_DOWN;
-
- /**
- * The Constant IMG_LEFT_ARROW.
- */
- private static final Image IMG_LEFT_ARROW = ImageManager.IMG_LEFT;
-
- /**
- * The Constant IMG_RIGHT_ARROW.
- */
- private static final Image IMG_RIGHT_ARROW = ImageManager.IMG_RIGHT;
-
- /**
- * listener of the button to add an elment form possiblelist into selectedList.
- *
- * @author Patrick Tessier
- */
- protected class AddButtonListener implements MouseListener {
-
- /**
- * The Constructor.
- */
- public AddButtonListener() {
- }
-
- /**
- * Mouse double click.
- *
- * @param e
- * the e
- */
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- /**
- * Mouse down.
- *
- * @param e
- * the e
- */
- public void mouseDown(MouseEvent e) {
- }
-
- /**
- * Mouse up.
- *
- * @param e
- * the e
- */
- public void mouseUp(MouseEvent e) {
- runActionAdd();
- }
- };
-
- /**
- * Listener of the button to add an element form selectedList into selectedList possiblelist.
- *
- * @author Patrick Tessier
- */
- protected class DeleteButtonListener implements MouseListener {
-
- /**
- * The Constructor.
- */
- public DeleteButtonListener() {
- }
-
- /**
- * Mouse double click.
- *
- * @param e
- * the e
- */
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- /**
- * Mouse down.
- *
- * @param e
- * the e
- */
- public void mouseDown(MouseEvent e) {
- }
-
- /**
- * Mouse up.
- *
- * @param e
- * the e
- */
- public void mouseUp(MouseEvent e) {
- runActionDelete();
- }
- };
-
- /**
- * listener of the button to move up an element.
- *
- * @author Patrick Tessier
- */
- protected class UpButtonListener implements MouseListener {
-
- /**
- * The Constructor.
- */
- public UpButtonListener() {
- }
-
- /**
- * Mouse double click.
- *
- * @param e
- * the e
- */
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- /**
- * Mouse down.
- *
- * @param e
- * the e
- */
- public void mouseDown(MouseEvent e) {
- }
-
- /**
- * Mouse up.
- *
- * @param e
- * the e
- */
- public void mouseUp(MouseEvent e) {
- runActionUp();
- }
- };
-
- /**
- * listener of the button to move bottom an element.
- *
- * @author Patrick Tessier
- */
- protected class BottomButtonListener implements MouseListener {
-
- /**
- * The Constructor.
- */
- public BottomButtonListener() {
- }
-
- /**
- * Mouse double click.
- *
- * @param e
- * the e
- */
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- /**
- * Mouse down.
- *
- * @param e
- * the e
- */
- public void mouseDown(MouseEvent e) {
- }
-
- /**
- * Mouse up.
- *
- * @param e
- * the e
- */
- public void mouseUp(MouseEvent e) {
- runActionBottom();
- }
- };
-
-
- /**
- * The Constructor.
- *
- * @param parentShell
- * the parent shell
- * @param selectedText
- * the selected text
- * @param possibleText
- * the possible text
- */
- public ChooseSetDialog(Shell parentShell,
- String possibleText,
- String selectedText) {
- super(parentShell);
- setShellStyle(SWT.RESIZE | super.getShellStyle());
- if(possibleText != null) {
- this.possibleText = possibleText; //set possible Text
- }
- if(selectedText != null) {
- this.selectedText = selectedText;//set selected Label
- }
- //Add listener
- this.addButtonListener = new AddButtonListener();
- this.deleteButtonListener = new DeleteButtonListener();
- this.upButtonListener = new UpButtonListener();
- this.bottomButtonListener = new BottomButtonListener();
- }
-
- /**
- * Creates the dialog area.
- *
- * @param parent
- * the parent
- *
- * @return the control
- */
- @Override
- protected Control createDialogArea(Composite parent) {
- //place all buttons
- Composite comp = (Composite)super.createDialogArea(parent);
- FormLayout layout = new FormLayout();
- comp.setLayout(layout);
-
- // initializes data
- FormData data;
-
- // create elements
- createElements(comp);
-
- // set fonts for elements that require fonts
- setFonts();
-
- // set data to the left elements: possible elements
- // Label: available elements title
- data = new FormData();
- data.top = new FormAttachment(0, ITabbedPropertyConstants.VSPACE);
- data.left = new FormAttachment(0, ITabbedPropertyConstants.HSPACE);
- possibleSetText.setLayoutData(data);
-
- // List: available elements list
- data = new FormData();
- data.height = 200;
- data.width = 300;
- data.top = new FormAttachment(possibleSetText, ITabbedPropertyConstants.VSPACE);
- data.left = new FormAttachment(0, ITabbedPropertyConstants.HSPACE);
- data.bottom = new FormAttachment(100, -ITabbedPropertyConstants.VSPACE);
- data.right = new FormAttachment(addButton, -ITabbedPropertyConstants.HSPACE);
- possibleElementList.setLayoutData(data);
-
- // buttons
- // add button
- data = new FormData();
- data.top = new FormAttachment(40, 0);
- data.right = new FormAttachment(50, -(ITabbedPropertyConstants.HSPACE) / 2);
- addButton.setLayoutData(data);
-
- // right button
- data = new FormData();
- data.top = new FormAttachment(addButton, ITabbedPropertyConstants.VSPACE, SWT.BOTTOM);
- data.right = new FormAttachment(50, -(ITabbedPropertyConstants.HSPACE) / 2);
- deleteButton.setLayoutData(data);
-
- // Right part
- // Label: selected elements title
- data = new FormData();
- data.top = new FormAttachment(0, ITabbedPropertyConstants.HSPACE);
- data.left = new FormAttachment(addButton, ITabbedPropertyConstants.HSPACE);
- selectedElementText.setLayoutData(data);
-
- // Label: selected elements list
- data = new FormData();
- data.left = new FormAttachment(addButton, ITabbedPropertyConstants.HSPACE);
- data.top = new FormAttachment(selectedElementText, ITabbedPropertyConstants.VSPACE);
- data.right = new FormAttachment(upButton, -ITabbedPropertyConstants.HSPACE);
- data.bottom = new FormAttachment(100, -ITabbedPropertyConstants.VSPACE);
- selectedElementList.setLayoutData(data);
-
- // up button
- data = new FormData();
- data.top = new FormAttachment(40, 0);
- data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
- upButton.setLayoutData(data);
-
- // down button
- data = new FormData();
- data.top = new FormAttachment(upButton, ITabbedPropertyConstants.HSPACE, SWT.BOTTOM);
- data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
- bottomButton.setLayoutData(data);
-
- // refresh both lists
- fillSelectedElementList();
- fillPossibleElementList();
-
- // add listeners to button
- addButtonListeners();
-
- // end of the dialog
- return comp;
- }
-
- /**
- * Create elements in the dialog.
- *
- * @param comp
- * the parent composite
- */
- private void createElements(Composite comp) {
- // buttons
- addButton = new Button(comp, SWT.CENTER);
- addButton.setImage(IMG_RIGHT_ARROW);
-
- deleteButton = new Button(comp, SWT.CENTER);
- deleteButton.setImage(IMG_LEFT_ARROW);
-
- upButton = new Button(comp, SWT.CENTER);
- upButton.setImage(IMG_UP_ARROW);
-
- bottomButton = new Button(comp, SWT.CENTER);
- bottomButton.setImage(IMG_DOWN_ARROW);
-
- // texts
- selectedElementText = new Label(comp, SWT.CENTER);
- selectedElementText.setText(selectedText);
-
- possibleSetText = new Label(comp, SWT.CENTER);
- possibleSetText.setText(possibleText);
-
- // lists
- selectedElementList = new List(comp, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
- possibleElementList = new List(comp, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
- }
-
- /**
- * Apply Font to elements that display text.
- */
- private void setFonts() {
- FontData[] fontdata = { new FontData("Arial", 9, SWT.NORMAL) };
- Font font = new FontManager().get(fontdata);
- selectedElementText.setFont(font);
- selectedElementList.setFont(font);
- possibleSetText.setFont(font);
- possibleElementList.setFont(font);
- }
-
- /**
- * Add listeners to buttons.
- */
- private void addButtonListeners() {
- addButton.addMouseListener(addButtonListener);
- deleteButton.addMouseListener(deleteButtonListener);
- upButton.addMouseListener(upButtonListener);
- bottomButton.addMouseListener(bottomButtonListener);
- }
-
- /**
- * Creates the composite.
- *
- * @param parent
- * the parent
- */
- protected void createComposite(Composite parent) {
- Composite comp = new Composite(parent, SWT.NONE);
- comp.setLayout(new GridLayout());
- }
-
- /**
- * fill the possible list.
- */
- protected void fillPossibleElementList() {
- for(int i = 0; i < 20; i++) {
- possibleElementList.add("item" + i);
- }
- }
-
- /**
- * fill the selected list.
- */
- protected void fillSelectedElementList() {
- for(int i = 0; i < 20; i++) {
- selectedElementList.add("itemSelected" + i);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
- */
- /**
- * Creates the buttons for button bar.
- *
- * @param parent
- * the parent
- */
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- super.createButtonsForButtonBar(parent);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
- */
- /**
- * Button pressed.
- *
- * @param buttonId
- * the button id
- */
- @Override
- protected void buttonPressed(int buttonId) {
- super.buttonPressed(buttonId);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- */
- /**
- * Ok pressed.
- */
- @Override
- protected void okPressed() {
- super.okPressed();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.Dialog#cancelPressed()
- */
- /**
- * Cancel pressed.
- */
- @Override
- protected void cancelPressed() {
- value = null;
- super.cancelPressed();
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.cea.papyrus.ui.dialogs.IChooseDialog#getValue()
- */
- /**
- * Gets the value.
- *
- * @return the value
- */
- public Object getValue() {
- return value;
- }
-
- /**
- * Behavior for the add button.
- */
- protected void runActionAdd() {
- }
-
- /**
- * Behavior for the delete button.
- */
- protected void runActionDelete() {
- }
-
- /**
- * Behavior for the up button.
- */
- protected void runActionUp() {
- }
-
- /**
- * Behavior for the bottom button.
- */
- protected void runActionBottom() {
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/ChooseSetStereotypeDialog.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/ChooseSetStereotypeDialog.java deleted file mode 100644 index 969ee3ee19a..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/ChooseSetStereotypeDialog.java +++ /dev/null @@ -1,226 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.dialogs;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.uml2.uml.Stereotype;
-
-
-// TODO: Auto-generated Javadoc
-/**
- * Dialog that allows user to add/remove stereotypes to an element.
- *
- * @author Patrick Tessier, Remi Schnekenburger
- */
-public class ChooseSetStereotypeDialog extends ChooseSetAssistedDialog implements IChooseDialog {
-
- /**
- * LabelProvider for stereotype completion proposal provider with qualified names.
- */
- final private StereotypeQualifiedLabelProvider qualifiedLabelProvider = new StereotypeQualifiedLabelProvider();
-
- /**
- * Default Constructor.
- *
- * @param parentShell
- * the parent shell
- * @param theElement
- * the UML element to be modified
- */
- public ChooseSetStereotypeDialog(Shell parentShell, org.eclipse.uml2.uml.Element theElement) {
- super(parentShell,
- "Applicable Stereotypes: ",
- "Applied Stereotypes: ");
- labelProvider = new StereotypeLabelProvider();
- decoratedContentProposalProvider = new StereotypeContentProposalProvider();
-
- Iterator<Stereotype> stereotypes = theElement.getAppliedStereotypes().iterator();
- while(stereotypes.hasNext()) {
- selectedElementList.addElement(stereotypes.next());
- }
-
- stereotypes = theElement.getApplicableStereotypes().iterator();
- while(stereotypes.hasNext()) {
- Stereotype current = (Stereotype)stereotypes.next();
- if(!selectedElementList.contains(current)) {
- possibleElementList.addElement(current);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.cea.papyrus.ui.dialogs.ChooseSetAssistedDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- /**
- * Creates the dialog area.
- *
- * @param parent
- * the parent
- *
- * @return the control
- */
- @Override
- protected Control createDialogArea(Composite parent) {
- Control composite = super.createDialogArea(parent);
-
- // Add 2 columns to the table area
- // possibleElementsTable.setLinesVisible(true);
- possibleElementsTable.setHeaderVisible(true);
-
- // 1st column with image/checkboxes - NOTE: The SWT.CENTER has no effect!!
- TableColumn column = new TableColumn(possibleElementsTable, SWT.CENTER, 0);
- column.setText("Stereotype");
- column.setWidth(150);
- column.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- possibleElementsTableViewer.setSorter(new AlphabeticalViewerSorter(0));
- }
- });
-
- // 2nd column with task Description
- column = new TableColumn(possibleElementsTable, SWT.LEFT, 1);
- column.setText("Information");
- column.setWidth(165);
- // Add listener to column so tasks are sorted by description when clicked
- column.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- possibleElementsTableViewer.setSorter(new AlphabeticalViewerSorter(1));
- }
- });
-
- // set sorter to the possible element table viewer
- possibleElementsTableViewer.setSorter(new AlphabeticalViewerSorter(0));
-
- return composite;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.cea.papyrus.ui.dialogs.ChooseSetAssistedDialog#runAddElement(java.lang.String)
- */
- /**
- * Run add element.
- *
- * @param name
- * the name
- */
- @Override
- protected void runAddElement(String name) {
- // find the stereotype in the list
- Stereotype stereotype = null;
- Iterator<Stereotype> it = possibleElementList.getElements().iterator();
- while(it.hasNext()) {
- Stereotype element = (Stereotype)it.next();
- if(name.equalsIgnoreCase(element.getName()) || name.equalsIgnoreCase(element.getQualifiedName())) {
- stereotype = element;
- }
- }
- if(stereotype != null) {
- runActionAdd(stereotype);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.cea.papyrus.ui.dialogs.ChooseSetAssistedDialog#isSelectableElement(java.lang.String)
- */
- /**
- * Checks if is selectable element.
- *
- * @param text
- * the text
- *
- * @return true, if is selectable element
- */
- @Override
- protected boolean isSelectableElement(String text) {
- // iterate through all possibilities and return true if text corresponds
- Iterator<Stereotype> it = possibleElementList.getElements().iterator();
- while(it.hasNext()) {
- Stereotype element = (Stereotype)it.next();
- if(text.equalsIgnoreCase(element.getName()) || text.equalsIgnoreCase(element.getQualifiedName())) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Content Proposal provider for stereotypes dialog. Propose the simple
- * name of the stereotype and its qualified name.
- *
- * @author Remi Schnekenburger
- */
- public class StereotypeContentProposalProvider extends DecoratedContentProposalProvider {
-
- /*
- * (non-Javadoc)
- *
- * @see com.cea.papyrus.ui.dialogs.ChooseSetAssistedDialog.DecoratedContentProposalProvider#getProposals(java.lang.String, int)
- */
- /**
- * Gets the proposals.
- *
- * @param contents
- * the contents
- * @param position
- * the position
- *
- * @return the proposals
- */
- @Override
- public DecoratedContentProposal[] getProposals(String contents, int position) {
- ArrayList<DecoratedContentProposal> proposals = new ArrayList<DecoratedContentProposal>();
-
- if(possibleElementList != null) {
- Iterator it = possibleElementList.getElements().iterator();
- while(it.hasNext()) {
- final Stereotype stereotype = (Stereotype)it.next();
- final String simpleName = stereotype.getName();
- final String qualifiedName = stereotype.getQualifiedName();
-
- if(position < simpleName.length() && contents.substring(0, position).equalsIgnoreCase(simpleName.substring(0, position))) {
- proposals.add(new DecoratedContentProposal(stereotype, labelProvider));
- }
-
- if(position < qualifiedName.length() && contents.substring(0, position).equalsIgnoreCase(qualifiedName.substring(0, position))) {
- proposals.add(new DecoratedContentProposal(stereotype, qualifiedLabelProvider));
- }
- }
- }
-
- Collections.sort(proposals);
- return proposals.toArray(new DecoratedContentProposal[proposals.size()]);
- }
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/DefinitionHistoryDialog.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/DefinitionHistoryDialog.java deleted file mode 100644 index c5869e5bb27..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/DefinitionHistoryDialog.java +++ /dev/null @@ -1,324 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.dialogs;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.uml.profile.ImageManager;
-import org.eclipse.papyrus.uml.profile.definition.IPapyrusVersionConstants;
-import org.eclipse.papyrus.uml.profile.definition.PapyrusDefinitionAnnotation;
-import org.eclipse.papyrus.uml.profile.utils.Util;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.uml2.uml.Profile;
-
-
-public class DefinitionHistoryDialog extends TitleAreaDialog {
-
- /** path to the banner image */
- public final static String PROFILE_ANNOTATION_IMG = ImageManager.IMAGE_PATH + "wizban/Annotation.gif";
-
- /** Profile for which definitions are displayed */
- protected Profile profile;
-
- /** list of previous definition annotations */
- List<PapyrusDefinitionAnnotation> oldVersionAnnotations = new ArrayList<PapyrusDefinitionAnnotation>();
-
- /**
- * Creates a new ProfileDefinitionDialog
- *
- * @param parentShell
- * the parent shell for this dialog
- * @param profile
- * the profile for which definition history is displayed
- */
- public DefinitionHistoryDialog(Shell parentShell, Profile profile) {
- super(parentShell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- this.profile = profile;
-
- computeHistoryAnnotations();
- }
-
- /**
- * retrieve version annotation history
- */
- private void computeHistoryAnnotations() {
- // get all annotations for the given profile
- oldVersionAnnotations = Util.getAllPapyrusDefinitionAnnotation(profile);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected Control createDialogArea(Composite parent) {
- // top level composite
- Composite parentComposite = (Composite)super.createDialogArea(parent);
-
- setTitle("Profile definition history");
- setTitleImage(ImageManager.getImage(PROFILE_ANNOTATION_IMG));
-
- // create a composite with standard margins and spacing
- Composite composite = new Composite(parentComposite, SWT.NONE);
- GridLayout layout = new GridLayout(1, true);
- layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
- layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- composite.setFont(parentComposite.getFont());
-
- // fill composite with information about definitions:
- GridData gd;
-
- Composite tableArea = createTableArea(composite);
- gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- tableArea.setLayoutData(gd);
-
- applyDialogFont(parentComposite);
- return parentComposite;
- }
-
- /**
- * Creates and returns the content of the advanced area.
- *
- * @param composite
- * The parent composite to contain the advanced area
- */
- private Composite createTableArea(Composite composite) {
- Composite parent = new Composite(composite, SWT.FILL);
- GridLayout layout = new GridLayout();
- parent.setLayout(layout);
- Font font = composite.getFont();
-
- TableViewer viewer = new TableViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
- final Table table = viewer.getTable();
- TableLayout tableLayout = new TableLayout();
- table.setLayout(tableLayout);
- table.setHeaderVisible(true);
- table.setFont(font);
- GridData gridData = new GridData(GridData.FILL_BOTH);
- gridData.widthHint = 450;
- gridData.heightHint = 300;
- viewer.getControl().setLayoutData(gridData);
- viewer.setContentProvider(new DefinitionHistoryContentProvider());
- viewer.setLabelProvider(new DefinitionHistoryTableLabelProvider());
-
- createTableColumn(table, 20, "version", true, SWT.CENTER);
- createTableColumn(table, 40, "author", true, SWT.CENTER);
- createTableColumn(table, 30, "date", true, SWT.CENTER);
- createTableColumn(table, 30, "comment", true, SWT.LEFT);
- createTableColumn(table, 50, "copyright", true, SWT.LEFT);
-
- // // display is a table with all history versions
- // final Table table = new Table(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- // final TableColumn versionColumn = new TableColumn(table, SWT.CENTER);
- // versionColumn.setText("version");
- // final TableColumn dateColumn = new TableColumn(table, SWT.CENTER);
- // dateColumn.setText("date");
- // final TableColumn authorColumn = new TableColumn(table, SWT.CENTER);
- // authorColumn.setText("author");
- // final TableColumn commentColumn = new TableColumn(table, SWT.CENTER);
- // commentColumn.setText("comment");
-
- // GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- // table.setLayoutData(gd);
-
- // TableViewer viewer = new TableViewer(table);
- // configure viewer
- viewer.setContentProvider(new DefinitionHistoryContentProvider());
- viewer.setLabelProvider(new DefinitionHistoryTableLabelProvider());
- viewer.setInput(profile);
-
- return parent;
- }
-
- /**
- * Creates table columns for the viewer
- *
- * @param table
- * the modified table
- * @param weight
- * weight of the column (size)
- * @param title
- * title of the column
- * @param resizable
- * is the column resizable
- * @return the create column
- */
- protected TableColumn createTableColumn(Table table, int weight, String title, boolean resizable, int style) {
- ((TableLayout)table.getLayout()).addColumnData(new ColumnWeightData(weight));
- final TableColumn tc = new TableColumn(table, style);
- tc.setResizable(true);
- tc.setText(title);
- return tc;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- shell.setText("Profile Definition"); //$NON-NLS-1$
- }
-
- /**
- * Content provider for table that displays information about Definition History
- */
- public class DefinitionHistoryContentProvider implements IStructuredContentProvider {
-
- /**
- * {@inheritDoc}
- */
- public Object[] getElements(Object inputElement) {
- if(inputElement instanceof Profile) {
- // retrieve all definitions
- EAnnotation eAnnotation = ((Profile)inputElement).getEAnnotation("http://www.eclipse.org/uml2/2.0.0/UML");
- if(eAnnotation != null) {
- EList<EObject> definitions = eAnnotation.getContents();
- List<Object> elements = new ArrayList<Object>();
- // convert Papyrus Upgraded Annotation if possible (annotation with PapyrusVersion source added to the definition)
- Iterator<EObject> it = definitions.listIterator();
- while(it.hasNext()) {
- EPackage object = (EPackage)it.next();
- EAnnotation annotation = object.getEAnnotation(IPapyrusVersionConstants.PAPYRUS_EANNOTATION_SOURCE);
- if(annotation == null) {
- elements.add(0, PapyrusDefinitionAnnotation.UNDEFINED_ANNOTATION);
- } else {
- elements.add(0, PapyrusDefinitionAnnotation.parseEAnnotation(annotation));
- }
- }
- return elements.toArray();
- }
- return new Object[]{};
- }
- return new Object[]{};
- }
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- }
-
- /**
- * {@inheritDoc}
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- }
-
- /**
- * Label provider for table that displays information about Definition History
- */
- public class DefinitionHistoryTableLabelProvider implements ITableLabelProvider {
-
- /**
- * {@inheritDoc}
- */
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getColumnText(Object element, int columnIndex) {
- if(element instanceof PapyrusDefinitionAnnotation) {
- return getColumnText((PapyrusDefinitionAnnotation)element, columnIndex);
- }
- // should never append
- return "naa";
- }
-
- /**
- * Returns the label text for the given column index
- *
- * @param annotation
- * the annotation representing the entire row (should never be <code>null</code>)
- * @param columnIndex
- * the zero-based index of the column in which the label appears
- * @return
- */
- public String getColumnText(PapyrusDefinitionAnnotation annotation, int columnIndex) {
- switch(columnIndex) {
- case 0:
- return annotation.getVersion().toString();
- case 1:
- return annotation.getAuthor();
- case 2:
- return annotation.getDate();
- case 3:
- return annotation.getComment();
- case 4:
- return annotation.getCopyright();
- default:
- return "unknown";
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void addListener(ILabelProviderListener listener) {
- }
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public void removeListener(ILabelProviderListener listener) {
- }
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/ElementList.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/ElementList.java index c5b76bc5728..d13faab326a 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/ElementList.java +++ b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/ElementList.java @@ -69,8 +69,9 @@ public class ElementList { public void addElement(Object element) {
elements.add(elements.size(), element);
Iterator iterator = changeListeners.iterator();
- while(iterator.hasNext())
+ while(iterator.hasNext()) {
((IListViewer)iterator.next()).addElement(element);
+ }
}
@@ -83,8 +84,9 @@ public class ElementList { public void removeElement(Object element) {
elements.remove(element);
Iterator iterator = changeListeners.iterator();
- while(iterator.hasNext())
+ while(iterator.hasNext()) {
((IListViewer)iterator.next()).removeElement(element);
+ }
}
/**
@@ -102,8 +104,9 @@ public class ElementList { }
Iterator iterator = changeListeners.iterator();
- while(iterator.hasNext())
+ while(iterator.hasNext()) {
((IListViewer)iterator.next()).updateElement(element);
+ }
}
@@ -122,8 +125,9 @@ public class ElementList { }
Iterator iterator = changeListeners.iterator();
- while(iterator.hasNext())
+ while(iterator.hasNext()) {
((IListViewer)iterator.next()).updateElement(element);
+ }
}
@@ -135,8 +139,9 @@ public class ElementList { */
public void elementChanged(Object element) {
Iterator iterator = changeListeners.iterator();
- while(iterator.hasNext())
+ while(iterator.hasNext()) {
((IListViewer)iterator.next()).updateElement(element);
+ }
}
/**
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/FileSelectionFilter.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/FileSelectionFilter.java deleted file mode 100644 index b46f6f005e8..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/FileSelectionFilter.java +++ /dev/null @@ -1,72 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.dialogs;
-
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-
-
-public class FileSelectionFilter extends ViewerFilter {
-
- /** Authorized file extensions */
- List<String> filetypes;
-
- /**
- * If newFileTypes is null, any extension is accepted
- *
- * @param newFiletypes
- * authorized extensions for the file viewer filter
- */
- public FileSelectionFilter(List<String> newFiletypes) {
- super();
- filetypes = newFiletypes;
- }
-
- @Override
- public boolean select(Viewer arg0, Object arg1, Object arg2) {
-
- if((arg2 instanceof IContainer) || (arg2 instanceof IFile)) {
-
- // Filter files
- if(arg2 instanceof IFile) {
- IFile file = (IFile)arg2;
- String file_ext = file.getFileExtension();
-
- if((filetypes != null) && (!filetypes.contains(file_ext))) {
- return false;
- }
- }
-
- // Filter folders
- if(arg2 instanceof IContainer) {
- IContainer container = (IContainer)arg2;
- String name = container.getName();
-
- // Mask hidden folder
- if(name.startsWith(".")) {
- return false;
- }
- }
-
- return true;
- }
- return false;
- }
-
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/FileSelectionValidator.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/FileSelectionValidator.java deleted file mode 100644 index 4d3e989d580..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/FileSelectionValidator.java +++ /dev/null @@ -1,44 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.dialogs;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.papyrus.uml.profile.Activator;
-import org.eclipse.ui.dialogs.ISelectionStatusValidator;
-
-
-
-public class FileSelectionValidator implements ISelectionStatusValidator {
-
- public IStatus validate(Object[] arg0) {
-
- if((arg0 == null) || (arg0.length < 1)) {
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "No selection.");
- }
-
- Object selection = arg0[0];
- if(!(selection instanceof IFile)) {
-
- return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "The selection should be a file.");
- }
-
- return new Status(
- IStatus.OK
- , Activator.PLUGIN_ID
- , "Selection is valid");
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/LabelEditorDialog.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/LabelEditorDialog.java deleted file mode 100644 index 44293c17ba5..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/LabelEditorDialog.java +++ /dev/null @@ -1,193 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.uml.profile.ui.dialogs;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IInputValidator;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-
-// equivalent au inputDialog (code recopie) mais donne un sourceviewer a la place du label
-public class LabelEditorDialog extends Dialog {
-
- /**
- * The title of the dialog.
- */
- protected String title;
-
- /**
- * The input value; the empty string by default.
- */
- protected String value = "";//$NON-NLS-1$
-
- /**
- * The input validator, or <code>null</code> if none.
- */
- protected IInputValidator validator;
-
- /**
- * Ok button widget.
- */
- protected Button okButton;
-
- /**
- * Error message label widget.
- */
- protected Text errorMessageText;
-
- /**
- * Error message string.
- */
- protected String errorMessage;
-
- /**
- * SourceViewer : area that displays text
- */
- protected SourceViewer viewer;
-
- /**
- * Creates a dialog with OK and Cancel buttons. Note that the dialog
- * will have no visual representation (no widgets) until it is told to open.
- * <p>
- * Note that the <code>open</code> method blocks for input dialogs.
- * </p>
- *
- * @param parentShell
- * the parent shell, or <code>null</code> to create a top-level shell
- * @param dialogTitle
- * the dialog title, or <code>null</code> if none
- * @param initialValue
- * the initial input value, or <code>null</code> if none (equivalent to the empty string)
- * @param validator
- * an input validator, or <code>null</code> if none
- */
- public LabelEditorDialog(Shell parentShell, String dialogTitle, String initialValue, IInputValidator validator) {
- super(parentShell);
- this.title = dialogTitle;
- if(initialValue == null) {
- value = "";//$NON-NLS-1$
- } else {
- value = initialValue;
- }
- this.validator = validator;
- }
-
- /*
- * (non-Javadoc) Method declared on Dialog.
- */
- protected void buttonPressed(int buttonId) {
- if(buttonId == IDialogConstants.OK_ID) {
- value = viewer.getDocument().get();
- } else {
- value = null;
- }
- super.buttonPressed(buttonId);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
- */
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- if(title != null) {
- shell.setText(title);
- }
- }
-
- /**
- * Returns the ok button.
- *
- * @return the ok button
- */
- protected Button getOkButton() {
- return okButton;
- }
-
- /**
- * Returns the text area.
- *
- * @return the text area
- */
- protected SourceViewer getSourceViewer() {
- return viewer;
- }
-
- /**
- * Returns the validator.
- *
- * @return the validator
- */
- protected IInputValidator getValidator() {
- return validator;
- }
-
- /**
- * Returns the string typed into this input dialog.
- *
- * @return the input string
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Validates the input.
- * <p>
- * The default implementation of this framework method delegates the request to the supplied input validator object; if it finds the input
- * invalid, the error message is displayed in the dialog's message line. This hook method is called whenever the text changes in the input field.
- * </p>
- */
- protected void validateInput() {
- String errorMessage = null;
- if(validator != null) {
- // errorMessage = validator.isValid(viewer.getDocument().get());
- }
- // Bug 16256: important not to treat "" (blank error) the same as null
- // (no error)
-
- //setErrorMessage(errorMessage);
- }
-
- /**
- * Sets or clears the error message.
- * If not <code>null</code>, the OK button is disabled.
- *
- * @param errorMessage
- * the error message, or <code>null</code> to clear
- * @since 3.0
- */
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
- if(errorMessageText != null && !errorMessageText.isDisposed()) {
- errorMessageText.setText(errorMessage == null ? "" : errorMessage); //$NON-NLS-1$
- errorMessageText.getParent().update();
- // Access the ok button by id, in case clients have overridden button creation.
- // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=113643
- Control button = getButton(IDialogConstants.OK_ID);
- if(button != null) {
- button.setEnabled(errorMessage.equals(""));
- }
- }
- }
-
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/Message.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/Message.java deleted file mode 100644 index ac66b4c4c7c..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/Message.java +++ /dev/null @@ -1,42 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 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: - * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation - * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.profile.ui.dialogs; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; - -public class Message { - - final Shell _message; - - public Message(String title, String text) { - _message = new Shell(new Shell(), SWT.APPLICATION_MODAL | SWT.SHELL_TRIM); - _message.setText(title); - _message.setSize(250, 100); - - final Label label = new Label(_message, SWT.NONE); - label.setText(text); - label.setBounds(20, 15, 100, 20); - } - - public void open() { - _message.open(); - } - - public void close() { - _message.close(); - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/PackageImportTreeSelectionDialog.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/PackageImportTreeSelectionDialog.java index a6d1f38340d..c422b380960 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/PackageImportTreeSelectionDialog.java +++ b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/PackageImportTreeSelectionDialog.java @@ -50,6 +50,7 @@ public class PackageImportTreeSelectionDialog extends ElementImportTreeSelection * @param _package
* @param elemTree
*/
+ @Override
protected void buildImportTreeList(TreeItem elemTree, Package _package) {
Iterator elemIter = _package.getPackagedElements().iterator();
while(elemIter.hasNext()) {
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/RegisteredProfileSelectionDialog.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/RegisteredProfileSelectionDialog.java deleted file mode 100644 index c34f760533d..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/RegisteredProfileSelectionDialog.java +++ /dev/null @@ -1,152 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 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: - * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation - * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.profile.ui.dialogs; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.papyrus.uml.extensionpoints.profile.RegisteredProfile; -import org.eclipse.papyrus.uml.extensionpoints.standard.FilteredRegisteredElementsSelectionDialog; -import org.eclipse.papyrus.uml.extensionpoints.utils.Util; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.Profile; - -/** - * - */ -public class RegisteredProfileSelectionDialog extends FilteredRegisteredElementsSelectionDialog { - - /** - * - */ - private RegisteredProfile[] regProfiles; - - /** - * - */ - private Package currentPackage; - - /** - * - * - * @param umlPackage - * @param parent - */ - public RegisteredProfileSelectionDialog(Composite parent, Package umlPackage) { - super(parent.getShell(), true, RegisteredProfile.getRegisteredProfiles(), - new ArrayList<Object>(), "Apply profiles from Papyrus repository :", ""); - currentPackage = umlPackage; - } - - /** - * - * - * @return - */ - public List<Profile> run() { - // /*String message= "List of profiles\n"; - // for(int i = 0; i < regProfiles.length ; i++) { - // message+= "|"+regProfiles[i].name+": "+regProfiles[i].qualifiednames+"|"; - // } - // MessageDialog dialog = new MessageDialog(new Shell(), - // "Profiles available", - // null, - // message, - // MessageDialog.INFORMATION, - // new String[] {"OK"}, - // 0); - // dialog.open(); - this.open(); - return this.treatSelection(); - } - - /** - * - * - * @return - */ - private List<Profile> treatSelection() { - - // User selection - Object[] selection = this.getResult(); - boolean hasChanged = false; - - ResourceSet resourceSet = Util.getResourceSet(currentPackage); - - if(selection == null) { // Cancel was selected - return new ArrayList<Profile>(); - } - - // This first list (listOfProfileToApply) contain every selected profile - // which owns sub-profiles (it is possible to select a set of sub-profiles) - // The list is used to build a profile selection tree - List<Package> listOfProfileToApply = new ArrayList<Package>(); - // try to parse the qualified names - - List<String> subprofilesList = new ArrayList<String>(); - for(int i = 0; i < selection.length; i++) { - - RegisteredProfile currentProfile = (RegisteredProfile)(selection[i]); - URI modelUri = currentProfile.uri; - Resource modelResource = resourceSet.getResource(modelUri, true); - - // retrieve registered sub-profiles to be selected - String qualifiedNames = currentProfile.qualifiednames; - - // try to parse the qualified names - String[] profiles = qualifiedNames.split(","); - - // make a collection with String with no space - for(int j = 0; j < profiles.length; j++) { - String string = profiles[j].trim(); - subprofilesList.add(string); - } - - if(modelResource.getContents().get(0) instanceof Profile) { - Message processMsg = new Message("Profile application", "Loading profiles..."); - processMsg.open(); - Profile profileToApply = (Profile)(modelResource.getContents().get(0)); - processMsg.close(); - // if (PackageUtil.getSubProfiles(profileToApply).isEmpty()) { - // No sub-profile -> apply profile directly - // PackageUtil.applyProfile(currentPackage, profileToApply, false); - // } else { - - listOfProfileToApply.add(profileToApply); - // } - } - } - - if(!listOfProfileToApply.isEmpty()) { - // Open package/profile selection tree selection - ProfileTreeSelectionDialog profileDialog = new ProfileTreeSelectionDialog(getShell(), listOfProfileToApply, subprofilesList); - int returnValue = profileDialog.open(); - - // Apply selected profile if ok was selected - if(Dialog.OK == returnValue) { - return (ArrayList<Profile>)profileDialog.getResult(); - } else { - new ArrayList<Profile>(); - } - } - return new ArrayList<Profile>(); - } - -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/StereotypeLabelProvider.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/StereotypeLabelProvider.java deleted file mode 100644 index 83c61898cfc..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/StereotypeLabelProvider.java +++ /dev/null @@ -1,78 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.dialogs;
-
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.papyrus.uml.profile.ImageManager;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.uml2.uml.Stereotype;
-
-
-/**
- * Label provider for stereotypes.
- */
-public class StereotypeLabelProvider extends LabelProvider implements ITableLabelProvider {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
- */
- @Override
- public Image getImage(Object element) {
- return ImageManager.IMG_STEREOTYPE;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
- */
- @Override
- public String getText(Object stereotype) {
- if(!(stereotype instanceof Stereotype)) {
- return "not a stereotype";
- } else {
- return ((Stereotype)stereotype).getName();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
- */
- public Image getColumnImage(Object element, int columnIndex) {
- if(columnIndex == 0) {
- return getImage(element);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
- */
- public String getColumnText(Object element, int columnIndex) {
- if(columnIndex == 0) {
- return getText(element);
- } else if(columnIndex == 1) {
- return ((Stereotype)element).getQualifiedName();
- }
- return "not the right column index";
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/StereotypeQualifiedLabelProvider.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/StereotypeQualifiedLabelProvider.java deleted file mode 100644 index 4ab6c4986c1..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/dialogs/StereotypeQualifiedLabelProvider.java +++ /dev/null @@ -1,38 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.dialogs;
-
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * Label provider for stereotypes that modifies {@link StereotypeLabelProvider#getText(Object)}.
- * It returns the qualified name of the Stereotype instead of the simple name.
- */
-public class StereotypeQualifiedLabelProvider extends StereotypeLabelProvider {
-
- /*
- * (non-Javadoc)
- *
- * @see com.cea.papyrus.ui.dialogs.ChooseSetStereotypeDialog.StereotypeLabelProvider#getText(java.lang.Object)
- */
- @Override
- public String getText(Object stereotype) {
- if(!(stereotype instanceof Stereotype)) {
- return "not a stereotype";
- } else {
- return ((Stereotype)stereotype).getQualifiedName();
- }
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/listeners/DoubleClickListener.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/listeners/DoubleClickListener.java deleted file mode 100644 index f485a526c9c..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/listeners/DoubleClickListener.java +++ /dev/null @@ -1,122 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 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: - * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation - * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.profile.ui.listeners; - -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.papyrus.uml.profile.tree.objects.AppliedStereotypePropertyTreeObject; -import org.eclipse.papyrus.uml.profile.tree.objects.ValueTreeObject; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.TreeItem; - - -// TODO: Auto-generated Javadoc -/** - * The Class DoubleClickListener. - */ -public class DoubleClickListener implements Listener { - - /** - * The tree viewer. - */ - protected TreeViewer treeViewer; - - /** - * - */ - public DoubleClickListener() { - super(); - } - - /** - * Handle event. - * - * @param e - * the e - */ - public void handleEvent(Event e) { - if((e.widget != null) && (e.widget.getData() != null) && (e.widget.getData() instanceof AppliedStereotypePropertyTreeObject)) { - AppliedStereotypePropertyTreeObject pto = (AppliedStereotypePropertyTreeObject)e.widget.getData(); - if((pto.getProperty() != null) && pto.getProperty().isReadOnly()) - return; - } - int index = getSelectionIndex(); - TreeItem item = getSelection(); - if(item != null) { - itemDClicked(item, index); - } - } - - /** - * When doubleclicked : opens a dialog to allow edition of a new PrimitiveType. - * - * @param item - * the item - * @param index - * the index - * @param selectedElt - * the element that owns the stereotype - * @param value - * the current value or list of values of the property if isMultivalued - * @param isMultivalued - * is the property multivalued or not - * @param selectedProp - * the selected property - * @param currentStereotype - * the stereotype associated to selectedProp - */ - protected void itemDClicked(TreeItem item, int index) { - if(!(item.getData() instanceof ValueTreeObject)) { - return; - } - ValueTreeObject object = (ValueTreeObject)item.getData(); - - if(object instanceof ValueTreeObject) { - ((ValueTreeObject)object).editMe(); - } - } - - /** - * Gets the selection index. - * - * @return the selection index - */ - private int getSelectionIndex() { - int index = -1; - - TreeItem selectedItem = getSelection(); - if(selectedItem != null) { - index = treeViewer.getTree().indexOf(selectedItem); - } - return index; - } - - /** - * Gets the selection. - * - * @return the selection - */ - private TreeItem getSelection() { - TreeItem item = null; - - if(treeViewer != null) { - TreeItem[] selectedItems = treeViewer.getTree().getSelection(); - if((selectedItems != null) && (selectedItems.length == 1)) { - item = selectedItems[0]; - } - } - return item; - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/listeners/NoValueException.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/listeners/NoValueException.java deleted file mode 100644 index 94c410d4ea1..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/listeners/NoValueException.java +++ /dev/null @@ -1,27 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 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: - * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation - * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.profile.ui.listeners; - -// TODO: Auto-generated Javadoc -/** - * The Class NoValueException. - */ -public class NoValueException extends Exception { - - /** - * The Constant serialVersionUID. - */ - private static final long serialVersionUID = 320671443887566989L; -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/panels/AbstractPanel.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/panels/AbstractPanel.java deleted file mode 100644 index b28f6c224c6..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/panels/AbstractPanel.java +++ /dev/null @@ -1,72 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.panels;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-// TODO: Auto-generated Javadoc
-/**
- * Abstract panel for the Accord/UML view.<br>
- *
- */
-public abstract class AbstractPanel extends Composite {
-
- /**
- * The Constant WARNING_IMAGE.
- */
- protected static final String WARNING_IMAGE = "resources/icons/warning.gif";
-
- /**
- * Default constructor.
- *
- * @param style
- * the style of this composite
- * @param parent
- * the parent of this composite
- */
- public AbstractPanel(Composite parent, int style) {
- super(parent, style);
-
- }
-
- /**
- * Creates the content for this panel, and returns its Control.
- *
- * @return the Control for this panel
- */
- public abstract Control createContent();
-
- /**
- * Action executed just after the panel is created for the specific element.
- */
- public void entryAction() {
- // do nothing
- }
-
- /**
- * Action executed just before moving to the new element.
- */
- public void exitAction() {
- // do nothing
- }
-
- /**
- * Refresh panel.
- */
- public void refresh() {
-
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/panels/AppliedProfilePanel.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/panels/AppliedProfilePanel.java deleted file mode 100644 index 5935673db68..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/panels/AppliedProfilePanel.java +++ /dev/null @@ -1,172 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.panels;
-
-import org.eclipse.papyrus.uml.profile.ui.compositesformodel.AppliedProfileCompositeOnModel;
-import org.eclipse.papyrus.uml.profile.ui.compositesformodel.AppliedStereotypeCompositeOnModel;
-import org.eclipse.papyrus.uml.profile.ui.compositesformodel.PropertyComposite;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
-import org.eclipse.uml2.uml.Package;
-
-// TODO: Auto-generated Javadoc
-/**
- * The Class ProfilePanel.
- *
- * @deprecated
- */
-public class AppliedProfilePanel extends AppliedStereotypePanel {
-
- /**
- * The profile composite.
- */
- protected AppliedProfileCompositeOnModel profileComposite;
-
- /**
- * The default constructor.
- *
- * @param style
- * the style of this panel
- * @param parent
- * the parent Composite for this panel
- */
- public AppliedProfilePanel(Composite parent, int style) {
- super(parent, style);
- factory = new TabbedPropertySheetWidgetFactory();
- this.parent = parent;
- }
-
- /**
- * A constructor parameterized by a factory.
- *
- * @param style
- * @param factory
- * @param parent
- */
- public AppliedProfilePanel(Composite parent, TabbedPropertySheetWidgetFactory factory, int style) {
- super(parent, style);
- this.parent = parent;
- this.factory = factory;
- }
-
- /**
- *
- *
- * @return the factory
- */
- public TabbedPropertySheetWidgetFactory getFactory() {
- return factory;
- }
-
- /**
- * Sets the selected.
- *
- * @param selected
- * The selected to set.
- * @param pkg
- * the pkg
- */
- public void setSelected(Package pkg) {
- super.setSelected(pkg);
- if(profileComposite != null) {
- selected = pkg;
- profileComposite.refresh();
- }
-
- super.setSelected(pkg);
- }
-
- /**
- * Gets the control.
- *
- * @return the control for this panel
- */
- @Override
- public Control getControl() {
- return this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.odf.platform.uml2.ui.panels.AbstractPanel#createContent()
- */
- /**
- * Creates the content.
- *
- * @return the control
- */
- @Override
- public Control createContent() {
-
- FormLayout panelLayout = new FormLayout();
- this.setLayout(panelLayout);
-
- // Create profile composite
- profileComposite = new AppliedProfileCompositeOnModel(this);
- profileComposite.createContent();
-
- FormData data = new FormData();
-
- // Composite placement
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(50, 0);
-
- profileComposite.setLayoutData(data);
-
- // Create profile composite
- stereotypeComposite = new AppliedStereotypeCompositeOnModel(this);
- stereotypeComposite.createContent(this, factory);
-
- propertyComposite = new PropertyComposite(this);
- propertyComposite.createContent(this, factory);
-
- // stereotypeComposite placement
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(50);
- data.top = new FormAttachment(profileComposite, 0);
- data.bottom = new FormAttachment(100, 0);
- data.height = 80;
- stereotypeComposite.setLayoutData(data);
-
- // propertyComposite placement
- data = new FormData();
- data.left = new FormAttachment(stereotypeComposite, 0);
- data.right = new FormAttachment(100, 0);
- data.top = new FormAttachment(profileComposite, 0);
- data.bottom = new FormAttachment(100, 0);
-
- propertyComposite.setLayoutData(data);
-
- return this;
- }
-
- /**
- * Refresh the content of applied the profile list.
- */
- @Override
- public void refresh() {
- // Refresh stereotypes
- profileComposite.refresh();
- super.refresh();
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/panels/AppliedStereotypePanel.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/panels/AppliedStereotypePanel.java deleted file mode 100644 index 1ddd72763f3..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/panels/AppliedStereotypePanel.java +++ /dev/null @@ -1,187 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.panels;
-
-import org.eclipse.papyrus.uml.profile.tree.objects.AppliedStereotypePropertyTreeObject;
-import org.eclipse.papyrus.uml.profile.tree.objects.StereotypedElementTreeObject;
-import org.eclipse.papyrus.uml.profile.ui.compositesformodel.AppliedStereotypeCompositeOnModel;
-import org.eclipse.papyrus.uml.profile.ui.compositesformodel.PropertyComposite;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
-import org.eclipse.uml2.uml.Element;
-
-// TODO: Auto-generated Javadoc
-/**
- * The Class StereotypePanel.
- */
-public class AppliedStereotypePanel extends AbstractPanel {
-
- /**
- *
- */
- public TabbedPropertySheetWidgetFactory factory;
-
- /**
- *
- */
- protected Composite parent;
-
- /**
- * The property composite.
- */
- protected PropertyComposite propertyComposite;
-
- /**
- * The selected.
- */
- protected Element selected;
-
- /**
- * The stereotype composite.
- */
- protected AppliedStereotypeCompositeOnModel stereotypeComposite;
-
- /**
- * The default constructor.
- *
- * @param style
- * the style of this panel
- * @param parent
- * the parent Composite for this panel
- */
- public AppliedStereotypePanel(Composite parent, int style) {
- super(parent, style);
- factory = new TabbedPropertySheetWidgetFactory();
- this.parent = parent;
- }
-
- /**
- * A constructor parameterized by a factory.
- *
- * @param style
- * @param factory
- * @param parent
- */
- public AppliedStereotypePanel(Composite parent, TabbedPropertySheetWidgetFactory factory, int style) {
- super(parent, style);
- this.factory = factory;
- this.parent = parent;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.odf.platform.uml2.ui.panels.AbstractPanel#createContent()
- */
- /**
- * Creates the content.
- *
- * @return the control
- */
- @Override
- public Control createContent() {
-
- this.setLayout(new FormLayout());
-
- // Create profile composite
- stereotypeComposite = new AppliedStereotypeCompositeOnModel(this);
- stereotypeComposite.createContent(this, factory);
-
- propertyComposite = new PropertyComposite(this);
- propertyComposite.createContent(this, factory);
-
- FormData data;
-
- // stereotypeComposite placement
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(50);
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
-
- stereotypeComposite.setLayoutData(data);
-
- // propertyComposite placement
- data = new FormData();
- data.left = new FormAttachment(stereotypeComposite, 0);
- data.right = new FormAttachment(100, 0);
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
-
- propertyComposite.setLayoutData(data);
- return this;
- }
-
- /**
- * Gets the control.
- *
- * @return the control for this panel
- */
- public Control getControl() {
- return this;
- }
-
- /**
- * Gets the selected.
- *
- * @return Returns the selected.
- */
- public Element getSelected() {
- return selected;
- }
-
- /**
- * Refresh the composites.
- */
- @Override
- public void refresh() {
- // Refresh stereotypes and property values
- stereotypeComposite.refresh();
- propertyComposite.refresh();
- }
-
- /**
- * Sets the selected.
- *
- * @param selected
- * The selected to set.
- * @param elt
- * the elt
- */
- public void setSelected(Element elt) {
-
- if(stereotypeComposite != null) {
- selected = elt;
- stereotypeComposite.setInput(new StereotypedElementTreeObject(elt));
- refresh();
- }
- }
-
- /**
- * Sets the selected property.
- *
- * @param selected
- * The selected to set.
- * @param elt
- * the elt
- */
- public void setSelectedProperty(AppliedStereotypePropertyTreeObject elt) {
- propertyComposite.setInput(elt);
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/panels/DefaultPanel.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/panels/DefaultPanel.java deleted file mode 100644 index ffae87ca821..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/panels/DefaultPanel.java +++ /dev/null @@ -1,78 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.panels;
-
-import org.eclipse.swt.SWT;
-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;
-
-// TODO: Auto-generated Javadoc
-/**
- * Default panel for the Accord/UML view.<BR>
- * If the element selected in the model explorer or in the diagrams, or if
- * the element selected is not a UML element, it is displayed in the view.
- *
- * @author Remi SCHNEKENBURGER
- */
-public class DefaultPanel extends AbstractPanel {
-
- // the label used to display text
- /**
- * The label.
- */
- private Label label;
-
- /**
- * Constructs a new instance of this class given its parent and a style
- * value describing its behavior and appearance.
- *
- * @param style
- * the style for this style
- * @param parent
- * the composite parent of this element
- */
- public DefaultPanel(Composite parent, int style) {
- super(parent, style);
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see com.cea.actionlanguage.texteditor.ui.panels.AccordUMLAbstractPanel#createContent()
- */
- /**
- * Creates the content.
- *
- * @return the control
- */
- @Override
- public Control createContent() {
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- this.setLayout(layout);
-
- label = new Label(this, SWT.NONE);
- label.setText("No selection.");
- GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gridData.horizontalSpan = 2;
- label.setLayoutData(gridData);
-
- return null;
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/section/AppliedProfileSection.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/section/AppliedProfileSection.java deleted file mode 100644 index 7d433ce321e..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/section/AppliedProfileSection.java +++ /dev/null @@ -1,121 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 CEA LIST, Obeo.
- *
- *
- * 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- * Jerome BENOIS (Obeo) jerome.benois@obeo.fr - improve to deal with EEF based properties view and model explorer
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.section;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.infra.core.utils.EditorUtils;
-import org.eclipse.papyrus.uml.profile.ui.compositeforview.AppliedProfileCompositeWithView;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
-
-/**
- * This section is used to apply a profile on packages or model
- *
- * @author <a href="mailto:jerome.benois@obeo.fr">Jerome Benois</a>
- */
-public class AppliedProfileSection extends AbstractPropertySection {
-
- private AppliedProfileCompositeWithView appliedProfileComposite;
-
- /**
- *
- * {@inheritDoc}
- */
- @Override
- public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) {
- super.createControls(parent, tabbedPropertySheetPage);
- appliedProfileComposite = new AppliedProfileCompositeWithView(parent, getWidgetFactory());
- appliedProfileComposite.createContent();
- }
-
- /**
- *
- *
- * @return
- */
- @Override
- public boolean shouldUseExtraSpace() {
- return true;
- }
-
- /**
- *
- * {@inheritDoc}
- */
- public void refresh() {
- appliedProfileComposite.refresh();
- }
-
- /**
- *
- * {@inheritDoc}
- */
- public void setInput(IWorkbenchPart part, ISelection selection) {
- super.setInput(part, selection);
- if(selection instanceof IStructuredSelection) {
- Object input = ((IStructuredSelection)selection).getFirstElement();
- if(input instanceof GraphicalEditPart && ((GraphicalEditPart)input).getModel() instanceof View) {
- GraphicalEditPart graphicalEditPart = (GraphicalEditPart)input;
- View view = (View)graphicalEditPart.getModel();
- if(view.getElement() != null) {
- appliedProfileComposite.setSelection(selection);
- }
- } else {
- EObject eObject = resolveSemanticObject(input);
- if(eObject != null && eObject instanceof EObject) {
- appliedProfileComposite.setSelection(selection);
- }
- }
-
- appliedProfileComposite.setDomain(EditorUtils.getTransactionalEditingDomain());
- }
- }
-
- /**
- * Resolve semantic element
- *
- * @param object
- * the object to resolve
- * @return <code>null</code> or the semantic element associated to the specified object
- */
- private EObject resolveSemanticObject(Object object) {
- if(object instanceof EObject) {
- return (EObject)object;
- } else if(object instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable)object;
- if(adaptable.getAdapter(EObject.class) != null) {
- return (EObject)adaptable.getAdapter(EObject.class);
- }
- }
- return null;
- }
-
- /**
- *
- */
- public void dispose() {
- super.dispose();
- if(appliedProfileComposite != null)
- appliedProfileComposite.disposeListeners();
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/section/AppliedStereotypeDisplaySection.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/section/AppliedStereotypeDisplaySection.java deleted file mode 100644 index 4cc8ea982b1..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/section/AppliedStereotypeDisplaySection.java +++ /dev/null @@ -1,111 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.section;
-
-import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.uml.profile.tree.objects.StereotypedElementTreeObject;
-import org.eclipse.papyrus.uml.profile.ui.compositeforview.AppearanceForAppliedStereotypeComposite;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.part.IContributedContentsView;
-import org.eclipse.ui.views.contentoutline.ContentOutline;
-import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
-import org.eclipse.uml2.uml.Element;
-
-/**
- * The Class StereotypePropertiesAppearanceSection manages the display of stereotype properties in Appearance Tab.
- */
-public class AppliedStereotypeDisplaySection extends AbstractPropertySection {
-
- private AppearanceForAppliedStereotypeComposite appearanceForAppliedStereotype;
-
- private EModelElement diagramElement;
-
- /**
- *
- * {@inheritDoc}
- */
- public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) {
- super.createControls(parent, tabbedPropertySheetPage);
- appearanceForAppliedStereotype = new AppearanceForAppliedStereotypeComposite(parent);
- appearanceForAppliedStereotype.createContent(parent, getWidgetFactory());
-
- }
-
- /**
- *
- * {@inheritDoc}
- */
- public void refresh() {
- appearanceForAppliedStereotype.refresh();
- }
-
- /**
- *
- * {@inheritDoc}
- */
- public void setInput(IWorkbenchPart part, ISelection selection) {
- super.setInput(part, selection);
- if(selection instanceof IStructuredSelection) {
- Object input = ((IStructuredSelection)selection).getFirstElement();
-
- if(input instanceof GraphicalEditPart && ((GraphicalEditPart)input).getModel() instanceof View) {
- appearanceForAppliedStereotype.setSelection(selection);
- diagramElement = (EModelElement)((AbstractGraphicalEditPart)input).getModel();
-
- if((diagramElement instanceof View) && ((View)diagramElement).getElement() != null) {
- appearanceForAppliedStereotype.setElement((Element)((View)diagramElement).getElement());
- appearanceForAppliedStereotype.setInput(new StereotypedElementTreeObject((Element)((View)diagramElement).getElement()));
-
- diagramElement = (EModelElement)((AbstractGraphicalEditPart)input).getModel();
- appearanceForAppliedStereotype.setDiagramElement(diagramElement);
-
- } else {
- // re-init the diagram element. Else, could cause a bug,
- // when the user selects a diagram element, then a non diagram element.
- // If display button is pressed, the "Toggle Display" button does not work correctly
- diagramElement = null;
- }
- // When the selection is computed from the outline, get the associated editor
- if(part instanceof ContentOutline) {
- IContributedContentsView contributedView = ((IContributedContentsView)((ContentOutline)part).getAdapter(IContributedContentsView.class));
- if(contributedView != null) {
- part = (IWorkbenchPart)contributedView.getContributingPart();
- }
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.cea.papyrus.core.ui.properties.tabbed.PropertyViewSection#dispose()
- */
- /**
- *
- */
- public void dispose() {
- super.dispose();
- if(appearanceForAppliedStereotype != null)
- appearanceForAppliedStereotype.disposeListeners();
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/section/AppliedStereotypeKindAppearanceSection.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/section/AppliedStereotypeKindAppearanceSection.java deleted file mode 100644 index d639ad82cd1..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/section/AppliedStereotypeKindAppearanceSection.java +++ /dev/null @@ -1,436 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.section;
-
-import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor;
-import org.eclipse.papyrus.infra.core.utils.EditorUtils;
-import org.eclipse.papyrus.uml.tools.utils.ElementUtil;
-import org.eclipse.papyrus.uml.tools.utils.ui.VisualInformationPapyrusConstant;
-import org.eclipse.papyrus.uml.tools.utils.ui.helper.AppliedStereotypeHelper;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.part.IContributedContentsView;
-import org.eclipse.ui.views.contentoutline.ContentOutline;
-import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.Stereotype;
-
-public class AppliedStereotypeKindAppearanceSection extends AbstractPropertySection {
-
- /** constant for stereotype text alignement */
- private static final String VERTICAL = "Vertical";
-
- /** constant for stereotype text alignement */
- private static final String HORIZONTAL = "Horizontal";
-
- /** constant for stereotype appearance section. Style: text and icon */
- private static final String TEXT_AND_ICON = "Text and Icon";
-
- /** constant for stereotype appearance section. Style: shape */
- private static final String SHAPE = "Shape";
-
- /** constant for stereotype appearance section. Style: icon */
- private static final String ICON = "Icon";
-
- /** constant for stereotype appearance section. Style: text */
- private static final String TEXT = "Text";
-
- /** current presentation for stereotype */
- private String stereotypePlacePresentation = VisualInformationPapyrusConstant.STEREOTYPE_COMPARTMENT_LOCATION;
-
- private EModelElement diagramElement;
-
- /**
- * The stereotype appearance.
- */
- private CLabel stereotypeAppearance;
-
- /**
- * The stereotype text alignment.
- */
- private CLabel stereotypeTextAlignement;
-
- /**
- * The combo stereotype appearance.
- */
- private CCombo comboStereotypeAppearance;
-
- /**
- * The combo stereotype alignment.
- */
- private CCombo comboStereotypeAlignement;
-
- /**
- * The combo stereotype appearance listener.
- */
- private SelectionListener comboStereotypeAppearanceListener;
-
- /**
- * The combo stereotype alignment listener.
- */
- private SelectionListener comboStereotypeAlignementListener;
-
- private TransactionalEditingDomain domain;
-
- private CLabel stereotypeDisplayPlace;
-
- private CCombo comboStereotypeDisplayPlace;
-
- private SelectionListener comboStereotypeDisplayListener;
-
- /**
- * Creates the controls.
- *
- * @param tabbedPropertySheetPage
- * the tabbed property sheet page
- * @param parent
- * the parent
- */
- @Override
- public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) {
- super.createControls(parent, tabbedPropertySheetPage);
- Composite composite = getWidgetFactory().createFlatFormComposite(parent);
- FormData data;
-
- stereotypeAppearance = getWidgetFactory().createCLabel(composite, "Stereotype Display:"); //$NON-NLS-1$
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- stereotypeAppearance.setLayoutData(data);
-
- comboStereotypeAppearance = getWidgetFactory().createCCombo(composite, SWT.BORDER | SWT.READ_ONLY);
- comboStereotypeAppearance.add(TEXT);
- comboStereotypeAppearance.add(ICON);
- comboStereotypeAppearance.add(TEXT_AND_ICON);
- comboStereotypeAppearance.add(SHAPE);
- data = new FormData();
- data.left = new FormAttachment(0, 135);
- data.top = new FormAttachment(0, 0);
- comboStereotypeAppearance.setLayoutData(data);
-
- comboStereotypeAppearanceListener = new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {
- if(diagramElement != null) {
- if(((View)(diagramElement)).getElement() != null) {
-
- org.eclipse.uml2.uml.Element elt = (Element)((View)(diagramElement)).getElement();
-
- // get the first displayed stereotype
- Stereotype stereotype = AppliedStereotypeHelper.getFirstDisplayedStereotype(diagramElement, elt);
-
- boolean hasIcons = ElementUtil.hasIcons(elt, stereotype);
- boolean hasShapes = ElementUtil.hasShapes(elt, stereotype);
- String appliedStereotypeKind = VisualInformationPapyrusConstant.STEREOTYPE_TEXT_HORIZONTAL_PRESENTATION;
- String stereotypeAppearance = comboStereotypeAppearance.getText();
- if(stereotypeAppearance.equals(TEXT)) {
- appliedStereotypeKind = VisualInformationPapyrusConstant.STEREOTYPE_TEXT_HORIZONTAL_PRESENTATION;
- } else if(stereotypeAppearance.equals(ICON) && hasIcons) {
- appliedStereotypeKind = VisualInformationPapyrusConstant.ICON_STEREOTYPE_PRESENTATION;
- } else if(stereotypeAppearance.equals(TEXT_AND_ICON) && hasIcons) {
- appliedStereotypeKind = VisualInformationPapyrusConstant.TEXT_ICON_STEREOTYPE_PRESENTATION;
- } else if(stereotypeAppearance.equals(SHAPE) && hasShapes) {
- appliedStereotypeKind = VisualInformationPapyrusConstant.IMAGE_STEREOTYPE_PRESENTATION;
- }
- String stereotypetoDisplay = AppliedStereotypeHelper.getStereotypesToDisplay(diagramElement);
- RecordingCommand command = AppliedStereotypeHelper.getAppliedStereotypeToDisplayCommand(domain, diagramElement, stereotypetoDisplay, appliedStereotypeKind);
- domain.getCommandStack().execute(command);
- refresh();
- }
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- };
- comboStereotypeAppearance.addSelectionListener(comboStereotypeAppearanceListener);
-
- stereotypeTextAlignement = getWidgetFactory().createCLabel(composite, "Text Alignement:"); //$NON-NLS-1$
- data = new FormData();
- data.left = new FormAttachment(comboStereotypeAppearance, 40);
- data.top = new FormAttachment(comboStereotypeAppearance, 1, SWT.CENTER);
- stereotypeTextAlignement.setLayoutData(data);
-
- comboStereotypeAlignement = getWidgetFactory().createCCombo(composite, SWT.BORDER | SWT.READ_ONLY);
- comboStereotypeAlignement.add(HORIZONTAL);
- comboStereotypeAlignement.add(VERTICAL);
- data = new FormData();
- data.left = new FormAttachment(stereotypeTextAlignement, 0);
- data.top = new FormAttachment(0, 0);
- comboStereotypeAlignement.setLayoutData(data);
-
- comboStereotypeAlignementListener = new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {
- if(diagramElement != null) {
- if(((View)(diagramElement)).getElement() != null) {
-
- String appliedStereotypeKind = VisualInformationPapyrusConstant.STEREOTYPE_TEXT_HORIZONTAL_PRESENTATION;
- if(comboStereotypeAlignement.getText().equals(HORIZONTAL)) {
- appliedStereotypeKind = VisualInformationPapyrusConstant.STEREOTYPE_TEXT_HORIZONTAL_PRESENTATION;
- } else if(comboStereotypeAlignement.getText().equals(VERTICAL)) {
- appliedStereotypeKind = VisualInformationPapyrusConstant.STEREOTYPE_TEXT_VERTICAL_PRESENTATION;
- }
- String stereotypetoDisplay = AppliedStereotypeHelper.getStereotypesToDisplay(diagramElement);
- RecordingCommand command = AppliedStereotypeHelper.getAppliedStereotypeToDisplayCommand(domain, diagramElement, stereotypetoDisplay, appliedStereotypeKind);
- domain.getCommandStack().execute(command);
- refresh();
- }
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- };
- comboStereotypeAlignement.addSelectionListener(comboStereotypeAlignementListener);
-
- // combo for display place choice
- stereotypeDisplayPlace = getWidgetFactory().createCLabel(composite, "Display Place:");
- data = new FormData();
- data.left = new FormAttachment(comboStereotypeAlignement, 40);
- data.top = new FormAttachment(comboStereotypeAlignement, 1, SWT.CENTER);
- stereotypeDisplayPlace.setLayoutData(data);
-
- comboStereotypeDisplayPlace = getWidgetFactory().createCCombo(composite, SWT.BORDER | SWT.READ_ONLY);
- comboStereotypeDisplayPlace.add(VisualInformationPapyrusConstant.STEREOTYPE_COMMENT_LOCATION);
- comboStereotypeDisplayPlace.add(VisualInformationPapyrusConstant.STEREOTYPE_COMPARTMENT_LOCATION);
- comboStereotypeDisplayPlace.add(VisualInformationPapyrusConstant.STEREOTYPE_BRACE_LOCATION);
-
- data = new FormData();
- data.left = new FormAttachment(stereotypeDisplayPlace, 0);
- data.top = new FormAttachment(0, 0);
- comboStereotypeDisplayPlace.setLayoutData(data);
-
- comboStereotypeDisplayListener = new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {
- if(diagramElement != null) {
- stereotypePlacePresentation = comboStereotypeDisplayPlace.getText();
-
- RecordingCommand command = AppliedStereotypeHelper.getSetAppliedStereotypePropertiesLocalizationCommand(domain, diagramElement, stereotypePlacePresentation);
- domain.getCommandStack().execute(command);
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- };
- comboStereotypeDisplayPlace.addSelectionListener(comboStereotypeDisplayListener);
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setInput(IWorkbenchPart part, ISelection selection) {
- super.setInput(part, selection);
- if(selection instanceof IStructuredSelection) {
- Object input = ((IStructuredSelection)selection).getFirstElement();
-
- if(input instanceof GraphicalEditPart && ((GraphicalEditPart)input).getModel() instanceof View) {
- diagramElement = (EModelElement)((GraphicalEditPart)input).getModel();
- } else {
- // re-init the diagram element. Else, could cause a bug,
- // when the user selects a diagram element, then a non diagram element.
- // If display button is pressed, the "Toggle Display" button does not work correctly
- diagramElement = null;
- }
- // When the selection is computed from the outline, get the associated editor
- if(part instanceof ContentOutline) {
- IContributedContentsView contributedView = ((IContributedContentsView)((ContentOutline)part).getAdapter(IContributedContentsView.class));
- if(contributedView != null) {
- part = (IWorkbenchPart)contributedView.getContributingPart();
- }
- }
- if(part instanceof IMultiDiagramEditor) {
- IMultiDiagramEditor editor = (IMultiDiagramEditor)part;
- domain = EditorUtils.getTransactionalEditingDomain();
- } else
- domain = null;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void refresh() {
- refreshStereotypeAppearance();
- refreshStereotypeAlignment();
- refreshStereotypeDisplayLocation();
- }
-
- private void refreshStereotypeDisplayLocation() {
- if(comboStereotypeDisplayPlace != null && !comboStereotypeDisplayPlace.isDisposed()) {
- comboStereotypeDisplayPlace.removeSelectionListener(comboStereotypeDisplayListener);
-
- if(diagramElement != null) {
- if(isComboEnabled()) {
- comboStereotypeDisplayPlace.setEnabled(true);
- stereotypePlacePresentation = AppliedStereotypeHelper.getAppliedStereotypesPropertiesLocalization(diagramElement);
- comboStereotypeDisplayPlace.setText(stereotypePlacePresentation);
- } else {
- comboStereotypeDisplayPlace.setEnabled(false);
- comboStereotypeDisplayPlace.setText(stereotypePlacePresentation);
- }
- }
- comboStereotypeDisplayPlace.addSelectionListener(comboStereotypeDisplayListener);
- }
- }
-
- /**
- * Helper method to indicate whether comboStereotypePropertiesPlace is enabled or not. The combo is enabled only within class and requirement
- * diagram
- */
- private boolean isComboEnabled() {
- if(!AppliedStereotypeHelper.getAppliedStereotypesPropertiesToDisplay(diagramElement).equals("")) {
- return true;
- }
- return false;
- }
-
- /**
- * Refresh Stereotype Alignement combo.
- */
- private void refreshStereotypeAlignment() {
- if(!comboStereotypeAlignement.isDisposed()) {
-
- comboStereotypeAlignement.removeSelectionListener(comboStereotypeAlignementListener);
-
- if(diagramElement != null) {
- if(((View)(diagramElement)).getElement() != null && ((Element)((View)(diagramElement)).getElement()).getAppliedStereotypes().size() != 0) {
- comboStereotypeAlignement.setEnabled(true);
-
- final String stereotypePresentation = AppliedStereotypeHelper.getAppliedStereotypePresentationKind(diagramElement);
-
- if(stereotypePresentation != null) {
-
- org.eclipse.uml2.uml.Element elt = (Element)((View)(diagramElement)).getElement();
- // get the first displayed stereotype
- Stereotype stereotype = AppliedStereotypeHelper.getFirstDisplayedStereotype(diagramElement, elt);
-
- boolean hasIcons = ElementUtil.hasIcons(elt, stereotype);
- boolean hasShapes = ElementUtil.hasShapes(elt, stereotype);
-
- if(stereotypePresentation.equals(VisualInformationPapyrusConstant.ICON_STEREOTYPE_PRESENTATION) && hasIcons) {
- comboStereotypeAlignement.setEnabled(false);
- } else if(stereotypePresentation.equals(VisualInformationPapyrusConstant.TEXT_ICON_STEREOTYPE_PRESENTATION) && hasIcons) {
- comboStereotypeAlignement.setEnabled(true);
- } else if(stereotypePresentation.equals(VisualInformationPapyrusConstant.IMAGE_STEREOTYPE_PRESENTATION) && hasShapes) {
- comboStereotypeAlignement.setEnabled(false);
- } else {
- comboStereotypeAlignement.setEnabled(true);
- }
-
- if(stereotypePresentation.equals(VisualInformationPapyrusConstant.STEREOTYPE_TEXT_HORIZONTAL_PRESENTATION)) {
- comboStereotypeAlignement.setText(HORIZONTAL);
- } else if(stereotypePresentation.equals(VisualInformationPapyrusConstant.STEREOTYPE_TEXT_VERTICAL_PRESENTATION)) {
- comboStereotypeAlignement.setText(VERTICAL);
- } else {
- comboStereotypeAlignement.setText(HORIZONTAL);
- }
-
- } else {
- comboStereotypeAlignement.setText(HORIZONTAL);
- }
-
- } else {
- comboStereotypeAlignement.setText("");
- comboStereotypeAlignement.setEnabled(false);
- }
- }
- comboStereotypeAlignement.addSelectionListener(comboStereotypeAlignementListener);
- }
- }
-
- /**
- * Refresh Stereotype appearance combo.
- */
- private void refreshStereotypeAppearance() {
- if(!comboStereotypeAppearance.isDisposed()) {
- comboStereotypeAppearance.removeSelectionListener(comboStereotypeAppearanceListener);
-
- if(diagramElement != null) {
- if(((View)(diagramElement)).getElement() != null && ((Element)((View)(diagramElement)).getElement()).getAppliedStereotypes().size() != 0) {
- comboStereotypeAppearance.setEnabled(true);
-
- final String stereotypePresentation = AppliedStereotypeHelper.getAppliedStereotypePresentationKind(diagramElement);
-
- if(stereotypePresentation != null) {
-
- org.eclipse.uml2.uml.Element elt = (Element)((View)(diagramElement)).getElement();
- // get the first displayed stereotype
- Stereotype stereotype = AppliedStereotypeHelper.getFirstDisplayedStereotype(diagramElement, elt);
-
- boolean hasIcons = ElementUtil.hasIcons(elt, stereotype);
- boolean hasShapes = ElementUtil.hasShapes(elt, stereotype);
- if(stereotypePresentation.equals(VisualInformationPapyrusConstant.ICON_STEREOTYPE_PRESENTATION) && hasIcons) {
- comboStereotypeAppearance.setText(ICON);
- } else if(stereotypePresentation.equals(VisualInformationPapyrusConstant.TEXT_ICON_STEREOTYPE_PRESENTATION) && hasIcons) {
- comboStereotypeAppearance.setText(TEXT_AND_ICON);
- } else if(stereotypePresentation.equals(VisualInformationPapyrusConstant.IMAGE_STEREOTYPE_PRESENTATION) && hasShapes) {
- comboStereotypeAppearance.setText(SHAPE);
- } else {
- comboStereotypeAppearance.setText(TEXT);
- }
-
- } else {
- comboStereotypeAppearance.setText(TEXT);
- }
-
- } else {
- comboStereotypeAppearance.setText("");
- comboStereotypeAppearance.setEnabled(false);
- }
- }
-
- comboStereotypeAppearance.addSelectionListener(comboStereotypeAppearanceListener);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- if(comboStereotypeAppearance != null && !comboStereotypeAppearance.isDisposed()) {
- comboStereotypeAppearance.removeSelectionListener(comboStereotypeAppearanceListener);
- }
- if(comboStereotypeAlignement != null && !comboStereotypeAlignement.isDisposed()) {
- comboStereotypeAlignement.removeSelectionListener(comboStereotypeAlignementListener);
- }
- if(comboStereotypeDisplayPlace != null && !comboStereotypeDisplayPlace.isDisposed()) {
- comboStereotypeDisplayPlace.removeSelectionListener(comboStereotypeDisplayListener);
- }
- if(diagramElement != null) {
- diagramElement.eAdapters().remove(this);
- }
- super.dispose();
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/section/AppliedStereotypePropertiesPlaceSection.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/section/AppliedStereotypePropertiesPlaceSection.java deleted file mode 100644 index ef90a3105ca..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/section/AppliedStereotypePropertiesPlaceSection.java +++ /dev/null @@ -1,207 +0,0 @@ -package org.eclipse.papyrus.uml.profile.ui.section; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.ecore.EModelElement; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.papyrus.infra.core.editor.IMultiDiagramEditor; -import org.eclipse.papyrus.infra.core.utils.EditorUtils; -import org.eclipse.papyrus.uml.tools.utils.ui.VisualInformationPapyrusConstant; -import org.eclipse.papyrus.uml.tools.utils.ui.helper.AppliedStereotypeHelper; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.part.IContributedContentsView; -import org.eclipse.ui.views.contentoutline.ContentOutline; -import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; - -// TODO: Auto-generated Javadoc -/** - * The Class StereotypePropertiesPlaceSection allows users to select the way to display stereotype properties. - * - */ -public class AppliedStereotypePropertiesPlaceSection extends AbstractPropertySection implements Adapter { - - /** - * The stereotype appearance. - */ - private CLabel stereotypePropertiesPlace; - - /** - * The combo stereotype appearance. - */ - private CCombo comboStereotypePropertiesPlace; - - /** - * The combo stereotype appearance listener. - */ - private SelectionListener comboStereotypePropertiesPlaceListener; - - private String stereotypePlacePresentation = VisualInformationPapyrusConstant.STEREOTYPE_COMPARTMENT_LOCATION; - - private EModelElement diagramElement; - - private TransactionalEditingDomain domain; - - /** - * Creates the controls. - * - * @param tabbedPropertySheetPage - * the tabbed property sheet page - * @param parent - * the parent - */ - @Override - public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) { - super.createControls(parent, tabbedPropertySheetPage); - Composite composite = getWidgetFactory().createFlatFormComposite(parent); - FormData data; - - comboStereotypePropertiesPlace = getWidgetFactory().createCCombo(composite, SWT.BORDER); - comboStereotypePropertiesPlace.add(VisualInformationPapyrusConstant.STEREOTYPE_COMMENT_LOCATION); - comboStereotypePropertiesPlace.add(VisualInformationPapyrusConstant.STEREOTYPE_COMPARTMENT_LOCATION); - comboStereotypePropertiesPlace.add(VisualInformationPapyrusConstant.STEREOTYPE_BRACE_LOCATION); - - data = new FormData(); - data.left = new FormAttachment(0, 200); - data.top = new FormAttachment(0, 0); - comboStereotypePropertiesPlace.setLayoutData(data); - - stereotypePropertiesPlace = getWidgetFactory().createCLabel(composite, "Place of applied stereotype properties:"); //$NON-NLS-1$ - data = new FormData(); - data.left = new FormAttachment(0, 0); - data.right = new FormAttachment(comboStereotypePropertiesPlace, 0); - data.top = new FormAttachment(comboStereotypePropertiesPlace, 1, SWT.CENTER); - stereotypePropertiesPlace.setLayoutData(data); - - comboStereotypePropertiesPlaceListener = new SelectionListener() { - - public void widgetSelected(SelectionEvent e) { - if(diagramElement != null) { - stereotypePlacePresentation = comboStereotypePropertiesPlace.getText(); - - RecordingCommand command = AppliedStereotypeHelper.getSetAppliedStereotypePropertiesLocalizationCommand(domain, diagramElement, stereotypePlacePresentation); - domain.getCommandStack().execute(command); - } - } - - public void widgetDefaultSelected(SelectionEvent e) { - } - }; - comboStereotypePropertiesPlace.addSelectionListener(comboStereotypePropertiesPlaceListener); - - } - - /** - * Refresh. - */ - @Override - public void refresh() { - if((!comboStereotypePropertiesPlace.isDisposed())) { - - comboStereotypePropertiesPlace.removeSelectionListener(comboStereotypePropertiesPlaceListener); - - if(diagramElement != null) { - if(isComboEnabled()) { - comboStereotypePropertiesPlace.setEnabled(true); - stereotypePlacePresentation = AppliedStereotypeHelper.getAppliedStereotypesPropertiesLocalization(diagramElement); - comboStereotypePropertiesPlace.setText(stereotypePlacePresentation); - } else { - comboStereotypePropertiesPlace.setEnabled(false); - comboStereotypePropertiesPlace.setText(stereotypePlacePresentation); - } - } - comboStereotypePropertiesPlace.addSelectionListener(comboStereotypePropertiesPlaceListener); - } - } - - /** - * - * {@inheritDoc} - */ - public void dispose() { - - super.dispose(); - diagramElement.eAdapters().remove(this); - if(comboStereotypePropertiesPlace != null && !comboStereotypePropertiesPlace.isDisposed()) - comboStereotypePropertiesPlace.removeSelectionListener(comboStereotypePropertiesPlaceListener); - } - - /** - * Helper method to indicate whether comboStereotypePropertiesPlace is enabled or not. The combo is enabled only within class and requirement - * diagram - */ - - private boolean isComboEnabled() { - if(!AppliedStereotypeHelper.getAppliedStereotypesPropertiesToDisplay(diagramElement).equals("")) { - return true; - } - return false; - } - - /** - * - * {@inheritDoc} - */ - @Override - public void setInput(IWorkbenchPart part, ISelection selection) { - super.setInput(part, selection); - if(selection instanceof IStructuredSelection) { - Object input = ((IStructuredSelection)selection).getFirstElement(); - - if(input instanceof GraphicalEditPart && ((GraphicalEditPart)input).getModel() instanceof View) { - diagramElement = (EModelElement)((GraphicalEditPart)input).getModel(); - diagramElement.eAdapters().add(this); - } else { - // re-init the diagram element. Else, could cause a bug, - // when the user selects a diagram element, then a non diagram element. - // If display button is pressed, the "Toggle Display" button does not work correctly - diagramElement = null; - } - // When the selection is computed from the outline, get the associated editor - if(part instanceof ContentOutline) { - IContributedContentsView contributedView = ((IContributedContentsView)((ContentOutline)part).getAdapter(IContributedContentsView.class)); - if(contributedView != null) { - part = (IWorkbenchPart)contributedView.getContributingPart(); - } - } - if(part instanceof IMultiDiagramEditor) { - IMultiDiagramEditor editor = (IMultiDiagramEditor)part; - domain = EditorUtils.getTransactionalEditingDomain(); - } else - domain = null; - } - } - - public void notifyChanged(Notification notification) { - refresh(); - - } - - public Notifier getTarget() { - // TODO Auto-generated method stub - return null; - } - - public boolean isAdapterForType(Object type) { - return type.equals(diagramElement.getClass()); - } - - public void setTarget(Notifier newTarget) { - // TODO Auto-generated method stub - - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/section/AppliedStereotypeSectionWithView.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/section/AppliedStereotypeSectionWithView.java deleted file mode 100644 index 78a95187585..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/section/AppliedStereotypeSectionWithView.java +++ /dev/null @@ -1,151 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2008 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:
- * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.profile.ui.section;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.uml.profile.tree.objects.StereotypedElementTreeObject;
-import org.eclipse.papyrus.uml.profile.ui.compositeforview.AppliedStereotypeCompositeWithView;
-import org.eclipse.papyrus.uml.profile.ui.compositeforview.AppliedStereotypePropertyCompositeWithView;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
-import org.eclipse.uml2.uml.Element;
-
-/**
- * This section is used to apply stereotype on uml Element.
- */
-public class AppliedStereotypeSectionWithView extends AbstractPropertySection {
-
- /** The stereotype composite. */
- private AppliedStereotypeCompositeWithView appliedStereotypeComposite;
-
- /** The property composite. */
- private AppliedStereotypePropertyCompositeWithView propertyComposite;
-
- /**
- * Creates the controls.
- *
- * @param tabbedPropertySheetPage
- * the tabbed property sheet page
- * @param parent
- * the parent
- */
- @Override
- public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) {
- super.createControls(parent, tabbedPropertySheetPage);
- appliedStereotypeComposite = new AppliedStereotypeCompositeWithView(parent);
- appliedStereotypeComposite.createContent(parent, getWidgetFactory());
-
- propertyComposite = new AppliedStereotypePropertyCompositeWithView(parent, appliedStereotypeComposite);
- propertyComposite.createContent(parent, getWidgetFactory());
-
- appliedStereotypeComposite.setPropertyComposite(propertyComposite);
- }
-
- /**
- * Refresh.
- */
- @Override
- public void refresh() {
- appliedStereotypeComposite.refresh();
- propertyComposite.refresh();
- }
-
- /**
- * Should use extra space.
- *
- * @return true, if successful
- */
- @Override
- public boolean shouldUseExtraSpace() {
- return true;
- }
-
- /**
- *
- * {@inheritDoc}
- */
- @Override
- public void setInput(IWorkbenchPart part, ISelection selection) {
- super.setInput(part, selection);
- if(selection instanceof IStructuredSelection) {
- Object input = ((IStructuredSelection)selection).getFirstElement();
-
- if(input instanceof GraphicalEditPart && ((GraphicalEditPart)input).getModel() instanceof View) {
- GraphicalEditPart graphicalEditPart = (GraphicalEditPart)input;
- View view = (View)graphicalEditPart.getModel();
- Element UMLElement = (Element)view.getElement();
- if(UMLElement != null) {
- appliedStereotypeComposite.setDiagramElement(view);
- propertyComposite.setDiagramElement(view);
- appliedStereotypeComposite.setElement(UMLElement);
- appliedStereotypeComposite.setInput(new StereotypedElementTreeObject(UMLElement));
- }
- }
- else{
- EObject eobject=resolveSemanticObject(input);
-
- if(eobject instanceof Element) {
- Element UMLElement = (Element)eobject;
- appliedStereotypeComposite.setDiagramElement(null);
- appliedStereotypeComposite.setElement(UMLElement);
- appliedStereotypeComposite.setInput(new StereotypedElementTreeObject(UMLElement));
- }
- }
-
- }
- }
- /**
- * Resolve semantic element
- *
- * @param object
- * the object to resolve
- * @return <code>null</code> or the semantic element associated to the specified object
- */
- private EObject resolveSemanticObject(Object object) {
- if (object instanceof EObject) {
- return (EObject) object;
- } else if (object instanceof IAdaptable) {
- IAdaptable adaptable = (IAdaptable) object;
- if (adaptable.getAdapter(EObject.class) != null) {
- return (EObject) adaptable.getAdapter(EObject.class);
- }
- }
- return null;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see com.cea.papyrus.core.ui.properties.tabbed.PropertyViewSection#dispose()
- */
- /**
- * Dispose.
- */
- public void dispose() {
- super.dispose();
- if(appliedStereotypeComposite != null)
- appliedStereotypeComposite.disposeListeners();
- if(propertyComposite != null)
- propertyComposite.disposeListeners();
- }
-}
diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/views/ProfilePanelView.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/views/ProfilePanelView.java deleted file mode 100644 index 7e4b84ab2fe..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/ui/views/ProfilePanelView.java +++ /dev/null @@ -1,247 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 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: - * Chokri Mraidha (CEA LIST) Chokri.Mraidha@cea.fr - Initial API and implementation - * Patrick Tessier (CEA LIST) Patrick.Tessier@cea.fr - modification - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.profile.ui.views; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.papyrus.uml.profile.ui.panels.AbstractPanel; -import org.eclipse.papyrus.uml.profile.ui.panels.AppliedProfilePanel; -import org.eclipse.papyrus.uml.profile.ui.panels.AppliedStereotypePanel; -import org.eclipse.papyrus.uml.profile.ui.panels.DefaultPanel; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.ISelectionListener; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.part.ViewPart; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.Package; - - -/** - * This view displays different panels, given a selected element. For a package (and model), - * it displays all profiles applied to this package. For an UML element, it displays - * stereotypes applied to this element. - * <p> - * Panels are created using a factory, which should be overloaded when using a new selection manager. - * - */ -public class ProfilePanelView extends ViewPart implements ISelectionListener, IPartListener { - - /** The parent. */ - protected Composite parent; - - /** The current target. */ - protected Object currentTarget; - - // keeps the reference to the panel (abstract class) - /** The panel. */ - protected AbstractPanel panel; - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - /** - * Creates the part control. - * - * @param parent - * the parent - */ - @Override - public void createPartControl(Composite parent) { - getViewSite().getPage().addSelectionListener(this); - getViewSite().getPage().addPartListener(this); - this.parent = parent; - panel = new DefaultPanel(parent, 0); - panel.createContent(); - } - - /** - * Passing the focus request to the viewer's control. - */ - @Override - public void setFocus() { - panel.setFocus(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) - */ - /** - * Selection changed. - * - * @param part - * the part - * @param selection - * the selection - */ - public void selectionChanged(IWorkbenchPart part, ISelection selection) { - - if(!selection.isEmpty()) { - - IStructuredSelection sSelection = (IStructuredSelection)selection; - Object previousTarget = currentTarget; - currentTarget = null; - - //If more or less than 1 element is selected then nothing is active - if(sSelection.size() == 1) { - // Retrieve selected object - Object object = sSelection.getFirstElement(); - // If the object is an edit part, try to get semantic bridge - if(object instanceof Package) { - currentTarget = (Package)object; - } else if(object instanceof Element) { - currentTarget = (Element)object; - } else { - currentTarget = null; - } - } - if(previousTarget != currentTarget) { - switchUI(); - } - } else { - currentTarget = null; - switchUI(); - } - } - - // IPartListener methods implementation - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IPartListener#partActivated(org.eclipse.ui.IWorkbenchPart) - */ - /** - * Part activated. - * - * @param part - * the part - */ - public void partActivated(IWorkbenchPart part) { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IPartListener#partDeactivated(org.eclipse.ui.IWorkbenchPart) - */ - /** - * Part deactivated. - * - * @param part - * the part - */ - public void partDeactivated(IWorkbenchPart part) { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IPartListener#partBroughtToTop(org.eclipse.ui.IWorkbenchPart) - */ - /** - * Part brought to top. - * - * @param part - * the part - */ - public void partBroughtToTop(IWorkbenchPart part) { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart) - */ - /** - * Part opened. - * - * @param part - * the part - */ - public void partOpened(IWorkbenchPart part) { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart) - */ - /** - * Part closed. - * - * @param part - * the part - */ - public void partClosed(IWorkbenchPart part) { - switchUIDefault(); - } - - /** - * Changes the panel displayed in the view, depending on the type of the - * newly selected element. - */ - protected void switchUI() { - if((currentTarget != null) && (currentTarget instanceof Element)) { - - /* - * test to check if the panel is not disposed. - * Closing the panel view and open it again creates a second - * instance of panel, one of it is disposed, the new one is active - */ - if(!panel.isDisposed()) { - panel.exitAction(); - panel.dispose(); - - if(currentTarget instanceof Package) { - panel = new AppliedProfilePanel(this.parent, 0); - panel.createContent(); - ((AppliedProfilePanel)panel).setSelected((Package)currentTarget); - } else if(currentTarget instanceof Element) { - panel = new AppliedStereotypePanel(this.parent, 0); - panel.createContent(); - ((AppliedStereotypePanel)panel).setSelected((Element)currentTarget); - } else { - panel = new DefaultPanel(this.parent, 0); - panel.createContent(); - } - panel.setBounds(panel.getParent().getBounds()); - panel.entryAction(); - } - } else { // Something selected out of the model ??? - switchUIDefault(); - } - } - - /** - * Replace current panel with default. - */ - private void switchUIDefault() { - if(!panel.isDisposed()) { - // Flush previous - panel.exitAction(); - panel.dispose(); - // Create default - panel = new DefaultPanel(this.parent, 0); - panel.createContent(); - // SetBounds - panel.setBounds(panel.getParent().getBounds()); - panel.entryAction(); - } - } -} diff --git a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/utils/UmlElementFilter.java b/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/utils/UmlElementFilter.java deleted file mode 100644 index f51f10541c0..00000000000 --- a/plugins/uml/org.eclipse.papyrus.uml.profile/src/org/eclipse/papyrus/uml/profile/utils/UmlElementFilter.java +++ /dev/null @@ -1,38 +0,0 @@ -/*******************************************************************************
- * Copyright (c) 2009 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.uml.profile.utils;
-
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.jface.viewers.IFilter;
-import org.eclipse.uml2.uml.Element;
-
-/**
- * Filter that returns <code>true</code> if the element associated to the object is a UML {@link Element}.
- */
-public class UmlElementFilter implements IFilter {
-
- /**
- * {@inheritDoc}
- */
- public boolean select(Object object) {
- // test element is a node edit part and its controlled element has an associated UML element
- if(object instanceof IGraphicalEditPart
- && ((IGraphicalEditPart)object).getNotationView().getElement() instanceof Element)
- return true;
-
- if(object instanceof Element) {
- return true;
- }
-
- return false;
- }
-
-}
|