Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/customization/org.eclipse.papyrus.customization.palette/src')
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/AspectActionsInformationComposite.java125
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/ExtendedPaletteContentPage.java5
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/LocalPaletteContentPage.java5
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/LocalPaletteInformationPage.java2
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/handler/DeployPaletteConfigurationHandler.java308
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/handler/UndeployPaletteConfigurationHandler.java112
6 files changed, 512 insertions, 45 deletions
diff --git a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/AspectActionsInformationComposite.java b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/AspectActionsInformationComposite.java
index 1468bcfc491..d1d3ca29430 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/AspectActionsInformationComposite.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/AspectActionsInformationComposite.java
@@ -15,17 +15,16 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.ITreeSelection;
-import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.uml.diagram.common.Activator;
import org.eclipse.papyrus.uml.diagram.common.Messages;
import org.eclipse.papyrus.uml.diagram.common.service.palette.AspectToolService;
@@ -35,6 +34,8 @@ import org.eclipse.papyrus.uml.diagram.common.service.palette.IPaletteAspectTool
import org.eclipse.papyrus.uml.diagram.common.service.palette.IPostAction;
import org.eclipse.papyrus.uml.diagram.common.service.palette.IPreAction;
import org.eclipse.swt.SWT;
+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.graphics.Image;
@@ -103,15 +104,6 @@ public class AspectActionsInformationComposite {
/** move down aspect action button */
protected Button moveDownActionButton;
- /** the current services registry */
- protected ServicesRegistry registry;
-
-
- public AspectActionsInformationComposite(ServicesRegistry registry) {
- Assert.isNotNull(registry);
- this.registry = registry;
- }
-
/**
* Creates the content for this composite
*
@@ -121,7 +113,6 @@ public class AspectActionsInformationComposite {
*/
public Composite createComposite(Composite parent, List<Profile> appliedProfiles) {
this.appliedProfiles = appliedProfiles;
-
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.marginWidth = 0;
@@ -148,22 +139,29 @@ public class AspectActionsInformationComposite {
addActionButton = new Button(actionList, SWT.NONE);
addActionButton.setImage(Activator.getPluginIconImage(Activator.ID, ICONS_ADD));
- addActionButton.addSelectionListener(new SelectionListener() {
+ addActionButton.addMouseListener(new MouseListener() {
- public void widgetSelected(SelectionEvent e) {
+ public void mouseUp(MouseEvent e) {
addButtonPressed();
}
- public void widgetDefaultSelected(SelectionEvent e) {
- //Nothing
+ public void mouseDown(MouseEvent e) {
+
+ }
+
+ public void mouseDoubleClick(MouseEvent e) {
+
}
});
removeActionButton = new Button(actionList, SWT.NONE);
removeActionButton.setImage(Activator.getPluginIconImage(Activator.ID, ICONS_REMOVE));
- removeActionButton.addSelectionListener(new SelectionListener() {
+ removeActionButton.addMouseListener(new MouseListener() {
- public void widgetSelected(SelectionEvent e) {
+ /**
+ * @{inheritDoc
+ */
+ public void mouseUp(MouseEvent e) {
// remove the selected aspect action(s)
ITreeSelection selection = (ITreeSelection)viewer.getSelection();
if(selection != null && selection.size() > 0) {
@@ -178,19 +176,29 @@ public class AspectActionsInformationComposite {
setSelectedEntryProxy(selectedEntryProxy);
}
- public void widgetDefaultSelected(SelectionEvent e) {
- //Nothing
+ /**
+ * @{inheritDoc
+ */
+ public void mouseDown(MouseEvent e) {
+
+ }
+
+ /**
+ * @{inheritDoc
+ */
+ public void mouseDoubleClick(MouseEvent e) {
+
}
});
moveUpActionButton = new Button(actionList, SWT.NONE);
moveUpActionButton.setImage(Activator.getPluginIconImage(Activator.ID, ICONS_UP));
- moveUpActionButton.addSelectionListener(new SelectionListener() {
+ moveUpActionButton.addMouseListener(new MouseListener() {
/**
* @{inheritDoc
*/
- public void widgetSelected(SelectionEvent e) {
+ public void mouseUp(MouseEvent e) {
IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
if(selection != null && selection.size() > 0 && selectedEntryProxy instanceof IPaletteAspectToolEntryProxy) {
IAspectAction action = (IAspectAction)selection.getFirstElement();
@@ -216,19 +224,29 @@ public class AspectActionsInformationComposite {
}
- public void widgetDefaultSelected(SelectionEvent e) {
- //Nothing
+ /**
+ * @{inheritDoc
+ */
+ public void mouseDown(MouseEvent e) {
+
+ }
+
+ /**
+ * @{inheritDoc
+ */
+ public void mouseDoubleClick(MouseEvent e) {
+
}
});
moveDownActionButton = new Button(actionList, SWT.NONE);
moveDownActionButton.setImage(Activator.getPluginIconImage(Activator.ID, ICONS_DOWN));
- moveDownActionButton.addSelectionListener(new SelectionListener() {
+ moveDownActionButton.addMouseListener(new MouseListener() {
/**
* @{inheritDoc
*/
- public void widgetSelected(SelectionEvent e) {
+ public void mouseUp(MouseEvent e) {
IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
if(selection != null && selection.size() > 0 && selectedEntryProxy instanceof IPaletteAspectToolEntryProxy) {
IAspectAction action = (IAspectAction)selection.getFirstElement();
@@ -254,8 +272,18 @@ public class AspectActionsInformationComposite {
}
- public void widgetDefaultSelected(SelectionEvent e) {
- //Nothing
+ /**
+ * @{inheritDoc
+ */
+ public void mouseDown(MouseEvent e) {
+
+ }
+
+ /**
+ * @{inheritDoc
+ */
+ public void mouseDoubleClick(MouseEvent e) {
+
}
});
@@ -304,7 +332,6 @@ public class AspectActionsInformationComposite {
public void widgetSelected(SelectionEvent e) {
IAspectActionProvider factory = (IAspectActionProvider)((MenuItem)e.getSource()).getData();
IAspectAction action = factory.createAction(null);
- action.setServicesRegistry(registry);
if(selectedEntryProxy instanceof IPaletteAspectToolEntryProxy) {
if(action instanceof IPostAction) {
((IPaletteAspectToolEntryProxy)selectedEntryProxy).getPostActions().add((IPostAction)action);
@@ -319,7 +346,7 @@ public class AspectActionsInformationComposite {
* @{inheritDoc
*/
public void widgetDefaultSelected(SelectionEvent e) {
- //Nothing
+
}
});
}
@@ -450,14 +477,14 @@ public class AspectActionsInformationComposite {
* @{inheritDoc
*/
public void dispose() {
- //Nothing
+
}
/**
* @{inheritDoc
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- //Nothing
+
}
}
@@ -465,12 +492,11 @@ public class AspectActionsInformationComposite {
/**
* Label provider for the aspect actions viewer
*/
- protected class AspectActionLabelProvider extends LabelProvider {
+ protected class AspectActionLabelProvider implements ILabelProvider {
/**
* @{inheritDoc
*/
- @Override
public Image getImage(Object element) {
if(element instanceof IAspectAction) {
return ((IAspectAction)element).getImage();
@@ -481,7 +507,6 @@ public class AspectActionsInformationComposite {
/**
* @{inheritDoc
*/
- @Override
public String getText(Object element) {
if(element instanceof IAspectAction) {
return ((IAspectAction)element).getLabel();
@@ -489,6 +514,34 @@ public class AspectActionsInformationComposite {
return "notAnAction";
}
+ /**
+ * @{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/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/ExtendedPaletteContentPage.java b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/ExtendedPaletteContentPage.java
index 33d4aceac81..6043daf451d 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/ExtendedPaletteContentPage.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/ExtendedPaletteContentPage.java
@@ -64,7 +64,6 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.uml.diagram.common.Activator;
import org.eclipse.papyrus.uml.diagram.common.Messages;
import org.eclipse.papyrus.uml.diagram.common.part.PaletteUtil;
@@ -225,7 +224,7 @@ public class ExtendedPaletteContentPage extends WizardPage implements Listener {
protected ConfigurationInformationComposite informationComposite = new ConfigurationInformationComposite();
/** class in charge of the aspect tool information composite */
- protected AspectActionsInformationComposite aspectActionComposite;
+ protected AspectActionsInformationComposite aspectActionComposite = new AspectActionsInformationComposite();
/** toolbar above tools */
protected ToolBar toolbar;
@@ -256,8 +255,6 @@ public class ExtendedPaletteContentPage extends WizardPage implements Listener {
super(Messages.Local_Palette_ContentPage_Name, Messages.Local_Palette_ContentPage_Title, Activator.getImageDescriptor(WIZARD_ICON));
this.editorPart = part;
this.customizer = customizer;
-
- aspectActionComposite = new AspectActionsInformationComposite((ServicesRegistry)editorPart.getAdapter(ServicesRegistry.class));
}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/LocalPaletteContentPage.java b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/LocalPaletteContentPage.java
index 4b319620d35..8e02014cde3 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/LocalPaletteContentPage.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/LocalPaletteContentPage.java
@@ -72,7 +72,6 @@ import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.papyrus.customization.palette.proxies.XMLDefinitionPaletteProxyFactory;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.uml.diagram.common.Activator;
import org.eclipse.papyrus.uml.diagram.common.Messages;
import org.eclipse.papyrus.uml.diagram.common.part.PaletteUtil;
@@ -229,7 +228,7 @@ public class LocalPaletteContentPage extends WizardPage implements Listener {
protected PaletteEntryProxyInformationComposite informationComposite = new PaletteEntryProxyInformationComposite();
/** class in charge of the aspect tool information composite */
- protected AspectActionsInformationComposite aspectActionComposite;
+ protected AspectActionsInformationComposite aspectActionComposite = new AspectActionsInformationComposite();
protected ToolBar toolbar;
@@ -250,8 +249,6 @@ public class LocalPaletteContentPage extends WizardPage implements Listener {
super(Messages.Local_Palette_ContentPage_Name, Messages.Local_Palette_ContentPage_Title, Activator.getImageDescriptor(WIZARD_ICON));
this.editorPart = part;
this.customizer = customizer;
-
- this.aspectActionComposite = new AspectActionsInformationComposite((ServicesRegistry)editorPart.getAdapter(ServicesRegistry.class));
}
/**
diff --git a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/LocalPaletteInformationPage.java b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/LocalPaletteInformationPage.java
index 06435d62f41..03bae76048d 100644
--- a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/LocalPaletteInformationPage.java
+++ b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/LocalPaletteInformationPage.java
@@ -172,7 +172,7 @@ public class LocalPaletteInformationPage extends WizardPage implements Listener
}
initEditorID(editorIDValue);
initPaletteID(descriptor.getContributionID());
- initPriority(PapyrusPalettePreferences.getPalettePriority(descriptor.getContributionID()));
+ initPriority(PapyrusPalettePreferences.getLocalPalettePriority(descriptor.getContributionID()));
validateOnLaunch = true;
}
diff --git a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/handler/DeployPaletteConfigurationHandler.java b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/handler/DeployPaletteConfigurationHandler.java
new file mode 100644
index 00000000000..7b5d16d25c9
--- /dev/null
+++ b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/handler/DeployPaletteConfigurationHandler.java
@@ -0,0 +1,308 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Remi Schnekenburger (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.customization.palette.handler;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+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.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.gmf.runtime.common.core.service.ProviderPriority;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.TrayDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.uml.diagram.common.Activator;
+import org.eclipse.papyrus.uml.diagram.common.part.PaletteUtil;
+import org.eclipse.papyrus.uml.diagram.common.part.PapyrusPalettePreferences;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+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.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.statushandlers.StatusManager;
+
+
+/**
+ * Handler to deploy new configuration
+ */
+public class DeployPaletteConfigurationHandler extends AbstractHandler implements IHandler {
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
+ if(!(currentSelection instanceof IStructuredSelection) || currentSelection.isEmpty()) {
+ return null;
+ }
+
+ final IStructuredSelection selection = (IStructuredSelection)currentSelection;
+
+ final Shell activeShell = HandlerUtil.getActiveShell(event);
+
+
+ doExecute(selection, activeShell, new NullProgressMonitor());
+ return null;
+
+ }
+
+ protected void doExecute(IStructuredSelection selection, Shell activeShell, IProgressMonitor monitor) {
+
+ Iterator<?> selectionIterator = selection.iterator();
+
+ MultiStatus result = new MultiStatus(Activator.ID, IStatus.OK, "The palette configuration has been successfully deployed and activated", null);
+
+ while(selectionIterator.hasNext()) {
+ Object selectedElement = selectionIterator.next();
+ if(selectedElement instanceof IAdaptable) {
+ IFile selectedFile = (IFile)((IAdaptable)selectedElement).getAdapter(IFile.class);
+ if(selectedFile == null) {
+ monitor.worked(1);
+ result.add(new Status(IStatus.ERROR, Activator.ID, "The selected element is not a file"));
+ continue;
+ }
+
+
+ String fileName = selectedFile.getFullPath().removeFileExtension().lastSegment();
+ monitor.subTask("Deploy " + fileName);
+
+ // retrieve info => open a dialog, filled by current opened editor ?
+ ProviderPriority priority = PapyrusPalettePreferences.getWorkspacePalettePriority(fileName);
+ String editorID = PapyrusPalettePreferences.getWorkspaceEditorID(fileName);
+ String paletteName = PapyrusPalettePreferences.getWorkspacePaletteName(fileName);
+ Set<String> requiredProfiles = PapyrusPalettePreferences.getRequiredProfiles(fileName);
+ String path = selectedFile.getFullPath().toString();
+
+
+ UpdateContentDialog dialog = new UpdateContentDialog(activeShell, fileName, paletteName, priority, editorID, requiredProfiles);
+ int returnCode = dialog.open();
+ if(Dialog.OK==returnCode) {
+ boolean validUpdate = true;
+ boolean alreadyDeployed = false;
+
+ // update values from the editor
+ if(dialog.paletteName !=null && dialog.paletteName.length()>0) {
+ paletteName = dialog.paletteName;
+ alreadyDeployed = true;
+ } else {
+ validUpdate = false;
+ }
+
+ if(dialog.priority !=null ) {
+ priority = dialog.priority;
+ alreadyDeployed = true;
+ }else {
+ validUpdate = false;
+ }
+
+ if(dialog.editorID !=null && dialog.editorID.length()>0) {
+ editorID = dialog.editorID;
+ alreadyDeployed = true;
+ }else {
+ validUpdate = false;
+ }
+
+ if(dialog.requiredProfiles !=null && dialog.requiredProfiles.length()>0) {
+ requiredProfiles = PaletteUtil.getProfileSetFromString(dialog.requiredProfiles);
+ }else {
+ validUpdate = false;
+ }
+
+ if(validUpdate) {
+ if(alreadyDeployed) {
+ // update values and set visible again
+ PapyrusPalettePreferences.addWorkspacePalette(fileName, paletteName, path, priority, editorID, requiredProfiles);
+ PapyrusPalettePreferences.changePaletteVisibility(fileName, editorID, true);
+ result.add(new Status(IStatus.OK, Activator.ID, "The palette configuration was already deployed, it has just been activated"));
+ } else {
+ // just add the palette
+ PapyrusPalettePreferences.addWorkspacePalette(fileName, paletteName, path, priority, editorID, requiredProfiles);
+ result.add(new Status(IStatus.OK, Activator.ID, "The palette configuration has been successfully deployed and activated"));
+ }
+ } else {
+ result.add(new Status(IStatus.ERROR, Activator.ID, "The palette configuration was not deployed, because dialog content was not valid"));
+ }
+ } else {
+ result.add(new Status(IStatus.ERROR, Activator.ID, "The palette configuration was not deployed, because user did cancel the dialog"));
+ }
+
+ }
+ }
+
+ if(result.getChildren().length == 1) {
+ if(result.isOK()) {
+ MessageDialog.openInformation(activeShell, "Success", result.getMessage());
+ } else if(result.getSeverity() < IStatus.ERROR) { //Errors are already logged
+ StatusManager.getManager().handle(result, StatusManager.SHOW);
+ }
+ } else { //Merge the result and specify an appropriate message based on the result
+ if(result.isOK()) {
+ MessageDialog.openInformation(activeShell, "Success", result.getMessage());
+ } else {
+ MultiStatus actualResult = new MultiStatus(Activator.ID, result.getCode(), "Some errors occurred during the deployment", result.getException());
+ actualResult.merge(result);
+ }
+ }
+ }
+
+
+ public static class UpdateContentDialog extends TrayDialog {
+ public String paletteName;
+ public ProviderPriority priority;
+ public String editorID;
+ public String requiredProfiles ;
+ public String fileName;
+ private Text nameText;
+ private Text editorText;
+ private Text profilesText;
+ private CCombo priorityCombo;
+
+
+ /**
+ * @param shell
+ * @param priority
+ * @param editorID
+ * @param requiredProfiles
+ */
+ protected UpdateContentDialog(Shell shell, String fileName, String paletteName, ProviderPriority priority, String editorID, Set<String> requiredProfiles) {
+ super(shell);
+ this.fileName = fileName;
+ this.paletteName = paletteName;
+ this.priority = priority;
+ this.editorID = editorID;
+ if(requiredProfiles !=null) {
+ this.requiredProfiles = PaletteUtil.getSerializedProfileList(requiredProfiles);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ if(newShell!=null) {
+ newShell.setText("Configure Deployment of the palette");
+ newShell.setSize(600, 400);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite superComposite = (Composite) super.createDialogArea(parent);
+ Composite composite = new Composite(superComposite, SWT.NONE);
+ composite.setLayout(new GridLayout(2, false));
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+
+ // new grid data will all necessary info
+ Label nameLabel = new Label(composite, SWT.NONE);
+ nameLabel.setText("Name:");
+ nameText = new Text(composite, SWT.BORDER);
+ if(paletteName == null) {
+ paletteName = fileName;
+ }
+ nameText.setText(paletteName);
+ nameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
+
+ Label priorityLabel = new Label(composite, SWT.NONE);
+ priorityLabel.setText("Priority:");
+ priorityCombo = new CCombo(composite, SWT.BORDER);
+ priorityCombo.setEditable(false);
+ priorityCombo.setItems(new String[] {ProviderPriority.LOWEST.getName(), ProviderPriority.LOW.getName(), ProviderPriority.MEDIUM.getName(), ProviderPriority.HIGH.getName(), ProviderPriority.HIGHEST.getName()});
+ if(ProviderPriority.LOWEST.equals(priority)) {
+ priorityCombo.select(0);
+ } else if(ProviderPriority.LOW.equals(priority)) {
+ priorityCombo.select(1);
+ } else if(ProviderPriority.MEDIUM.equals(priority)) {
+ priorityCombo.select(2);
+ } else if(ProviderPriority.HIGH.equals(priority)) {
+ priorityCombo.select(3);
+ } else if(ProviderPriority.HIGHEST.equals(priority)) {
+ priorityCombo.select(4);
+ } else {
+ priorityCombo.select(2); // default = medium
+ }
+ priorityCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
+
+ Label editorLabel = new Label(composite, SWT.NONE);
+ editorLabel.setText("Editor:");
+ editorText = new Text(composite, SWT.BORDER);
+ if(editorID == null) {
+ // TODO: try to see if a Papyrus editor is currently opened?
+ editorID = "";
+ }
+ editorText.setText(editorID);
+ editorText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
+
+ // list of profiles
+ Label profilesLabel = new Label(composite, SWT.NONE);
+ profilesLabel.setText("Profiles:");
+ profilesText = new Text(composite, SWT.BORDER);
+ if(requiredProfiles != null) {
+ profilesText.setText(requiredProfiles);
+ }
+ profilesText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
+
+ return superComposite;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void okPressed() {
+ // updates values
+ if(nameText!=null && ! nameText.isDisposed()) {
+ paletteName = nameText.getText();
+ }
+
+ if(editorText!=null && ! editorText.isDisposed()) {
+ editorID = editorText.getText();
+ }
+
+ if(priorityCombo!=null && ! priorityCombo.isDisposed()) {
+ priority = ProviderPriority.parse(priorityCombo.getText());
+ }
+
+ if(profilesText!=null && ! profilesText.isDisposed()) {
+ requiredProfiles = profilesText.getText();
+ }
+
+ super.okPressed();
+ }
+
+ }
+} \ No newline at end of file
diff --git a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/handler/UndeployPaletteConfigurationHandler.java b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/handler/UndeployPaletteConfigurationHandler.java
new file mode 100644
index 00000000000..ca09effadc7
--- /dev/null
+++ b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/handler/UndeployPaletteConfigurationHandler.java
@@ -0,0 +1,112 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Remi Schnekenburger (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.customization.palette.handler;
+
+import java.util.Iterator;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+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.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.uml.diagram.common.Activator;
+import org.eclipse.papyrus.uml.diagram.common.part.PapyrusPalettePreferences;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.statushandlers.StatusManager;
+
+
+/**
+ * @author RS211865
+ */
+public class UndeployPaletteConfigurationHandler extends AbstractHandler {
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
+ if(!(currentSelection instanceof IStructuredSelection) || currentSelection.isEmpty()) {
+ return null;
+ }
+
+ final IStructuredSelection selection = (IStructuredSelection)currentSelection;
+
+ final Shell activeShell = HandlerUtil.getActiveShell(event);
+
+
+ doExecute(selection,activeShell, new NullProgressMonitor());
+ return null;
+ }
+
+ protected void doExecute(IStructuredSelection selection, Shell activeShell, IProgressMonitor monitor) {
+ Iterator<?> selectionIterator = selection.iterator();
+
+ MultiStatus result = new MultiStatus(Activator.ID, IStatus.OK, "The palette configuration has been successfully deactivated and undeployed", null);
+
+ while(selectionIterator.hasNext()) {
+ Object selectedElement = selectionIterator.next();
+ if(selectedElement instanceof IAdaptable) {
+ IFile selectedFile = (IFile)((IAdaptable)selectedElement).getAdapter(IFile.class);
+ if(selectedFile == null) {
+ monitor.worked(1);
+ result.add(new Status(IStatus.ERROR, Activator.ID, "The selected element is not a file"));
+ continue;
+ }
+
+
+ String fileName = selectedFile.getFullPath().removeFileExtension().lastSegment();
+ monitor.subTask("Undeploy " + fileName);
+
+ // do not delete.
+ // PapyrusPalettePreferences.deleteWorkspacePalette(fileName);
+
+ // if not deploy, do nothing and onlyh warn
+ String editorId = PapyrusPalettePreferences.getWorkspaceEditorID(fileName);
+ if(editorId == null) {
+ // not deployed: cancel the undeploy action
+ MessageDialog.openInformation(activeShell, "Not deployed", "This palette is currently not deployed");
+ result.add(new Status(IStatus.ERROR, Activator.ID, "The palette configuration "+fileName+" was not undeployed already"));
+ } else {
+ // change visibility instead =>
+ PapyrusPalettePreferences.changePaletteVisibility(fileName, editorId, false);
+ result.add(new Status(IStatus.OK, Activator.ID, "The palette configuration "+fileName+" has been successfully deactivated and undeployed"));
+ }
+
+ }
+ }
+
+ if(result.getChildren().length == 1) {
+ if(result.isOK()) {
+ MessageDialog.openInformation(activeShell, "Success", result.getMessage());
+ } else if(result.getSeverity() < IStatus.ERROR) { //Errors are already logged
+ StatusManager.getManager().handle(result, StatusManager.SHOW);
+ }
+ } else { //Merge the result and specify an appropriate message based on the result
+ if(result.isOK()) {
+ MessageDialog.openInformation(activeShell, "Success", result.getMessage());
+ } else {
+ MultiStatus actualResult = new MultiStatus(Activator.ID, result.getCode(), "Some errors occurred during the deployment", result.getException());
+ actualResult.merge(result);
+ }
+ }
+ }
+}

Back to the top