diff options
Diffstat (limited to 'extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus')
10 files changed, 0 insertions, 1104 deletions
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/Activator.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/Activator.java deleted file mode 100644 index 507eaf2fb16..00000000000 --- a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/Activator.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 Atos - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Arthur Daussy - initial implementation - *******************************************************************************/ -package org.eclipse.papyrus.team.collaborative.controlmode; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class Activator extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "org.eclipse.papyrus.team.collaborative.core.integration.papyrus.svn"; //$NON-NLS-1$ - - // The shared instance - private static Activator plugin; - - /** - * The constructor. - */ - public Activator() { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ - @Override - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static Activator getDefault() { - return plugin; - } - - /** - * - * This method returns an <code>org.eclipse.swt.graphics.Image</code> identified by its pluginId and iconPath.<BR> - */ - public static Image getPluginIconImage(String pluginId, String iconPath) { - String key = pluginId + iconPath; - ImageRegistry registry = getDefault().getImageRegistry(); - Image image = registry.get(key); - if (image == null) { - ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(pluginId, iconPath); - registry.put(key, desc); - image = registry.get(key); - } - return image; - } - -} diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/commands/AddFileToCollabSVN.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/commands/AddFileToCollabSVN.java deleted file mode 100644 index 676a03cefb2..00000000000 --- a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/commands/AddFileToCollabSVN.java +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 Atos - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Arthur Daussy - initial implementation - *******************************************************************************/ -package org.eclipse.papyrus.team.collaborative.controlmode.commands; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest; -import org.eclipse.papyrus.team.collaborative.core.IExtendedURI; -import org.eclipse.papyrus.team.collaborative.core.utils.CollabFunctionsFactory; -import org.eclipse.papyrus.team.collaborative.strategy.ui.actions.CommitHandler; -import org.eclipse.papyrus.team.collaborative.strategy.ui.actions.LockAction; -import org.eclipse.papyrus.team.collaborative.strategy.utils.UIUtils; -import org.eclipse.papyrus.team.collaborative.svn.utils.SVNUtils; - -import com.google.common.collect.Collections2; -import com.google.common.collect.Sets; - - -/** - * The Class AddFileToCollabSVN. - * This command is used to add file to a SVN repository using a {@link ControlModeRequest}. - * The files shall be already serialized. - */ -public class AddFileToCollabSVN extends AbstractTransactionalCommand { - - // private Collection<URI> uris; - /** The request. */ - private ControlModeRequest request; - - /** - * Instantiates a new adds the file to collab svn. - * - * @param domain - * the domain - * @param request - * the request - */ - public AddFileToCollabSVN(TransactionalEditingDomain domain, ControlModeRequest request) { - super(domain, "Add fiel to collacb", null); - this.request = request; - } - - /** - * Adds the source resource. - * - * @param extension - * the extension - * @param resources - * the resources - */ - protected void addSourceResource(String extension, Collection<Resource> resources) { - Resource resource = request.getSourceResource(extension); - if (resource != null) { - resources.add(resource); - } - } - - /** - * Adds the target resource. - * - * @param extension - * the extension - * @param resources - * the resources - */ - protected void addTargetResource(String extension, Collection<Resource> resources) { - Resource resource = request.getTargetResource(extension); - if (resource != null) { - resources.add(resource); - } - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, - * org.eclipse.core.runtime.IAdaptable) - */ - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - /* - * This part should be more generic - */ - Set<Resource> targetResource = new HashSet<Resource>(); - addTargetResource("uml", targetResource); - addTargetResource("di", targetResource); - addTargetResource("notation", targetResource); - Set<Resource> sourceResource = new HashSet<Resource>(); - addSourceResource("uml", sourceResource); - addSourceResource("di", sourceResource); - addSourceResource("notation", sourceResource); - - // Add target resource to repository - Collection<IFile> targetExtendedFiles = Collections2.transform(targetResource, CollabFunctionsFactory.getResourceToIFile()); - IStatus status = SVNUtils.addToRepository(UIUtils.getLabel(request.getTargetObject()), targetExtendedFiles); - if (!status.isOK()) { - throw new ExecutionException(status.getMessage(), status.getException()); - } - // Commit source resources - HashSet<IExtendedURI> sourceExtendedURIs = Sets.newHashSet(Collections2.transform(sourceResource, CollabFunctionsFactory.getResourceToExtendedURIWithContainment())); - ResourceSet resourceSet = request.getEditingDomain().getResourceSet(); - StringBuilder commitMessage = new StringBuilder("Creation of new partition "); - commitMessage.append(getPartitionName()); - status = CommitHandler.doCommit(sourceExtendedURIs, resourceSet, false, commitMessage.toString()); - if (!status.isOK()) { - throw new ExecutionException(status.getMessage(), status.getException()); - } - // Take lock in new resources - Set<IExtendedURI> targetExtendedURIs = Sets.newHashSet(Collections2.transform(targetResource, CollabFunctionsFactory.getResourceToExtendedURIWithContainment())); - status = LockAction.doSafeLock(resourceSet, targetExtendedURIs, false); - if (!status.isOK()) { - throw new ExecutionException(status.getMessage(), status.getException()); - } - return CommandResult.newOKCommandResult(); - } - - /** - * Gets the partition name. - * - * @return the partition name - */ - protected String getPartitionName() { - return request.getTargetResource("uml").getURI().trimFileExtension().segment(1); - } - -} diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/commands/SaveCommand.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/commands/SaveCommand.java deleted file mode 100644 index 213a9ac90c5..00000000000 --- a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/commands/SaveCommand.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 Atos - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Arthur Daussy - initial implementation - *******************************************************************************/ -package org.eclipse.papyrus.team.collaborative.controlmode.commands; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.ui.ISaveablePart; - - -/** - * The Class SaveCommand. - * Command to save an editor - */ -public class SaveCommand extends AbstractTransactionalCommand { - - /** The editor. */ - private ISaveablePart editor; - - /** - * Instantiates a new save command. - * - * @param domain - * the domain - * @param editor - * the editor - */ - public SaveCommand(TransactionalEditingDomain domain, ISaveablePart editor) { - // Set list command to null the save command is secure with read only - super(domain, "Save command", null); - this.editor = editor; - } - - /* - * (non-Javadoc) - * - * @see - * org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, - * org.eclipse.core.runtime.IAdaptable) - */ - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - try { - editor.doSave(monitor); - } catch (Exception e) { - return CommandResult.newErrorCommandResult(e); - } - return CommandResult.newOKCommandResult(); - } - -} diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/control/SVNControlModeParticipant.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/control/SVNControlModeParticipant.java deleted file mode 100644 index 046ebb85a22..00000000000 --- a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/control/SVNControlModeParticipant.java +++ /dev/null @@ -1,133 +0,0 @@ -/*******************************************************************************
- * Copyright (c) 2013 Atos
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Arthur Daussy - initial implementation
- *******************************************************************************/
-package org.eclipse.papyrus.team.collaborative.controlmode.control;
-
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
-import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest;
-import org.eclipse.papyrus.infra.services.controlmode.participants.IControlCommandParticipant;
-import org.eclipse.papyrus.infra.services.controlmode.participants.IUncontrolCommandParticipant;
-import org.eclipse.papyrus.team.collaborative.controlmode.commands.AddFileToCollabSVN;
-import org.eclipse.papyrus.team.collaborative.controlmode.commands.SaveCommand;
-import org.eclipse.papyrus.team.collaborative.core.utils.CollabUtils;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.ISaveablePart;
-import org.eclipse.ui.PlatformUI;
-
-
-/**
- * The Class SVNControlModeParticipant.
- * This {@link IControlCommandParticipant} provide mean to automatically integrate file generated after a control into a SVN repository
- * WARNING: The {@link IUncontrolCommandParticipant} is not implemented yet
- */
-public class SVNControlModeParticipant implements IControlCommandParticipant, IUncontrolCommandParticipant {
-
- /**
- * Instantiates a new sVN control mode participant.
- */
- public SVNControlModeParticipant() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.papyrus.controlmode.interfaces.IControlModeParticipant#getID()
- */
- @Override
- public String getID() {
- return "org.eclipse.papyrus.team.collaborative.core.integration.papyrus.control.SVNControlModeParticipant";
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.papyrus.controlmode.interfaces.IControlModeParticipant#getPriority()
- */
- @Override
- public int getPriority() {
- return 10000;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.papyrus.controlmode.interfaces.IUncontrolCommandParticipant#provideUnControlCommand(org.eclipse.papyrus.controlmode.request.
- * ControlModeRequest)
- */
- @Override
- public boolean provideUnControlCommand(ControlModeRequest request) {
- return CollabUtils.isCollab(request.getTargetObject());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.papyrus.controlmode.interfaces.IUncontrolCommandParticipant#getPreUncontrolCommand(org.eclipse.papyrus.controlmode.request.
- * ControlModeRequest)
- */
- @Override
- public ICommand getPreUncontrolCommand(ControlModeRequest request) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.papyrus.controlmode.interfaces.IUncontrolCommandParticipant#getPostUncontrolCommand(org.eclipse.papyrus.controlmode.request.
- * ControlModeRequest)
- */
- @Override
- public ICommand getPostUncontrolCommand(ControlModeRequest request) {
- // TODO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.papyrus.controlmode.interfaces.IControlCommandParticipant#provideControlCommand(org.eclipse.papyrus.controlmode.request.
- * ControlModeRequest)
- */
- @Override
- public boolean provideControlCommand(ControlModeRequest request) {
- return CollabUtils.isCollab(request.getTargetObject());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.papyrus.controlmode.interfaces.IControlCommandParticipant#getPreControlCommand(org.eclipse.papyrus.controlmode.request.
- * ControlModeRequest)
- */
- @Override
- public ICommand getPreControlCommand(ControlModeRequest request) {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.papyrus.controlmode.interfaces.IControlCommandParticipant#getPostControlCommand(org.eclipse.papyrus.controlmode.request.
- * ControlModeRequest)
- */
- @Override
- public ICommand getPostControlCommand(ControlModeRequest request) {
- CompositeTransactionalCommand cc = new CompositeTransactionalCommand(request.getEditingDomain(), "Share file to SVN with need lock");
- IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- if (editor instanceof ISaveablePart) {
- cc.compose(new SaveCommand(request.getEditingDomain(), editor));
- cc.compose(new AddFileToCollabSVN(request.getEditingDomain(), request));
- }
- return cc;
- }
-
-}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/handler/SVNCollabControlCommandHandler.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/handler/SVNCollabControlCommandHandler.java deleted file mode 100644 index d2d1fab81df..00000000000 --- a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/handler/SVNCollabControlCommandHandler.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 Atos - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Arthur Daussy - initial implementation - * Philippe Roland (Atos) philippe.roland@atos.net - minor change to the - * default naming algorithm to ensure it suggests a valid name - *******************************************************************************/ -package org.eclipse.papyrus.team.collaborative.controlmode.handler; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ModelElementItem; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.jface.window.Window; -import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper; -import org.eclipse.papyrus.infra.services.controlmode.ControlModeManager; -import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest; -import org.eclipse.papyrus.infra.services.controlmode.IControlModeManager; -import org.eclipse.papyrus.infra.widgets.toolbox.notification.builders.NotificationBuilder; -import org.eclipse.papyrus.team.collaborative.controlmode.ui.CreateCollabModelFragmentDialog; -import org.eclipse.papyrus.team.collaborative.strategy.ui.dialogs.PreviewDialog; -import org.eclipse.papyrus.team.collaborative.strategy.ui.providers.ExtensivePartitionNameLabelProvider; -import org.eclipse.papyrus.team.collaborative.strategy.utils.UIUtils; -import org.eclipse.papyrus.views.modelexplorer.handler.AbstractModelExplorerHandler; -import org.eclipse.swt.widgets.Display; - - -/** - * The Class SVNCollabControlCommandHandler. - * Specific handler for fragment creation. - * This handler retrict the {@link URI} of the new target {@link Resource} - */ -public class SVNCollabControlCommandHandler extends AbstractModelExplorerHandler { - - private static final String PARTITION_PREFIX = "__Partition"; - - private static final String ILLEGAL_CHARACTERS = "[^a-zA-Z0-9_]"; - - private static final String EMPTY_STRING = ""; - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - - List<EObject> selection = getCurrentSelectionAdaptedToType(event, EObject.class); - if (selection == null || selection.isEmpty() || selection.size() > 1) { - NotificationBuilder.createInfoPopup("Nothing to control").run(); - return null; - } - EObject eObjectToControl = selection.get(0); - Resource eResource = eObjectToControl.eResource(); - CreateCollabModelFragmentDialog dialog = new CreateCollabModelFragmentDialog(Display.getDefault().getActiveShell(), eResource, getDefaultName(event)); - if (dialog.open() == Window.OK) { - ControlModeRequest controlRequest = ControlModeRequest.createUIControlModelRequest(getEditingDomain(), eObjectToControl, dialog.getURI()); - IControlModeManager controlMng = ControlModeManager.getInstance(); - ICommand controlCommand = controlMng.getControlCommand(controlRequest); - getEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(controlCommand)); - PreviewDialog partitionDialog = new PreviewDialog(Display.getDefault().getActiveShell(), new ExtensivePartitionNameLabelProvider(UIUtils.getModelExplorerLavelProvider()), "Model Partition", EMPTY_STRING); - if (selection != null && !selection.isEmpty()) { - partitionDialog.setObjectsToReveal(Collections.singleton(eObjectToControl)); - } - partitionDialog.open(); - } - return null; - } - - /** - * Create the default resource name from the selected element - * - * @param event - * @return - * @throws ExecutionException - */ - protected String getDefaultName(ExecutionEvent event) throws ExecutionException { - List<ModelElementItem> selection = getCurrentSelectionAdaptedToType(event, ModelElementItem.class); - if (selection != null && !selection.isEmpty()) { - String label = selection.get(0).getText().trim() + PARTITION_PREFIX; - label = label.replaceAll(ILLEGAL_CHARACTERS, ""); - return label; - } - return EMPTY_STRING; - } - - -} diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/handler/ShowModelPartitionHandler.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/handler/ShowModelPartitionHandler.java deleted file mode 100644 index b3e7845619d..00000000000 --- a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/handler/ShowModelPartitionHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 Atos - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Arthur Daussy - initial implementation - *******************************************************************************/ -package org.eclipse.papyrus.team.collaborative.controlmode.handler; - -import java.util.List; - -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.papyrus.team.collaborative.strategy.ui.dialogs.PreviewDialog; -import org.eclipse.papyrus.team.collaborative.strategy.ui.providers.ExtensivePartitionNameLabelProvider; -import org.eclipse.papyrus.team.collaborative.strategy.utils.UIUtils; -import org.eclipse.papyrus.views.modelexplorer.handler.AbstractModelExplorerHandler; -import org.eclipse.swt.widgets.Display; - - -/** - * The Class ShowModelPartitionHandler. - * Handler use to display the current partitioning of a model. It will reveal the current selected element - */ -public class ShowModelPartitionHandler extends AbstractModelExplorerHandler { - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) - */ - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - List<EObject> selection = getCurrentSelectionAdaptedToType(event, EObject.class); - PreviewDialog dialog = new PreviewDialog(Display.getDefault().getActiveShell(), new ExtensivePartitionNameLabelProvider(UIUtils.getModelExplorerLavelProvider()), "Model Partition", - "The name of each partition appear between the [] before each element name"); - if (selection != null && !selection.isEmpty()) { - dialog.setObjectsToReveal(selection); - } - dialog.open(); - return null; - } - - -} diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/queries/IsCollabQuery.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/queries/IsCollabQuery.java deleted file mode 100644 index ac8a606e20f..00000000000 --- a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/queries/IsCollabQuery.java +++ /dev/null @@ -1,70 +0,0 @@ -/*******************************************************************************
- * Copyright (c) 2013 Atos
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Arthur Daussy - initial implementation
- *******************************************************************************/
-package org.eclipse.papyrus.team.collaborative.controlmode.queries;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException;
-import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery;
-import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList;
-import org.eclipse.papyrus.team.collaborative.core.ICollaborativeManager;
-import org.eclipse.papyrus.team.collaborative.core.IExtendedURI;
-import org.eclipse.papyrus.team.collaborative.core.participants.locker.ILocker;
-import org.eclipse.papyrus.team.collaborative.core.utils.CollabFunctionsFactory;
-import org.eclipse.papyrus.team.collaborative.strategy.utils.PapyrusResourceUtils;
-
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Sets;
-
-
-/**
- * Return true if the element is a collab element
- *
- * @author adaussy
- *
- */
-public class IsCollabQuery implements IJavaModelQuery<EObject, Boolean> {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery#evaluate(org.eclipse.emf.ecore.EObject,
- * org.eclipse.emf.facet.infra.query.core.java.ParameterValueList)
- */
- @Override
- public Boolean evaluate(EObject arg0, ParameterValueList arg1) throws ModelQueryExecutionException {
- List<URI> uris = new ArrayList<URI>();
- URI uri = arg0.eResource().getURI();
- ResourceSet resourceSet = arg0.eResource().getResourceSet();
- uris.add(uri);
- PapyrusResourceUtils.addExtraResources(resourceSet, uris, uri);
- Set<IExtendedURI> extendedURIS = Sets.newHashSet(Collections2.transform(uris, CollabFunctionsFactory.getURIToExtendedURIWithContainment()));
- ILocker locker = ICollaborativeManager.INSTANCE.getLocker(extendedURIS, resourceSet);
- if (locker == null) {
- return false;
- }
- boolean result = false;
- for (IExtendedURI extURI : extendedURIS) {
- if (locker.isLocked(extURI).isOK()) {
- result = true;
- }
- }
- return result;
-
-
- }
-
-}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/queries/IsPartialyLocked.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/queries/IsPartialyLocked.java deleted file mode 100644 index a025c8b5dd9..00000000000 --- a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/queries/IsPartialyLocked.java +++ /dev/null @@ -1,70 +0,0 @@ -/*******************************************************************************
- * Copyright (c) 2013 Atos
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Arthur Daussy - initial implementation
- *******************************************************************************/
-package org.eclipse.papyrus.team.collaborative.controlmode.queries;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.facet.infra.query.core.exception.ModelQueryExecutionException;
-import org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery;
-import org.eclipse.emf.facet.infra.query.core.java.ParameterValueList;
-import org.eclipse.papyrus.team.collaborative.core.ICollaborativeManager;
-import org.eclipse.papyrus.team.collaborative.core.IExtendedURI;
-import org.eclipse.papyrus.team.collaborative.core.participants.locker.ILocker;
-import org.eclipse.papyrus.team.collaborative.core.utils.CollabFunctionsFactory;
-import org.eclipse.papyrus.team.collaborative.strategy.utils.PapyrusResourceUtils;
-
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Sets;
-
-
-/**
- * The Class IsPartialyLocked.
- * Return true if the element is partialy locked. Partialy locked mean that there is one of the di or uml or notation model that has not been locked
- */
-public class IsPartialyLocked implements IJavaModelQuery<EObject, Boolean> {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.facet.infra.query.core.java.IJavaModelQuery#evaluate(org.eclipse.emf.ecore.EObject,
- * org.eclipse.emf.facet.infra.query.core.java.ParameterValueList)
- */
- @Override
- public Boolean evaluate(EObject arg0, ParameterValueList arg1) throws ModelQueryExecutionException {
- List<URI> uris = new ArrayList<URI>();
- URI uri = arg0.eResource().getURI();
- ResourceSet resourceSet = arg0.eResource().getResourceSet();
- uris.add(uri);
- PapyrusResourceUtils.addExtraResources(resourceSet, uris, uri);
- Set<IExtendedURI> extendedURIS = Sets.newHashSet(Collections2.transform(uris, CollabFunctionsFactory.getURIToExtendedURIWithContainment()));
- ILocker locker = ICollaborativeManager.INSTANCE.getLocker(extendedURIS, resourceSet);
- if (locker == null) {
- return false;
- }
- boolean oneLocked = false;
- boolean oneUnlocked = false;
- for (IExtendedURI extURI : extendedURIS) {
- if (locker.isLocked(extURI).isOK()) {
- oneLocked = true;
- } else {
- oneUnlocked = true;
- }
- }
- return oneUnlocked && oneLocked;
-
- }
-
-}
diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/ui/CreateCollabModelFragmentDialog.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/ui/CreateCollabModelFragmentDialog.java deleted file mode 100644 index 758b4164933..00000000000 --- a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/ui/CreateCollabModelFragmentDialog.java +++ /dev/null @@ -1,373 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Anyware Technologies. 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: Jacques Lescot (Anyware Technologies) - initial API and - * implementation - ******************************************************************************/ -package org.eclipse.papyrus.team.collaborative.controlmode.ui; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.papyrus.team.collaborative.controlmode.Activator; -import org.eclipse.papyrus.team.collaborative.core.reports.LogHelper; -import org.eclipse.papyrus.team.collaborative.core.utils.CollabFunctionsFactory; -import org.eclipse.papyrus.team.collaborative.core.utils.URIUtils; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.layout.FormLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -/** - * Dialog that will ask the user the name of the new partition and create an {@link URI} - * - * @author adaussy - * - */ -public class CreateCollabModelFragmentDialog extends Dialog { - - private URI uri; - - private Resource currentResource; - - private String defaultName; - - - private static final String COLLAB_FOLDER_PATH = ".collab/"; - - /** - * The constructor - * - * @param parent - * @param theDomain - * @param theCurrentResource - * @param defaultName - */ - public CreateCollabModelFragmentDialog(Shell parent, Resource theCurrentResource, String defaultName) { - super(parent); - this.currentResource = theCurrentResource; - this.defaultName = defaultName; - this.title = "Create new partition"; - this.style = SWT.SAVE; - - normalizeStyle(); - setShellStyle(getShellStyle() | SWT.MAX | SWT.RESIZE); - } - - private URI computetURI() { - IFile file = CollabFunctionsFactory.getResourceToIFile().apply(currentResource); - IProject project = file.getProject(); - IFolder folder = project.getFolder(COLLAB_FOLDER_PATH); - if (!folder.exists()) { - try { - folder.create(true, true, null); - } catch (CoreException e) { - e.printStackTrace(); - LogHelper.getInstance().logError("Unable to fragment the model", Activator.PLUGIN_ID, e); - return null; - } - } - - return URIUtils.getURI(folder.getFullPath()); - } - - @Override - protected Control createContents(Composite parent) { - Control result = super.createContents(parent); - this.uriField.setText(defaultName); - return result; - } - - /** - * Creates and, if it already exists, loads the specified resource. This implementation verifies - * that a resource can be opened for that URI, that the resource is not the object's current - * container, and that it is not read-only in the editing domain. If there is an existing - * resource with that URI, it prompts before overriding or adding to it. - * - * @see org.eclipse.emf.common.ui.dialogs.ResourceDialog#processResources() - */ - protected boolean processResources() { - String uriText = getURIText(); - if ("".equals(uriText)) { - ErrorDialog.openError(Display.getDefault().getActiveShell(), "Illegal partition name", "The name can not be empty", new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Illegal name")); - return false; - } - Matcher matcher = LEGAL_NAME.matcher(uriText); - if (matcher.matches()) { - URI uri = computetURI().appendSegment(uriText).appendFileExtension("uml"); - if (!alreadyExist(uri)) { - this.uri = uri; - return true; - } else { - ErrorDialog.openError(Display.getDefault().getActiveShell(), "Illegal partition name", "This name is already used", new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Illegal name")); - return false; - } - } - ErrorDialog.openError(Display.getDefault().getActiveShell(), "Illegal partition name", "The partition name shoudl respect ^[a-zA-Z][a-zA-Z0-9]*?$ convention", new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Illegal name")); - return false; - } - - protected boolean alreadyExist(URI uri) { - for (Resource r : currentResource.getResourceSet().getResources()) { - if (r.getURI().equals(uri)) { - return true; - } - } - return false; - } - - private static final Pattern LEGAL_NAME = Pattern.compile("^[a-zA-Z][a-zA-Z0-9_]*?$"); - - /** - * Return the created Resource - * - * @return the Resource - */ - public URI getURI() { - return uri; - } - - - protected static final int CONTROL_OFFSET = 10; - - protected String title; - - protected int style; - - protected Text uriField; - - protected String uriText; - - protected void normalizeStyle() { - // Ensure there are no extraneous style bits. - // - if ((style & ~(SWT.MULTI | SWT.SINGLE | SWT.OPEN | SWT.SAVE)) != 0) { - throw new IllegalArgumentException("extraneous style bits specified (only SWT.MULTI, SWT.SINGLE, SWT.OPEN, SWT.SAVE allowed"); - } - - // Assign default style bits, if necessary, and ensure none conflict. - // - if ((style & SWT.MULTI) == 0 && (style & SWT.SINGLE) == 0) { - style |= SWT.SINGLE; - } else if ((style & SWT.MULTI) != 0 && (style & SWT.SINGLE) != 0) { - throw new IllegalArgumentException("conflicting style bits specified (sWT.MUTLI and SWT.SINGLE)"); - } - - if ((style & SWT.OPEN) == 0 && (style & SWT.SAVE) == 0) { - style |= SWT.OPEN; - } else if ((style & SWT.OPEN) != 0 && (style & SWT.SAVE) != 0) { - throw new IllegalArgumentException("conflicting style bits specified (sWT.OPEN and SWT.SAVE)"); - } - - if (isMulti() && isSave()) { - throw new IllegalArgumentException("conflicting style bits specified (sWT.MULTI and SWT.SAVE)"); - } - } - - protected boolean isSave() { - return (style & SWT.SAVE) != 0; - } - - protected boolean isMulti() { - return (style & SWT.MULTI) != 0; - } - - @Override - protected void configureShell(Shell shell) { - super.configureShell(shell); - shell.setText(title); - } - - /** - * Creates and returns the contents of the upper part of this dialog. - * This implementation creates a labeled text field for the URI(s) and buttons for browsing the - * file system and workspace. These buttons are configured (selection listeners are added) by calling {@link #prepareBrowseFileSystemButton} and {@link #prepareBrowseWorkspaceButton}, respectively. - */ - @Override - protected Control createDialogArea(Composite parent) { - Composite composite = (Composite) super.createDialogArea(parent); - { - FormLayout layout = new FormLayout(); - composite.setLayout(layout); - - GridData data = new GridData(); - data.verticalAlignment = GridData.FILL; - data.grabExcessVerticalSpace = true; - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - data.widthHint = 500; - composite.setLayoutData(data); - } - - // buttonComposite has to be the first child of composite because subclasses are expecting this. - Composite buttonComposite = new Composite(composite, SWT.NONE); - - Label resourceURILabel = new Label(composite, SWT.LEFT); - { - resourceURILabel.setText("Name of the new partition"); - FormData data = new FormData(); - data.left = new FormAttachment(0, CONTROL_OFFSET); - data.top = new FormAttachment(0, CONTROL_OFFSET); - resourceURILabel.setLayoutData(data); - } - - { - FormData data = new FormData(); - data.top = new FormAttachment(resourceURILabel, CONTROL_OFFSET, SWT.CENTER); - data.left = new FormAttachment(resourceURILabel, CONTROL_OFFSET); - data.right = new FormAttachment(100, -CONTROL_OFFSET); - buttonComposite.setLayoutData(data); - - buttonComposite.setLayout(new FormLayout()); - } - - uriField = new Text(composite, SWT.BORDER); - { - FormData data = new FormData(); - data.top = new FormAttachment(buttonComposite, CONTROL_OFFSET); - data.left = new FormAttachment(0, CONTROL_OFFSET); - data.right = new FormAttachment(100, -CONTROL_OFFSET); - uriField.setLayoutData(data); - } - - composite.setTabList(new Control[] { uriField, buttonComposite }); - return composite; - } - - /** - * Called to prepare the Browse File System button, this implementation adds a selection listener - * that creates an appropriate {@link FileDialog}. - */ - protected void prepareBrowseFileSystemButton(Button browseFileSystemButton) { - browseFileSystemButton.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent event) { - FileDialog fileDialog = new FileDialog(getShell(), style); - fileDialog.open(); - - String filterPath = fileDialog.getFilterPath(); - if (isMulti()) { - String[] fileNames = fileDialog.getFileNames(); - StringBuffer uris = new StringBuffer(); - - for (int i = 0, len = fileNames.length; i < len; i++) { - uris.append(URI.createFileURI(filterPath + File.separator + fileNames[i]).toString()); - uris.append(" "); - } - uriField.setText((uriField.getText() + " " + uris.toString()).trim()); - } else { - String fileName = fileDialog.getFileName(); - if (fileName != null) { - uriField.setText(URI.createFileURI(filterPath + File.separator + fileName).toString()); - } - } - } - }); - } - - /** - * Called to prepare the Browse Workspace button, this implementation adds a selection listener - * that creates an appropriate {@link WorkspaceResourceDialog}. - */ - protected void prepareBrowseWorkspaceButton(Button browseWorkspaceButton) { - browseWorkspaceButton.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent event) { - if (isMulti()) { - StringBuffer uris = new StringBuffer(); - - IFile[] files = WorkspaceResourceDialog.openFileSelection(getShell(), null, null, true, null, null); - for (int i = 0, len = files.length; i < len; i++) { - uris.append(URI.createPlatformResourceURI(files[i].getFullPath().toString(), true)); - uris.append(" "); - } - uriField.setText((uriField.getText() + " " + uris.toString()).trim()); - } else { - IFile file = null; - - if (isSave()) { - file = WorkspaceResourceDialog.openNewFile(getShell(), null, null, null, null); - } else { - IFile[] files = WorkspaceResourceDialog.openFileSelection(getShell(), null, null, false, null, null); - if (files.length != 0) { - file = files[0]; - } - } - - if (file != null) { - uriField.setText(URI.createPlatformResourceURI(file.getFullPath().toString(), true).toString()); - } - } - } - }); - } - - /** - * Called when the OK button has been pressed, this method calls {@link #getURIText} to cache and return - * the URI text field's value (so that it may be retrieved even after the field has been disposed). - * It then calls {@link #processResources} to handle the specified URIs and optionally closes the dialog, - * based on its return value. - */ - @Override - protected void okPressed() { - uriText = getURIText(); - if (processResources()) { - super.okPressed(); - } else { - uriField.selectAll(); - uriField.setFocus(); - } - } - - /** - * Returns the value of the URI text field. - */ - public String getURIText() { - return uriField != null && !uriField.isDisposed() ? uriField.getText() : uriText; - } - - /** - * Returns the list of space-separated URIs from the URI text field. - */ - public List<URI> getURIs() { - List<URI> uris = new ArrayList<URI>(); - for (StringTokenizer stringTokenizer = new StringTokenizer(getURIText()); stringTokenizer.hasMoreTokens();) { - String uri = stringTokenizer.nextToken(); - uris.add(URI.createURI(uri)); - } - return uris; - } - - -} diff --git a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/ui/IconsPath.java b/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/ui/IconsPath.java deleted file mode 100644 index 19bb9db32ec..00000000000 --- a/extraplugins/team.collaborative/org.eclipse.papyrus.team.collaborative.controlmode/src/org/eclipse/papyrus/team/collaborative/controlmode/ui/IconsPath.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 Atos - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Arthur Daussy - initial implementation - *******************************************************************************/ -package org.eclipse.papyrus.team.collaborative.controlmode.ui; - - -/** - * The Interface IconsPath. - */ -public interface IconsPath { - - /** The Constant PARTIAL_LOCKED_OVERLAY. */ - public static final String PARTIAL_LOCKED_OVERLAY = "/org.eclipse.papyrus.team.collaborative.core.integration.papyrus.svn/icons/PartialLock_16x16.png"; - -} |