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/ConstraintNameEditPartCN.java')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintNameEditPartCN.java99
1 files changed, 48 insertions, 51 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintNameEditPartCN.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintNameEditPartCN.java
index 9d5786b00e7..5fe8b72a8ff 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintNameEditPartCN.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.profile/src/org/eclipse/papyrus/uml/diagram/profile/edit/parts/ConstraintNameEditPartCN.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;
@@ -72,9 +72,11 @@ 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;
@@ -110,18 +112,17 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
/**
* 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
*/
@@ -139,6 +140,7 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy());
}
+
/**
* @generated
*/
@@ -194,7 +196,7 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
/**
* @generated
*/
- public void setLabel(WrappingLabel figure) {
+ public void setLabel(IFigure figure) {
unregisterVisuals();
setFigure(figure);
defaultText = getLabelTextHelper(figure);
@@ -205,7 +207,7 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
/**
* @generated
*/
- protected List getModelChildren() {
+ protected List<?> getModelChildren() {
return Collections.EMPTY_LIST;
}
@@ -219,6 +221,13 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
/**
* @generated
*/
+ public void setParser(IParser parser) {
+ this.parser = parser;
+ }
+
+ /**
+ * @generated
+ */
protected EObject getParserElement() {
return resolveSemanticElement();
}
@@ -288,7 +297,7 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
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));
@@ -299,6 +308,7 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
ie.printStackTrace();
}
}
+
// shouldn't get here
return null;
}
@@ -353,7 +363,12 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
* @generated
*/
protected void performDirectEdit() {
- getManager().show();
+ BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() {
+
+ public void run() {
+ getManager().show();
+ }
+ });
}
/**
@@ -380,7 +395,9 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
* @generated
*/
protected void performDirectEditRequest(Request request) {
+
final Request theRequest = request;
+
if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) {
directEditionMode = getDirectEditionType();
}
@@ -391,6 +408,8 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
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());
@@ -411,6 +430,7 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
return;
}
final Dialog finalDialog = dialog;
+
if(Window.OK == dialog.open()) {
TransactionalEditingDomain domain = getEditingDomain();
RecordingCommand command = new RecordingCommand(domain, "Edit Label") {
@@ -418,6 +438,7 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
@Override
protected void doExecute() {
configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue());
+
}
};
domain.getCommandStack().execute(command);
@@ -425,27 +446,7 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
}
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;
@@ -455,13 +456,6 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
/**
* @generated
*/
- public void setParser(IParser parser) {
- this.parser = parser;
- }
-
- /**
- * @generated
- */
protected void initializeDirectEditManager(final Request request) {
// initialize the direct edit manager
try {
@@ -472,9 +466,6 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
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 if((request instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) {
- DirectEditRequest editRequest = (DirectEditRequest)request;
- performDirectEdit(editRequest.getLocation());
} else {
performDirectEdit();
}
@@ -485,7 +476,7 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
e.printStackTrace();
}
}
-
+
/**
* @generated
*/
@@ -626,6 +617,7 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
if(checkDefaultEdition()) {
return IDirectEdition.DEFAULT_DIRECT_EDITOR;
}
+
// not a named element. no specific editor => do nothing
return IDirectEdition.NO_DIRECT_EDITION;
}
@@ -655,7 +647,6 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
/**
* Initializes the extended editor configuration
- *
* @generated
*/
protected void initExtendedEditorConfiguration() {
@@ -671,12 +662,11 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
/**
* 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;
@@ -685,9 +675,7 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
/**
* 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) {
@@ -714,6 +702,7 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
}
}
+
/**
* @generated
*/
@@ -730,6 +719,7 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
removeListenerFilter("PrimaryView"); //$NON-NLS-1$
}
+
/**
* @generated
*/
@@ -771,11 +761,13 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
return null;
}
+
/**
* @generated
*/
private static final String ADD_PARENT_MODEL = "AddParentModel";
+
/**
* @generated
*/
@@ -789,6 +781,7 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
*/
protected void addOwnerElementListeners() {
addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); //$NON-NLS-1$
+
}
/**
@@ -797,12 +790,16 @@ public class ConstraintNameEditPartCN extends PapyrusCompartmentEditPart impleme
public void deactivate() {
removeOwnerElementListeners();
super.deactivate();
+
}
+
/**
* @generated
*/
protected void removeOwnerElementListeners() {
removeListenerFilter(ADD_PARENT_MODEL);
+
}
+
}

Back to the top