Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ElementImportAliasEditPart.java')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ElementImportAliasEditPart.java128
1 files changed, 72 insertions, 56 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ElementImportAliasEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ElementImportAliasEditPart.java
index f7a3f5fdfab..a2a283a7110 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ElementImportAliasEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ElementImportAliasEditPart.java
@@ -1,16 +1,16 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- *
+/*
+ * Copyright (c) 2014 CEA LIST.
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
+ *
+ *
+ */
package org.eclipse.papyrus.uml.diagram.profile.edit.parts;
import java.util.Collections;
@@ -53,6 +53,7 @@ import org.eclipse.jface.viewers.ICellEditorValidator;
import org.eclipse.jface.window.Window;
import org.eclipse.papyrus.extensionpoints.editors.Activator;
import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration;
+import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration;
import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration;
import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration;
import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog;
@@ -63,7 +64,6 @@ import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds;
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy;
import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager;
-import org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition;
import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure;
import org.eclipse.papyrus.uml.diagram.profile.edit.policies.UMLTextSelectionEditPolicy;
@@ -72,16 +72,18 @@ import org.eclipse.papyrus.uml.diagram.profile.providers.UMLElementTypes;
import org.eclipse.papyrus.uml.diagram.profile.providers.UMLParserProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.uml2.uml.Feature;
/**
* @generated
*/
-public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, ILabelRoleProvider {
+public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart {
/**
* @generated
@@ -110,17 +112,17 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
/**
* direct edition mode (default, undefined, registered editor, etc.)
- *
* @generated
*/
protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR;
/**
* configuration from a registered edit dialog
- *
* @generated
*/
protected IDirectEditorConfiguration configuration;
+
+
/**
* @generated
*/
@@ -152,6 +154,7 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
return ConnectionLocator.MIDDLE;
}
+
/**
* @generated
*/
@@ -207,7 +210,7 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
/**
* @generated
*/
- public void setLabel(WrappingLabel figure) {
+ public void setLabel(IFigure figure) {
unregisterVisuals();
setFigure(figure);
defaultText = getLabelTextHelper(figure);
@@ -218,7 +221,7 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
/**
* @generated
*/
- protected List getModelChildren() {
+ protected List<?> getModelChildren() {
return Collections.EMPTY_LIST;
}
@@ -232,6 +235,13 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
/**
* @generated
*/
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @generated
+ */
protected EObject getParserElement() {
return resolveSemanticElement();
}
@@ -301,7 +311,7 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
final EObject element = getParserElement();
final IParser parser = getParser();
try {
- IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl() {
+ IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() {
public void run() {
setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value));
@@ -312,6 +322,7 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
ie.printStackTrace();
}
}
+
// shouldn't get here
return null;
}
@@ -366,7 +377,12 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
* @generated
*/
protected void performDirectEdit() {
- getManager().show();
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
}
/**
@@ -393,7 +409,9 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
* @generated
*/
protected void performDirectEditRequest(Request request) {
+
final Request theRequest = request;
+
if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
directEditionMode = getDirectEditionType();
}
@@ -404,11 +422,17 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
case IDirectEdition.EXTENDED_DIRECT_EDITOR:
updateExtendedEditorConfiguration();
if(configuration == null || configuration.getLanguage() == null) {
+ // Create default edit manager
+ setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this)));
performDefaultDirectEditorEdit(theRequest);
} else {
configuration.preEditAction(resolveSemanticElement());
Dialog dialog = null;
- if(configuration instanceof IPopupEditorConfiguration) {
+ if(configuration instanceof ICustomDirectEditorConfiguration) {
+ setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this));
+ initializeDirectEditManager(theRequest);
+ return;
+ } else if(configuration instanceof IPopupEditorConfiguration) {
IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this);
helper.showEditor();
return;
@@ -420,6 +444,7 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
return;
}
final Dialog finalDialog = dialog;
+
if(Window.OK == dialog.open()) {
TransactionalEditingDomain domain = getEditingDomain();
RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
@@ -427,6 +452,7 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
@Override
protected void doExecute() {
configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue());
+
}
};
domain.getCommandStack().execute(command);
@@ -434,27 +460,7 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
}
break;
case IDirectEdition.DEFAULT_DIRECT_EDITOR:
- // initialize the direct edit manager
- try {
- getEditingDomain().runExclusive(new Runnable() {
-
- public void run() {
- if(isActive() && isEditable()) {
- if(theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
- Character initialChar = (Character)theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) {
- DirectEditRequest editRequest = (DirectEditRequest)theRequest;
- performDirectEdit(editRequest.getLocation());
- } else {
- performDirectEdit();
- }
- }
- }
- });
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
+ initializeDirectEditManager(theRequest);
break;
default:
break;
@@ -464,6 +470,30 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
/**
* @generated
*/
+ protected void initializeDirectEditManager(final Request request) {
+ // initialize the direct edit manager
+ try {
+ getEditingDomain().runExclusive(new Runnable() {
+
+ public void run() {
+ if(isActive() && isEditable()) {
+ if(request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) {
+ Character initialChar = (Character)request.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
+ performDirectEdit(initialChar.charValue());
+ } else {
+ performDirectEdit();
+ }
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * @generated
+ */
protected void refreshVisuals() {
super.refreshVisuals();
refreshLabel();
@@ -601,6 +631,7 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
if(checkDefaultEdition()) {
return IDirectEdition.DEFAULT_DIRECT_EDITOR;
}
+
// not a named element. no specific editor => do nothing
return IDirectEdition.NO_DIRECT_EDITION;
}
@@ -630,7 +661,6 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
/**
* Initializes the extended editor configuration
- *
* @generated
*/
protected void initExtendedEditorConfiguration() {
@@ -646,12 +676,11 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
/**
* Updates the preference configuration
- *
* @generated
*/
protected void updateExtendedEditorConfiguration() {
String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName());
- if(languagePreferred != null && !languagePreferred.equals("") && languagePreferred != configuration.getLanguage()) {
+ if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) {
configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement().eClass().getInstanceClassName());
} else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) {
configuration = null;
@@ -660,9 +689,7 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
/**
* Performs the direct edit usually used by GMF editors.
- *
- * @param theRequest
- * the direct edit request that starts the direct edit system
+ * @param theRequest the direct edit request that starts the direct edit system
* @generated
*/
protected void performDefaultDirectEditorEdit(final Request theRequest) {
@@ -689,6 +716,7 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
}
}
+
/**
* @generated
*/
@@ -718,6 +746,7 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
}
}
}
+
super.handleNotificationEvent(event);
}
@@ -729,17 +758,4 @@ public class ElementImportAliasEditPart extends PapyrusLabelEditPart implements
return null;
}
- /**
- * @generated
- */
- public String getLabelRole() {
- return "Alias";//$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- public String getIconPathRole() {
- return "platform:/plugin/org.eclipse.papyrus.uml.diagram.common/icons/label_role/alias.png";//$NON-NLS-1$
- }
}

Back to the top