diff options
author | Ansgar Radermacher | 2016-03-30 11:50:48 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-03-31 15:02:28 +0000 |
commit | f4ac6679ed7650958fdb5ceb0adc5754e0b17aaa (patch) | |
tree | 685fddaa0a59757cabff67a83ad3225ac76f6737 /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine | |
parent | 4c9df31e913e0b244197a144cc5fdc09f3f009e4 (diff) | |
download | org.eclipse.papyrus-f4ac6679ed7650958fdb5ceb0adc5754e0b17aaa.tar.gz org.eclipse.papyrus-f4ac6679ed7650958fdb5ceb0adc5754e0b17aaa.tar.xz org.eclipse.papyrus-f4ac6679ed7650958fdb5ceb0adc5754e0b17aaa.zip |
Bug 481767 - [State Machine Diagram] - Pseudo state not placed correctly when added on the edge of a composite state
Change includes a diagram regeneration which implies changes to all existing files due
to different code formatters (existing code has been generated using a "wrong" formatter)
Only generated file with non-white-space changes is diagram/statemachine/edit/parts/StateMachineEditPart.java
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine')
99 files changed, 6427 insertions, 8693 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/custom/expressions/UMLAbstractExpression.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/custom/expressions/UMLAbstractExpression.java index c7188761295..65a225e6c01 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/custom/expressions/UMLAbstractExpression.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/custom/expressions/UMLAbstractExpression.java @@ -41,9 +41,8 @@ public abstract class UMLAbstractExpression { protected void setStatus(int severity, String message, Throwable throwable) { String pluginID = UMLDiagramEditorPlugin.ID; this.status = new Status(severity, pluginID, -1, (message != null) ? message : "", throwable); //$NON-NLS-1$ - if (!this.status.isOK()) { - UMLDiagramEditorPlugin.getInstance().logError("Expression problem:" + message + "body:" + body(), //$NON-NLS-1$//$NON-NLS-2$ - throwable); + if(!this.status.isOK()) { + UMLDiagramEditorPlugin.getInstance().logError("Expression problem:" + message + "body:" + body(), throwable); //$NON-NLS-1$ //$NON-NLS-2$ } } @@ -104,7 +103,7 @@ public abstract class UMLAbstractExpression { */ @SuppressWarnings("rawtypes") public Object evaluate(Object context, Map env) { - if (context().isInstance(context)) { + if(context().isInstance(context)) { try { return doEvaluate(context, env); } catch (Exception e) { @@ -121,48 +120,48 @@ public abstract class UMLAbstractExpression { * @generated */ public static Object performCast(Object value, EDataType targetType) { - if (targetType instanceof EEnum) { - if (value instanceof EEnumLiteral) { - EEnumLiteral literal = (EEnumLiteral) value; + if(targetType instanceof EEnum) { + if(value instanceof EEnumLiteral) { + EEnumLiteral literal = (EEnumLiteral)value; return (literal.getInstance() != null) ? literal.getInstance() : literal; } } - if (false == value instanceof Number || targetType == null || targetType.getInstanceClass() == null) { + if(false == value instanceof Number || targetType == null || targetType.getInstanceClass() == null) { return value; } Class<?> targetClass = targetType.getInstanceClass(); - Number num = (Number) value; + Number num = (Number)value; Class<?> valClass = value.getClass(); Class<?> targetWrapperClass = targetClass; - if (targetClass.isPrimitive()) { + if(targetClass.isPrimitive()) { targetWrapperClass = EcoreUtil.wrapperClassFor(targetClass); } - if (valClass.equals(targetWrapperClass)) { + if(valClass.equals(targetWrapperClass)) { return value; } - if (Number.class.isAssignableFrom(targetWrapperClass)) { - if (targetWrapperClass.equals(Byte.class)) { + if(Number.class.isAssignableFrom(targetWrapperClass)) { + if(targetWrapperClass.equals(Byte.class)) { return new Byte(num.byteValue()); } - if (targetWrapperClass.equals(Integer.class)) { + if(targetWrapperClass.equals(Integer.class)) { return new Integer(num.intValue()); } - if (targetWrapperClass.equals(Short.class)) { + if(targetWrapperClass.equals(Short.class)) { return new Short(num.shortValue()); } - if (targetWrapperClass.equals(Long.class)) { + if(targetWrapperClass.equals(Long.class)) { return new Long(num.longValue()); } - if (targetWrapperClass.equals(BigInteger.class)) { + if(targetWrapperClass.equals(BigInteger.class)) { return BigInteger.valueOf(num.longValue()); } - if (targetWrapperClass.equals(Float.class)) { + if(targetWrapperClass.equals(Float.class)) { return new Float(num.floatValue()); } - if (targetWrapperClass.equals(Double.class)) { + if(targetWrapperClass.equals(Double.class)) { return new Double(num.doubleValue()); } - if (targetWrapperClass.equals(BigDecimal.class)) { + if(targetWrapperClass.equals(BigDecimal.class)) { return new BigDecimal(num.doubleValue()); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/custom/expressions/UMLOCLFactory.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/custom/expressions/UMLOCLFactory.java index d0a58cf1533..31c07503e96 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/custom/expressions/UMLOCLFactory.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/custom/expressions/UMLOCLFactory.java @@ -48,11 +48,10 @@ public class UMLOCLFactory { */ protected UMLOCLFactory() { this.expressions = new UMLAbstractExpression[4]; - this.expressionBodies = new String[] { - "(kind = TransitionKind::internal) implies (source.oclIsKindOf (State) and source = target)", //$NON-NLS-1$ - "if self.owner.oclIsKindOf(State)\r\nthen self.owner.oclAsType(State).exit->includes(self)\r\nelse false endif", //$NON-NLS-1$ - "if self.owner.oclIsKindOf(State)\r\nthen self.owner.oclAsType(State).entry->includes(self)\r\nelse false endif", //$NON-NLS-1$ - "if self.owner.oclIsKindOf(State)\r\nthen self.owner.oclAsType(State).doActivity->includes(self)\r\nelse false endif", //$NON-NLS-1$ + this.expressionBodies = new String[]{ "(kind = TransitionKind::internal) implies (source.oclIsKindOf (State) and source = target)", //$NON-NLS-1$ + "if self.owner.oclIsKindOf(State)\r\nthen self.owner.oclAsType(State).exit->includes(self)\r\nelse false endif", //$NON-NLS-1$ + "if self.owner.oclIsKindOf(State)\r\nthen self.owner.oclAsType(State).entry->includes(self)\r\nelse false endif", //$NON-NLS-1$ + "if self.owner.oclIsKindOf(State)\r\nthen self.owner.oclAsType(State).doActivity->includes(self)\r\nelse false endif", //$NON-NLS-1$ }; } @@ -61,7 +60,7 @@ public class UMLOCLFactory { */ private static UMLOCLFactory getInstance() { UMLOCLFactory instance = UMLDiagramEditorPlugin.getInstance().getUMLOCLFactory(); - if (instance == null) { + if(instance == null) { UMLDiagramEditorPlugin.getInstance().setUMLOCLFactory(instance = new UMLOCLFactory()); } return instance; @@ -77,15 +76,13 @@ public class UMLOCLFactory { /** * @generated */ - public static UMLAbstractExpression getExpression(int index, EClassifier context, - Map<String, EClassifier> environment) { + public static UMLAbstractExpression getExpression(int index, EClassifier context, Map<String, EClassifier> environment) { UMLOCLFactory cached = getInstance(); - if (index < 0 || index >= cached.expressions.length) { + if(index < 0 || index >= cached.expressions.length) { throw new IllegalArgumentException(); } - if (cached.expressions[index] == null) { - cached.expressions[index] = getExpression(cached.expressionBodies[index], context, - environment == null ? Collections.<String, EClassifier>emptyMap() : environment); + if(cached.expressions[index] == null) { + cached.expressions[index] = getExpression(cached.expressionBodies[index], context, environment == null ? Collections.<String, EClassifier> emptyMap() : environment); } return cached.expressions[index]; } @@ -95,8 +92,7 @@ public class UMLOCLFactory { * * @generated */ - public static UMLAbstractExpression getExpression(String body, EClassifier context, - Map<String, EClassifier> environment) { + public static UMLAbstractExpression getExpression(String body, EClassifier context, Map<String, EClassifier> environment) { return new Expression(body, context, environment); } @@ -106,7 +102,7 @@ public class UMLOCLFactory { * @generated */ public static UMLAbstractExpression getExpression(String body, EClassifier context) { - return getExpression(body, context, Collections.<String, EClassifier>emptyMap()); + return getExpression(body, context, Collections.<String, EClassifier> emptyMap()); } /** @@ -147,14 +143,14 @@ public class UMLOCLFactory { @Override @SuppressWarnings("rawtypes") protected Object doEvaluate(Object context, Map env) { - if (oclExpression == null) { + if(oclExpression == null) { return null; } // on the first call, both evalEnvironment and extentMap are clear, for later we have finally, below. EvaluationEnvironment<?, ?, ?, ?, ?> evalEnv = oclInstance.getEvaluationEnvironment(); // initialize environment - for (Object nextKey : env.keySet()) { - evalEnv.replace((String) nextKey, env.get(nextKey)); + for(Object nextKey : env.keySet()) { + evalEnv.replace((String)nextKey, env.get(nextKey)); } try { Object result = oclInstance.evaluate(context, oclExpression); @@ -168,12 +164,10 @@ public class UMLOCLFactory { /** * @generated */ - private static void initCustomEnv(Environment<?, EClassifier, ?, ?, ?, EParameter, ?, ?, ?, ?, ?, ?> ecoreEnv, - Map<String, EClassifier> environment) { + private static void initCustomEnv(Environment<?, EClassifier, ?, ?, ?, EParameter, ?, ?, ?, ?, ?, ?> ecoreEnv, Map<String, EClassifier> environment) { // Use EObject as implicit root class for any object, to allow eContainer() and other EObject operations from OCL expressions - ParsingOptions.setOption(ecoreEnv, ParsingOptions.implicitRootClass(ecoreEnv), - EcorePackage.eINSTANCE.getEObject()); - for (String varName : environment.keySet()) { + ParsingOptions.setOption(ecoreEnv, ParsingOptions.implicitRootClass(ecoreEnv), EcorePackage.eINSTANCE.getEObject()); + for(String varName : environment.keySet()) { EClassifier varType = environment.get(varName); ecoreEnv.addElement(varName, createVar(ecoreEnv, varName, varType), false); } @@ -182,8 +176,7 @@ public class UMLOCLFactory { /** * @generated */ - private static Variable createVar(Environment<?, EClassifier, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?> ecoreEnv, - String name, EClassifier type) { + private static Variable createVar(Environment<?, EClassifier, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?> ecoreEnv, String name, EClassifier type) { Variable var = EcoreFactory.eINSTANCE.createVariable(); var.setName(name); var.setType(ecoreEnv.getUMLReflection().getOCLType(type)); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/CommentAnnotatedElementEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/CommentAnnotatedElementEditPart.java index 4c317ffdf89..d051fb7e377 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/CommentAnnotatedElementEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/CommentAnnotatedElementEditPart.java @@ -63,6 +63,6 @@ public class CommentAnnotatedElementEditPart extends UMLConnectionNodeEditPart i */ @Override public SimpleDashedEdgeFigure getPrimaryShape() { - return (SimpleDashedEdgeFigure) getFigure(); + return (SimpleDashedEdgeFigure)getFigure(); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/CommentBodyEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/CommentBodyEditPart.java index 2d8ac17a1fb..bdc6d0228b6 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/CommentBodyEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/CommentBodyEditPart.java @@ -82,8 +82,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class CommentBodyEditPart extends PapyrusCompartmentEditPart - implements ITextAwareEditPart, IControlParserForDirectEdit { +public class CommentBodyEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated @@ -146,12 +145,12 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -159,12 +158,12 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -172,12 +171,12 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -185,12 +184,12 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -249,11 +248,10 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -266,12 +264,12 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -280,11 +278,10 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -303,25 +300,22 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(ParserUtil.getParserAdapter( - getParserElement(), CommentBodyEditPart.this), (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), CommentBodyEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -333,7 +327,7 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -352,7 +346,7 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart */ @Override public IParser getParser() { - if (parser == null) { + if(parser == null) { parser = ParserUtil.getParser(UMLElementTypes.Comment_Shape, getParserElement(), this, VISUAL_ID); } return parser; @@ -362,10 +356,8 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -394,8 +386,8 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -403,8 +395,8 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -415,58 +407,46 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -488,13 +468,12 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -525,12 +504,12 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { - View view = (View) getModel(); - if (view.isVisible()) { + if(maskLabelPolicy == null) { + View view = (View)getModel(); + if(view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -539,12 +518,12 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -552,15 +531,15 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -569,9 +548,9 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -580,10 +559,9 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -601,11 +579,11 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -617,8 +595,8 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -631,7 +609,7 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -657,14 +635,13 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -676,7 +653,7 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -698,15 +675,12 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -717,13 +691,10 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -742,15 +713,12 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -788,27 +756,24 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -845,8 +810,7 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); - + addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); } /** @@ -856,7 +820,6 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart public void deactivate() { removeOwnerElementListeners(); super.deactivate(); - } /** @@ -864,6 +827,5 @@ public class CommentBodyEditPart extends PapyrusCompartmentEditPart */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); - } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/CommentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/CommentEditPart.java index 0baf6adee6f..7fd67d55590 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/CommentEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/CommentEditPart.java @@ -72,12 +72,9 @@ public class CommentEditPart extends NodeEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy(EditPolicyRoles.OPEN_ROLE, new OpenDiagramEditPolicy()); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new PapyrusReflowableShapeEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies @@ -93,7 +90,7 @@ public class CommentEditPart extends NodeEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { + if(result == null) { result = new NonResizableEditPolicy(); } return result; @@ -127,18 +124,17 @@ public class CommentEditPart extends NodeEditPart { */ @Override public HTMLCornerBentFigure getPrimaryShape() { - return (HTMLCornerBentFigure) primaryShape; + return (HTMLCornerBentFigure)primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if (childEditPart instanceof CommentBodyEditPart) { - ((CommentBodyEditPart) childEditPart).setLabel(getPrimaryShape().getCornerBentFigure()); + if(childEditPart instanceof CommentBodyEditPart) { + ((CommentBodyEditPart)childEditPart).setLabel(getPrimaryShape().getCornerBentFigure()); return true; } - return false; } @@ -146,7 +142,7 @@ public class CommentEditPart extends NodeEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if (childEditPart instanceof CommentBodyEditPart) { + if(childEditPart instanceof CommentBodyEditPart) { return true; } return false; @@ -157,7 +153,7 @@ public class CommentEditPart extends NodeEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if (addFixedChild(childEditPart)) { + if(addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -168,7 +164,7 @@ public class CommentEditPart extends NodeEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if (removeFixedChild(childEditPart)) { + if(removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -202,7 +198,6 @@ public class CommentEditPart extends NodeEditPart { @Override protected NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); - } /** @@ -215,7 +210,7 @@ public class CommentEditPart extends NodeEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if (nodeShape.getLayoutManager() == null) { + if(nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -228,7 +223,7 @@ public class CommentEditPart extends NodeEditPart { */ @Override public IFigure getContentPane() { - if (contentPane != null) { + if(contentPane != null) { return contentPane; } return super.getContentPane(); @@ -239,7 +234,7 @@ public class CommentEditPart extends NodeEditPart { */ @Override protected void setForegroundColor(Color color) { - if (primaryShape != null) { + if(primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -257,8 +252,8 @@ public class CommentEditPart extends NodeEditPart { */ @Override protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); + if(primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConnectionPointReferenceEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConnectionPointReferenceEditPart.java index 9b01f4aade5..de50accfcb2 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConnectionPointReferenceEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConnectionPointReferenceEditPart.java @@ -86,13 +86,10 @@ public class ConnectionPointReferenceEditPart extends AbstractBorderEditPart { super.createDefaultEditPolicies(); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, getPrimaryDragEditPolicy()); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); } @@ -105,17 +102,17 @@ public class ConnectionPointReferenceEditPart extends AbstractBorderEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); + View childView = (View)child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if (vid != null) { - switch (vid) { + if(vid != null) { + switch(vid) { case ConnectionPointReferenceNameEditPart.VISUAL_ID: case ConnectionPointReferenceStereotypeEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -123,7 +120,7 @@ public class ConnectionPointReferenceEditPart extends AbstractBorderEditPart { } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { + if(result == null) { result = new NonResizableEditPolicy(); } return result; @@ -153,17 +150,16 @@ public class ConnectionPointReferenceEditPart extends AbstractBorderEditPart { * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View) getModel()).getChildren(); - if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if (modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View)getModel()).getChildren(); + if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if(modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); - } /** @@ -180,7 +176,7 @@ public class ConnectionPointReferenceEditPart extends AbstractBorderEditPart { */ @Override public ConnectionPointReferenceFigure getPrimaryShape() { - return (ConnectionPointReferenceFigure) primaryShape; + return (ConnectionPointReferenceFigure)primaryShape; } /** @@ -188,11 +184,11 @@ public class ConnectionPointReferenceEditPart extends AbstractBorderEditPart { */ @Override protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof ConnectionPointReferenceStereotypeEditPart) { + if(borderItemEditPart instanceof ConnectionPointReferenceStereotypeEditPart) { BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH); locator.setBorderItemOffset(new Dimension(-20, -20)); borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else if (borderItemEditPart instanceof ConnectionPointReferenceNameEditPart) { + } else if(borderItemEditPart instanceof ConnectionPointReferenceNameEditPart) { IBorderItemLocator locator = new ExternalLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); } else { @@ -224,7 +220,6 @@ public class ConnectionPointReferenceEditPart extends AbstractBorderEditPart { figure.add(shape); contentPane = setupContentPane(shape); return figure; - } /** @@ -244,7 +239,7 @@ public class ConnectionPointReferenceEditPart extends AbstractBorderEditPart { */ @Override public IFigure getContentPane() { - if (contentPane != null) { + if(contentPane != null) { return contentPane; } return super.getContentPane(); @@ -255,7 +250,7 @@ public class ConnectionPointReferenceEditPart extends AbstractBorderEditPart { */ @Override protected void setForegroundColor(Color color) { - if (primaryShape != null) { + if(primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -273,8 +268,8 @@ public class ConnectionPointReferenceEditPart extends AbstractBorderEditPart { */ @Override protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); + if(primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConnectionPointReferenceNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConnectionPointReferenceNameEditPart.java index d8169413eb5..8be7ff78adb 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConnectionPointReferenceNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConnectionPointReferenceNameEditPart.java @@ -86,8 +86,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart, ILabelRoleProvider { +public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart, ILabelRoleProvider { /** * @generated @@ -131,10 +130,7 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.ConnectionPointReferenceNameEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.ConnectionPointReferenceNameEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -161,9 +157,9 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -173,10 +169,10 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -184,12 +180,12 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -197,12 +193,12 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -210,12 +206,12 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -223,12 +219,12 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -286,11 +282,10 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -303,12 +298,12 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -317,11 +312,10 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -340,28 +334,22 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult( - parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - ConnectionPointReferenceNameEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), ConnectionPointReferenceNameEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -373,7 +361,7 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -392,9 +380,8 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.ConnectionPointReference_Shape, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.ConnectionPointReference_Shape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -403,10 +390,8 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -435,8 +420,8 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -444,8 +429,8 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -456,58 +441,46 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -529,13 +502,12 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -566,20 +538,20 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -587,15 +559,15 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -604,9 +576,9 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -615,10 +587,9 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -636,11 +607,11 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -652,8 +623,8 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -666,7 +637,7 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -692,14 +663,13 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -711,7 +681,7 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -733,15 +703,12 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -752,13 +719,10 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -777,15 +741,12 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -804,27 +765,24 @@ public class ConnectionPointReferenceNameEditPart extends PapyrusLabelEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConnectionPointReferenceStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConnectionPointReferenceStereotypeEditPart.java index 3045cb9d51c..f506ef0f130 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConnectionPointReferenceStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConnectionPointReferenceStereotypeEditPart.java @@ -88,8 +88,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart, ILabelRoleProvider { +public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart, ILabelRoleProvider { /** * @generated @@ -133,10 +132,7 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.ConnectionPointReferenceStereotypeEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.ConnectionPointReferenceStereotypeEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -154,8 +150,7 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi super.createDefaultEditPolicies(); installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeExternalNodeEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeExternalNodeEditPolicy()); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ExternalLabelPrimaryDragRoleEditPolicy()); } @@ -165,9 +160,9 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -177,10 +172,10 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -188,12 +183,12 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -201,12 +196,12 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -214,12 +209,12 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -227,12 +222,12 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -290,11 +285,10 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -307,12 +301,12 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -321,11 +315,10 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -344,27 +337,22 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - ConnectionPointReferenceStereotypeEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), ConnectionPointReferenceStereotypeEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -376,7 +364,7 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -395,9 +383,8 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.ConnectionPointReference_Shape, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.ConnectionPointReference_Shape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -406,10 +393,8 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -438,8 +423,8 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -447,8 +432,8 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -459,58 +444,46 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -532,13 +505,12 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -569,20 +541,20 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -590,15 +562,15 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -607,9 +579,9 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -618,10 +590,9 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -639,11 +610,11 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -655,8 +626,8 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -669,7 +640,7 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -695,14 +666,13 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -714,7 +684,7 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -736,15 +706,12 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -755,13 +722,10 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -780,15 +744,12 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -807,27 +768,24 @@ public class ConnectionPointReferenceStereotypeEditPart extends AbstractLabelEdi @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConstraintBodyEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConstraintBodyEditPart.java index 7de50cd902f..1758a9fb0ac 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConstraintBodyEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConstraintBodyEditPart.java @@ -82,8 +82,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart - implements ITextAwareEditPart, IControlParserForDirectEdit { +public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated @@ -146,12 +145,12 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -159,12 +158,12 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -172,12 +171,12 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -185,12 +184,12 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -249,11 +248,10 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -266,12 +264,12 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -280,11 +278,10 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -303,25 +300,22 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(ParserUtil.getParserAdapter( - getParserElement(), ConstraintBodyEditPart.this), (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), ConstraintBodyEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -333,7 +327,7 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -352,7 +346,7 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart */ @Override public IParser getParser() { - if (parser == null) { + if(parser == null) { parser = ParserUtil.getParser(UMLElementTypes.Constraint_Shape, getParserElement(), this, VISUAL_ID); } return parser; @@ -362,10 +356,8 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -394,8 +386,8 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -403,8 +395,8 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -415,58 +407,46 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -488,13 +468,12 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -525,12 +504,12 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { - View view = (View) getModel(); - if (view.isVisible()) { + if(maskLabelPolicy == null) { + View view = (View)getModel(); + if(view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -539,12 +518,12 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -552,15 +531,15 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -569,9 +548,9 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -580,10 +559,9 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -601,11 +579,11 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -617,8 +595,8 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -631,7 +609,7 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -657,14 +635,13 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -676,7 +653,7 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -698,15 +675,12 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -717,13 +691,10 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -742,15 +713,12 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -788,27 +756,24 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -845,8 +810,7 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); - + addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); } /** @@ -856,7 +820,6 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart public void deactivate() { removeOwnerElementListeners(); super.deactivate(); - } /** @@ -864,6 +827,5 @@ public class ConstraintBodyEditPart extends PapyrusCompartmentEditPart */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); - } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConstraintConstrainedElementEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConstraintConstrainedElementEditPart.java index f82f299cbc1..2d3eb1263e2 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConstraintConstrainedElementEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConstraintConstrainedElementEditPart.java @@ -63,6 +63,6 @@ public class ConstraintConstrainedElementEditPart extends UMLConnectionNodeEditP */ @Override public SimpleDashedEdgeFigure getPrimaryShape() { - return (SimpleDashedEdgeFigure) getFigure(); + return (SimpleDashedEdgeFigure)getFigure(); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConstraintEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConstraintEditPart.java index c8f795e043e..b9655a5e5cb 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConstraintEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConstraintEditPart.java @@ -71,12 +71,9 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); } @@ -90,7 +87,7 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { + if(result == null) { result = new NonResizableEditPolicy(); } return result; @@ -117,7 +114,6 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { @Override protected void handleNotificationEvent(Notification event) { super.handleNotificationEvent(event); - } /** @@ -135,22 +131,21 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { */ @Override public ConstraintFigure getPrimaryShape() { - return (ConstraintFigure) primaryShape; + return (ConstraintFigure)primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if (childEditPart instanceof ConstraintNameLabelEditPart) { - ((ConstraintNameLabelEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if(childEditPart instanceof ConstraintNameLabelEditPart) { + ((ConstraintNameLabelEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } - if (childEditPart instanceof ConstraintBodyEditPart) { - ((ConstraintBodyEditPart) childEditPart).setLabel(getPrimaryShape().getConstraintFigure()); + if(childEditPart instanceof ConstraintBodyEditPart) { + ((ConstraintBodyEditPart)childEditPart).setLabel(getPrimaryShape().getConstraintFigure()); return true; } - return false; } @@ -158,10 +153,10 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if (childEditPart instanceof ConstraintNameLabelEditPart) { + if(childEditPart instanceof ConstraintNameLabelEditPart) { return true; } - if (childEditPart instanceof ConstraintBodyEditPart) { + if(childEditPart instanceof ConstraintBodyEditPart) { return true; } return false; @@ -172,7 +167,7 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if (addFixedChild(childEditPart)) { + if(addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -183,7 +178,7 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if (removeFixedChild(childEditPart)) { + if(removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -217,7 +212,6 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { @Override protected NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); - } /** @@ -230,7 +224,7 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if (nodeShape.getLayoutManager() == null) { + if(nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -243,7 +237,7 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { */ @Override public IFigure getContentPane() { - if (contentPane != null) { + if(contentPane != null) { return contentPane; } return super.getContentPane(); @@ -254,7 +248,7 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { */ @Override protected void setForegroundColor(Color color) { - if (primaryShape != null) { + if(primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -272,8 +266,8 @@ public class ConstraintEditPart extends AbstractConstraintEditPart { */ @Override protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); + if(primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConstraintNameLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConstraintNameLabelEditPart.java index 4e4c8121c8c..40c116745b8 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConstraintNameLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ConstraintNameLabelEditPart.java @@ -86,8 +86,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart - implements ITextAwareEditPart, IControlParserForDirectEdit { +public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated @@ -150,12 +149,12 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -163,12 +162,12 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -176,12 +175,12 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -189,12 +188,12 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -245,12 +244,12 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart */ protected Image getLabelIcon() { EObject parserElement = getParserElement(); - if (parserElement == null) { + if(parserElement == null) { return null; } List<View> views = DiagramEditPartsUtil.findViews(parserElement, getViewer()); - for (View view : views) { - if (AppearanceHelper.showElementIcon(view)) { + for(View view : views) { + if(AppearanceHelper.showElementIcon(view)) { return UMLElementTypes.getImage(parserElement.eClass()); } } @@ -263,11 +262,10 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -280,12 +278,12 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -294,11 +292,10 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -317,25 +314,22 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(ParserUtil.getParserAdapter( - getParserElement(), ConstraintNameLabelEditPart.this), (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), ConstraintNameLabelEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -347,7 +341,7 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -366,7 +360,7 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart */ @Override public IParser getParser() { - if (parser == null) { + if(parser == null) { parser = ParserUtil.getParser(UMLElementTypes.Constraint_Shape, getParserElement(), this, VISUAL_ID); } return parser; @@ -376,10 +370,8 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -408,8 +400,8 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -417,8 +409,8 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -429,58 +421,46 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -502,13 +482,12 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -539,12 +518,12 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { - View view = (View) getModel(); - if (view.isVisible()) { + if(maskLabelPolicy == null) { + View view = (View)getModel(); + if(view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -553,12 +532,12 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -566,15 +545,15 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -583,9 +562,9 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -594,10 +573,9 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -615,11 +593,11 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -631,8 +609,8 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -645,7 +623,7 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -671,14 +649,13 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -690,7 +667,7 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -712,15 +689,12 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -731,13 +705,10 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -756,15 +727,12 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -802,35 +770,31 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } - if (event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON - .equals(((EAnnotation) event.getNewValue()).getSource())) { + if(event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON.equals(((EAnnotation)event.getNewValue()).getSource())) { refreshLabel(); } super.handleNotificationEvent(event); @@ -863,8 +827,7 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); - + addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); } /** @@ -874,7 +837,6 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart public void deactivate() { removeOwnerElementListeners(); super.deactivate(); - } /** @@ -882,6 +844,5 @@ public class ConstraintNameLabelEditPart extends PapyrusCompartmentEditPart */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); - } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ContextLinkAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ContextLinkAppliedStereotypeEditPart.java index 10e25985ca2..57af3d44e2a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ContextLinkAppliedStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ContextLinkAppliedStereotypeEditPart.java @@ -84,8 +84,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart - implements ITextAwareEditPart, IControlParserForDirectEdit { +public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated @@ -129,10 +128,7 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.ContextLinkAppliedStereotypeEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.ContextLinkAppliedStereotypeEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -166,12 +162,12 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -179,12 +175,12 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -192,12 +188,12 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -205,12 +201,12 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -269,11 +265,10 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -286,12 +281,12 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -300,11 +295,10 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -323,28 +317,22 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult( - parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - ContextLinkAppliedStereotypeEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), ContextLinkAppliedStereotypeEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -356,7 +344,7 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -375,7 +363,7 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart */ @Override public IParser getParser() { - if (parser == null) { + if(parser == null) { parser = ParserUtil.getParser(UMLElementTypes.Constraint_ContextEdge, getParserElement(), this, VISUAL_ID); } return parser; @@ -385,10 +373,8 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -417,8 +403,8 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -426,8 +412,8 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -438,58 +424,46 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -511,13 +485,12 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -548,20 +521,20 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -569,15 +542,15 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -586,9 +559,9 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -597,10 +570,9 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -618,11 +590,11 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -634,8 +606,8 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -648,7 +620,7 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -685,7 +657,7 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -707,15 +679,12 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -726,13 +695,10 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -751,15 +717,12 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -778,34 +741,30 @@ public class ContextLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } - super.handleNotificationEvent(event); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ContextLinkEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ContextLinkEditPart.java index ce645aa3091..39dee1baae5 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ContextLinkEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ContextLinkEditPart.java @@ -47,8 +47,7 @@ public class ContextLinkEditPart extends UMLConnectionNodeEditPart implements IT protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new CustomAppliedStereotypeContextLinkLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new CustomAppliedStereotypeContextLinkLabelDisplayEditPolicy()); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ContextLinkSemanticEditPolicy()); } @@ -56,9 +55,8 @@ public class ContextLinkEditPart extends UMLConnectionNodeEditPart implements IT * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if (childEditPart instanceof ContextLinkAppliedStereotypeEditPart) { - ((ContextLinkAppliedStereotypeEditPart) childEditPart) - .setLabel(getPrimaryShape().getAppliedStereotypeLabel()); + if(childEditPart instanceof ContextLinkAppliedStereotypeEditPart) { + ((ContextLinkAppliedStereotypeEditPart)childEditPart).setLabel(getPrimaryShape().getAppliedStereotypeLabel()); } return false; } @@ -68,7 +66,7 @@ public class ContextLinkEditPart extends UMLConnectionNodeEditPart implements IT */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if (addFixedChild(childEditPart)) { + if(addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -78,7 +76,7 @@ public class ContextLinkEditPart extends UMLConnectionNodeEditPart implements IT * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if (childEditPart instanceof ContextLinkAppliedStereotypeEditPart) { + if(childEditPart instanceof ContextLinkAppliedStereotypeEditPart) { return true; } return false; @@ -89,7 +87,7 @@ public class ContextLinkEditPart extends UMLConnectionNodeEditPart implements IT */ @Override protected void removeChildVisual(EditPart childEditPart) { - if (removeFixedChild(childEditPart)) { + if(removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -113,6 +111,6 @@ public class ContextLinkEditPart extends UMLConnectionNodeEditPart implements IT */ @Override public CustomContextLinkFigure getPrimaryShape() { - return (CustomContextLinkFigure) getFigure(); + return (CustomContextLinkFigure)getFigure(); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/DoActivityStateBehaviorStateEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/DoActivityStateBehaviorStateEditPart.java index 1c064b9168b..f113d4bf599 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/DoActivityStateBehaviorStateEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/DoActivityStateBehaviorStateEditPart.java @@ -92,8 +92,7 @@ import org.eclipse.uml2.uml.UMLPackage; /** * @generated */ -public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart - implements ITextAwareEditPart, IPrimaryEditPart, IControlParserForDirectEdit { +public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart implements ITextAwareEditPart, IPrimaryEditPart, IControlParserForDirectEdit { /** * @generated @@ -146,7 +145,7 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart */ @Override public DragTracker getDragTracker(Request request) { - if (request instanceof SelectionRequest && ((SelectionRequest) request).getLastButtonPressed() == 3) { + if(request instanceof SelectionRequest && ((SelectionRequest)request).getLastButtonPressed() == 3) { return null; } return new DragEditPartsTrackerEx(this); @@ -169,12 +168,12 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -182,12 +181,12 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -195,12 +194,12 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -208,12 +207,12 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -272,11 +271,10 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -289,12 +287,12 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -303,11 +301,10 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -326,28 +323,22 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult( - parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - DoActivityStateBehaviorStateEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), DoActivityStateBehaviorStateEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -359,7 +350,7 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -378,9 +369,8 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.Behavior_DoActivityBehaviorLabel, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Behavior_DoActivityBehaviorLabel, getParserElement(), this, VISUAL_ID); } return parser; } @@ -389,10 +379,8 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -421,8 +409,8 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -430,8 +418,8 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -442,58 +430,46 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -515,13 +491,12 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -552,12 +527,12 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { - View view = (View) getModel(); - if (view.isVisible()) { + if(maskLabelPolicy == null) { + View view = (View)getModel(); + if(view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -566,12 +541,12 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -579,15 +554,15 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -596,9 +571,9 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -607,10 +582,9 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -628,11 +602,11 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -644,8 +618,8 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -658,7 +632,7 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -684,14 +658,13 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -703,7 +676,7 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -725,15 +698,12 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -744,13 +714,10 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -769,15 +736,12 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -814,34 +778,31 @@ public class DoActivityStateBehaviorStateEditPart extends CompartmentEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } - if (UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature)) { + if(UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature)) { refreshUnderline(); } super.handleNotificationEvent(event); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/EntryStateBehaviorEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/EntryStateBehaviorEditPart.java index 89ef06a3acc..ae5f49d2208 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/EntryStateBehaviorEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/EntryStateBehaviorEditPart.java @@ -92,8 +92,7 @@ import org.eclipse.uml2.uml.UMLPackage; /** * @generated */ -public class EntryStateBehaviorEditPart extends CompartmentEditPart - implements ITextAwareEditPart, IPrimaryEditPart, IControlParserForDirectEdit { +public class EntryStateBehaviorEditPart extends CompartmentEditPart implements ITextAwareEditPart, IPrimaryEditPart, IControlParserForDirectEdit { /** * @generated @@ -146,7 +145,7 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart */ @Override public DragTracker getDragTracker(Request request) { - if (request instanceof SelectionRequest && ((SelectionRequest) request).getLastButtonPressed() == 3) { + if(request instanceof SelectionRequest && ((SelectionRequest)request).getLastButtonPressed() == 3) { return null; } return new DragEditPartsTrackerEx(this); @@ -169,12 +168,12 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -182,12 +181,12 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -195,12 +194,12 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -208,12 +207,12 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -272,11 +271,10 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -289,12 +287,12 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -303,11 +301,10 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -326,25 +323,22 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(ParserUtil.getParserAdapter( - getParserElement(), EntryStateBehaviorEditPart.this), (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), EntryStateBehaviorEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -356,7 +350,7 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -375,9 +369,8 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.Behavior_EntryBehaviorLabel, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Behavior_EntryBehaviorLabel, getParserElement(), this, VISUAL_ID); } return parser; } @@ -386,10 +379,8 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -418,8 +409,8 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -427,8 +418,8 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -439,58 +430,46 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -512,13 +491,12 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -549,12 +527,12 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { - View view = (View) getModel(); - if (view.isVisible()) { + if(maskLabelPolicy == null) { + View view = (View)getModel(); + if(view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -563,12 +541,12 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -576,15 +554,15 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -593,9 +571,9 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -604,10 +582,9 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -625,11 +602,11 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -641,8 +618,8 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -655,7 +632,7 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -681,14 +658,13 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -700,7 +676,7 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -722,15 +698,12 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -741,13 +714,10 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -766,15 +736,12 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -811,34 +778,31 @@ public class EntryStateBehaviorEditPart extends CompartmentEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } - if (UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature)) { + if(UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature)) { refreshUnderline(); } super.handleNotificationEvent(event); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ExitStateBehaviorEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ExitStateBehaviorEditPart.java index 186d31130ac..d5fe31a2b64 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ExitStateBehaviorEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/ExitStateBehaviorEditPart.java @@ -92,8 +92,7 @@ import org.eclipse.uml2.uml.UMLPackage; /** * @generated */ -public class ExitStateBehaviorEditPart extends CompartmentEditPart - implements ITextAwareEditPart, IPrimaryEditPart, IControlParserForDirectEdit { +public class ExitStateBehaviorEditPart extends CompartmentEditPart implements ITextAwareEditPart, IPrimaryEditPart, IControlParserForDirectEdit { /** * @generated @@ -146,7 +145,7 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart */ @Override public DragTracker getDragTracker(Request request) { - if (request instanceof SelectionRequest && ((SelectionRequest) request).getLastButtonPressed() == 3) { + if(request instanceof SelectionRequest && ((SelectionRequest)request).getLastButtonPressed() == 3) { return null; } return new DragEditPartsTrackerEx(this); @@ -169,12 +168,12 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -182,12 +181,12 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -195,12 +194,12 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -208,12 +207,12 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -272,11 +271,10 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -289,12 +287,12 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -303,11 +301,10 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -326,25 +323,22 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(ParserUtil.getParserAdapter( - getParserElement(), ExitStateBehaviorEditPart.this), (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), ExitStateBehaviorEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -356,7 +350,7 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -375,9 +369,8 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.Behavior_ExitBehaviorLabel, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Behavior_ExitBehaviorLabel, getParserElement(), this, VISUAL_ID); } return parser; } @@ -386,10 +379,8 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -418,8 +409,8 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -427,8 +418,8 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -439,58 +430,46 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -512,13 +491,12 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -549,12 +527,12 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { - View view = (View) getModel(); - if (view.isVisible()) { + if(maskLabelPolicy == null) { + View view = (View)getModel(); + if(view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -563,12 +541,12 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -576,15 +554,15 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -593,9 +571,9 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -604,10 +582,9 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -625,11 +602,11 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -641,8 +618,8 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -655,7 +632,7 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -681,14 +658,13 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -700,7 +676,7 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -722,15 +698,12 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -741,13 +714,10 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -766,15 +736,12 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -811,34 +778,31 @@ public class ExitStateBehaviorEditPart extends CompartmentEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } - if (UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature)) { + if(UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature)) { refreshUnderline(); } super.handleNotificationEvent(event); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/FinalStateEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/FinalStateEditPart.java index ef3e268f75b..866df4e2907 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/FinalStateEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/FinalStateEditPart.java @@ -82,9 +82,7 @@ public class FinalStateEditPart extends RoundedCompartmentEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy()); @@ -100,17 +98,17 @@ public class FinalStateEditPart extends RoundedCompartmentEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); + View childView = (View)child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if (vid != null) { - switch (vid) { + if(vid != null) { + switch(vid) { case FinalStateFloatingLabelEditPart.VISUAL_ID: case FinalStateStereotypeEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -118,7 +116,7 @@ public class FinalStateEditPart extends RoundedCompartmentEditPart { } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { + if(result == null) { result = new NonResizableEditPolicy(); } return result; @@ -148,17 +146,16 @@ public class FinalStateEditPart extends RoundedCompartmentEditPart { * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View) getModel()).getChildren(); - if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if (modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View)getModel()).getChildren(); + if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if(modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); - } /** @@ -176,7 +173,7 @@ public class FinalStateEditPart extends RoundedCompartmentEditPart { */ @Override public RoundedCompartmentFigure getPrimaryShape() { - return (RoundedCompartmentFigure) primaryShape; + return (RoundedCompartmentFigure)primaryShape; } /** @@ -184,10 +181,10 @@ public class FinalStateEditPart extends RoundedCompartmentEditPart { */ @Override protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof FinalStateFloatingLabelEditPart) { + if(borderItemEditPart instanceof FinalStateFloatingLabelEditPart) { IBorderItemLocator locator = new RoundedRectangleLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else if (borderItemEditPart instanceof FinalStateStereotypeEditPart) { + } else if(borderItemEditPart instanceof FinalStateStereotypeEditPart) { IBorderItemLocator locator = new ExternalLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); } else { @@ -215,7 +212,6 @@ public class FinalStateEditPart extends RoundedCompartmentEditPart { @Override protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); - } /** @@ -236,7 +232,7 @@ public class FinalStateEditPart extends RoundedCompartmentEditPart { */ @Override public IFigure getContentPane() { - if (contentPane != null) { + if(contentPane != null) { return contentPane; } return super.getContentPane(); @@ -247,7 +243,7 @@ public class FinalStateEditPart extends RoundedCompartmentEditPart { */ @Override protected void setForegroundColor(Color color) { - if (primaryShape != null) { + if(primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -265,8 +261,8 @@ public class FinalStateEditPart extends RoundedCompartmentEditPart { */ @Override protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); + if(primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/FinalStateFloatingLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/FinalStateFloatingLabelEditPart.java index 04d0f58e3c5..a402d571644 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/FinalStateFloatingLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/FinalStateFloatingLabelEditPart.java @@ -85,8 +85,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -130,10 +129,7 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.FinalStateFloatingLabelEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.FinalStateFloatingLabelEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -160,9 +156,9 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -172,10 +168,10 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -183,12 +179,12 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -196,12 +192,12 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -209,12 +205,12 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -222,12 +218,12 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -285,11 +281,10 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -302,12 +297,12 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -316,11 +311,10 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -339,26 +333,22 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult( - parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), - FinalStateFloatingLabelEditPart.this), (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), FinalStateFloatingLabelEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -370,7 +360,7 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -389,7 +379,7 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart */ @Override public IParser getParser() { - if (parser == null) { + if(parser == null) { parser = ParserUtil.getParser(UMLElementTypes.FinalState_Shape, getParserElement(), this, VISUAL_ID); } return parser; @@ -399,10 +389,8 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -431,8 +419,8 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -440,8 +428,8 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -452,58 +440,46 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -525,13 +501,12 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -562,20 +537,20 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -583,15 +558,15 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -600,9 +575,9 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -611,10 +586,9 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -632,11 +606,11 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -648,8 +622,8 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -662,7 +636,7 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -688,14 +662,13 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -707,7 +680,7 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -729,15 +702,12 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -748,13 +718,10 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -773,15 +740,12 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -800,27 +764,24 @@ public class FinalStateFloatingLabelEditPart extends FloatingLabelEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/FinalStateStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/FinalStateStereotypeEditPart.java index 3333277a6fe..bcfa56c0b7d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/FinalStateStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/FinalStateStereotypeEditPart.java @@ -87,8 +87,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class FinalStateStereotypeEditPart extends AbstractLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class FinalStateStereotypeEditPart extends AbstractLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -132,10 +131,7 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.FinalStateStereotypeEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.FinalStateStereotypeEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -153,8 +149,7 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart super.createDefaultEditPolicies(); installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeExternalNodeEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeExternalNodeEditPolicy()); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ExternalLabelPrimaryDragRoleEditPolicy()); } @@ -164,9 +159,9 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -176,10 +171,10 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -187,12 +182,12 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -200,12 +195,12 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -213,12 +208,12 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -226,12 +221,12 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -289,11 +284,10 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -306,12 +300,12 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -320,11 +314,10 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -343,26 +336,22 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult( - parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), - FinalStateStereotypeEditPart.this), (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), FinalStateStereotypeEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -374,7 +363,7 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -393,7 +382,7 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart */ @Override public IParser getParser() { - if (parser == null) { + if(parser == null) { parser = ParserUtil.getParser(UMLElementTypes.FinalState_Shape, getParserElement(), this, VISUAL_ID); } return parser; @@ -403,10 +392,8 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -435,8 +422,8 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -444,8 +431,8 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -456,58 +443,46 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -529,13 +504,12 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -566,20 +540,20 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -587,15 +561,15 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -604,9 +578,9 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -615,10 +589,9 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -636,11 +609,11 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -652,8 +625,8 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -666,7 +639,7 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -692,14 +665,13 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -711,7 +683,7 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -733,15 +705,12 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -752,13 +721,10 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -777,15 +743,12 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -804,27 +767,24 @@ public class FinalStateStereotypeEditPart extends AbstractLabelEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/GeneralizationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/GeneralizationEditPart.java index 8bdfa572352..c928ff5e04f 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/GeneralizationEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/GeneralizationEditPart.java @@ -45,16 +45,15 @@ public class GeneralizationEditPart extends UMLConnectionNodeEditPart implements protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeLinkLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy()); } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if (childEditPart instanceof GeneralizationStereotypeEditPart) { - ((GeneralizationStereotypeEditPart) childEditPart).setLabel(getPrimaryShape().getAppliedStereotypeLabel()); + if(childEditPart instanceof GeneralizationStereotypeEditPart) { + ((GeneralizationStereotypeEditPart)childEditPart).setLabel(getPrimaryShape().getAppliedStereotypeLabel()); } return false; } @@ -64,7 +63,7 @@ public class GeneralizationEditPart extends UMLConnectionNodeEditPart implements */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if (addFixedChild(childEditPart)) { + if(addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -74,7 +73,7 @@ public class GeneralizationEditPart extends UMLConnectionNodeEditPart implements * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if (childEditPart instanceof GeneralizationStereotypeEditPart) { + if(childEditPart instanceof GeneralizationStereotypeEditPart) { return true; } return false; @@ -85,7 +84,7 @@ public class GeneralizationEditPart extends UMLConnectionNodeEditPart implements */ @Override protected void removeChildVisual(EditPart childEditPart) { - if (removeFixedChild(childEditPart)) { + if(removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -109,6 +108,6 @@ public class GeneralizationEditPart extends UMLConnectionNodeEditPart implements */ @Override public GeneralizationFigure getPrimaryShape() { - return (GeneralizationFigure) getFigure(); + return (GeneralizationFigure)getFigure(); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/GeneralizationStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/GeneralizationStereotypeEditPart.java index 1c775ff383d..bd04af9f827 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/GeneralizationStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/GeneralizationStereotypeEditPart.java @@ -83,8 +83,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart - implements ITextAwareEditPart, IControlParserForDirectEdit { +public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated @@ -128,10 +127,7 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.GeneralizationStereotypeEditPart.VISUAL_ID), - new Point(0, 40)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.GeneralizationStereotypeEditPart.VISUAL_ID), new Point(0, 40)); } /** @@ -164,12 +160,12 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -177,12 +173,12 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -190,12 +186,12 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -203,12 +199,12 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -267,11 +263,10 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -284,12 +279,12 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -298,11 +293,10 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -321,28 +315,22 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult( - parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - GeneralizationStereotypeEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), GeneralizationStereotypeEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -354,7 +342,7 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -373,7 +361,7 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart */ @Override public IParser getParser() { - if (parser == null) { + if(parser == null) { parser = ParserUtil.getParser(UMLElementTypes.Generalization_Edge, getParserElement(), this, VISUAL_ID); } return parser; @@ -383,10 +371,8 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -415,8 +401,8 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -424,8 +410,8 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -436,58 +422,46 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -509,13 +483,12 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -546,20 +519,20 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -567,15 +540,15 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -584,9 +557,9 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -595,10 +568,9 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -616,11 +588,11 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -632,8 +604,8 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -646,7 +618,7 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -683,7 +655,7 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -705,15 +677,12 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -724,13 +693,10 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -749,15 +715,12 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -776,34 +739,30 @@ public class GeneralizationStereotypeEditPart extends PapyrusLabelEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } - super.handleNotificationEvent(event); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/InternalTransitionEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/InternalTransitionEditPart.java index 4f9886a3604..223cec94188 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/InternalTransitionEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/InternalTransitionEditPart.java @@ -92,8 +92,7 @@ import org.eclipse.uml2.uml.UMLPackage; /** * @generated */ -public class InternalTransitionEditPart extends CompartmentEditPart - implements ITextAwareEditPart, IPrimaryEditPart, IControlParserForDirectEdit { +public class InternalTransitionEditPart extends CompartmentEditPart implements ITextAwareEditPart, IPrimaryEditPart, IControlParserForDirectEdit { /** * @generated @@ -146,7 +145,7 @@ public class InternalTransitionEditPart extends CompartmentEditPart */ @Override public DragTracker getDragTracker(Request request) { - if (request instanceof SelectionRequest && ((SelectionRequest) request).getLastButtonPressed() == 3) { + if(request instanceof SelectionRequest && ((SelectionRequest)request).getLastButtonPressed() == 3) { return null; } return new DragEditPartsTrackerEx(this); @@ -169,12 +168,12 @@ public class InternalTransitionEditPart extends CompartmentEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -182,12 +181,12 @@ public class InternalTransitionEditPart extends CompartmentEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -195,12 +194,12 @@ public class InternalTransitionEditPart extends CompartmentEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -208,12 +207,12 @@ public class InternalTransitionEditPart extends CompartmentEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -272,11 +271,10 @@ public class InternalTransitionEditPart extends CompartmentEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -289,12 +287,12 @@ public class InternalTransitionEditPart extends CompartmentEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -303,11 +301,10 @@ public class InternalTransitionEditPart extends CompartmentEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -326,25 +323,22 @@ public class InternalTransitionEditPart extends CompartmentEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(ParserUtil.getParserAdapter( - getParserElement(), InternalTransitionEditPart.this), (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), InternalTransitionEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -356,7 +350,7 @@ public class InternalTransitionEditPart extends CompartmentEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -375,9 +369,8 @@ public class InternalTransitionEditPart extends CompartmentEditPart */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.Transition_InternalTransitionLabel, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Transition_InternalTransitionLabel, getParserElement(), this, VISUAL_ID); } return parser; } @@ -386,10 +379,8 @@ public class InternalTransitionEditPart extends CompartmentEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -418,8 +409,8 @@ public class InternalTransitionEditPart extends CompartmentEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -427,8 +418,8 @@ public class InternalTransitionEditPart extends CompartmentEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -439,58 +430,46 @@ public class InternalTransitionEditPart extends CompartmentEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -512,13 +491,12 @@ public class InternalTransitionEditPart extends CompartmentEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -549,12 +527,12 @@ public class InternalTransitionEditPart extends CompartmentEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { - View view = (View) getModel(); - if (view.isVisible()) { + if(maskLabelPolicy == null) { + View view = (View)getModel(); + if(view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -563,12 +541,12 @@ public class InternalTransitionEditPart extends CompartmentEditPart } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -576,15 +554,15 @@ public class InternalTransitionEditPart extends CompartmentEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -593,9 +571,9 @@ public class InternalTransitionEditPart extends CompartmentEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -604,10 +582,9 @@ public class InternalTransitionEditPart extends CompartmentEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -625,11 +602,11 @@ public class InternalTransitionEditPart extends CompartmentEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -641,8 +618,8 @@ public class InternalTransitionEditPart extends CompartmentEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -655,7 +632,7 @@ public class InternalTransitionEditPart extends CompartmentEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -692,7 +669,7 @@ public class InternalTransitionEditPart extends CompartmentEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -714,15 +691,12 @@ public class InternalTransitionEditPart extends CompartmentEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -733,13 +707,10 @@ public class InternalTransitionEditPart extends CompartmentEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -758,15 +729,12 @@ public class InternalTransitionEditPart extends CompartmentEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -803,34 +771,31 @@ public class InternalTransitionEditPart extends CompartmentEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } - if (UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature)) { + if(UMLPackage.eINSTANCE.getFeature_IsStatic().equals(feature)) { refreshUnderline(); } super.handleNotificationEvent(event); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PackageEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PackageEditPart.java index 737fb625447..403acb5749d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PackageEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PackageEditPart.java @@ -53,20 +53,16 @@ public class PackageEditPart extends PapyrusDiagramEditPart { @Override protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); - installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy()); installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); - installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultCompartmentSemanticEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.statemachine.edit.policies.PackageCanonicalEditPolicy()); - installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CustomPackageCreationEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, new CustomPackageXYLayoutEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomStateMachineDiagramDragDropEditPolicy()); - installEditPolicy(AbstractShowHideRelatedLinkEditPolicy.SHOW_HIDE_RELATED_LINK_ROLE, - new ShowHideRelatedLinkEditPolicy()); + installEditPolicy(AbstractShowHideRelatedLinkEditPolicy.SHOW_HIDE_RELATED_LINK_ROLE, new ShowHideRelatedLinkEditPolicy()); // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.POPUPBAR_ROLE); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateChoiceEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateChoiceEditPart.java index 9deb58d533e..c6e5b2a6347 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateChoiceEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateChoiceEditPart.java @@ -84,13 +84,10 @@ public class PseudostateChoiceEditPart extends RoundedCompartmentEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); @@ -104,17 +101,17 @@ public class PseudostateChoiceEditPart extends RoundedCompartmentEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); + View childView = (View)child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if (vid != null) { - switch (vid) { + if(vid != null) { + switch(vid) { case PseudostateChoiceFloatingLabelEditPart.VISUAL_ID: case PseudostateChoiceStereotypeEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -122,7 +119,7 @@ public class PseudostateChoiceEditPart extends RoundedCompartmentEditPart { } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { + if(result == null) { result = new NonResizableEditPolicy(); } return result; @@ -152,17 +149,16 @@ public class PseudostateChoiceEditPart extends RoundedCompartmentEditPart { * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View) getModel()).getChildren(); - if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if (modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View)getModel()).getChildren(); + if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if(modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); - } /** @@ -180,7 +176,7 @@ public class PseudostateChoiceEditPart extends RoundedCompartmentEditPart { */ @Override public RoundedCompartmentFigure getPrimaryShape() { - return (RoundedCompartmentFigure) primaryShape; + return (RoundedCompartmentFigure)primaryShape; } /** @@ -188,10 +184,10 @@ public class PseudostateChoiceEditPart extends RoundedCompartmentEditPart { */ @Override protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof PseudostateChoiceFloatingLabelEditPart) { + if(borderItemEditPart instanceof PseudostateChoiceFloatingLabelEditPart) { IBorderItemLocator locator = new RoundedRectangleLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else if (borderItemEditPart instanceof PseudostateChoiceStereotypeEditPart) { + } else if(borderItemEditPart instanceof PseudostateChoiceStereotypeEditPart) { IBorderItemLocator locator = new ExternalLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); } else { @@ -219,7 +215,6 @@ public class PseudostateChoiceEditPart extends RoundedCompartmentEditPart { @Override protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); - } /** @@ -240,7 +235,7 @@ public class PseudostateChoiceEditPart extends RoundedCompartmentEditPart { */ @Override public IFigure getContentPane() { - if (contentPane != null) { + if(contentPane != null) { return contentPane; } return super.getContentPane(); @@ -251,7 +246,7 @@ public class PseudostateChoiceEditPart extends RoundedCompartmentEditPart { */ @Override protected void setForegroundColor(Color color) { - if (primaryShape != null) { + if(primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -269,8 +264,8 @@ public class PseudostateChoiceEditPart extends RoundedCompartmentEditPart { */ @Override protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); + if(primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateChoiceFloatingLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateChoiceFloatingLabelEditPart.java index a74bf06a0cb..253fd03211f 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateChoiceFloatingLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateChoiceFloatingLabelEditPart.java @@ -85,8 +85,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -130,10 +129,7 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateChoiceFloatingLabelEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateChoiceFloatingLabelEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -160,9 +156,9 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -172,10 +168,10 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -183,12 +179,12 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -196,12 +192,12 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -209,12 +205,12 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -222,12 +218,12 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -285,11 +281,10 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -302,12 +297,12 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -316,11 +311,10 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -339,28 +333,22 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult( - parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - PseudostateChoiceFloatingLabelEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateChoiceFloatingLabelEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -372,7 +360,7 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -391,7 +379,7 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar */ @Override public IParser getParser() { - if (parser == null) { + if(parser == null) { parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_ChoiceShape, getParserElement(), this, VISUAL_ID); } return parser; @@ -401,10 +389,8 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -433,8 +419,8 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -442,8 +428,8 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -454,58 +440,46 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -527,13 +501,12 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -564,20 +537,20 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -585,15 +558,15 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -602,9 +575,9 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -613,10 +586,9 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -634,11 +606,11 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -650,8 +622,8 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -664,7 +636,7 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -690,14 +662,13 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -709,7 +680,7 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -731,15 +702,12 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -750,13 +718,10 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -775,15 +740,12 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -802,27 +764,24 @@ public class PseudostateChoiceFloatingLabelEditPart extends FloatingLabelEditPar @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateChoiceStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateChoiceStereotypeEditPart.java index da0936373ef..0ca9eef6916 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateChoiceStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateChoiceStereotypeEditPart.java @@ -87,8 +87,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -132,10 +131,7 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateChoiceStereotypeEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateChoiceStereotypeEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -153,8 +149,7 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart super.createDefaultEditPolicies(); installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeExternalNodeEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeExternalNodeEditPolicy()); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ExternalLabelPrimaryDragRoleEditPolicy()); } @@ -164,9 +159,9 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -176,10 +171,10 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -187,12 +182,12 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -200,12 +195,12 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -213,12 +208,12 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -226,12 +221,12 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -289,11 +284,10 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -306,12 +300,12 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -320,11 +314,10 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -343,28 +336,22 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult( - parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - PseudostateChoiceStereotypeEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateChoiceStereotypeEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -376,7 +363,7 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -395,7 +382,7 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart */ @Override public IParser getParser() { - if (parser == null) { + if(parser == null) { parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_ChoiceShape, getParserElement(), this, VISUAL_ID); } return parser; @@ -405,10 +392,8 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -437,8 +422,8 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -446,8 +431,8 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -458,58 +443,46 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -531,13 +504,12 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -568,20 +540,20 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -589,15 +561,15 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -606,9 +578,9 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -617,10 +589,9 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -638,11 +609,11 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -654,8 +625,8 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -668,7 +639,7 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -694,14 +665,13 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -713,7 +683,7 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -735,15 +705,12 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -754,13 +721,10 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -779,15 +743,12 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -806,27 +767,24 @@ public class PseudostateChoiceStereotypeEditPart extends AbstractLabelEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateDeepHistoryEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateDeepHistoryEditPart.java index 59886ae7833..1001b1f6ec6 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateDeepHistoryEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateDeepHistoryEditPart.java @@ -84,13 +84,10 @@ public class PseudostateDeepHistoryEditPart extends RoundedCompartmentEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); @@ -104,17 +101,17 @@ public class PseudostateDeepHistoryEditPart extends RoundedCompartmentEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); + View childView = (View)child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if (vid != null) { - switch (vid) { + if(vid != null) { + switch(vid) { case PseudostateDeepHistoryFloatingLabelEditPart.VISUAL_ID: case PseudostateDeepHistoryStereotypeEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -122,7 +119,7 @@ public class PseudostateDeepHistoryEditPart extends RoundedCompartmentEditPart { } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { + if(result == null) { result = new NonResizableEditPolicy(); } return result; @@ -152,17 +149,16 @@ public class PseudostateDeepHistoryEditPart extends RoundedCompartmentEditPart { * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View) getModel()).getChildren(); - if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if (modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View)getModel()).getChildren(); + if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if(modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); - } /** @@ -180,7 +176,7 @@ public class PseudostateDeepHistoryEditPart extends RoundedCompartmentEditPart { */ @Override public RoundedCompartmentFigure getPrimaryShape() { - return (RoundedCompartmentFigure) primaryShape; + return (RoundedCompartmentFigure)primaryShape; } /** @@ -188,10 +184,10 @@ public class PseudostateDeepHistoryEditPart extends RoundedCompartmentEditPart { */ @Override protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof PseudostateDeepHistoryFloatingLabelEditPart) { + if(borderItemEditPart instanceof PseudostateDeepHistoryFloatingLabelEditPart) { IBorderItemLocator locator = new RoundedRectangleLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else if (borderItemEditPart instanceof PseudostateDeepHistoryStereotypeEditPart) { + } else if(borderItemEditPart instanceof PseudostateDeepHistoryStereotypeEditPart) { IBorderItemLocator locator = new ExternalLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); } else { @@ -219,7 +215,6 @@ public class PseudostateDeepHistoryEditPart extends RoundedCompartmentEditPart { @Override protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); - } /** @@ -240,7 +235,7 @@ public class PseudostateDeepHistoryEditPart extends RoundedCompartmentEditPart { */ @Override public IFigure getContentPane() { - if (contentPane != null) { + if(contentPane != null) { return contentPane; } return super.getContentPane(); @@ -251,7 +246,7 @@ public class PseudostateDeepHistoryEditPart extends RoundedCompartmentEditPart { */ @Override protected void setForegroundColor(Color color) { - if (primaryShape != null) { + if(primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -269,8 +264,8 @@ public class PseudostateDeepHistoryEditPart extends RoundedCompartmentEditPart { */ @Override protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); + if(primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); } } @@ -279,7 +274,6 @@ public class PseudostateDeepHistoryEditPart extends RoundedCompartmentEditPart { */ @Override public EditPart getPrimaryChildEditPart() { - return getChildBySemanticHint( - UMLVisualIDRegistry.getType(PseudostateDeepHistoryFloatingLabelEditPart.VISUAL_ID)); + return getChildBySemanticHint(UMLVisualIDRegistry.getType(PseudostateDeepHistoryFloatingLabelEditPart.VISUAL_ID)); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateDeepHistoryFloatingLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateDeepHistoryFloatingLabelEditPart.java index 3e5453714a7..e1eeeb88854 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateDeepHistoryFloatingLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateDeepHistoryFloatingLabelEditPart.java @@ -85,8 +85,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -130,10 +129,7 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateDeepHistoryFloatingLabelEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateDeepHistoryFloatingLabelEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -160,9 +156,9 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -172,10 +168,10 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -183,12 +179,12 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -196,12 +192,12 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -209,12 +205,12 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -222,12 +218,12 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -285,11 +281,10 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -302,12 +297,12 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -316,11 +311,10 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -339,27 +333,22 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - PseudostateDeepHistoryFloatingLabelEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateDeepHistoryFloatingLabelEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -371,7 +360,7 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -390,9 +379,8 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_DeepHistoryShape, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_DeepHistoryShape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -401,10 +389,8 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -433,8 +419,8 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -442,8 +428,8 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -454,58 +440,46 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -527,13 +501,12 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -564,20 +537,20 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -585,15 +558,15 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -602,9 +575,9 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -613,10 +586,9 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -634,11 +606,11 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -650,8 +622,8 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -664,7 +636,7 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -690,14 +662,13 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -709,7 +680,7 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -731,15 +702,12 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -750,13 +718,10 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -775,15 +740,12 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -802,27 +764,24 @@ public class PseudostateDeepHistoryFloatingLabelEditPart extends FloatingLabelEd @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateDeepHistoryStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateDeepHistoryStereotypeEditPart.java index bcb1b24f256..331810ad3ee 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateDeepHistoryStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateDeepHistoryStereotypeEditPart.java @@ -87,8 +87,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -132,10 +131,7 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateDeepHistoryStereotypeEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateDeepHistoryStereotypeEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -153,8 +149,7 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP super.createDefaultEditPolicies(); installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeExternalNodeEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeExternalNodeEditPolicy()); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ExternalLabelPrimaryDragRoleEditPolicy()); } @@ -164,9 +159,9 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -176,10 +171,10 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -187,12 +182,12 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -200,12 +195,12 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -213,12 +208,12 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -226,12 +221,12 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -289,11 +284,10 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -306,12 +300,12 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -320,11 +314,10 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -343,27 +336,22 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - PseudostateDeepHistoryStereotypeEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateDeepHistoryStereotypeEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -375,7 +363,7 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -394,9 +382,8 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_DeepHistoryShape, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_DeepHistoryShape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -405,10 +392,8 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -437,8 +422,8 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -446,8 +431,8 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -458,58 +443,46 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -531,13 +504,12 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -568,20 +540,20 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -589,15 +561,15 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -606,9 +578,9 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -617,10 +589,9 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -638,11 +609,11 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -654,8 +625,8 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -668,7 +639,7 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -694,14 +665,13 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -713,7 +683,7 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -735,15 +705,12 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -754,13 +721,10 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -779,15 +743,12 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -806,27 +767,24 @@ public class PseudostateDeepHistoryStereotypeEditPart extends AbstractLabelEditP @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateEntryPointEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateEntryPointEditPart.java index 462f20fb39b..cfba1347275 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateEntryPointEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateEntryPointEditPart.java @@ -85,13 +85,10 @@ public class PseudostateEntryPointEditPart extends RoundedBorderNamedElementEdit super.createDefaultEditPolicies(); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, getPrimaryDragEditPolicy()); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); @@ -105,17 +102,17 @@ public class PseudostateEntryPointEditPart extends RoundedBorderNamedElementEdit @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); + View childView = (View)child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if (vid != null) { - switch (vid) { + if(vid != null) { + switch(vid) { case PseudostateEntryPointFloatingLabelEditPart.VISUAL_ID: case PseudostateEntryPointStereotypeEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -123,7 +120,7 @@ public class PseudostateEntryPointEditPart extends RoundedBorderNamedElementEdit } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { + if(result == null) { result = new NonResizableEditPolicy(); } return result; @@ -153,17 +150,16 @@ public class PseudostateEntryPointEditPart extends RoundedBorderNamedElementEdit * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View) getModel()).getChildren(); - if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if (modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View)getModel()).getChildren(); + if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if(modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); - } /** @@ -180,7 +176,7 @@ public class PseudostateEntryPointEditPart extends RoundedBorderNamedElementEdit */ @Override public RoundedCompartmentFigure getPrimaryShape() { - return (RoundedCompartmentFigure) primaryShape; + return (RoundedCompartmentFigure)primaryShape; } /** @@ -188,10 +184,10 @@ public class PseudostateEntryPointEditPart extends RoundedBorderNamedElementEdit */ @Override protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof PseudostateEntryPointFloatingLabelEditPart) { + if(borderItemEditPart instanceof PseudostateEntryPointFloatingLabelEditPart) { IBorderItemLocator locator = new RoundedRectangleLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else if (borderItemEditPart instanceof PseudostateEntryPointStereotypeEditPart) { + } else if(borderItemEditPart instanceof PseudostateEntryPointStereotypeEditPart) { IBorderItemLocator locator = new ExternalLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); } else { @@ -223,7 +219,6 @@ public class PseudostateEntryPointEditPart extends RoundedBorderNamedElementEdit figure.add(shape); contentPane = setupContentPane(shape); return figure; - } /** @@ -243,7 +238,7 @@ public class PseudostateEntryPointEditPart extends RoundedBorderNamedElementEdit */ @Override public IFigure getContentPane() { - if (contentPane != null) { + if(contentPane != null) { return contentPane; } return super.getContentPane(); @@ -254,7 +249,7 @@ public class PseudostateEntryPointEditPart extends RoundedBorderNamedElementEdit */ @Override protected void setForegroundColor(Color color) { - if (primaryShape != null) { + if(primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -272,8 +267,8 @@ public class PseudostateEntryPointEditPart extends RoundedBorderNamedElementEdit */ @Override protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); + if(primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); } } @@ -282,7 +277,6 @@ public class PseudostateEntryPointEditPart extends RoundedBorderNamedElementEdit */ @Override public EditPart getPrimaryChildEditPart() { - return getChildBySemanticHint( - UMLVisualIDRegistry.getType(PseudostateEntryPointFloatingLabelEditPart.VISUAL_ID)); + return getChildBySemanticHint(UMLVisualIDRegistry.getType(PseudostateEntryPointFloatingLabelEditPart.VISUAL_ID)); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateEntryPointFloatingLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateEntryPointFloatingLabelEditPart.java index d7f243b932f..ba66d8236d2 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateEntryPointFloatingLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateEntryPointFloatingLabelEditPart.java @@ -85,8 +85,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -130,10 +129,7 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateEntryPointFloatingLabelEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateEntryPointFloatingLabelEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -160,9 +156,9 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -172,10 +168,10 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -183,12 +179,12 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -196,12 +192,12 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -209,12 +205,12 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -222,12 +218,12 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -285,11 +281,10 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -302,12 +297,12 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -316,11 +311,10 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -339,27 +333,22 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - PseudostateEntryPointFloatingLabelEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateEntryPointFloatingLabelEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -371,7 +360,7 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -390,9 +379,8 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_EntryPointShape, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_EntryPointShape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -401,10 +389,8 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -433,8 +419,8 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -442,8 +428,8 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -454,58 +440,46 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -527,13 +501,12 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -564,20 +537,20 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -585,15 +558,15 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -602,9 +575,9 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -613,10 +586,9 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -634,11 +606,11 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -650,8 +622,8 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -664,7 +636,7 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -690,14 +662,13 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -709,7 +680,7 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -731,15 +702,12 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -750,13 +718,10 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -775,15 +740,12 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -802,27 +764,24 @@ public class PseudostateEntryPointFloatingLabelEditPart extends FloatingLabelEdi @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateEntryPointStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateEntryPointStereotypeEditPart.java index 18cddc64b1e..771e4ba1c96 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateEntryPointStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateEntryPointStereotypeEditPart.java @@ -88,8 +88,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart, ILabelRoleProvider { +public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart, ILabelRoleProvider { /** * @generated @@ -133,10 +132,7 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateEntryPointStereotypeEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateEntryPointStereotypeEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -154,8 +150,7 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa super.createDefaultEditPolicies(); installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeExternalNodeEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeExternalNodeEditPolicy()); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ExternalLabelPrimaryDragRoleEditPolicy()); } @@ -165,9 +160,9 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -177,10 +172,10 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -188,12 +183,12 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -201,12 +196,12 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -214,12 +209,12 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -227,12 +222,12 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -290,11 +285,10 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -307,12 +301,12 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -321,11 +315,10 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -344,28 +337,22 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult( - parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - PseudostateEntryPointStereotypeEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateEntryPointStereotypeEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -377,7 +364,7 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -396,9 +383,8 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_EntryPointShape, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_EntryPointShape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -407,10 +393,8 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -439,8 +423,8 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -448,8 +432,8 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -460,58 +444,46 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -533,13 +505,12 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -570,20 +541,20 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -591,15 +562,15 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -608,9 +579,9 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -619,10 +590,9 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -640,11 +610,11 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -656,8 +626,8 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -670,7 +640,7 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -696,14 +666,13 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -715,7 +684,7 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -737,15 +706,12 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -756,13 +722,10 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -781,15 +744,12 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -808,27 +768,24 @@ public class PseudostateEntryPointStereotypeEditPart extends AbstractLabelEditPa @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateExitPointEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateExitPointEditPart.java index 8e3dd34771e..cdbc72dc1f9 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateExitPointEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateExitPointEditPart.java @@ -87,13 +87,10 @@ public class PseudostateExitPointEditPart extends RoundedBorderNamedElementEditP super.createDefaultEditPolicies(); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, getPrimaryDragEditPolicy()); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); @@ -107,17 +104,17 @@ public class PseudostateExitPointEditPart extends RoundedBorderNamedElementEditP @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); + View childView = (View)child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if (vid != null) { - switch (vid) { + if(vid != null) { + switch(vid) { case PseudostateExitPointFloatingLabelEditPart.VISUAL_ID: case PseudostateExitPointStereotypeEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -125,7 +122,7 @@ public class PseudostateExitPointEditPart extends RoundedBorderNamedElementEditP } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { + if(result == null) { result = new NonResizableEditPolicy(); } return result; @@ -155,17 +152,16 @@ public class PseudostateExitPointEditPart extends RoundedBorderNamedElementEditP * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View) getModel()).getChildren(); - if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if (modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View)getModel()).getChildren(); + if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if(modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); - } /** @@ -182,7 +178,7 @@ public class PseudostateExitPointEditPart extends RoundedBorderNamedElementEditP */ @Override public PseudostateExitPointFigure getPrimaryShape() { - return (PseudostateExitPointFigure) primaryShape; + return (PseudostateExitPointFigure)primaryShape; } /** @@ -190,11 +186,11 @@ public class PseudostateExitPointEditPart extends RoundedBorderNamedElementEditP */ @Override protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof PseudostateExitPointStereotypeEditPart) { + if(borderItemEditPart instanceof PseudostateExitPointStereotypeEditPart) { BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH); locator.setBorderItemOffset(new Dimension(-20, -20)); borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else if (borderItemEditPart instanceof PseudostateExitPointFloatingLabelEditPart) { + } else if(borderItemEditPart instanceof PseudostateExitPointFloatingLabelEditPart) { IBorderItemLocator locator = new RoundedRectangleLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); } else { @@ -226,7 +222,6 @@ public class PseudostateExitPointEditPart extends RoundedBorderNamedElementEditP figure.add(shape); contentPane = setupContentPane(shape); return figure; - } /** @@ -246,7 +241,7 @@ public class PseudostateExitPointEditPart extends RoundedBorderNamedElementEditP */ @Override public IFigure getContentPane() { - if (contentPane != null) { + if(contentPane != null) { return contentPane; } return super.getContentPane(); @@ -257,7 +252,7 @@ public class PseudostateExitPointEditPart extends RoundedBorderNamedElementEditP */ @Override protected void setForegroundColor(Color color) { - if (primaryShape != null) { + if(primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -275,8 +270,8 @@ public class PseudostateExitPointEditPart extends RoundedBorderNamedElementEditP */ @Override protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); + if(primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateExitPointFloatingLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateExitPointFloatingLabelEditPart.java index 98e33cade4b..1b8af07acfd 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateExitPointFloatingLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateExitPointFloatingLabelEditPart.java @@ -85,8 +85,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -130,10 +129,7 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateExitPointFloatingLabelEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateExitPointFloatingLabelEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -160,9 +156,9 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -172,10 +168,10 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -183,12 +179,12 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -196,12 +192,12 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -209,12 +205,12 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -222,12 +218,12 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -285,11 +281,10 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -302,12 +297,12 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -316,11 +311,10 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -339,27 +333,22 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - PseudostateExitPointFloatingLabelEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateExitPointFloatingLabelEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -371,7 +360,7 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -390,9 +379,8 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_ExitPointShape, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_ExitPointShape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -401,10 +389,8 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -433,8 +419,8 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -442,8 +428,8 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -454,58 +440,46 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -527,13 +501,12 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -564,20 +537,20 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -585,15 +558,15 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -602,9 +575,9 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -613,10 +586,9 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -634,11 +606,11 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -650,8 +622,8 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -664,7 +636,7 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -690,14 +662,13 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -709,7 +680,7 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -731,15 +702,12 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -750,13 +718,10 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -775,15 +740,12 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -802,27 +764,24 @@ public class PseudostateExitPointFloatingLabelEditPart extends FloatingLabelEdit @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateExitPointStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateExitPointStereotypeEditPart.java index acee170a21f..01bd6e89440 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateExitPointStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateExitPointStereotypeEditPart.java @@ -88,8 +88,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart, ILabelRoleProvider { +public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart, ILabelRoleProvider { /** * @generated @@ -133,10 +132,7 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateExitPointStereotypeEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateExitPointStereotypeEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -154,8 +150,7 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar super.createDefaultEditPolicies(); installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeExternalNodeEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeExternalNodeEditPolicy()); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ExternalLabelPrimaryDragRoleEditPolicy()); } @@ -165,9 +160,9 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -177,10 +172,10 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -188,12 +183,12 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -201,12 +196,12 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -214,12 +209,12 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -227,12 +222,12 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -290,11 +285,10 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -307,12 +301,12 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -321,11 +315,10 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -344,28 +337,22 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult( - parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - PseudostateExitPointStereotypeEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateExitPointStereotypeEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -377,7 +364,7 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -396,9 +383,8 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_ExitPointShape, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_ExitPointShape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -407,10 +393,8 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -439,8 +423,8 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -448,8 +432,8 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -460,58 +444,46 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -533,13 +505,12 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -570,20 +541,20 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -591,15 +562,15 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -608,9 +579,9 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -619,10 +590,9 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -640,11 +610,11 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -656,8 +626,8 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -670,7 +640,7 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -696,14 +666,13 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -715,7 +684,7 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -737,15 +706,12 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -756,13 +722,10 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -781,15 +744,12 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -808,27 +768,24 @@ public class PseudostateExitPointStereotypeEditPart extends AbstractLabelEditPar @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateForkEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateForkEditPart.java index 83f3eb1360c..58ebf34fd03 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateForkEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateForkEditPart.java @@ -85,13 +85,10 @@ public class PseudostateForkEditPart extends RoundedCompartmentEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new CustomPseudostateForkJoinResizeEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies @@ -106,17 +103,17 @@ public class PseudostateForkEditPart extends RoundedCompartmentEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); + View childView = (View)child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if (vid != null) { - switch (vid) { + if(vid != null) { + switch(vid) { case PseudostateForkNameEditPart.VISUAL_ID: case PseudostateForkStereotypeEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -124,7 +121,7 @@ public class PseudostateForkEditPart extends RoundedCompartmentEditPart { } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { + if(result == null) { result = new NonResizableEditPolicy(); } return result; @@ -154,17 +151,16 @@ public class PseudostateForkEditPart extends RoundedCompartmentEditPart { * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View) getModel()).getChildren(); - if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if (modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View)getModel()).getChildren(); + if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if(modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); - } /** @@ -182,7 +178,7 @@ public class PseudostateForkEditPart extends RoundedCompartmentEditPart { */ @Override public RoundedCompartmentFigure getPrimaryShape() { - return (RoundedCompartmentFigure) primaryShape; + return (RoundedCompartmentFigure)primaryShape; } /** @@ -190,10 +186,10 @@ public class PseudostateForkEditPart extends RoundedCompartmentEditPart { */ @Override protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof PseudostateForkNameEditPart) { + if(borderItemEditPart instanceof PseudostateForkNameEditPart) { IBorderItemLocator locator = new RoundedRectangleLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else if (borderItemEditPart instanceof PseudostateForkStereotypeEditPart) { + } else if(borderItemEditPart instanceof PseudostateForkStereotypeEditPart) { IBorderItemLocator locator = new ExternalLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); } else { @@ -221,7 +217,6 @@ public class PseudostateForkEditPart extends RoundedCompartmentEditPart { @Override protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); - } /** @@ -242,7 +237,7 @@ public class PseudostateForkEditPart extends RoundedCompartmentEditPart { */ @Override public IFigure getContentPane() { - if (contentPane != null) { + if(contentPane != null) { return contentPane; } return super.getContentPane(); @@ -253,7 +248,7 @@ public class PseudostateForkEditPart extends RoundedCompartmentEditPart { */ @Override protected void setForegroundColor(Color color) { - if (primaryShape != null) { + if(primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -271,8 +266,8 @@ public class PseudostateForkEditPart extends RoundedCompartmentEditPart { */ @Override protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); + if(primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateForkNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateForkNameEditPart.java index bcea9acc9f1..5fbb2e0b01a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateForkNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateForkNameEditPart.java @@ -85,8 +85,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateForkNameEditPart extends FloatingLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class PseudostateForkNameEditPart extends FloatingLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -130,10 +129,7 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateForkNameEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateForkNameEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -160,9 +156,9 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -172,10 +168,10 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -183,12 +179,12 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -196,12 +192,12 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -209,12 +205,12 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -222,12 +218,12 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -285,11 +281,10 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -302,12 +297,12 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -316,11 +311,10 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -339,25 +333,22 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(ParserUtil.getParserAdapter( - getParserElement(), PseudostateForkNameEditPart.this), (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateForkNameEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -369,7 +360,7 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -388,7 +379,7 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart */ @Override public IParser getParser() { - if (parser == null) { + if(parser == null) { parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_ForkShape, getParserElement(), this, VISUAL_ID); } return parser; @@ -398,10 +389,8 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -430,8 +419,8 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -439,8 +428,8 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -451,58 +440,46 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -524,13 +501,12 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -561,20 +537,20 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -582,15 +558,15 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -599,9 +575,9 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -610,10 +586,9 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -631,11 +606,11 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -647,8 +622,8 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -661,7 +636,7 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -687,14 +662,13 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -706,7 +680,7 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -728,15 +702,12 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -747,13 +718,10 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -772,15 +740,12 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -799,27 +764,24 @@ public class PseudostateForkNameEditPart extends FloatingLabelEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateForkStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateForkStereotypeEditPart.java index e114b6d19f4..61710a2f7f2 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateForkStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateForkStereotypeEditPart.java @@ -87,8 +87,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -132,10 +131,7 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateForkStereotypeEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateForkStereotypeEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -153,8 +149,7 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart super.createDefaultEditPolicies(); installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeExternalNodeEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeExternalNodeEditPolicy()); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ExternalLabelPrimaryDragRoleEditPolicy()); } @@ -164,9 +159,9 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -176,10 +171,10 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -187,12 +182,12 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -200,12 +195,12 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -213,12 +208,12 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -226,12 +221,12 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -289,11 +284,10 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -306,12 +300,12 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -320,11 +314,10 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -343,28 +336,22 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult( - parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - PseudostateForkStereotypeEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateForkStereotypeEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -376,7 +363,7 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -395,7 +382,7 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart */ @Override public IParser getParser() { - if (parser == null) { + if(parser == null) { parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_ForkShape, getParserElement(), this, VISUAL_ID); } return parser; @@ -405,10 +392,8 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -437,8 +422,8 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -446,8 +431,8 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -458,58 +443,46 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -531,13 +504,12 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -568,20 +540,20 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -589,15 +561,15 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -606,9 +578,9 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -617,10 +589,9 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -638,11 +609,11 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -654,8 +625,8 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -668,7 +639,7 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -694,14 +665,13 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -713,7 +683,7 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -735,15 +705,12 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -754,13 +721,10 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -779,15 +743,12 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -806,27 +767,24 @@ public class PseudostateForkStereotypeEditPart extends AbstractLabelEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateInitialEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateInitialEditPart.java index 8b438b137e4..b9046c223e5 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateInitialEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateInitialEditPart.java @@ -84,13 +84,10 @@ public class PseudostateInitialEditPart extends RoundedCompartmentEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); @@ -104,17 +101,17 @@ public class PseudostateInitialEditPart extends RoundedCompartmentEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); + View childView = (View)child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if (vid != null) { - switch (vid) { + if(vid != null) { + switch(vid) { case PseudostateInitialFloatingLabelEditPart.VISUAL_ID: case PseudostateInitialStereotypeEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -122,7 +119,7 @@ public class PseudostateInitialEditPart extends RoundedCompartmentEditPart { } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { + if(result == null) { result = new NonResizableEditPolicy(); } return result; @@ -152,17 +149,16 @@ public class PseudostateInitialEditPart extends RoundedCompartmentEditPart { * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View) getModel()).getChildren(); - if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if (modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View)getModel()).getChildren(); + if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if(modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); - } /** @@ -180,7 +176,7 @@ public class PseudostateInitialEditPart extends RoundedCompartmentEditPart { */ @Override public RoundedCompartmentFigure getPrimaryShape() { - return (RoundedCompartmentFigure) primaryShape; + return (RoundedCompartmentFigure)primaryShape; } /** @@ -188,10 +184,10 @@ public class PseudostateInitialEditPart extends RoundedCompartmentEditPart { */ @Override protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof PseudostateInitialFloatingLabelEditPart) { + if(borderItemEditPart instanceof PseudostateInitialFloatingLabelEditPart) { IBorderItemLocator locator = new RoundedRectangleLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else if (borderItemEditPart instanceof PseudostateInitialStereotypeEditPart) { + } else if(borderItemEditPart instanceof PseudostateInitialStereotypeEditPart) { IBorderItemLocator locator = new ExternalLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); } else { @@ -219,7 +215,6 @@ public class PseudostateInitialEditPart extends RoundedCompartmentEditPart { @Override protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); - } /** @@ -240,7 +235,7 @@ public class PseudostateInitialEditPart extends RoundedCompartmentEditPart { */ @Override public IFigure getContentPane() { - if (contentPane != null) { + if(contentPane != null) { return contentPane; } return super.getContentPane(); @@ -251,7 +246,7 @@ public class PseudostateInitialEditPart extends RoundedCompartmentEditPart { */ @Override protected void setForegroundColor(Color color) { - if (primaryShape != null) { + if(primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -269,8 +264,8 @@ public class PseudostateInitialEditPart extends RoundedCompartmentEditPart { */ @Override protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); + if(primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateInitialFloatingLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateInitialFloatingLabelEditPart.java index 5047a124e68..f594c31cb9c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateInitialFloatingLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateInitialFloatingLabelEditPart.java @@ -85,8 +85,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -130,10 +129,7 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateInitialFloatingLabelEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateInitialFloatingLabelEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -160,9 +156,9 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -172,10 +168,10 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -183,12 +179,12 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -196,12 +192,12 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -209,12 +205,12 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -222,12 +218,12 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -285,11 +281,10 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -302,12 +297,12 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -316,11 +311,10 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -339,28 +333,22 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult( - parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - PseudostateInitialFloatingLabelEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateInitialFloatingLabelEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -372,7 +360,7 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -391,9 +379,8 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_InitialShape, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_InitialShape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -402,10 +389,8 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -434,8 +419,8 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -443,8 +428,8 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -455,58 +440,46 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -528,13 +501,12 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -565,20 +537,20 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -586,15 +558,15 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -603,9 +575,9 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -614,10 +586,9 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -635,11 +606,11 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -651,8 +622,8 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -665,7 +636,7 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -691,14 +662,13 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -710,7 +680,7 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -732,15 +702,12 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -751,13 +718,10 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -776,15 +740,12 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -803,27 +764,24 @@ public class PseudostateInitialFloatingLabelEditPart extends FloatingLabelEditPa @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateInitialStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateInitialStereotypeEditPart.java index f945e111bca..f132efca4ef 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateInitialStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateInitialStereotypeEditPart.java @@ -87,8 +87,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -132,10 +131,7 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateInitialStereotypeEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateInitialStereotypeEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -153,8 +149,7 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart super.createDefaultEditPolicies(); installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeExternalNodeEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeExternalNodeEditPolicy()); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ExternalLabelPrimaryDragRoleEditPolicy()); } @@ -164,9 +159,9 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -176,10 +171,10 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -187,12 +182,12 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -200,12 +195,12 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -213,12 +208,12 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -226,12 +221,12 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -289,11 +284,10 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -306,12 +300,12 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -320,11 +314,10 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -343,28 +336,22 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult( - parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - PseudostateInitialStereotypeEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateInitialStereotypeEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -376,7 +363,7 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -395,9 +382,8 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_InitialShape, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_InitialShape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -406,10 +392,8 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -438,8 +422,8 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -447,8 +431,8 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -459,58 +443,46 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -532,13 +504,12 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -569,20 +540,20 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -590,15 +561,15 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -607,9 +578,9 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -618,10 +589,9 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -639,11 +609,11 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -655,8 +625,8 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -669,7 +639,7 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -695,14 +665,13 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -714,7 +683,7 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -736,15 +705,12 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -755,13 +721,10 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -780,15 +743,12 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -807,27 +767,24 @@ public class PseudostateInitialStereotypeEditPart extends AbstractLabelEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJoinEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJoinEditPart.java index adb4b29cf65..c125a1c2c0d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJoinEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJoinEditPart.java @@ -85,13 +85,10 @@ public class PseudostateJoinEditPart extends RoundedCompartmentEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new CustomPseudostateForkJoinResizeEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies @@ -106,17 +103,17 @@ public class PseudostateJoinEditPart extends RoundedCompartmentEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); + View childView = (View)child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if (vid != null) { - switch (vid) { + if(vid != null) { + switch(vid) { case PseudostateJoinFloatingLabelEditPart.VISUAL_ID: case PseudostateJoinStereotypeEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -124,7 +121,7 @@ public class PseudostateJoinEditPart extends RoundedCompartmentEditPart { } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { + if(result == null) { result = new NonResizableEditPolicy(); } return result; @@ -154,17 +151,16 @@ public class PseudostateJoinEditPart extends RoundedCompartmentEditPart { * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View) getModel()).getChildren(); - if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if (modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View)getModel()).getChildren(); + if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if(modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); - } /** @@ -182,7 +178,7 @@ public class PseudostateJoinEditPart extends RoundedCompartmentEditPart { */ @Override public RoundedCompartmentFigure getPrimaryShape() { - return (RoundedCompartmentFigure) primaryShape; + return (RoundedCompartmentFigure)primaryShape; } /** @@ -190,10 +186,10 @@ public class PseudostateJoinEditPart extends RoundedCompartmentEditPart { */ @Override protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof PseudostateJoinFloatingLabelEditPart) { + if(borderItemEditPart instanceof PseudostateJoinFloatingLabelEditPart) { IBorderItemLocator locator = new RoundedRectangleLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else if (borderItemEditPart instanceof PseudostateJoinStereotypeEditPart) { + } else if(borderItemEditPart instanceof PseudostateJoinStereotypeEditPart) { IBorderItemLocator locator = new ExternalLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); } else { @@ -221,7 +217,6 @@ public class PseudostateJoinEditPart extends RoundedCompartmentEditPart { @Override protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); - } /** @@ -242,7 +237,7 @@ public class PseudostateJoinEditPart extends RoundedCompartmentEditPart { */ @Override public IFigure getContentPane() { - if (contentPane != null) { + if(contentPane != null) { return contentPane; } return super.getContentPane(); @@ -253,7 +248,7 @@ public class PseudostateJoinEditPart extends RoundedCompartmentEditPart { */ @Override protected void setForegroundColor(Color color) { - if (primaryShape != null) { + if(primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -271,8 +266,8 @@ public class PseudostateJoinEditPart extends RoundedCompartmentEditPart { */ @Override protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); + if(primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJoinFloatingLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJoinFloatingLabelEditPart.java index 20f19ba4ea0..161c903281e 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJoinFloatingLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJoinFloatingLabelEditPart.java @@ -85,8 +85,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -130,10 +129,7 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateJoinFloatingLabelEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateJoinFloatingLabelEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -160,9 +156,9 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -172,10 +168,10 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -183,12 +179,12 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -196,12 +192,12 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -209,12 +205,12 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -222,12 +218,12 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -285,11 +281,10 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -302,12 +297,12 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -316,11 +311,10 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -339,28 +333,22 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult( - parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - PseudostateJoinFloatingLabelEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateJoinFloatingLabelEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -372,7 +360,7 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -391,7 +379,7 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart */ @Override public IParser getParser() { - if (parser == null) { + if(parser == null) { parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_JoinShape, getParserElement(), this, VISUAL_ID); } return parser; @@ -401,10 +389,8 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -433,8 +419,8 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -442,8 +428,8 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -454,58 +440,46 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -527,13 +501,12 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -564,20 +537,20 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -585,15 +558,15 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -602,9 +575,9 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -613,10 +586,9 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -634,11 +606,11 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -650,8 +622,8 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -664,7 +636,7 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -690,14 +662,13 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -709,7 +680,7 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -731,15 +702,12 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -750,13 +718,10 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -775,15 +740,12 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -802,27 +764,24 @@ public class PseudostateJoinFloatingLabelEditPart extends FloatingLabelEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJoinStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJoinStereotypeEditPart.java index 1fd27eb35dc..99def223e6f 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJoinStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJoinStereotypeEditPart.java @@ -87,8 +87,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -132,10 +131,7 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateJoinStereotypeEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateJoinStereotypeEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -153,8 +149,7 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart super.createDefaultEditPolicies(); installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeExternalNodeEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeExternalNodeEditPolicy()); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ExternalLabelPrimaryDragRoleEditPolicy()); } @@ -164,9 +159,9 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -176,10 +171,10 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -187,12 +182,12 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -200,12 +195,12 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -213,12 +208,12 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -226,12 +221,12 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -289,11 +284,10 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -306,12 +300,12 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -320,11 +314,10 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -343,28 +336,22 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult( - parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - PseudostateJoinStereotypeEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateJoinStereotypeEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -376,7 +363,7 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -395,7 +382,7 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart */ @Override public IParser getParser() { - if (parser == null) { + if(parser == null) { parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_JoinShape, getParserElement(), this, VISUAL_ID); } return parser; @@ -405,10 +392,8 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -437,8 +422,8 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -446,8 +431,8 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -458,58 +443,46 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -531,13 +504,12 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -568,20 +540,20 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -589,15 +561,15 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -606,9 +578,9 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -617,10 +589,9 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -638,11 +609,11 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -654,8 +625,8 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -668,7 +639,7 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -694,14 +665,13 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -713,7 +683,7 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -735,15 +705,12 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -754,13 +721,10 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -779,15 +743,12 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -806,27 +767,24 @@ public class PseudostateJoinStereotypeEditPart extends AbstractLabelEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJunctionEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJunctionEditPart.java index 7cd029fad93..2debe3f1f2f 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJunctionEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJunctionEditPart.java @@ -84,13 +84,10 @@ public class PseudostateJunctionEditPart extends RoundedCompartmentEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); @@ -104,17 +101,17 @@ public class PseudostateJunctionEditPart extends RoundedCompartmentEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); + View childView = (View)child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if (vid != null) { - switch (vid) { + if(vid != null) { + switch(vid) { case PseudostateJunctionFloatingLabelEditPart.VISUAL_ID: case PseudostateJunctionStereotypeEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -122,7 +119,7 @@ public class PseudostateJunctionEditPart extends RoundedCompartmentEditPart { } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { + if(result == null) { result = new NonResizableEditPolicy(); } return result; @@ -152,17 +149,16 @@ public class PseudostateJunctionEditPart extends RoundedCompartmentEditPart { * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View) getModel()).getChildren(); - if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if (modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View)getModel()).getChildren(); + if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if(modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); - } /** @@ -180,7 +176,7 @@ public class PseudostateJunctionEditPart extends RoundedCompartmentEditPart { */ @Override public RoundedCompartmentFigure getPrimaryShape() { - return (RoundedCompartmentFigure) primaryShape; + return (RoundedCompartmentFigure)primaryShape; } /** @@ -188,10 +184,10 @@ public class PseudostateJunctionEditPart extends RoundedCompartmentEditPart { */ @Override protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof PseudostateJunctionFloatingLabelEditPart) { + if(borderItemEditPart instanceof PseudostateJunctionFloatingLabelEditPart) { IBorderItemLocator locator = new RoundedRectangleLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else if (borderItemEditPart instanceof PseudostateJunctionStereotypeEditPart) { + } else if(borderItemEditPart instanceof PseudostateJunctionStereotypeEditPart) { IBorderItemLocator locator = new ExternalLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); } else { @@ -219,7 +215,6 @@ public class PseudostateJunctionEditPart extends RoundedCompartmentEditPart { @Override protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); - } /** @@ -240,7 +235,7 @@ public class PseudostateJunctionEditPart extends RoundedCompartmentEditPart { */ @Override public IFigure getContentPane() { - if (contentPane != null) { + if(contentPane != null) { return contentPane; } return super.getContentPane(); @@ -251,7 +246,7 @@ public class PseudostateJunctionEditPart extends RoundedCompartmentEditPart { */ @Override protected void setForegroundColor(Color color) { - if (primaryShape != null) { + if(primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -269,8 +264,8 @@ public class PseudostateJunctionEditPart extends RoundedCompartmentEditPart { */ @Override protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); + if(primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJunctionFloatingLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJunctionFloatingLabelEditPart.java index d4cea36f0e2..abde25a4018 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJunctionFloatingLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJunctionFloatingLabelEditPart.java @@ -85,8 +85,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -130,10 +129,7 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateJunctionFloatingLabelEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateJunctionFloatingLabelEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -160,9 +156,9 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -172,10 +168,10 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -183,12 +179,12 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -196,12 +192,12 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -209,12 +205,12 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -222,12 +218,12 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -285,11 +281,10 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -302,12 +297,12 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -316,11 +311,10 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -339,27 +333,22 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - PseudostateJunctionFloatingLabelEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateJunctionFloatingLabelEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -371,7 +360,7 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -390,9 +379,8 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_JunctionShape, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_JunctionShape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -401,10 +389,8 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -433,8 +419,8 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -442,8 +428,8 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -454,58 +440,46 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -527,13 +501,12 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -564,20 +537,20 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -585,15 +558,15 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -602,9 +575,9 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -613,10 +586,9 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -634,11 +606,11 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -650,8 +622,8 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -664,7 +636,7 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -690,14 +662,13 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -709,7 +680,7 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -731,15 +702,12 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -750,13 +718,10 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -775,15 +740,12 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -802,27 +764,24 @@ public class PseudostateJunctionFloatingLabelEditPart extends FloatingLabelEditP @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJunctionStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJunctionStereotypeEditPart.java index 93636e8335c..29da133ae34 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJunctionStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateJunctionStereotypeEditPart.java @@ -87,8 +87,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -132,10 +131,7 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateJunctionStereotypeEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateJunctionStereotypeEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -153,8 +149,7 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart super.createDefaultEditPolicies(); installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeExternalNodeEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeExternalNodeEditPolicy()); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ExternalLabelPrimaryDragRoleEditPolicy()); } @@ -164,9 +159,9 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -176,10 +171,10 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -187,12 +182,12 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -200,12 +195,12 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -213,12 +208,12 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -226,12 +221,12 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -289,11 +284,10 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -306,12 +300,12 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -320,11 +314,10 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -343,28 +336,22 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult( - parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - PseudostateJunctionStereotypeEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateJunctionStereotypeEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -376,7 +363,7 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -395,9 +382,8 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_JunctionShape, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_JunctionShape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -406,10 +392,8 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -438,8 +422,8 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -447,8 +431,8 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -459,58 +443,46 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -532,13 +504,12 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -569,20 +540,20 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -590,15 +561,15 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -607,9 +578,9 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -618,10 +589,9 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -639,11 +609,11 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -655,8 +625,8 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -669,7 +639,7 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -695,14 +665,13 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -714,7 +683,7 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -736,15 +705,12 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -755,13 +721,10 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -780,15 +743,12 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -807,27 +767,24 @@ public class PseudostateJunctionStereotypeEditPart extends AbstractLabelEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateShallowHistoryEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateShallowHistoryEditPart.java index 87528aae759..036fd46181b 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateShallowHistoryEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateShallowHistoryEditPart.java @@ -84,13 +84,10 @@ public class PseudostateShallowHistoryEditPart extends RoundedCompartmentEditPar protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); @@ -104,17 +101,17 @@ public class PseudostateShallowHistoryEditPart extends RoundedCompartmentEditPar @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); + View childView = (View)child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if (vid != null) { - switch (vid) { + if(vid != null) { + switch(vid) { case PseudostateShallowHistoryFloatingLabelEditPart.VISUAL_ID: case PseudostateShallowHistoryStereotypeEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -122,7 +119,7 @@ public class PseudostateShallowHistoryEditPart extends RoundedCompartmentEditPar } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { + if(result == null) { result = new NonResizableEditPolicy(); } return result; @@ -152,17 +149,16 @@ public class PseudostateShallowHistoryEditPart extends RoundedCompartmentEditPar * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View) getModel()).getChildren(); - if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if (modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View)getModel()).getChildren(); + if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if(modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); - } /** @@ -180,7 +176,7 @@ public class PseudostateShallowHistoryEditPart extends RoundedCompartmentEditPar */ @Override public RoundedCompartmentFigure getPrimaryShape() { - return (RoundedCompartmentFigure) primaryShape; + return (RoundedCompartmentFigure)primaryShape; } /** @@ -188,10 +184,10 @@ public class PseudostateShallowHistoryEditPart extends RoundedCompartmentEditPar */ @Override protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof PseudostateShallowHistoryFloatingLabelEditPart) { + if(borderItemEditPart instanceof PseudostateShallowHistoryFloatingLabelEditPart) { IBorderItemLocator locator = new RoundedRectangleLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else if (borderItemEditPart instanceof PseudostateShallowHistoryStereotypeEditPart) { + } else if(borderItemEditPart instanceof PseudostateShallowHistoryStereotypeEditPart) { IBorderItemLocator locator = new ExternalLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); } else { @@ -219,7 +215,6 @@ public class PseudostateShallowHistoryEditPart extends RoundedCompartmentEditPar @Override protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); - } /** @@ -240,7 +235,7 @@ public class PseudostateShallowHistoryEditPart extends RoundedCompartmentEditPar */ @Override public IFigure getContentPane() { - if (contentPane != null) { + if(contentPane != null) { return contentPane; } return super.getContentPane(); @@ -251,7 +246,7 @@ public class PseudostateShallowHistoryEditPart extends RoundedCompartmentEditPar */ @Override protected void setForegroundColor(Color color) { - if (primaryShape != null) { + if(primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -269,8 +264,8 @@ public class PseudostateShallowHistoryEditPart extends RoundedCompartmentEditPar */ @Override protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); + if(primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); } } @@ -279,7 +274,6 @@ public class PseudostateShallowHistoryEditPart extends RoundedCompartmentEditPar */ @Override public EditPart getPrimaryChildEditPart() { - return getChildBySemanticHint( - UMLVisualIDRegistry.getType(PseudostateShallowHistoryFloatingLabelEditPart.VISUAL_ID)); + return getChildBySemanticHint(UMLVisualIDRegistry.getType(PseudostateShallowHistoryFloatingLabelEditPart.VISUAL_ID)); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateShallowHistoryFloatingLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateShallowHistoryFloatingLabelEditPart.java index c63d6f3e2cc..8fc19157d21 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateShallowHistoryFloatingLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateShallowHistoryFloatingLabelEditPart.java @@ -85,8 +85,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -130,10 +129,7 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateShallowHistoryFloatingLabelEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateShallowHistoryFloatingLabelEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -160,9 +156,9 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -172,10 +168,10 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -183,12 +179,12 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -196,12 +192,12 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -209,12 +205,12 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -222,12 +218,12 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -285,11 +281,10 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -302,12 +297,12 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -316,11 +311,10 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -339,27 +333,22 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - PseudostateShallowHistoryFloatingLabelEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateShallowHistoryFloatingLabelEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -371,7 +360,7 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -390,9 +379,8 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_ShallowHistoryShape, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_ShallowHistoryShape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -401,10 +389,8 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -433,8 +419,8 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -442,8 +428,8 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -454,58 +440,46 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -527,13 +501,12 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -564,20 +537,20 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -585,15 +558,15 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -602,9 +575,9 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -613,10 +586,9 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -634,11 +606,11 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -650,8 +622,8 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -664,7 +636,7 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -690,14 +662,13 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -709,7 +680,7 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -731,15 +702,12 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -750,13 +718,10 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -775,15 +740,12 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -802,27 +764,24 @@ public class PseudostateShallowHistoryFloatingLabelEditPart extends FloatingLabe @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateShallowHistoryStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateShallowHistoryStereotypeEditPart.java index 33764c47206..141382ec1cb 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateShallowHistoryStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateShallowHistoryStereotypeEditPart.java @@ -87,8 +87,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -132,10 +131,7 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateShallowHistoryStereotypeEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateShallowHistoryStereotypeEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -153,8 +149,7 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd super.createDefaultEditPolicies(); installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeExternalNodeEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeExternalNodeEditPolicy()); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ExternalLabelPrimaryDragRoleEditPolicy()); } @@ -164,9 +159,9 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -176,10 +171,10 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -187,12 +182,12 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -200,12 +195,12 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -213,12 +208,12 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -226,12 +221,12 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -289,11 +284,10 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -306,12 +300,12 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -320,11 +314,10 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -343,27 +336,22 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - PseudostateShallowHistoryStereotypeEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateShallowHistoryStereotypeEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -375,7 +363,7 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -394,9 +382,8 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_ShallowHistoryShape, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_ShallowHistoryShape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -405,10 +392,8 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -437,8 +422,8 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -446,8 +431,8 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -458,58 +443,46 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -531,13 +504,12 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -568,20 +540,20 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -589,15 +561,15 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -606,9 +578,9 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -617,10 +589,9 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -638,11 +609,11 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -654,8 +625,8 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -668,7 +639,7 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -694,14 +665,13 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -713,7 +683,7 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -735,15 +705,12 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -754,13 +721,10 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -779,15 +743,12 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -806,27 +767,24 @@ public class PseudostateShallowHistoryStereotypeEditPart extends AbstractLabelEd @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateTerminateEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateTerminateEditPart.java index efca7d4492f..90f31f06de5 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateTerminateEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateTerminateEditPart.java @@ -84,13 +84,10 @@ public class PseudostateTerminateEditPart extends RoundedCompartmentEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); @@ -104,17 +101,17 @@ public class PseudostateTerminateEditPart extends RoundedCompartmentEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); + View childView = (View)child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if (vid != null) { - switch (vid) { + if(vid != null) { + switch(vid) { case PseudostateTerminateFloatingLabelEditPart.VISUAL_ID: case PseudostateTerminateStereotypeEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -122,7 +119,7 @@ public class PseudostateTerminateEditPart extends RoundedCompartmentEditPart { } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { + if(result == null) { result = new NonResizableEditPolicy(); } return result; @@ -152,17 +149,16 @@ public class PseudostateTerminateEditPart extends RoundedCompartmentEditPart { * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View) getModel()).getChildren(); - if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if (modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View)getModel()).getChildren(); + if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if(modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); - } /** @@ -180,7 +176,7 @@ public class PseudostateTerminateEditPart extends RoundedCompartmentEditPart { */ @Override public RoundedCompartmentFigure getPrimaryShape() { - return (RoundedCompartmentFigure) primaryShape; + return (RoundedCompartmentFigure)primaryShape; } /** @@ -188,10 +184,10 @@ public class PseudostateTerminateEditPart extends RoundedCompartmentEditPart { */ @Override protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof PseudostateTerminateFloatingLabelEditPart) { + if(borderItemEditPart instanceof PseudostateTerminateFloatingLabelEditPart) { IBorderItemLocator locator = new RoundedRectangleLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else if (borderItemEditPart instanceof PseudostateTerminateStereotypeEditPart) { + } else if(borderItemEditPart instanceof PseudostateTerminateStereotypeEditPart) { IBorderItemLocator locator = new ExternalLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); } else { @@ -219,7 +215,6 @@ public class PseudostateTerminateEditPart extends RoundedCompartmentEditPart { @Override protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); - } /** @@ -240,7 +235,7 @@ public class PseudostateTerminateEditPart extends RoundedCompartmentEditPart { */ @Override public IFigure getContentPane() { - if (contentPane != null) { + if(contentPane != null) { return contentPane; } return super.getContentPane(); @@ -251,7 +246,7 @@ public class PseudostateTerminateEditPart extends RoundedCompartmentEditPart { */ @Override protected void setForegroundColor(Color color) { - if (primaryShape != null) { + if(primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -269,8 +264,8 @@ public class PseudostateTerminateEditPart extends RoundedCompartmentEditPart { */ @Override protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); + if(primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateTerminateFloatingLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateTerminateFloatingLabelEditPart.java index 82601ba841f..4603ed1b361 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateTerminateFloatingLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateTerminateFloatingLabelEditPart.java @@ -85,8 +85,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -130,10 +129,7 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateTerminateFloatingLabelEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateTerminateFloatingLabelEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -160,9 +156,9 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -172,10 +168,10 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -183,12 +179,12 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -196,12 +192,12 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -209,12 +205,12 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -222,12 +218,12 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -285,11 +281,10 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -302,12 +297,12 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -316,11 +311,10 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -339,27 +333,22 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - PseudostateTerminateFloatingLabelEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateTerminateFloatingLabelEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -371,7 +360,7 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -390,9 +379,8 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_TerminateShape, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_TerminateShape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -401,10 +389,8 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -433,8 +419,8 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -442,8 +428,8 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -454,58 +440,46 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -527,13 +501,12 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -564,20 +537,20 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -585,15 +558,15 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -602,9 +575,9 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -613,10 +586,9 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -634,11 +606,11 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -650,8 +622,8 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -664,7 +636,7 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -690,14 +662,13 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -709,7 +680,7 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -731,15 +702,12 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -750,13 +718,10 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -775,15 +740,12 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -802,27 +764,24 @@ public class PseudostateTerminateFloatingLabelEditPart extends FloatingLabelEdit @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateTerminateStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateTerminateStereotypeEditPart.java index a41ef1a8ef8..c48b2d7578c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateTerminateStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/PseudostateTerminateStereotypeEditPart.java @@ -87,8 +87,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -132,10 +131,7 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateTerminateStereotypeEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.PseudostateTerminateStereotypeEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -153,8 +149,7 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar super.createDefaultEditPolicies(); installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeExternalNodeEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeExternalNodeEditPolicy()); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ExternalLabelPrimaryDragRoleEditPolicy()); } @@ -164,9 +159,9 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -176,10 +171,10 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -187,12 +182,12 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -200,12 +195,12 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -213,12 +208,12 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -226,12 +221,12 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -289,11 +284,10 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -306,12 +300,12 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -320,11 +314,10 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -343,28 +336,22 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult( - parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - PseudostateTerminateStereotypeEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), PseudostateTerminateStereotypeEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -376,7 +363,7 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -395,9 +382,8 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar */ @Override public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_TerminateShape, getParserElement(), this, - VISUAL_ID); + if(parser == null) { + parser = ParserUtil.getParser(UMLElementTypes.Pseudostate_TerminateShape, getParserElement(), this, VISUAL_ID); } return parser; } @@ -406,10 +392,8 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -438,8 +422,8 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -447,8 +431,8 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -459,58 +443,46 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -532,13 +504,12 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -569,20 +540,20 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -590,15 +561,15 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -607,9 +578,9 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -618,10 +589,9 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -639,11 +609,11 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -655,8 +625,8 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -669,7 +639,7 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -695,14 +665,13 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -714,7 +683,7 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -736,15 +705,12 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -755,13 +721,10 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -780,15 +743,12 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -807,27 +767,24 @@ public class PseudostateTerminateStereotypeEditPart extends AbstractLabelEditPar @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/RegionCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/RegionCompartmentEditPart.java index f180a23156e..5e92a23490c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/RegionCompartmentEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/RegionCompartmentEditPart.java @@ -66,7 +66,7 @@ public class RegionCompartmentEditPart extends LinkLFShapeCompartmentEditPart { */ @Override public IFigure createFigure() { - ResizableCompartmentFigure result = (ResizableCompartmentFigure) super.createFigure(); + ResizableCompartmentFigure result = (ResizableCompartmentFigure)super.createFigure(); result.setTitleVisibility(false); return result; } @@ -83,7 +83,6 @@ public class RegionCompartmentEditPart extends LinkLFShapeCompartmentEditPart { installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.statemachine.edit.policies.RegionCompartmentCanonicalEditPolicy()); - installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CustomRegionCompartmentCreationEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomStateMachineDiagramDragDropEditPolicy()); @@ -95,7 +94,7 @@ public class RegionCompartmentEditPart extends LinkLFShapeCompartmentEditPart { */ @Override protected void setRatio(Double ratio) { - if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { + if(getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { super.setRatio(ratio); } } @@ -105,7 +104,6 @@ public class RegionCompartmentEditPart extends LinkLFShapeCompartmentEditPart { */ @Override public EditPart getTargetEditPart(Request request) { - return super.getTargetEditPart(request); } @@ -115,10 +113,7 @@ public class RegionCompartmentEditPart extends LinkLFShapeCompartmentEditPart { @Override protected void handleNotificationEvent(Notification notification) { Object feature = notification.getFeature(); - if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) - || NotationPackage.eINSTANCE.getSize_Height().equals(feature) - || NotationPackage.eINSTANCE.getLocation_X().equals(feature) - || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { + if(NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { refreshBounds(); } super.handleNotificationEvent(notification); @@ -128,13 +123,13 @@ public class RegionCompartmentEditPart extends LinkLFShapeCompartmentEditPart { * @generated */ protected void refreshBounds() { - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); Dimension size = new Dimension(width, height); - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); Point loc = new Point(x, y); - ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); + ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/RegionEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/RegionEditPart.java index 9999955554f..2ec82dd4368 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/RegionEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/RegionEditPart.java @@ -70,13 +70,10 @@ public class RegionEditPart extends NamedElementEditPart { protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(EditPolicy.COMPONENT_ROLE, new CustomRegionComponentEditPolicy()); - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, - new ShowHideCompartmentEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); } @@ -90,7 +87,7 @@ public class RegionEditPart extends NamedElementEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { + if(result == null) { result = new NonResizableEditPolicy(); } return result; @@ -117,7 +114,6 @@ public class RegionEditPart extends NamedElementEditPart { @Override protected void handleNotificationEvent(Notification event) { super.handleNotificationEvent(event); - } /** @@ -135,21 +131,19 @@ public class RegionEditPart extends NamedElementEditPart { */ @Override public RegionFigure getPrimaryShape() { - return (RegionFigure) primaryShape; + return (RegionFigure)primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - - if (childEditPart instanceof RegionCompartmentEditPart) { + if(childEditPart instanceof RegionCompartmentEditPart) { IFigure pane = getPrimaryShape().getRegionCompartmentFigure(); setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way - pane.add(((RegionCompartmentEditPart) childEditPart).getFigure()); + pane.add(((RegionCompartmentEditPart)childEditPart).getFigure()); return true; } - return false; } @@ -157,9 +151,9 @@ public class RegionEditPart extends NamedElementEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if (childEditPart instanceof RegionCompartmentEditPart) { + if(childEditPart instanceof RegionCompartmentEditPart) { IFigure pane = getPrimaryShape().getRegionCompartmentFigure(); - pane.remove(((RegionCompartmentEditPart) childEditPart).getFigure()); + pane.remove(((RegionCompartmentEditPart)childEditPart).getFigure()); return true; } return false; @@ -170,7 +164,7 @@ public class RegionEditPart extends NamedElementEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if (addFixedChild(childEditPart)) { + if(addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -181,7 +175,7 @@ public class RegionEditPart extends NamedElementEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if (removeFixedChild(childEditPart)) { + if(removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -192,7 +186,7 @@ public class RegionEditPart extends NamedElementEditPart { */ @Override protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if (editPart instanceof RegionCompartmentEditPart) { + if(editPart instanceof RegionCompartmentEditPart) { return getPrimaryShape().getRegionCompartmentFigure(); } return getContentPane(); @@ -218,7 +212,6 @@ public class RegionEditPart extends NamedElementEditPart { @Override protected NodeFigure createNodeFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); - } /** @@ -231,7 +224,7 @@ public class RegionEditPart extends NamedElementEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if (nodeShape.getLayoutManager() == null) { + if(nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -244,7 +237,7 @@ public class RegionEditPart extends NamedElementEditPart { */ @Override public IFigure getContentPane() { - if (contentPane != null) { + if(contentPane != null) { return contentPane; } return super.getContentPane(); @@ -255,7 +248,7 @@ public class RegionEditPart extends NamedElementEditPart { */ @Override protected void setForegroundColor(Color color) { - if (primaryShape != null) { + if(primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -273,8 +266,8 @@ public class RegionEditPart extends NamedElementEditPart { */ @Override protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); + if(primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); } } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateCompartmentEditPart.java index f713d2e3ac1..498a0843944 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateCompartmentEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateCompartmentEditPart.java @@ -67,7 +67,7 @@ public class StateCompartmentEditPart extends LinkLFShapeCompartmentEditPart { */ @Override public IFigure createFigure() { - ResizableCompartmentFigure result = (ResizableCompartmentFigure) super.createFigure(); + ResizableCompartmentFigure result = (ResizableCompartmentFigure)super.createFigure(); result.setTitleVisibility(false); return result; } @@ -84,7 +84,6 @@ public class StateCompartmentEditPart extends LinkLFShapeCompartmentEditPart { installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.statemachine.edit.policies.StateCompartmentCanonicalEditPolicy()); - installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicy.LAYOUT_ROLE, new CustomStateCompartmentXYLayoutEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomStateMachineDiagramDragDropEditPolicy()); @@ -97,7 +96,7 @@ public class StateCompartmentEditPart extends LinkLFShapeCompartmentEditPart { */ @Override protected void setRatio(Double ratio) { - if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { + if(getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { super.setRatio(ratio); } } @@ -107,7 +106,6 @@ public class StateCompartmentEditPart extends LinkLFShapeCompartmentEditPart { */ @Override public EditPart getTargetEditPart(Request request) { - return super.getTargetEditPart(request); } @@ -117,10 +115,7 @@ public class StateCompartmentEditPart extends LinkLFShapeCompartmentEditPart { @Override protected void handleNotificationEvent(Notification notification) { Object feature = notification.getFeature(); - if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) - || NotationPackage.eINSTANCE.getSize_Height().equals(feature) - || NotationPackage.eINSTANCE.getLocation_X().equals(feature) - || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { + if(NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { refreshBounds(); } super.handleNotificationEvent(notification); @@ -130,13 +125,13 @@ public class StateCompartmentEditPart extends LinkLFShapeCompartmentEditPart { * @generated */ protected void refreshBounds() { - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); Dimension size = new Dimension(width, height); - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); Point loc = new Point(x, y); - ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); + ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateEditPart.java index 361cae51ed6..084079020b2 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateEditPart.java @@ -96,24 +96,18 @@ public class StateEditPart extends RoundedCompartmentEditPart { installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy()); super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.statemachine.edit.policies.StateCanonicalEditPolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, new CustomStateLayoutEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomStateMachineDiagramDragDropEditPolicy()); - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, - new ShowHideCompartmentEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CustomStateCreationEditPolicy()); - installEditPolicy(AffixedNodeAlignmentEditPolicy.AFFIXED_CHILD_ALIGNMENT_ROLE, - new AffixedNodeAlignmentEditPolicy()); + installEditPolicy(AffixedNodeAlignmentEditPolicy.AFFIXED_CHILD_ALIGNMENT_ROLE, new AffixedNodeAlignmentEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, new GetChildLayoutEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); @@ -127,16 +121,16 @@ public class StateEditPart extends RoundedCompartmentEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); + View childView = (View)child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if (vid != null) { - switch (vid) { + if(vid != null) { + switch(vid) { case StateFloatingLabelEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @Override protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); + MoveHandle mh = new MoveHandle((GraphicalEditPart)getHost()); mh.setBorder(null); return Collections.singletonList(mh); } @@ -148,7 +142,7 @@ public class StateEditPart extends RoundedCompartmentEditPart { } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { + if(result == null) { result = new NonResizableEditPolicy(); } return result; @@ -178,17 +172,16 @@ public class StateEditPart extends RoundedCompartmentEditPart { * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! */ - if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + if(NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { Object notifier = event.getNotifier(); - List<?> modelChildren = ((View) getModel()).getChildren(); - if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { - if (modelChildren.contains(event.getNotifier())) { + List<?> modelChildren = ((View)getModel()).getChildren(); + if(false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if(modelChildren.contains(event.getNotifier())) { return; } } } super.handleNotificationEvent(event); - } /** @@ -206,49 +199,41 @@ public class StateEditPart extends RoundedCompartmentEditPart { */ @Override public StateFigure getPrimaryShape() { - return (StateFigure) primaryShape; + return (StateFigure)primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if (childEditPart instanceof StateNameEditPart) { - ((StateNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if(childEditPart instanceof StateNameEditPart) { + ((StateNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } - - if (childEditPart instanceof StateCompartmentEditPart) { + if(childEditPart instanceof StateCompartmentEditPart) { IFigure pane = getPrimaryShape().getStateCompartmentFigure(); setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way - pane.add(((StateCompartmentEditPart) childEditPart).getFigure()); + pane.add(((StateCompartmentEditPart)childEditPart).getFigure()); return true; } - //Papyrus Gencode :Affixed EntryExitPoints ConnectionPointReferences Locator - if (childEditPart instanceof PseudostateEntryPointEditPart) { + if(childEditPart instanceof PseudostateEntryPointEditPart) { IBorderItemLocator locator = new PortPositionLocator(getMainFigure(), PositionConstants.NONE); - getBorderedFigure().getBorderItemContainer() - .add(((PseudostateEntryPointEditPart) childEditPart).getFigure(), locator); + getBorderedFigure().getBorderItemContainer().add(((PseudostateEntryPointEditPart)childEditPart).getFigure(), locator); return true; } - //Papyrus Gencode :Affixed EntryExitPoints ConnectionPointReferences Locator - if (childEditPart instanceof PseudostateExitPointEditPart) { + if(childEditPart instanceof PseudostateExitPointEditPart) { IBorderItemLocator locator = new PortPositionLocator(getMainFigure(), PositionConstants.NONE); - getBorderedFigure().getBorderItemContainer().add(((PseudostateExitPointEditPart) childEditPart).getFigure(), - locator); + getBorderedFigure().getBorderItemContainer().add(((PseudostateExitPointEditPart)childEditPart).getFigure(), locator); return true; } - //Papyrus Gencode :Affixed EntryExitPoints ConnectionPointReferences Locator - if (childEditPart instanceof ConnectionPointReferenceEditPart) { + if(childEditPart instanceof ConnectionPointReferenceEditPart) { IBorderItemLocator locator = new PortPositionLocator(getMainFigure(), PositionConstants.NONE); - getBorderedFigure().getBorderItemContainer() - .add(((ConnectionPointReferenceEditPart) childEditPart).getFigure(), locator); + getBorderedFigure().getBorderItemContainer().add(((ConnectionPointReferenceEditPart)childEditPart).getFigure(), locator); return true; } - return false; } @@ -256,27 +241,24 @@ public class StateEditPart extends RoundedCompartmentEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if (childEditPart instanceof StateNameEditPart) { + if(childEditPart instanceof StateNameEditPart) { return true; } - if (childEditPart instanceof StateCompartmentEditPart) { + if(childEditPart instanceof StateCompartmentEditPart) { IFigure pane = getPrimaryShape().getStateCompartmentFigure(); - pane.remove(((StateCompartmentEditPart) childEditPart).getFigure()); + pane.remove(((StateCompartmentEditPart)childEditPart).getFigure()); return true; } - if (childEditPart instanceof PseudostateEntryPointEditPart) { - getBorderedFigure().getBorderItemContainer() - .remove(((PseudostateEntryPointEditPart) childEditPart).getFigure()); + if(childEditPart instanceof PseudostateEntryPointEditPart) { + getBorderedFigure().getBorderItemContainer().remove(((PseudostateEntryPointEditPart)childEditPart).getFigure()); return true; } - if (childEditPart instanceof PseudostateExitPointEditPart) { - getBorderedFigure().getBorderItemContainer() - .remove(((PseudostateExitPointEditPart) childEditPart).getFigure()); + if(childEditPart instanceof PseudostateExitPointEditPart) { + getBorderedFigure().getBorderItemContainer().remove(((PseudostateExitPointEditPart)childEditPart).getFigure()); return true; } - if (childEditPart instanceof ConnectionPointReferenceEditPart) { - getBorderedFigure().getBorderItemContainer() - .remove(((ConnectionPointReferenceEditPart) childEditPart).getFigure()); + if(childEditPart instanceof ConnectionPointReferenceEditPart) { + getBorderedFigure().getBorderItemContainer().remove(((ConnectionPointReferenceEditPart)childEditPart).getFigure()); return true; } return false; @@ -287,7 +269,7 @@ public class StateEditPart extends RoundedCompartmentEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if (addFixedChild(childEditPart)) { + if(addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -298,7 +280,7 @@ public class StateEditPart extends RoundedCompartmentEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if (removeFixedChild(childEditPart)) { + if(removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -309,10 +291,10 @@ public class StateEditPart extends RoundedCompartmentEditPart { */ @Override protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if (editPart instanceof StateCompartmentEditPart) { + if(editPart instanceof StateCompartmentEditPart) { return getPrimaryShape().getStateCompartmentFigure(); } - if (editPart instanceof IBorderItemEditPart) { + if(editPart instanceof IBorderItemEditPart) { return getBorderedFigure().getBorderItemContainer(); } return getContentPane(); @@ -323,7 +305,7 @@ public class StateEditPart extends RoundedCompartmentEditPart { */ @Override protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof StateFloatingLabelEditPart) { + if(borderItemEditPart instanceof StateFloatingLabelEditPart) { IBorderItemLocator locator = new RoundedRectangleLabelPositionLocator(getMainFigure()); borderItemContainer.add(borderItemEditPart.getFigure(), locator); } else { @@ -351,7 +333,6 @@ public class StateEditPart extends RoundedCompartmentEditPart { @Override protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); - } /** @@ -364,7 +345,7 @@ public class StateEditPart extends RoundedCompartmentEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if (nodeShape.getLayoutManager() == null) { + if(nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -377,7 +358,7 @@ public class StateEditPart extends RoundedCompartmentEditPart { */ @Override public IFigure getContentPane() { - if (contentPane != null) { + if(contentPane != null) { return contentPane; } return super.getContentPane(); @@ -388,7 +369,7 @@ public class StateEditPart extends RoundedCompartmentEditPart { */ @Override protected void setForegroundColor(Color color) { - if (primaryShape != null) { + if(primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -406,8 +387,8 @@ public class StateEditPart extends RoundedCompartmentEditPart { */ @Override protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); + if(primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateFloatingLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateFloatingLabelEditPart.java index ece2c30b632..3b4e245ea62 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateFloatingLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateFloatingLabelEditPart.java @@ -85,8 +85,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class StateFloatingLabelEditPart extends FloatingLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class StateFloatingLabelEditPart extends FloatingLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated @@ -130,10 +129,7 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.StateFloatingLabelEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.StateFloatingLabelEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -160,9 +156,9 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart @Override public IBorderItemLocator getBorderItemLocator() { IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { + if(parentFigure != null && parentFigure.getLayoutManager() != null) { Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; + return (IBorderItemLocator)constraint; } return null; } @@ -172,10 +168,10 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart */ @Override public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); } @@ -183,12 +179,12 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -196,12 +192,12 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -209,12 +205,12 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -222,12 +218,12 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -285,11 +281,10 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -302,12 +297,12 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -316,11 +311,10 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -339,25 +333,22 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(ParserUtil.getParserAdapter( - getParserElement(), StateFloatingLabelEditPart.this), (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), StateFloatingLabelEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -369,7 +360,7 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -388,7 +379,7 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart */ @Override public IParser getParser() { - if (parser == null) { + if(parser == null) { parser = ParserUtil.getParser(UMLElementTypes.State_Shape, getParserElement(), this, VISUAL_ID); } return parser; @@ -398,10 +389,8 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -430,8 +419,8 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -439,8 +428,8 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -451,58 +440,46 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -524,13 +501,12 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -561,20 +537,20 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -582,15 +558,15 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -599,9 +575,9 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -610,10 +586,9 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -631,11 +606,11 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -647,8 +622,8 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -661,7 +636,7 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -687,14 +662,13 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -706,7 +680,7 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -728,15 +702,12 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -747,13 +718,10 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -772,15 +740,12 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -799,27 +764,24 @@ public class StateFloatingLabelEditPart extends FloatingLabelEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateMachineCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateMachineCompartmentEditPart.java index af38e873dfa..64f4fd60bdc 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateMachineCompartmentEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateMachineCompartmentEditPart.java @@ -66,7 +66,7 @@ public class StateMachineCompartmentEditPart extends LinkLFShapeCompartmentEditP */ @Override public IFigure createFigure() { - ResizableCompartmentFigure result = (ResizableCompartmentFigure) super.createFigure(); + ResizableCompartmentFigure result = (ResizableCompartmentFigure)super.createFigure(); result.setTitleVisibility(false); return result; } @@ -83,7 +83,6 @@ public class StateMachineCompartmentEditPart extends LinkLFShapeCompartmentEditP installEditPolicy(PasteEditPolicy.PASTE_ROLE, new PasteEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.statemachine.edit.policies.StateMachineCompartmentCanonicalEditPolicy()); - installEditPolicy("RemoveOrphanView", new RemoveOrphanViewPolicy()); //$NON-NLS-1$ installEditPolicy(EditPolicy.LAYOUT_ROLE, new CustomStateMachineCompartmentXYLayoutEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomStateMachineDiagramDragDropEditPolicy()); @@ -95,7 +94,7 @@ public class StateMachineCompartmentEditPart extends LinkLFShapeCompartmentEditP */ @Override protected void setRatio(Double ratio) { - if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { + if(getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) { super.setRatio(ratio); } } @@ -105,7 +104,6 @@ public class StateMachineCompartmentEditPart extends LinkLFShapeCompartmentEditP */ @Override public EditPart getTargetEditPart(Request request) { - return super.getTargetEditPart(request); } @@ -115,10 +113,7 @@ public class StateMachineCompartmentEditPart extends LinkLFShapeCompartmentEditP @Override protected void handleNotificationEvent(Notification notification) { Object feature = notification.getFeature(); - if (NotationPackage.eINSTANCE.getSize_Width().equals(feature) - || NotationPackage.eINSTANCE.getSize_Height().equals(feature) - || NotationPackage.eINSTANCE.getLocation_X().equals(feature) - || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { + if(NotationPackage.eINSTANCE.getSize_Width().equals(feature) || NotationPackage.eINSTANCE.getSize_Height().equals(feature) || NotationPackage.eINSTANCE.getLocation_X().equals(feature) || NotationPackage.eINSTANCE.getLocation_Y().equals(feature)) { refreshBounds(); } super.handleNotificationEvent(notification); @@ -128,13 +123,13 @@ public class StateMachineCompartmentEditPart extends LinkLFShapeCompartmentEditP * @generated */ protected void refreshBounds() { - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + int width = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); Dimension size = new Dimension(width, height); - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + int x = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer)getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); Point loc = new Point(x, y); - ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); + ((GraphicalEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(loc, size)); } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateMachineEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateMachineEditPart.java index 2065649fec4..85a8cb878fa 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateMachineEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateMachineEditPart.java @@ -13,6 +13,8 @@ package org.eclipse.papyrus.uml.diagram.statemachine.edit.parts; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.PositionConstants; +import org.eclipse.draw2d.Shape; +import org.eclipse.draw2d.StackLayout; import org.eclipse.emf.common.notify.Notification; import org.eclipse.gef.EditPart; import org.eclipse.gef.EditPolicy; @@ -21,14 +23,19 @@ import org.eclipse.gef.commands.Command; import org.eclipse.gef.editpolicies.LayoutEditPolicy; import org.eclipse.gef.editpolicies.NonResizableEditPolicy; import org.eclipse.gef.requests.CreateRequest; +import org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator; import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout; +import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure; import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.gmf.tooling.runtime.edit.policies.reparent.CreationEditPolicyWithCustomReparent; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; @@ -42,6 +49,7 @@ import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeNode import org.eclipse.papyrus.uml.diagram.common.editpolicies.BorderItemResizableEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editpolicies.ShowHideCompartmentEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.SideAffixedNodesCreationEditPolicy; import org.eclipse.papyrus.uml.diagram.common.locator.PortPositionLocator; import org.eclipse.papyrus.uml.diagram.statemachine.custom.figures.StateMachineFigure; import org.eclipse.papyrus.uml.diagram.statemachine.custom.policies.CustomStateMachineDiagramDragDropEditPolicy; @@ -84,23 +92,18 @@ public class StateMachineEditPart extends RoundedCompartmentEditPart { installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy()); super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy()); //in Papyrus diagrams are not strongly synchronised //installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.statemachine.edit.policies.StateMachineCanonicalEditPolicy()); - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeNodeLabelDisplayEditPolicy()); - installEditPolicy(AffixedNodeAlignmentEditPolicy.AFFIXED_CHILD_ALIGNMENT_ROLE, - new AffixedNodeAlignmentEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeNodeLabelDisplayEditPolicy()); + installEditPolicy(AffixedNodeAlignmentEditPolicy.AFFIXED_CHILD_ALIGNMENT_ROLE, new AffixedNodeAlignmentEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, new CustomStateMachineLayoutEditPolicy()); installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new CustomStateMachineDiagramDragDropEditPolicy()); - installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, - new ShowHideCompartmentEditPolicy()); + installEditPolicy(ShowHideCompartmentEditPolicy.SHOW_HIDE_COMPARTMENT_POLICY, new ShowHideCompartmentEditPolicy()); + installEditPolicy(EditPolicyRoles.CREATION_ROLE, new SideAffixedNodesCreationEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); } @@ -113,17 +116,17 @@ public class StateMachineEditPart extends RoundedCompartmentEditPart { @Override protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); + View childView = (View)child.getModel(); String vid = UMLVisualIDRegistry.getVisualID(childView); - if (vid != null) { - switch (vid) { + if(vid != null) { + switch(vid) { case PseudostateEntryPointEditPart.VISUAL_ID: case PseudostateExitPointEditPart.VISUAL_ID: return new BorderItemResizableEditPolicy(); } } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { + if(result == null) { result = new NonResizableEditPolicy(); } return result; @@ -143,14 +146,11 @@ public class StateMachineEditPart extends RoundedCompartmentEditPart { } /** - * Papyrus codeGen - * - * @generated - **/ - @Override + *Papyrus codeGen + *@generated + **/ protected void handleNotificationEvent(Notification event) { super.handleNotificationEvent(event); - } /** @@ -168,41 +168,35 @@ public class StateMachineEditPart extends RoundedCompartmentEditPart { */ @Override public StateMachineFigure getPrimaryShape() { - return (StateMachineFigure) primaryShape; + return (StateMachineFigure)primaryShape; } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if (childEditPart instanceof StateMachineNameEditPart) { - ((StateMachineNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); + if(childEditPart instanceof StateMachineNameEditPart) { + ((StateMachineNameEditPart)childEditPart).setLabel(getPrimaryShape().getNameLabel()); return true; } - - if (childEditPart instanceof StateMachineCompartmentEditPart) { + if(childEditPart instanceof StateMachineCompartmentEditPart) { IFigure pane = getPrimaryShape().getStateMachineCompartmentFigure(); setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way - pane.add(((StateMachineCompartmentEditPart) childEditPart).getFigure()); + pane.add(((StateMachineCompartmentEditPart)childEditPart).getFigure()); return true; } - //Papyrus Gencode :Affixed EntryExitPoints ConnectionPointReferences Locator - if (childEditPart instanceof PseudostateEntryPointEditPart) { + if(childEditPart instanceof PseudostateEntryPointEditPart) { IBorderItemLocator locator = new PortPositionLocator(getMainFigure(), PositionConstants.NONE); - getBorderedFigure().getBorderItemContainer() - .add(((PseudostateEntryPointEditPart) childEditPart).getFigure(), locator); + getBorderedFigure().getBorderItemContainer().add(((PseudostateEntryPointEditPart)childEditPart).getFigure(), locator); return true; } - //Papyrus Gencode :Affixed EntryExitPoints ConnectionPointReferences Locator - if (childEditPart instanceof PseudostateExitPointEditPart) { + if(childEditPart instanceof PseudostateExitPointEditPart) { IBorderItemLocator locator = new PortPositionLocator(getMainFigure(), PositionConstants.NONE); - getBorderedFigure().getBorderItemContainer().add(((PseudostateExitPointEditPart) childEditPart).getFigure(), - locator); + getBorderedFigure().getBorderItemContainer().add(((PseudostateExitPointEditPart)childEditPart).getFigure(), locator); return true; } - return false; } @@ -210,22 +204,20 @@ public class StateMachineEditPart extends RoundedCompartmentEditPart { * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if (childEditPart instanceof StateMachineNameEditPart) { + if(childEditPart instanceof StateMachineNameEditPart) { return true; } - if (childEditPart instanceof StateMachineCompartmentEditPart) { + if(childEditPart instanceof StateMachineCompartmentEditPart) { IFigure pane = getPrimaryShape().getStateMachineCompartmentFigure(); - pane.remove(((StateMachineCompartmentEditPart) childEditPart).getFigure()); + pane.remove(((StateMachineCompartmentEditPart)childEditPart).getFigure()); return true; } - if (childEditPart instanceof PseudostateEntryPointEditPart) { - getBorderedFigure().getBorderItemContainer() - .remove(((PseudostateEntryPointEditPart) childEditPart).getFigure()); + if(childEditPart instanceof PseudostateEntryPointEditPart) { + getBorderedFigure().getBorderItemContainer().remove(((PseudostateEntryPointEditPart)childEditPart).getFigure()); return true; } - if (childEditPart instanceof PseudostateExitPointEditPart) { - getBorderedFigure().getBorderItemContainer() - .remove(((PseudostateExitPointEditPart) childEditPart).getFigure()); + if(childEditPart instanceof PseudostateExitPointEditPart) { + getBorderedFigure().getBorderItemContainer().remove(((PseudostateExitPointEditPart)childEditPart).getFigure()); return true; } return false; @@ -236,7 +228,7 @@ public class StateMachineEditPart extends RoundedCompartmentEditPart { */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if (addFixedChild(childEditPart)) { + if(addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -247,7 +239,7 @@ public class StateMachineEditPart extends RoundedCompartmentEditPart { */ @Override protected void removeChildVisual(EditPart childEditPart) { - if (removeFixedChild(childEditPart)) { + if(removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -258,10 +250,10 @@ public class StateMachineEditPart extends RoundedCompartmentEditPart { */ @Override protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if (editPart instanceof StateMachineCompartmentEditPart) { + if(editPart instanceof StateMachineCompartmentEditPart) { return getPrimaryShape().getStateMachineCompartmentFigure(); } - if (editPart instanceof IBorderItemEditPart) { + if(editPart instanceof IBorderItemEditPart) { return getBorderedFigure().getBorderItemContainer(); } return getContentPane(); @@ -287,7 +279,6 @@ public class StateMachineEditPart extends RoundedCompartmentEditPart { @Override protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); - } /** @@ -300,7 +291,7 @@ public class StateMachineEditPart extends RoundedCompartmentEditPart { */ @Override protected IFigure setupContentPane(IFigure nodeShape) { - if (nodeShape.getLayoutManager() == null) { + if(nodeShape.getLayoutManager() == null) { ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); layout.setSpacing(5); nodeShape.setLayoutManager(layout); @@ -313,7 +304,7 @@ public class StateMachineEditPart extends RoundedCompartmentEditPart { */ @Override public IFigure getContentPane() { - if (contentPane != null) { + if(contentPane != null) { return contentPane; } return super.getContentPane(); @@ -324,7 +315,7 @@ public class StateMachineEditPart extends RoundedCompartmentEditPart { */ @Override protected void setForegroundColor(Color color) { - if (primaryShape != null) { + if(primaryShape != null) { primaryShape.setForegroundColor(color); } } @@ -342,8 +333,8 @@ public class StateMachineEditPart extends RoundedCompartmentEditPart { */ @Override protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); + if(primaryShape instanceof IPapyrusNodeFigure) { + ((IPapyrusNodeFigure)primaryShape).setLineStyle(style); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateMachineNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateMachineNameEditPart.java index 3bced6b4e97..5bfa9170be9 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateMachineNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateMachineNameEditPart.java @@ -82,8 +82,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class StateMachineNameEditPart extends PapyrusCompartmentEditPart - implements ITextAwareEditPart, IControlParserForDirectEdit { +public class StateMachineNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated @@ -146,12 +145,12 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -159,12 +158,12 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -172,12 +171,12 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -185,12 +184,12 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -249,11 +248,10 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -266,12 +264,12 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -280,11 +278,10 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -303,25 +300,22 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(ParserUtil.getParserAdapter( - getParserElement(), StateMachineNameEditPart.this), (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), StateMachineNameEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -333,7 +327,7 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -352,7 +346,7 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart */ @Override public IParser getParser() { - if (parser == null) { + if(parser == null) { parser = ParserUtil.getParser(UMLElementTypes.StateMachine_Shape, getParserElement(), this, VISUAL_ID); } return parser; @@ -362,10 +356,8 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -394,8 +386,8 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -403,8 +395,8 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -415,58 +407,46 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -488,13 +468,12 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -525,12 +504,12 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { - View view = (View) getModel(); - if (view.isVisible()) { + if(maskLabelPolicy == null) { + View view = (View)getModel(); + if(view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -539,12 +518,12 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -552,15 +531,15 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -569,9 +548,9 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -580,10 +559,9 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -601,11 +579,11 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -617,8 +595,8 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -631,7 +609,7 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -657,14 +635,13 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -676,7 +653,7 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -698,15 +675,12 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -717,13 +691,10 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -742,15 +713,12 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -788,27 +756,24 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -845,8 +810,7 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); - + addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); } /** @@ -856,7 +820,6 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart public void deactivate() { removeOwnerElementListeners(); super.deactivate(); - } /** @@ -864,6 +827,5 @@ public class StateMachineNameEditPart extends PapyrusCompartmentEditPart */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); - } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateNameEditPart.java index f07388bb31e..9a6ece9dbf6 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/StateNameEditPart.java @@ -82,8 +82,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class StateNameEditPart extends PapyrusCompartmentEditPart - implements ITextAwareEditPart, IControlParserForDirectEdit { +public class StateNameEditPart extends PapyrusCompartmentEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated @@ -146,12 +145,12 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -159,12 +158,12 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -172,12 +171,12 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -185,12 +184,12 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -249,11 +248,10 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -266,12 +264,12 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -280,11 +278,10 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -303,26 +300,22 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), StateNameEditPart.this), - (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), StateNameEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -334,7 +327,7 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -353,7 +346,7 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart */ @Override public IParser getParser() { - if (parser == null) { + if(parser == null) { parser = ParserUtil.getParser(UMLElementTypes.State_Shape, getParserElement(), this, VISUAL_ID); } return parser; @@ -363,10 +356,8 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -395,8 +386,8 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -404,8 +395,8 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -416,58 +407,46 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -489,13 +468,12 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -526,12 +504,12 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { - View view = (View) getModel(); - if (view.isVisible()) { + if(maskLabelPolicy == null) { + View view = (View)getModel(); + if(view.isVisible()) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } else { @@ -540,12 +518,12 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart } } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -553,15 +531,15 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -570,9 +548,9 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -581,10 +559,9 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -602,11 +579,11 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -618,8 +595,8 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -632,7 +609,7 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -658,14 +635,13 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -677,7 +653,7 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -699,15 +675,12 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -718,13 +691,10 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -743,15 +713,12 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -789,27 +756,24 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart protected void handleNotificationEvent(Notification event) { refreshLabel(); Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); @@ -846,8 +810,7 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart * @generated */ protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); - + addListenerFilter(ADD_PARENT_MODEL, this, ((View)getParent().getModel())); } /** @@ -857,7 +820,6 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart public void deactivate() { removeOwnerElementListeners(); super.deactivate(); - } /** @@ -865,6 +827,5 @@ public class StateNameEditPart extends PapyrusCompartmentEditPart */ protected void removeOwnerElementListeners() { removeListenerFilter(ADD_PARENT_MODEL); - } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/TransitionEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/TransitionEditPart.java index 04636c1135b..96544f5673e 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/TransitionEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/TransitionEditPart.java @@ -47,16 +47,15 @@ public class TransitionEditPart extends UMLConnectionNodeEditPart implements ITr super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); installEditPolicy(QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY, new QualifiedNameDisplayEditPolicy()); - installEditPolicy(AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeLinkLabelDisplayEditPolicy()); + installEditPolicy(AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy()); } /** * @generated */ protected boolean addFixedChild(EditPart childEditPart) { - if (childEditPart instanceof TransitionStereotypeEditPart) { - ((TransitionStereotypeEditPart) childEditPart).setLabel(getPrimaryShape().getAppliedStereotypeLabel()); + if(childEditPart instanceof TransitionStereotypeEditPart) { + ((TransitionStereotypeEditPart)childEditPart).setLabel(getPrimaryShape().getAppliedStereotypeLabel()); } return false; } @@ -66,7 +65,7 @@ public class TransitionEditPart extends UMLConnectionNodeEditPart implements ITr */ @Override protected void addChildVisual(EditPart childEditPart, int index) { - if (addFixedChild(childEditPart)) { + if(addFixedChild(childEditPart)) { return; } super.addChildVisual(childEditPart, -1); @@ -76,7 +75,7 @@ public class TransitionEditPart extends UMLConnectionNodeEditPart implements ITr * @generated */ protected boolean removeFixedChild(EditPart childEditPart) { - if (childEditPart instanceof TransitionStereotypeEditPart) { + if(childEditPart instanceof TransitionStereotypeEditPart) { return true; } return false; @@ -87,7 +86,7 @@ public class TransitionEditPart extends UMLConnectionNodeEditPart implements ITr */ @Override protected void removeChildVisual(EditPart childEditPart) { - if (removeFixedChild(childEditPart)) { + if(removeFixedChild(childEditPart)) { return; } super.removeChildVisual(childEditPart); @@ -111,6 +110,6 @@ public class TransitionEditPart extends UMLConnectionNodeEditPart implements ITr */ @Override public TransitionFigure getPrimaryShape() { - return (TransitionFigure) getFigure(); + return (TransitionFigure)getFigure(); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/TransitionGuardEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/TransitionGuardEditPart.java index d2ea7fba9e1..3fdf559c22b 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/TransitionGuardEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/TransitionGuardEditPart.java @@ -84,8 +84,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class TransitionGuardEditPart extends PapyrusLabelEditPart - implements ITextAwareEditPart, IControlParserForDirectEdit { +public class TransitionGuardEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated @@ -129,10 +128,7 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.TransitionGuardEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.TransitionGuardEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -165,12 +161,12 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -178,12 +174,12 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -191,12 +187,12 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -204,12 +200,12 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -268,11 +264,10 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -285,12 +280,12 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -299,11 +294,10 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -322,25 +316,22 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(ParserUtil.getParserAdapter( - getParserElement(), TransitionGuardEditPart.this), (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), TransitionGuardEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -352,7 +343,7 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -371,7 +362,7 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart */ @Override public IParser getParser() { - if (parser == null) { + if(parser == null) { parser = ParserUtil.getParser(UMLElementTypes.Transition_Edge, getParserElement(), this, VISUAL_ID); } return parser; @@ -381,10 +372,8 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -413,8 +402,8 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -422,8 +411,8 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -434,58 +423,46 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -507,13 +484,12 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -544,20 +520,20 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -565,15 +541,15 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -582,9 +558,9 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -593,10 +569,9 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -614,11 +589,11 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -630,8 +605,8 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -644,7 +619,7 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -670,14 +645,13 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -689,7 +663,7 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -711,15 +685,12 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -730,13 +701,10 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -755,15 +723,12 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -782,34 +747,30 @@ public class TransitionGuardEditPart extends PapyrusLabelEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } - super.handleNotificationEvent(event); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/TransitionNameEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/TransitionNameEditPart.java index b102a872b3b..df65941c4df 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/TransitionNameEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/TransitionNameEditPart.java @@ -84,8 +84,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class TransitionNameEditPart extends PapyrusLabelEditPart - implements ITextAwareEditPart, IControlParserForDirectEdit { +public class TransitionNameEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated @@ -129,10 +128,7 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.TransitionNameEditPart.VISUAL_ID), - new Point(0, 0)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.TransitionNameEditPart.VISUAL_ID), new Point(0, 0)); } /** @@ -165,12 +161,12 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -178,12 +174,12 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -191,12 +187,12 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -204,12 +200,12 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -268,11 +264,10 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -285,12 +280,12 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -299,11 +294,10 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -322,25 +316,22 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString(ParserUtil.getParserAdapter( - getParserElement(), TransitionNameEditPart.this), (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), TransitionNameEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -352,7 +343,7 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -371,7 +362,7 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart */ @Override public IParser getParser() { - if (parser == null) { + if(parser == null) { parser = ParserUtil.getParser(UMLElementTypes.Transition_Edge, getParserElement(), this, VISUAL_ID); } return parser; @@ -381,10 +372,8 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -413,8 +402,8 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -422,8 +411,8 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -434,58 +423,46 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -507,13 +484,12 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -544,20 +520,20 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -565,15 +541,15 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -582,9 +558,9 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -593,10 +569,9 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -614,11 +589,11 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -630,8 +605,8 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -644,7 +619,7 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -670,14 +645,13 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart * @generated */ public int getDirectEditionType() { - if (checkExtendedEditor()) { + if(checkExtendedEditor()) { initExtendedEditorConfiguration(); return IDirectEdition.EXTENDED_DIRECT_EDITOR; } - if (checkDefaultEdition()) { + if(checkDefaultEdition()) { return IDirectEdition.DEFAULT_DIRECT_EDITOR; } - // not a named element. no specific editor => do nothing return IDirectEdition.NO_DIRECT_EDITION; } @@ -689,7 +663,7 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -711,15 +685,12 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -730,13 +701,10 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -755,15 +723,12 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -782,34 +747,30 @@ public class TransitionNameEditPart extends PapyrusLabelEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } - super.handleNotificationEvent(event); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/TransitionStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/TransitionStereotypeEditPart.java index 74e8f249c10..d49f6ad0c3c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/TransitionStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/TransitionStereotypeEditPart.java @@ -83,8 +83,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class TransitionStereotypeEditPart extends PapyrusLabelEditPart - implements ITextAwareEditPart, IControlParserForDirectEdit { +public class TransitionStereotypeEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IControlParserForDirectEdit { /** * @generated @@ -128,10 +127,7 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart * @generated */ static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.TransitionStereotypeEditPart.VISUAL_ID), - new Point(0, 60)); + registerSnapBackPosition(UMLVisualIDRegistry.getType(org.eclipse.papyrus.uml.diagram.statemachine.edit.parts.TransitionStereotypeEditPart.VISUAL_ID), new Point(0, 60)); } /** @@ -164,12 +160,12 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getText(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getText(); } else { - return ((Label) figure).getText(); + return ((Label)figure).getText(); } } @@ -177,12 +173,12 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setText(text); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setText(text); } else { - ((Label) figure).setText(text); + ((Label)figure).setText(text); } } @@ -190,12 +186,12 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); + if(figure instanceof WrappingLabel) { + return ((WrappingLabel)figure).getIcon(); + } else if(figure instanceof ILabelFigure) { + return ((ILabelFigure)figure).getIcon(); } else { - return ((Label) figure).getIcon(); + return ((Label)figure).getIcon(); } } @@ -203,12 +199,12 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); + if(figure instanceof WrappingLabel) { + ((WrappingLabel)figure).setIcon(icon); + } else if(figure instanceof ILabelFigure) { + ((ILabelFigure)figure).setIcon(icon); } else { - ((Label) figure).setIcon(icon); + ((Label)figure).setIcon(icon); } } @@ -267,11 +263,10 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart protected String getLabelText() { String text = null; EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + if(parserElement != null && getParser() != null) { + text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } - if (text == null || text.length() == 0) { + if(text == null || text.length() == 0) { text = defaultText; } return text; @@ -284,12 +279,12 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart public void setLabelText(String text) { setLabelTextHelper(getFigure(), text); Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -298,11 +293,10 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart */ @Override public String getEditText() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return ""; //$NON-NLS-1$ } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); + return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), getParserOptions().intValue()); } /** @@ -321,26 +315,22 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart @Override public String isValid(final Object value) { - if (value instanceof String) { + if(value instanceof String) { final EObject element = getParserElement(); final IParser parser = getParser(); try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult( - parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), - TransitionStereotypeEditPart.this), (String) value)); - } - }); + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { + + @Override + public void run() { + setResult(parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), TransitionStereotypeEditPart.this), (String)value)); + } + }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); } catch (InterruptedException ie) { ie.printStackTrace(); } } - // shouldn't get here return null; } @@ -352,7 +342,7 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart */ @Override public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { + if(getParserElement() == null || getParser() == null) { return null; } return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); @@ -371,7 +361,7 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart */ @Override public IParser getParser() { - if (parser == null) { + if(parser == null) { parser = ParserUtil.getParser(UMLElementTypes.Transition_Edge, getParserElement(), this, VISUAL_ID); } return parser; @@ -381,10 +371,8 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + if(manager == null) { + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); } return manager; } @@ -413,8 +401,8 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); } } @@ -422,8 +410,8 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); + if(getManager() instanceof TextDirectEditManager) { + ((TextDirectEditManager)getManager()).show(initialCharacter); } else { performDirectEdit(); } @@ -434,58 +422,46 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart */ @Override protected void performDirectEditRequest(Request request) { - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { + if(IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { directEditionMode = getDirectEditionType(); } - switch (directEditionMode) { + switch(directEditionMode) { case IDirectEdition.NO_DIRECT_EDITION: // no direct edition mode => does nothing return; case IDirectEdition.EXTENDED_DIRECT_EDITOR: updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { + if(configuration == null || configuration.getLanguage() == null) { // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); + setManager(new MultilineLabelDirectEditManager(this, MultilineLabelDirectEditManager.getTextCellEditorClass(this), UMLEditPartFactory.getTextCellEditorLocator(this))); performDefaultDirectEditorEdit(theRequest); } else { configuration.preEditAction(resolveSemanticElement()); Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); + if(configuration instanceof ICustomDirectEditorConfiguration) { + setManager(((ICustomDirectEditorConfiguration)configuration).createDirectEditManager(this)); initializeDirectEditManager(theRequest); return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); + } else if(configuration instanceof IPopupEditorConfiguration) { + IPopupEditorHelper helper = ((IPopupEditorConfiguration)configuration).createPopupEditorHelper(this); helper.showEditor(); return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); + } else if(configuration instanceof IAdvancedEditorConfiguration) { + dialog = ((IAdvancedEditorConfiguration)configuration).createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement())); + } else if(configuration instanceof IDirectEditorConfiguration) { + dialog = new ExtendedDirectEditionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), configuration.getTextToEdit(resolveSemanticElement()), configuration); } else { return; } final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { + if(Window.OK == dialog.open()) { TransactionalEditingDomain domain = getEditingDomain(); RecordingCommand command = new RecordingCommand(domain, "Edit Label") { @Override protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - + configuration.postEditAction(resolveSemanticElement(), ((ILabelEditorDialog)finalDialog).getValue()); } }; domain.getCommandStack().execute(command); @@ -507,13 +483,12 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart // initialize the direct edit manager try { getEditingDomain().runExclusive(new Runnable() { + @Override 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); + 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(); @@ -544,20 +519,20 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart */ protected void refreshLabel() { EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); } - if (maskLabelPolicy == null) { + if(maskLabelPolicy == null) { setLabelTextHelper(getFigure(), getLabelText()); setLabelIconHelper(getFigure(), getLabelIcon()); } Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); + if(pdEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); } Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); + if(sfEditPolicy instanceof UMLTextSelectionEditPolicy) { + ((UMLTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); } } @@ -565,15 +540,15 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); + if(resolveSemanticElement() instanceof Feature) { + if(((Feature)resolveSemanticElement()).isStatic()) { + ((WrappingLabel)getFigure()).setTextUnderline(true); } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); + ((WrappingLabel)getFigure()).setTextUnderline(false); } } } @@ -582,9 +557,9 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null && getFigure() instanceof WrappingLabel) { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); } } @@ -593,10 +568,9 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart */ @Override protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if(style != null) { + FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } } @@ -614,11 +588,11 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart */ @Override protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { + if(getParser() instanceof ISemanticParser) { EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ + parserElements = ((ISemanticParser)getParser()).getSemanticElementsBeingParsed(element); + for(int i = 0; i < parserElements.size(); i++) { + addListenerFilter("SemanticModel" + i, this, (EObject)parserElements.get(i)); //$NON-NLS-1$ } } else { super.addSemanticListeners(); @@ -630,8 +604,8 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart */ @Override protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { + if(parserElements != null) { + for(int i = 0; i < parserElements.size(); i++) { removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ } } else { @@ -644,7 +618,7 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart */ @Override protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { + if(accessibleEP == null) { accessibleEP = new AccessibleGraphicalEditPart() { @Override @@ -681,7 +655,7 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); } return false; @@ -703,15 +677,12 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); + if(configuration == null) { + final String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("")) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); + configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, resolveSemanticElement(), this); } } } @@ -722,13 +693,10 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart * @generated */ protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { + String languagePreferred = Activator.getDefault().getPreferenceStore().getString(IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); + if(languagePreferred != null && !languagePreferred.equals("") && !languagePreferred.equals(configuration.getLanguage())) { + configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), this); + } else if(IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { configuration = null; } } @@ -747,15 +715,12 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart @Override 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); + 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; + } else if((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; performDirectEdit(editRequest.getLocation()); } else { performDirectEdit(); @@ -774,34 +739,30 @@ public class TransitionStereotypeEditPart extends PapyrusLabelEditPart @Override protected void handleNotificationEvent(Notification event) { Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); + if(NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { + Integer c = (Integer)event.getNewValue(); setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { + } else if(NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { refreshFont(); } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { + if(getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { refreshLabel(); } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { + if(getParser() instanceof ISemanticParser) { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if(modelParser.areSemanticElementsAffected(null, event)) { removeSemanticListeners(); - if (resolveSemanticElement() != null) { + if(resolveSemanticElement() != null) { addSemanticListeners(); } refreshLabel(); } } } - super.handleNotificationEvent(event); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/UMLEditPartFactory.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/UMLEditPartFactory.java index 2798325f968..7a07903dbc0 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/UMLEditPartFactory.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/parts/UMLEditPartFactory.java @@ -35,205 +35,139 @@ public class UMLEditPartFactory implements EditPartFactory { */ @Override public EditPart createEditPart(EditPart context, Object model) { - if (model instanceof View) { - View view = (View) model; - switch (UMLVisualIDRegistry.getVisualID(view)) { - + if(model instanceof View) { + View view = (View)model; + switch(UMLVisualIDRegistry.getVisualID(view)) { case PackageEditPart.VISUAL_ID: return new PackageEditPart(view); - case StateMachineEditPart.VISUAL_ID: return new StateMachineEditPart(view); - case StateMachineNameEditPart.VISUAL_ID: return new StateMachineNameEditPart(view); - case RegionEditPart.VISUAL_ID: return new RegionEditPart(view); - case FinalStateEditPart.VISUAL_ID: return new FinalStateEditPart(view); - case FinalStateFloatingLabelEditPart.VISUAL_ID: return new FinalStateFloatingLabelEditPart(view); - case FinalStateStereotypeEditPart.VISUAL_ID: return new FinalStateStereotypeEditPart(view); - case StateEditPart.VISUAL_ID: return new StateEditPart(view); - case StateNameEditPart.VISUAL_ID: return new StateNameEditPart(view); - case StateFloatingLabelEditPart.VISUAL_ID: return new StateFloatingLabelEditPart(view); - case PseudostateInitialEditPart.VISUAL_ID: return new PseudostateInitialEditPart(view); - case PseudostateInitialFloatingLabelEditPart.VISUAL_ID: return new PseudostateInitialFloatingLabelEditPart(view); - case PseudostateInitialStereotypeEditPart.VISUAL_ID: return new PseudostateInitialStereotypeEditPart(view); - case PseudostateJoinEditPart.VISUAL_ID: return new PseudostateJoinEditPart(view); - case PseudostateJoinFloatingLabelEditPart.VISUAL_ID: return new PseudostateJoinFloatingLabelEditPart(view); - case PseudostateJoinStereotypeEditPart.VISUAL_ID: return new PseudostateJoinStereotypeEditPart(view); - case PseudostateForkEditPart.VISUAL_ID: return new PseudostateForkEditPart(view); - case PseudostateForkNameEditPart.VISUAL_ID: return new PseudostateForkNameEditPart(view); - case PseudostateForkStereotypeEditPart.VISUAL_ID: return new PseudostateForkStereotypeEditPart(view); - case PseudostateChoiceEditPart.VISUAL_ID: return new PseudostateChoiceEditPart(view); - case PseudostateChoiceFloatingLabelEditPart.VISUAL_ID: return new PseudostateChoiceFloatingLabelEditPart(view); - case PseudostateChoiceStereotypeEditPart.VISUAL_ID: return new PseudostateChoiceStereotypeEditPart(view); - case PseudostateJunctionEditPart.VISUAL_ID: return new PseudostateJunctionEditPart(view); - case PseudostateJunctionFloatingLabelEditPart.VISUAL_ID: return new PseudostateJunctionFloatingLabelEditPart(view); - case PseudostateJunctionStereotypeEditPart.VISUAL_ID: return new PseudostateJunctionStereotypeEditPart(view); - case PseudostateShallowHistoryEditPart.VISUAL_ID: return new PseudostateShallowHistoryEditPart(view); - case PseudostateShallowHistoryFloatingLabelEditPart.VISUAL_ID: return new PseudostateShallowHistoryFloatingLabelEditPart(view); - case PseudostateShallowHistoryStereotypeEditPart.VISUAL_ID: return new PseudostateShallowHistoryStereotypeEditPart(view); - case PseudostateDeepHistoryEditPart.VISUAL_ID: return new PseudostateDeepHistoryEditPart(view); - case PseudostateDeepHistoryFloatingLabelEditPart.VISUAL_ID: return new PseudostateDeepHistoryFloatingLabelEditPart(view); - case PseudostateDeepHistoryStereotypeEditPart.VISUAL_ID: return new PseudostateDeepHistoryStereotypeEditPart(view); - case PseudostateTerminateEditPart.VISUAL_ID: return new PseudostateTerminateEditPart(view); - case PseudostateTerminateFloatingLabelEditPart.VISUAL_ID: return new PseudostateTerminateFloatingLabelEditPart(view); - case PseudostateTerminateStereotypeEditPart.VISUAL_ID: return new PseudostateTerminateStereotypeEditPart(view); - case PseudostateEntryPointEditPart.VISUAL_ID: return new PseudostateEntryPointEditPart(view); - case PseudostateEntryPointFloatingLabelEditPart.VISUAL_ID: return new PseudostateEntryPointFloatingLabelEditPart(view); - case PseudostateEntryPointStereotypeEditPart.VISUAL_ID: return new PseudostateEntryPointStereotypeEditPart(view); - case PseudostateExitPointEditPart.VISUAL_ID: return new PseudostateExitPointEditPart(view); - case PseudostateExitPointFloatingLabelEditPart.VISUAL_ID: return new PseudostateExitPointFloatingLabelEditPart(view); - case PseudostateExitPointStereotypeEditPart.VISUAL_ID: return new PseudostateExitPointStereotypeEditPart(view); - case ConnectionPointReferenceEditPart.VISUAL_ID: return new ConnectionPointReferenceEditPart(view); - case ConnectionPointReferenceNameEditPart.VISUAL_ID: return new ConnectionPointReferenceNameEditPart(view); - case ConnectionPointReferenceStereotypeEditPart.VISUAL_ID: return new ConnectionPointReferenceStereotypeEditPart(view); - case CommentEditPart.VISUAL_ID: return new CommentEditPart(view); - case CommentBodyEditPart.VISUAL_ID: return new CommentBodyEditPart(view); - case ConstraintEditPart.VISUAL_ID: return new ConstraintEditPart(view); - case ConstraintNameLabelEditPart.VISUAL_ID: return new ConstraintNameLabelEditPart(view); - case ConstraintBodyEditPart.VISUAL_ID: return new ConstraintBodyEditPart(view); - case InternalTransitionEditPart.VISUAL_ID: return new InternalTransitionEditPart(view); - case EntryStateBehaviorEditPart.VISUAL_ID: return new EntryStateBehaviorEditPart(view); - case DoActivityStateBehaviorStateEditPart.VISUAL_ID: return new DoActivityStateBehaviorStateEditPart(view); - case ExitStateBehaviorEditPart.VISUAL_ID: return new ExitStateBehaviorEditPart(view); - case RegionCompartmentEditPart.VISUAL_ID: return new RegionCompartmentEditPart(view); - case StateMachineCompartmentEditPart.VISUAL_ID: return new StateMachineCompartmentEditPart(view); - case StateCompartmentEditPart.VISUAL_ID: return new StateCompartmentEditPart(view); - case TransitionEditPart.VISUAL_ID: return new TransitionEditPart(view); - case TransitionNameEditPart.VISUAL_ID: return new TransitionNameEditPart(view); - case TransitionGuardEditPart.VISUAL_ID: return new TransitionGuardEditPart(view); - case TransitionStereotypeEditPart.VISUAL_ID: return new TransitionStereotypeEditPart(view); - case GeneralizationEditPart.VISUAL_ID: return new GeneralizationEditPart(view); - case GeneralizationStereotypeEditPart.VISUAL_ID: return new GeneralizationStereotypeEditPart(view); - case CommentAnnotatedElementEditPart.VISUAL_ID: return new CommentAnnotatedElementEditPart(view); - case ConstraintConstrainedElementEditPart.VISUAL_ID: return new ConstraintConstrainedElementEditPart(view); - case ContextLinkEditPart.VISUAL_ID: return new ContextLinkEditPart(view); - case ContextLinkAppliedStereotypeEditPart.VISUAL_ID: return new ContextLinkAppliedStereotypeEditPart(view); - } } return createUnrecognizedEditPart(context, model); @@ -251,11 +185,10 @@ public class UMLEditPartFactory implements EditPartFactory { * @generated */ public static CellEditorLocator getTextCellEditorLocator(ITextAwareEditPart source) { - if (source.getFigure() instanceof IMultilineEditableFigure) { - return new MultilineCellEditorLocator((IMultilineEditableFigure) source.getFigure()); + if(source.getFigure() instanceof IMultilineEditableFigure) { + return new MultilineCellEditorLocator((IMultilineEditableFigure)source.getFigure()); } else { return CellEditorLocatorAccess.INSTANCE.getTextCellEditorLocator(source); - } } @@ -288,15 +221,15 @@ public class UMLEditPartFactory implements EditPartFactory { */ @Override public void relocate(CellEditor celleditor) { - Text text = (Text) celleditor.getControl(); + Text text = (Text)celleditor.getControl(); Rectangle rect = getMultilineEditableFigure().getBounds().getCopy(); rect.x = getMultilineEditableFigure().getEditionLocation().x; rect.y = getMultilineEditableFigure().getEditionLocation().y; getMultilineEditableFigure().translateToAbsolute(rect); - if (getMultilineEditableFigure().getText().length() > 0) { + if(getMultilineEditableFigure().getText().length() > 0) { rect.setSize(new Dimension(text.computeSize(rect.width, SWT.DEFAULT))); } - if (!rect.equals(new Rectangle(text.getBounds()))) { + if(!rect.equals(new Rectangle(text.getBounds()))) { text.setBounds(rect.x, rect.y, rect.width, rect.height); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/policies/OpenDiagramEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/policies/OpenDiagramEditPolicy.java index 78321f042e3..e2f3b5a6b75 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/policies/OpenDiagramEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/policies/OpenDiagramEditPolicy.java @@ -60,15 +60,15 @@ public class OpenDiagramEditPolicy extends OpenEditPolicy { @Override protected Command getOpenCommand(Request request) { EditPart targetEditPart = getTargetEditPart(request); - if (false == targetEditPart.getModel() instanceof View) { + if(false == targetEditPart.getModel() instanceof View) { return null; } - View view = (View) targetEditPart.getModel(); + View view = (View)targetEditPart.getModel(); Style link = view.getStyle(NotationPackage.eINSTANCE.getHintedDiagramLinkStyle()); - if (false == link instanceof HintedDiagramLinkStyle) { + if(false == link instanceof HintedDiagramLinkStyle) { return null; } - return new ICommandProxy(new OpenDiagramCommand((HintedDiagramLinkStyle) link)); + return new ICommandProxy(new OpenDiagramCommand((HintedDiagramLinkStyle)link)); } /** @@ -96,11 +96,10 @@ public class OpenDiagramEditPolicy extends OpenEditPolicy { * @generated */ @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException { + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { try { Diagram diagram = getDiagramToOpen(); - if (diagram == null) { + if(diagram == null) { diagram = intializeNewDiagram(); } URI uri = EcoreUtil.getURI(diagram); @@ -126,26 +125,25 @@ public class OpenDiagramEditPolicy extends OpenEditPolicy { */ protected Diagram intializeNewDiagram() throws ExecutionException { Diagram d = ViewService.createDiagram(getDiagramDomainElement(), getDiagramKind(), getPreferencesHint()); - if (d == null) { + if(d == null) { throw new ExecutionException("Can't create diagram of '" + getDiagramKind() + "' kind"); } diagramFacet.setDiagramLink(d); assert diagramFacet.eResource() != null; diagramFacet.eResource().getContents().add(d); EObject container = diagramFacet.eContainer(); - while (container instanceof View) { - ((View) container).persist(); + while(container instanceof View) { + ((View)container).persist(); container = container.eContainer(); } try { new WorkspaceModifyOperation() { - protected void execute(IProgressMonitor monitor) - throws CoreException, InvocationTargetException, InterruptedException { + + protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { try { - for (Iterator<?> it = diagramFacet.eResource().getResourceSet().getResources() - .iterator(); it.hasNext();) { - Resource nextResource = (Resource) it.next(); - if (nextResource.isLoaded() && !getEditingDomain().isReadOnly(nextResource)) { + for(Iterator<?> it = diagramFacet.eResource().getResourceSet().getResources().iterator(); it.hasNext();) { + Resource nextResource = (Resource)it.next(); + if(nextResource.isLoaded() && !getEditingDomain().isReadOnly(nextResource)) { nextResource.save(UMLDiagramEditorUtil.getSaveOptions()); } } @@ -167,7 +165,7 @@ public class OpenDiagramEditPolicy extends OpenEditPolicy { */ protected EObject getDiagramDomainElement() { // use same element as associated with EP - return ((View) diagramFacet.eContainer()).getElement(); + return ((View)diagramFacet.eContainer()).getElement(); } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/policies/UMLBaseItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/policies/UMLBaseItemSemanticEditPolicy.java index 40309e934a8..4d70e403b94 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/policies/UMLBaseItemSemanticEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/policies/UMLBaseItemSemanticEditPolicy.java @@ -105,10 +105,10 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { @Override @SuppressWarnings("unchecked") public Command getCommand(Request request) { - if (request instanceof ReconnectRequest) { - Object view = ((ReconnectRequest) request).getConnectionEditPart().getModel(); - if (view instanceof View) { - String id = UMLVisualIDRegistry.getVisualID((View) view); + if(request instanceof ReconnectRequest) { + Object view = ((ReconnectRequest)request).getConnectionEditPart().getModel(); + if(view instanceof View) { + String id = UMLVisualIDRegistry.getVisualID((View)view); request.getExtendedData().put(VISUAL_ID_KEY, id); request.getExtendedData().put(GRAPHICAL_RECONNECTED_EDGE, view); } @@ -122,7 +122,7 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { * @generated */ protected String getVisualID(IEditCommandRequest request) { - return (String) request.getParameter(VISUAL_ID_KEY); + return (String)request.getParameter(VISUAL_ID_KEY); } /** @@ -133,8 +133,8 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { IEditCommandRequest completedRequest = completeRequest(request); Command semanticCommand = getSemanticCommandSwitch(completedRequest); semanticCommand = getEditHelperCommand(completedRequest, semanticCommand); - if (completedRequest instanceof DestroyRequest) { - DestroyRequest destroyRequest = (DestroyRequest) completedRequest; + if(completedRequest instanceof DestroyRequest) { + DestroyRequest destroyRequest = (DestroyRequest)completedRequest; return shouldProceed(destroyRequest) ? addDeleteViewCommand(semanticCommand, destroyRequest) : null; } return semanticCommand; @@ -144,7 +144,7 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { * @generated */ protected Command addDeleteViewCommand(Command mainCommand, DestroyRequest completedRequest) { - Command deleteViewCommand = getGEFWrapper(new DeleteCommand(getEditingDomain(), (View) getHost().getModel())); + Command deleteViewCommand = getGEFWrapper(new DeleteCommand(getEditingDomain(), (View)getHost().getModel())); return mainCommand == null ? deleteViewCommand : mainCommand.chain(deleteViewCommand); } @@ -152,9 +152,8 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { * @generated */ private Command getEditHelperCommand(IEditCommandRequest request, Command editPolicyCommand) { - if (editPolicyCommand != null) { - ICommand command = editPolicyCommand instanceof ICommandProxy - ? ((ICommandProxy) editPolicyCommand).getICommand() : new CommandProxy(editPolicyCommand); + if(editPolicyCommand != null) { + ICommand command = editPolicyCommand instanceof ICommandProxy ? ((ICommandProxy)editPolicyCommand).getICommand() : new CommandProxy(editPolicyCommand); request.setParameter(GeneratedEditHelperBase.EDIT_POLICY_COMMAND, command); } IElementType requestContextElementType = getContextElementType(request); @@ -162,8 +161,8 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { ICommand command = requestContextElementType.getEditCommand(request); request.setParameter(GeneratedEditHelperBase.EDIT_POLICY_COMMAND, null); request.setParameter(GeneratedEditHelperBase.CONTEXT_ELEMENT_TYPE, null); - if (command != null) { - if (!(command instanceof CompositeTransactionalCommand)) { + if(command != null) { + if(!(command instanceof CompositeTransactionalCommand)) { command = new CompositeTransactionalCommand(getEditingDomain(), command.getLabel()).compose(command); } return new ICommandProxy(command); @@ -183,28 +182,28 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { * @generated */ protected Command getSemanticCommandSwitch(IEditCommandRequest req) { - if (req instanceof CreateRelationshipRequest) { - return getCreateRelationshipCommand((CreateRelationshipRequest) req); - } else if (req instanceof CreateElementRequest) { - return getCreateCommand((CreateElementRequest) req); - } else if (req instanceof ConfigureRequest) { - return getConfigureCommand((ConfigureRequest) req); - } else if (req instanceof DestroyElementRequest) { - return getDestroyElementCommand((DestroyElementRequest) req); - } else if (req instanceof DestroyReferenceRequest) { - return getDestroyReferenceCommand((DestroyReferenceRequest) req); - } else if (req instanceof DuplicateElementsRequest) { - return getDuplicateCommand((DuplicateElementsRequest) req); - } else if (req instanceof GetEditContextRequest) { - return getEditContextCommand((GetEditContextRequest) req); - } else if (req instanceof MoveRequest) { - return getMoveCommand((MoveRequest) req); - } else if (req instanceof ReorientReferenceRelationshipRequest) { - return getReorientReferenceRelationshipCommand((ReorientReferenceRelationshipRequest) req); - } else if (req instanceof ReorientRelationshipRequest) { - return getReorientRelationshipCommand((ReorientRelationshipRequest) req); - } else if (req instanceof SetRequest) { - return getSetCommand((SetRequest) req); + if(req instanceof CreateRelationshipRequest) { + return getCreateRelationshipCommand((CreateRelationshipRequest)req); + } else if(req instanceof CreateElementRequest) { + return getCreateCommand((CreateElementRequest)req); + } else if(req instanceof ConfigureRequest) { + return getConfigureCommand((ConfigureRequest)req); + } else if(req instanceof DestroyElementRequest) { + return getDestroyElementCommand((DestroyElementRequest)req); + } else if(req instanceof DestroyReferenceRequest) { + return getDestroyReferenceCommand((DestroyReferenceRequest)req); + } else if(req instanceof DuplicateElementsRequest) { + return getDuplicateCommand((DuplicateElementsRequest)req); + } else if(req instanceof GetEditContextRequest) { + return getEditContextCommand((GetEditContextRequest)req); + } else if(req instanceof MoveRequest) { + return getMoveCommand((MoveRequest)req); + } else if(req instanceof ReorientReferenceRelationshipRequest) { + return getReorientReferenceRelationshipCommand((ReorientReferenceRelationshipRequest)req); + } else if(req instanceof ReorientRelationshipRequest) { + return getReorientRelationshipCommand((ReorientRelationshipRequest)req); + } else if(req instanceof SetRequest) { + return getSetCommand((SetRequest)req); } return null; } @@ -228,11 +227,11 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { */ protected Command getCreateCommand(CreateElementRequest req) { IElementType requestElementType = req.getElementType(); - if (requestElementType instanceof IElementType) { + if(requestElementType instanceof IElementType) { IElementEditService commandProvider = ElementEditServiceUtils.getCommandProvider(req.getContainer()); - if (commandProvider != null) { + if(commandProvider != null) { ICommand command = commandProvider.getEditCommand(req); - if (command != null && command.canExecute()) { + if(command != null && command.canExecute()) { return new ICommandProxy(command); } } @@ -245,7 +244,7 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { */ protected Command getExtendedTypeCreationCommand(CreateElementRequest request, IElementType requestElementType) { IElementEditService provider = ElementEditServiceUtils.getCommandProvider(request.getContainer()); - if (provider == null) { + if(provider == null) { return UnexecutableCommand.INSTANCE; } // Retrieve create command from the Element Edit service @@ -256,10 +255,9 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { /** * @generated */ - protected Command getExtendedStartCreateRelationshipCommand(CreateElementRequest request, - IElementType requestElementType) { + protected Command getExtendedStartCreateRelationshipCommand(CreateElementRequest request, IElementType requestElementType) { IElementEditService provider = ElementEditServiceUtils.getCommandProvider(requestElementType); - if (provider == null) { + if(provider == null) { return UnexecutableCommand.INSTANCE; } // Retrieve create command from the Element Edit service @@ -270,10 +268,9 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { /** * @generated */ - protected Command getExtendedCompleteCreateRelationshipCommand(CreateElementRequest request, - IElementType requestElementType) { + protected Command getExtendedCompleteCreateRelationshipCommand(CreateElementRequest request, IElementType requestElementType) { IElementEditService provider = ElementEditServiceUtils.getCommandProvider(requestElementType); - if (provider == null) { + if(provider == null) { return UnexecutableCommand.INSTANCE; } // Retrieve create command from the Element Edit service @@ -322,11 +319,11 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { */ protected Command getMoveCommand(MoveRequest req) { EObject targetCEObject = req.getTargetContainer(); - if (targetCEObject != null) { + if(targetCEObject != null) { IElementEditService provider = ElementEditServiceUtils.getCommandProvider(targetCEObject); - if (provider != null) { + if(provider != null) { ICommand moveCommand = provider.getEditCommand(req); - if (moveCommand != null) { + if(moveCommand != null) { return new ICommandProxy(moveCommand); } } @@ -334,7 +331,6 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { } else { return getGEFWrapper(new MoveElementsCommand(req)); } - } /** @@ -364,7 +360,7 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { * @generated */ protected TransactionalEditingDomain getEditingDomain() { - return ((IGraphicalEditPart) getHost()).getEditingDomain(); + return ((IGraphicalEditPart)getHost()).getEditingDomain(); } /** @@ -374,10 +370,9 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { */ protected void addDestroyShortcutsCommand(ICompositeCommand cmd, View view) { assert view.getEAnnotation("Shortcut") == null; //$NON-NLS-1$ - for (Iterator<?> it = view.getDiagram().getChildren().iterator(); it.hasNext();) { - View nextView = (View) it.next(); - if (nextView.getEAnnotation("Shortcut") == null || !nextView.isSetElement() //$NON-NLS-1$ - || nextView.getElement() != view.getElement()) { + for(Iterator<?> it = view.getDiagram().getChildren().iterator(); it.hasNext();) { + View nextView = (View)it.next(); + if(nextView.getEAnnotation("Shortcut") == null || !nextView.isSetElement() || nextView.getElement() != view.getElement()) { //$NON-NLS-1$ continue; } cmd.add(new DeleteCommand(getEditingDomain(), nextView)); @@ -389,7 +384,7 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { */ public static LinkConstraints getLinkConstraints() { LinkConstraints cached = UMLDiagramEditorPlugin.getInstance().getLinkConstraints(); - if (cached == null) { + if(cached == null) { UMLDiagramEditorPlugin.getInstance().setLinkConstraints(cached = new LinkConstraints()); } return cached; @@ -424,12 +419,11 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { * @generated */ public boolean canCreateComment_AnnotatedElementEdge(Comment source, Element target) { - if (source != null) { - if (source.getAnnotatedElements().contains(target)) { + if(source != null) { + if(source.getAnnotatedElements().contains(target)) { return false; } } - return canExistComment_AnnotatedElementEdge(source, target); } @@ -437,12 +431,11 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { * @generated */ public boolean canCreateConstraint_ConstrainedElementEdge(Constraint source, Element target) { - if (source != null) { - if (source.getConstrainedElements().contains(target)) { + if(source != null) { + if(source.getConstrainedElements().contains(target)) { return false; } } - return canExistConstraint_ConstrainedElementEdge(source, target); } @@ -450,23 +443,21 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { * @generated */ public boolean canCreateConstraint_ContextEdge(Constraint source, Namespace target) { - if (source != null) { - if (source.getContext() != null) { + if(source != null) { + if(source.getContext() != null) { return false; } } - if (target != null && (target.getOwnedRules().contains(target))) { + if(target != null && (target.getOwnedRules().contains(target))) { return false; } - return canExistConstraint_ContextEdge(source, target); } /** * @generated */ - public boolean canExistTransition_Edge(Region container, Transition linkInstance, Vertex source, - Vertex target) { + public boolean canExistTransition_Edge(Region container, Transition linkInstance, Vertex source, Vertex target) { return true; } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/policies/UMLTextNonResizableEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/policies/UMLTextNonResizableEditPolicy.java index 3b2174f31a2..aad6a374c40 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/policies/UMLTextNonResizableEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/policies/UMLTextNonResizableEditPolicy.java @@ -54,9 +54,9 @@ public class UMLTextNonResizableEditPolicy extends NonResizableEditPolicyEx impl */ @Override protected void showPrimarySelection() { - if (getHostFigure() instanceof WrappingLabel) { - ((WrappingLabel) getHostFigure()).setSelected(true); - ((WrappingLabel) getHostFigure()).setFocus(true); + if(getHostFigure() instanceof WrappingLabel) { + ((WrappingLabel)getHostFigure()).setSelected(true); + ((WrappingLabel)getHostFigure()).setFocus(true); } else { showSelection(); showFocus(); @@ -68,9 +68,9 @@ public class UMLTextNonResizableEditPolicy extends NonResizableEditPolicyEx impl */ @Override protected void showSelection() { - if (getHostFigure() instanceof WrappingLabel) { - ((WrappingLabel) getHostFigure()).setSelected(true); - ((WrappingLabel) getHostFigure()).setFocus(false); + if(getHostFigure() instanceof WrappingLabel) { + ((WrappingLabel)getHostFigure()).setSelected(true); + ((WrappingLabel)getHostFigure()).setFocus(false); } else { hideSelection(); addFeedback(selectionFeedbackFigure = createSelectionFeedbackFigure()); @@ -85,11 +85,11 @@ public class UMLTextNonResizableEditPolicy extends NonResizableEditPolicyEx impl */ @Override protected void hideSelection() { - if (getHostFigure() instanceof WrappingLabel) { - ((WrappingLabel) getHostFigure()).setSelected(false); - ((WrappingLabel) getHostFigure()).setFocus(false); + if(getHostFigure() instanceof WrappingLabel) { + ((WrappingLabel)getHostFigure()).setSelected(false); + ((WrappingLabel)getHostFigure()).setFocus(false); } else { - if (selectionFeedbackFigure != null) { + if(selectionFeedbackFigure != null) { removeFeedback(selectionFeedbackFigure); getHostFigure().removeFigureListener(getHostPositionListener()); selectionFeedbackFigure = null; @@ -103,8 +103,8 @@ public class UMLTextNonResizableEditPolicy extends NonResizableEditPolicyEx impl */ @Override protected void showFocus() { - if (getHostFigure() instanceof WrappingLabel) { - ((WrappingLabel) getHostFigure()).setFocus(true); + if(getHostFigure() instanceof WrappingLabel) { + ((WrappingLabel)getHostFigure()).setFocus(true); } else { hideFocus(); addFeedback(focusFeedbackFigure = createFocusFeedbackFigure()); @@ -117,10 +117,10 @@ public class UMLTextNonResizableEditPolicy extends NonResizableEditPolicyEx impl */ @Override protected void hideFocus() { - if (getHostFigure() instanceof WrappingLabel) { - ((WrappingLabel) getHostFigure()).setFocus(false); + if(getHostFigure() instanceof WrappingLabel) { + ((WrappingLabel)getHostFigure()).setFocus(false); } else { - if (focusFeedbackFigure != null) { + if(focusFeedbackFigure != null) { removeFeedback(focusFeedbackFigure); focusFeedbackFigure = null; } @@ -132,8 +132,8 @@ public class UMLTextNonResizableEditPolicy extends NonResizableEditPolicyEx impl */ protected Rectangle getFeedbackBounds() { Rectangle bounds; - if (getHostFigure() instanceof Label) { - bounds = ((Label) getHostFigure()).getTextBounds(); + if(getHostFigure() instanceof Label) { + bounds = ((Label)getHostFigure()).getTextBounds(); bounds.intersect(getHostFigure().getBounds()); } else { bounds = getHostFigure().getBounds().getCopy(); @@ -147,7 +147,7 @@ public class UMLTextNonResizableEditPolicy extends NonResizableEditPolicyEx impl * @generated */ protected IFigure createSelectionFeedbackFigure() { - if (getHostFigure() instanceof Label) { + if(getHostFigure() instanceof Label) { Label feedbackFigure = new Label(); feedbackFigure.setOpaque(true); feedbackFigure.setBackgroundColor(ColorConstants.menuBackgroundSelected); @@ -177,7 +177,7 @@ public class UMLTextNonResizableEditPolicy extends NonResizableEditPolicyEx impl * @generated */ protected void updateLabel(Label target) { - Label source = (Label) getHostFigure(); + Label source = (Label)getHostFigure(); target.setText(source.getText()); target.setTextAlignment(source.getTextAlignment()); target.setFont(source.getFont()); @@ -187,9 +187,9 @@ public class UMLTextNonResizableEditPolicy extends NonResizableEditPolicyEx impl * @generated */ protected void refreshSelectionFeedback() { - if (selectionFeedbackFigure != null) { - if (selectionFeedbackFigure instanceof Label) { - updateLabel((Label) selectionFeedbackFigure); + if(selectionFeedbackFigure != null) { + if(selectionFeedbackFigure instanceof Label) { + updateLabel((Label)selectionFeedbackFigure); selectionFeedbackFigure.setBounds(getFeedbackBounds()); } else { selectionFeedbackFigure.setBounds(getFeedbackBounds().expand(5, 5)); @@ -201,7 +201,7 @@ public class UMLTextNonResizableEditPolicy extends NonResizableEditPolicyEx impl * @generated */ protected void refreshFocusFeedback() { - if (focusFeedbackFigure != null) { + if(focusFeedbackFigure != null) { focusFeedbackFigure.setBounds(getFeedbackBounds()); } } @@ -219,8 +219,9 @@ public class UMLTextNonResizableEditPolicy extends NonResizableEditPolicyEx impl * @generated */ private FigureListener getHostPositionListener() { - if (hostPositionListener == null) { + if(hostPositionListener == null) { hostPositionListener = new FigureListener() { + @Override public void figureMoved(IFigure source) { refreshFeedback(); @@ -235,7 +236,7 @@ public class UMLTextNonResizableEditPolicy extends NonResizableEditPolicyEx impl */ @Override protected List<?> createSelectionHandles() { - MoveHandle moveHandle = new MoveHandle((GraphicalEditPart) getHost()); + MoveHandle moveHandle = new MoveHandle((GraphicalEditPart)getHost()); moveHandle.setBorder(null); moveHandle.setDragTracker(new DragEditPartsTrackerEx(getHost())); return Collections.singletonList(moveHandle); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/policies/UMLTextSelectionEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/policies/UMLTextSelectionEditPolicy.java index 5f019e2fe7b..2391cde6f9e 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/policies/UMLTextSelectionEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/policies/UMLTextSelectionEditPolicy.java @@ -48,9 +48,9 @@ public class UMLTextSelectionEditPolicy extends SelectionEditPolicy implements I */ @Override protected void showPrimarySelection() { - if (getHostFigure() instanceof WrappingLabel) { - ((WrappingLabel) getHostFigure()).setSelected(true); - ((WrappingLabel) getHostFigure()).setFocus(true); + if(getHostFigure() instanceof WrappingLabel) { + ((WrappingLabel)getHostFigure()).setSelected(true); + ((WrappingLabel)getHostFigure()).setFocus(true); } else { showSelection(); showFocus(); @@ -62,9 +62,9 @@ public class UMLTextSelectionEditPolicy extends SelectionEditPolicy implements I */ @Override protected void showSelection() { - if (getHostFigure() instanceof WrappingLabel) { - ((WrappingLabel) getHostFigure()).setSelected(true); - ((WrappingLabel) getHostFigure()).setFocus(false); + if(getHostFigure() instanceof WrappingLabel) { + ((WrappingLabel)getHostFigure()).setSelected(true); + ((WrappingLabel)getHostFigure()).setFocus(false); } else { hideSelection(); addFeedback(selectionFeedbackFigure = createSelectionFeedbackFigure()); @@ -79,11 +79,11 @@ public class UMLTextSelectionEditPolicy extends SelectionEditPolicy implements I */ @Override protected void hideSelection() { - if (getHostFigure() instanceof WrappingLabel) { - ((WrappingLabel) getHostFigure()).setSelected(false); - ((WrappingLabel) getHostFigure()).setFocus(false); + if(getHostFigure() instanceof WrappingLabel) { + ((WrappingLabel)getHostFigure()).setSelected(false); + ((WrappingLabel)getHostFigure()).setFocus(false); } else { - if (selectionFeedbackFigure != null) { + if(selectionFeedbackFigure != null) { removeFeedback(selectionFeedbackFigure); getHostFigure().removeFigureListener(getHostPositionListener()); selectionFeedbackFigure = null; @@ -97,8 +97,8 @@ public class UMLTextSelectionEditPolicy extends SelectionEditPolicy implements I */ @Override protected void showFocus() { - if (getHostFigure() instanceof WrappingLabel) { - ((WrappingLabel) getHostFigure()).setFocus(true); + if(getHostFigure() instanceof WrappingLabel) { + ((WrappingLabel)getHostFigure()).setFocus(true); } else { hideFocus(); addFeedback(focusFeedbackFigure = createFocusFeedbackFigure()); @@ -111,10 +111,10 @@ public class UMLTextSelectionEditPolicy extends SelectionEditPolicy implements I */ @Override protected void hideFocus() { - if (getHostFigure() instanceof WrappingLabel) { - ((WrappingLabel) getHostFigure()).setFocus(false); + if(getHostFigure() instanceof WrappingLabel) { + ((WrappingLabel)getHostFigure()).setFocus(false); } else { - if (focusFeedbackFigure != null) { + if(focusFeedbackFigure != null) { removeFeedback(focusFeedbackFigure); focusFeedbackFigure = null; } @@ -126,8 +126,8 @@ public class UMLTextSelectionEditPolicy extends SelectionEditPolicy implements I */ protected Rectangle getFeedbackBounds() { Rectangle bounds; - if (getHostFigure() instanceof Label) { - bounds = ((Label) getHostFigure()).getTextBounds(); + if(getHostFigure() instanceof Label) { + bounds = ((Label)getHostFigure()).getTextBounds(); bounds.intersect(getHostFigure().getBounds()); } else { bounds = getHostFigure().getBounds().getCopy(); @@ -141,7 +141,7 @@ public class UMLTextSelectionEditPolicy extends SelectionEditPolicy implements I * @generated */ protected IFigure createSelectionFeedbackFigure() { - if (getHostFigure() instanceof Label) { + if(getHostFigure() instanceof Label) { Label feedbackFigure = new Label(); feedbackFigure.setOpaque(true); feedbackFigure.setBackgroundColor(ColorConstants.menuBackgroundSelected); @@ -171,7 +171,7 @@ public class UMLTextSelectionEditPolicy extends SelectionEditPolicy implements I * @generated */ protected void updateLabel(Label target) { - Label source = (Label) getHostFigure(); + Label source = (Label)getHostFigure(); target.setText(source.getText()); target.setTextAlignment(source.getTextAlignment()); target.setFont(source.getFont()); @@ -181,9 +181,9 @@ public class UMLTextSelectionEditPolicy extends SelectionEditPolicy implements I * @generated */ protected void refreshSelectionFeedback() { - if (selectionFeedbackFigure != null) { - if (selectionFeedbackFigure instanceof Label) { - updateLabel((Label) selectionFeedbackFigure); + if(selectionFeedbackFigure != null) { + if(selectionFeedbackFigure instanceof Label) { + updateLabel((Label)selectionFeedbackFigure); selectionFeedbackFigure.setBounds(getFeedbackBounds()); } else { selectionFeedbackFigure.setBounds(getFeedbackBounds().expand(5, 5)); @@ -195,7 +195,7 @@ public class UMLTextSelectionEditPolicy extends SelectionEditPolicy implements I * @generated */ protected void refreshFocusFeedback() { - if (focusFeedbackFigure != null) { + if(focusFeedbackFigure != null) { focusFeedbackFigure.setBounds(getFeedbackBounds()); } } @@ -213,8 +213,9 @@ public class UMLTextSelectionEditPolicy extends SelectionEditPolicy implements I * @generated */ private FigureListener getHostPositionListener() { - if (hostPositionListener == null) { + if(hostPositionListener == null) { hostPositionListener = new FigureListener() { + @Override public void figureMoved(IFigure source) { refreshFeedback(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/parsers/MessageFormatParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/parsers/MessageFormatParser.java index cb7b438bc79..f144063698f 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/parsers/MessageFormatParser.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/parsers/MessageFormatParser.java @@ -74,10 +74,10 @@ public class MessageFormatParser extends AbstractAttributeParser { * @generated */ protected String getDefaultPattern() { - if (defaultPattern == null) { + if(defaultPattern == null) { StringBuffer sb = new StringBuffer(); - for (int i = 0; i < features.length; i++) { - if (i > 0) { + for(int i = 0; i < features.length; i++) { + if(i > 0) { sb.append(' '); } sb.append('{'); @@ -111,7 +111,7 @@ public class MessageFormatParser extends AbstractAttributeParser { * @generated */ protected MessageFormat getViewProcessor() { - if (viewProcessor == null) { + if(viewProcessor == null) { viewProcessor = new MessageFormat(getViewPattern() == null ? getDefaultPattern() : getViewPattern()); } return viewProcessor; @@ -121,9 +121,8 @@ public class MessageFormatParser extends AbstractAttributeParser { * @generated */ protected MessageFormat getEditorProcessor() { - if (editorProcessor == null) { - editorProcessor = new MessageFormat( - getEditorPattern() == null ? getDefaultEditablePattern() : getEditorPattern()); + if(editorProcessor == null) { + editorProcessor = new MessageFormat(getEditorPattern() == null ? getDefaultEditablePattern() : getEditorPattern()); } return editorProcessor; } @@ -132,10 +131,10 @@ public class MessageFormatParser extends AbstractAttributeParser { * @generated */ protected String getDefaultEditablePattern() { - if (defaultEditablePattern == null) { + if(defaultEditablePattern == null) { StringBuffer sb = new StringBuffer(); - for (int i = 0; i < editableFeatures.length; i++) { - if (i > 0) { + for(int i = 0; i < editableFeatures.length; i++) { + if(i > 0) { sb.append(' '); } sb.append('{'); @@ -160,9 +159,8 @@ public class MessageFormatParser extends AbstractAttributeParser { * @generated */ protected MessageFormat getEditProcessor() { - if (editProcessor == null) { - editProcessor = new MessageFormat( - getEditPattern() == null ? getDefaultEditablePattern() : getEditPattern()); + if(editProcessor == null) { + editProcessor = new MessageFormat(getEditPattern() == null ? getDefaultEditablePattern() : getEditPattern()); } return editProcessor; } @@ -172,9 +170,8 @@ public class MessageFormatParser extends AbstractAttributeParser { */ @Override public String getEditString(IAdaptable adapter, int flags) { - EObject element = (EObject) adapter.getAdapter(EObject.class); - return getEditorProcessor().format(getEditableValues(element), new StringBuffer(), new FieldPosition(0)) - .toString(); + EObject element = (EObject)adapter.getAdapter(EObject.class); + return getEditorProcessor().format(getEditableValues(element), new StringBuffer(), new FieldPosition(0)).toString(); } /** @@ -184,9 +181,8 @@ public class MessageFormatParser extends AbstractAttributeParser { public IParserEditStatus isValidEditString(IAdaptable adapter, String editString) { ParsePosition pos = new ParsePosition(0); Object[] values = getEditProcessor().parse(editString, pos); - if (values == null) { - return new ParserEditStatus(UMLDiagramEditorPlugin.ID, IParserEditStatus.UNEDITABLE, - NLS.bind(Messages.MessageFormatParser_InvalidInputError, new Integer(pos.getErrorIndex()))); + if(values == null) { + return new ParserEditStatus(UMLDiagramEditorPlugin.ID, IParserEditStatus.UNEDITABLE, NLS.bind(Messages.MessageFormatParser_InvalidInputError, new Integer(pos.getErrorIndex()))); } return validateNewValues(values); } @@ -205,7 +201,7 @@ public class MessageFormatParser extends AbstractAttributeParser { */ @Override public String getPrintString(IAdaptable adapter, int flags) { - EObject element = (EObject) adapter.getAdapter(EObject.class); + EObject element = (EObject)adapter.getAdapter(EObject.class); return getViewProcessor().format(getValues(element), new StringBuffer(), new FieldPosition(0)).toString(); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/DiagramEditorContextMenuProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/DiagramEditorContextMenuProvider.java index 4bff9482771..fde8e3ae303 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/DiagramEditorContextMenuProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/DiagramEditorContextMenuProvider.java @@ -45,16 +45,14 @@ public class DiagramEditorContextMenuProvider extends DiagramContextMenuProvider public void buildContextMenu(final IMenuManager menu) { getViewer().flush(); try { - TransactionUtil.getEditingDomain((EObject) getViewer().getContents().getModel()) - .runExclusive(new Runnable() { + TransactionUtil.getEditingDomain((EObject)getViewer().getContents().getModel()).runExclusive(new Runnable() { - @Override - public void run() { - ContributionItemService.getInstance() - .contributeToPopupMenu(DiagramEditorContextMenuProvider.this, part); - menu.remove(ActionIds.ACTION_DELETE_FROM_MODEL); - } - }); + @Override + public void run() { + ContributionItemService.getInstance().contributeToPopupMenu(DiagramEditorContextMenuProvider.this, part); + menu.remove(ActionIds.ACTION_DELETE_FROM_MODEL); + } + }); } catch (Exception e) { UMLDiagramEditorPlugin.getInstance().logError("Error building context menu", e); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLCreationWizard.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLCreationWizard.java index 7a43066f4aa..f8d6b1bbf42 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLCreationWizard.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLCreationWizard.java @@ -103,8 +103,7 @@ public class UMLCreationWizard extends Wizard implements INewWizard { this.workbench = workbench; this.selection = selection; setWindowTitle(Messages.UMLCreationWizardTitle); - setDefaultPageImageDescriptor( - UMLDiagramEditorPlugin.getBundledImageDescriptor("icons/wizban/NewUMLWizard.gif")); //$NON-NLS-1$ + setDefaultPageImageDescriptor(UMLDiagramEditorPlugin.getBundledImageDescriptor("icons/wizban/NewUMLWizard.gif")); //$NON-NLS-1$ setNeedsProgressMonitor(true); } @@ -113,21 +112,18 @@ public class UMLCreationWizard extends Wizard implements INewWizard { */ @Override public void addPages() { - diagramModelFilePage = new UMLCreationWizardPage("DiagramModelFile", getSelection(), //$NON-NLS-1$ - "PapyrusUMLStateMachine_diagram"); //$NON-NLS-1$ + diagramModelFilePage = new UMLCreationWizardPage("DiagramModelFile", getSelection(), "PapyrusUMLStateMachine_diagram"); //$NON-NLS-1$ //$NON-NLS-2$ diagramModelFilePage.setTitle(Messages.UMLCreationWizard_DiagramModelFilePageTitle); diagramModelFilePage.setDescription(Messages.UMLCreationWizard_DiagramModelFilePageDescription); addPage(diagramModelFilePage); - domainModelFilePage = new UMLCreationWizardPage("DomainModelFile", getSelection(), "PapyrusUMLStateMachine") { //$NON-NLS-1$ //$NON-NLS-2$ @Override public void setVisible(boolean visible) { - if (visible) { + if(visible) { String fileName = diagramModelFilePage.getFileName(); fileName = fileName.substring(0, fileName.length() - ".PapyrusUMLStateMachine_diagram".length()); //$NON-NLS-1$ - setFileName(UMLDiagramEditorUtil.getUniqueFileName(getContainerFullPath(), fileName, - "PapyrusUMLStateMachine")); //$NON-NLS-1$ + setFileName(UMLDiagramEditorUtil.getUniqueFileName(getContainerFullPath(), fileName, "PapyrusUMLStateMachine")); //$NON-NLS-1$ } super.setVisible(visible); } @@ -146,14 +142,12 @@ public class UMLCreationWizard extends Wizard implements INewWizard { @Override protected void execute(IProgressMonitor monitor) throws CoreException, InterruptedException { - diagram = UMLDiagramEditorUtil.createDiagram(diagramModelFilePage.getURI(), - domainModelFilePage.getURI(), monitor); - if (isOpenNewlyCreatedDiagramEditor() && diagram != null) { + diagram = UMLDiagramEditorUtil.createDiagram(diagramModelFilePage.getURI(), domainModelFilePage.getURI(), monitor); + if(isOpenNewlyCreatedDiagramEditor() && diagram != null) { try { UMLDiagramEditorUtil.openDiagram(diagram); } catch (PartInitException e) { - ErrorDialog.openError(getContainer().getShell(), Messages.UMLCreationWizardOpenEditorError, - null, e.getStatus()); + ErrorDialog.openError(getContainer().getShell(), Messages.UMLCreationWizardOpenEditorError, null, e.getStatus()); } } } @@ -163,9 +157,8 @@ public class UMLCreationWizard extends Wizard implements INewWizard { } catch (InterruptedException e) { return false; } catch (InvocationTargetException e) { - if (e.getTargetException() instanceof CoreException) { - ErrorDialog.openError(getContainer().getShell(), Messages.UMLCreationWizardCreationError, null, - ((CoreException) e.getTargetException()).getStatus()); + if(e.getTargetException() instanceof CoreException) { + ErrorDialog.openError(getContainer().getShell(), Messages.UMLCreationWizardCreationError, null, ((CoreException)e.getTargetException()).getStatus()); } else { UMLDiagramEditorPlugin.getInstance().logError("Error creating diagram", e.getTargetException()); //$NON-NLS-1$ } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLCreationWizardPage.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLCreationWizardPage.java index 0ef4cd97c8a..b8fbebfb2d1 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLCreationWizardPage.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLCreationWizardPage.java @@ -58,11 +58,11 @@ public class UMLCreationWizardPage extends WizardNewFileCreationPage { */ protected IPath getFilePath() { IPath path = getContainerFullPath(); - if (path == null) { + if(path == null) { path = new Path(""); //$NON-NLS-1$ } String fileName = getFileName(); - if (fileName != null) { + if(fileName != null) { path = path.append(fileName); } return path; @@ -83,11 +83,11 @@ public class UMLCreationWizardPage extends WizardNewFileCreationPage { */ @Override protected boolean validatePage() { - if (!super.validatePage()) { + if(!super.validatePage()) { return false; } String extension = getExtension(); - if (extension != null && !getFilePath().toString().endsWith("." + extension)) { + if(extension != null && !getFilePath().toString().endsWith("." + extension)) { setErrorMessage(NLS.bind(Messages.UMLCreationWizardPageExtensionError, extension)); return false; } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramActionBarContributor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramActionBarContributor.java index 3ffada49a2d..9a3af4e0df0 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramActionBarContributor.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramActionBarContributor.java @@ -52,7 +52,7 @@ public class UMLDiagramActionBarContributor extends DiagramActionBarContributor fileMenu.remove("pageSetupAction"); //$NON-NLS-1$ IMenuManager editMenu = bars.getMenuManager().findMenuUsingPath(IWorkbenchActionConstants.M_EDIT); assert editMenu != null; - if (editMenu.find("validationGroup") == null) { //$NON-NLS-1$ + if(editMenu.find("validationGroup") == null) { //$NON-NLS-1$ editMenu.add(new GroupMarker("validationGroup")); //$NON-NLS-1$ } IAction validateAction = new ValidateAction(page); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramEditor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramEditor.java index 4dd36709785..4f12ba533c6 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramEditor.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramEditor.java @@ -102,17 +102,13 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh */ public UMLDiagramEditor(ServicesRegistry servicesRegistry, Diagram diagram) throws ServiceException { super(servicesRegistry, diagram); - // adds a listener to the palette service, which reacts to palette customizations PapyrusPaletteService.getInstance().addProviderChangeListener(this); - // Share the same editing provider editingDomain = servicesRegistry.getService(TransactionalEditingDomain.class); documentProvider = new GmfMultiDiagramDocumentProvider(editingDomain); - // overrides editing domain created by super constructor setDocumentProvider(documentProvider); - } /** @@ -129,7 +125,7 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh @Override protected PaletteRoot createPaletteRoot(PaletteRoot existingPaletteRoot) { PaletteRoot paletteRoot; - if (existingPaletteRoot == null) { + if(existingPaletteRoot == null) { paletteRoot = PapyrusPaletteService.getInstance().createPalette(this, getDefaultPaletteContent()); } else { PapyrusPaletteService.getInstance().updatePalette(existingPaletteRoot, this, getDefaultPaletteContent()); @@ -225,8 +221,7 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh @Override protected void configureGraphicalViewer() { super.configureGraphicalViewer(); - DiagramEditorContextMenuProvider provider = new DiagramEditorContextMenuProvider(this, - getDiagramGraphicalViewer()); + DiagramEditorContextMenuProvider provider = new DiagramEditorContextMenuProvider(this, getDiagramGraphicalViewer()); getDiagramGraphicalViewer().setContextMenu(provider); getSite().registerContextMenu(ActionIds.DIAGRAM_EDITOR_CONTEXT_MENU, provider, getDiagramGraphicalViewer()); } @@ -268,7 +263,7 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh * @generated */ protected OperationHistoryDirtyState getDirtyState() { - if (dirtyState == null) { + if(dirtyState == null) { dirtyState = OperationHistoryDirtyState.newInstance(getUndoContext(), getOperationHistory()); } return dirtyState; @@ -279,11 +274,10 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh */ @Override protected void setUndoContext(IUndoContext context) { - if (dirtyState != null) { + if(dirtyState != null) { dirtyState.dispose(); dirtyState = null; } - super.setUndoContext(context); } @@ -301,9 +295,8 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh @Override public void providerChanged(ProviderChangeEvent event) { // update the palette if the palette service has changed - if (PapyrusPaletteService.getInstance().equals(event.getSource())) { - PapyrusPaletteService.getInstance().updatePalette(getPaletteViewer().getPaletteRoot(), this, - getDefaultPaletteContent()); + if(PapyrusPaletteService.getInstance().equals(event.getSource())) { + PapyrusPaletteService.getInstance().updatePalette(getPaletteViewer().getPaletteRoot(), this, getDefaultPaletteContent()); } } @@ -315,12 +308,10 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh // remove palette service listener // remove preference listener PapyrusPaletteService.getInstance().removeProviderChangeListener(this); - - if (dirtyState != null) { + if(dirtyState != null) { dirtyState.dispose(); dirtyState = null; } - super.dispose(); } @@ -357,13 +348,10 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh @Override protected void configurePaletteViewer(PaletteViewer viewer) { super.configurePaletteViewer(viewer); - // customize menu... viewer.setContextMenu(new PapyrusPaletteContextMenuProvider(viewer)); - viewer.getKeyHandler().setParent(getPaletteKeyHandler()); viewer.getControl().addMouseListener(getPaletteMouseListener()); - // Add a transfer drag target listener that is supported on // palette template entries whose template is a creation tool. // This will enable drag and drop of the palette shape creation @@ -385,9 +373,7 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh * @return Palette Key Handler for the palette */ private KeyHandler getPaletteKeyHandler() { - - if (paletteKeyHandler == null) { - + if(paletteKeyHandler == null) { paletteKeyHandler = new KeyHandler() { /** @@ -402,27 +388,18 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh */ @Override public boolean keyReleased(KeyEvent event) { - - if (event.keyCode == SWT.Selection) { - + if(event.keyCode == SWT.Selection) { Tool tool = getPaletteViewer().getActiveTool().createTool(); - - if (toolSupportsAccessibility(tool)) { - + if(toolSupportsAccessibility(tool)) { tool.keyUp(event, getDiagramGraphicalViewer()); - // deactivate current selection getPaletteViewer().setActiveTool(null); - return true; } - } return super.keyReleased(event); } - }; - } return paletteKeyHandler; } @@ -431,9 +408,7 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh * @return Palette Mouse listener for the palette */ private MouseListener getPaletteMouseListener() { - - if (paletteMouseListener == null) { - + if(paletteMouseListener == null) { paletteMouseListener = new MouseListener() { /** @@ -451,13 +426,10 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh @Override public void mouseDoubleClick(MouseEvent e) { Tool tool = getPaletteViewer().getActiveTool().createTool(); - - if (toolSupportsAccessibility(tool)) { - + if(toolSupportsAccessibility(tool)) { tool.setViewer(getDiagramGraphicalViewer()); tool.setEditDomain(getDiagramGraphicalViewer().getEditDomain()); tool.mouseDoubleClick(e, getDiagramGraphicalViewer()); - // Current active tool should be deactivated, // but if it is down here it will get // reactivated deep in GEF palette code after @@ -475,18 +447,15 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh public void mouseUp(MouseEvent e) { // Deactivate current active tool here if a // double-click was handled. - if (clearActiveTool) { + if(clearActiveTool) { getPaletteViewer().setActiveTool(null); clearActiveTool = false; } - } }; - } return paletteMouseListener; } - }; } @@ -504,23 +473,20 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh @Override protected void initializeGraphicalViewer() { super.initializeGraphicalViewer(); - // Enable Drop - getDiagramGraphicalViewer().addDropTargetListener( - new DropTargetListener(getDiagramGraphicalViewer(), LocalSelectionTransfer.getTransfer()) { + getDiagramGraphicalViewer().addDropTargetListener(new DropTargetListener(getDiagramGraphicalViewer(), LocalSelectionTransfer.getTransfer()) { - @Override - protected Object getJavaObject(TransferData data) { - // It is usual for the transfer data not to be set because it is available locally - return LocalSelectionTransfer.getTransfer().getSelection(); - } - - @Override - protected TransactionalEditingDomain getTransactionalEditingDomain() { - return getEditingDomain(); - } - }); + @Override + protected Object getJavaObject(TransferData data) { + // It is usual for the transfer data not to be set because it is available locally + return LocalSelectionTransfer.getTransfer().getSelection(); + } + @Override + protected TransactionalEditingDomain getTransactionalEditingDomain() { + return getEditingDomain(); + } + }); } /** @@ -528,10 +494,10 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh */ @Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { - if (getSite().getPage().getActiveEditor() instanceof IMultiDiagramEditor) { - IMultiDiagramEditor editor = (IMultiDiagramEditor) getSite().getPage().getActiveEditor(); + if(getSite().getPage().getActiveEditor() instanceof IMultiDiagramEditor) { + IMultiDiagramEditor editor = (IMultiDiagramEditor)getSite().getPage().getActiveEditor(); // If not the active editor, ignore selection changed. - if (this.equals(editor.getActiveEditor())) { + if(this.equals(editor.getActiveEditor())) { updateActions(getSelectionActions()); super.selectionChanged(part, selection); } else { @@ -543,7 +509,7 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh // from // org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.selectionChanged(IWorkbenchPart, // ISelection) - if (part == this) { + if(part == this) { rebuildStatusLine(); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramEditorPlugin.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramEditorPlugin.java index 033e35ff6a9..ceef308b465 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramEditorPlugin.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramEditorPlugin.java @@ -96,11 +96,9 @@ public class UMLDiagramEditorPlugin extends AbstractUIPlugin { instance = this; myLogHelper = new LogHelper(this); PreferencesHint.registerPreferenceStore(DIAGRAM_PREFERENCES_HINT, getPreferenceStore()); - adapterFactory = org.eclipse.papyrus.infra.gmfdiag.common.Activator.getInstance() - .getItemProvidersAdapterFactory(); + adapterFactory = org.eclipse.papyrus.infra.gmfdiag.common.Activator.getInstance().getItemProvidersAdapterFactory(); DiagramPreferenceInitializer diagramPreferenceInitializer = new DiagramPreferenceInitializer(); diagramPreferenceInitializer.initializeDefaultPreferences(); - } /** @@ -143,8 +141,8 @@ public class UMLDiagramEditorPlugin extends AbstractUIPlugin { * @generated */ public ImageDescriptor getItemImageDescriptor(Object item) { - IItemLabelProvider labelProvider = (IItemLabelProvider) adapterFactory.adapt(item, IItemLabelProvider.class); - if (labelProvider != null) { + IItemLabelProvider labelProvider = (IItemLabelProvider)adapterFactory.adapt(item, IItemLabelProvider.class); + if(labelProvider != null) { return ExtendedImageRegistry.getInstance().getImageDescriptor(labelProvider.getImage(item)); } return null; @@ -175,9 +173,8 @@ public class UMLDiagramEditorPlugin extends AbstractUIPlugin { */ public static ImageDescriptor findImageDescriptor(String path) { final IPath p = new Path(path); - if (p.isAbsolute() && p.segmentCount() > 1) { - return AbstractUIPlugin.imageDescriptorFromPlugin(p.segment(0), - p.removeFirstSegments(1).makeAbsolute().toString()); + if(p.isAbsolute() && p.segmentCount() > 1) { + return AbstractUIPlugin.imageDescriptorFromPlugin(p.segment(0), p.removeFirstSegments(1).makeAbsolute().toString()); } else { return getBundledImageDescriptor(p.makeAbsolute().toString()); } @@ -194,7 +191,7 @@ public class UMLDiagramEditorPlugin extends AbstractUIPlugin { */ public Image getBundledImage(String path) { Image image = getImageRegistry().get(path); - if (image == null) { + if(image == null) { getImageRegistry().put(path, getBundledImageDescriptor(path)); image = getImageRegistry().get(path); } @@ -214,7 +211,7 @@ public class UMLDiagramEditorPlugin extends AbstractUIPlugin { * @generated */ public UMLDocumentProvider getDocumentProvider() { - if (documentProvider == null) { + if(documentProvider == null) { documentProvider = new UMLDocumentProvider(); } return documentProvider; diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramEditorUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramEditorUtil.java index 702ef996192..0eb565fb546 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramEditorUtil.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramEditorUtil.java @@ -85,9 +85,9 @@ public class UMLDiagramEditorUtil { public static boolean openDiagram(Resource diagram) throws PartInitException { String path = diagram.getURI().toPlatformString(true); IResource workspaceResource = ResourcesPlugin.getWorkspace().getRoot().findMember(new Path(path)); - if (workspaceResource instanceof IFile) { + if(workspaceResource instanceof IFile) { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - return null != page.openEditor(new FileEditorInput((IFile) workspaceResource), UMLDiagramEditor.ID); + return null != page.openEditor(new FileEditorInput((IFile)workspaceResource), UMLDiagramEditor.ID); } return false; } @@ -96,7 +96,7 @@ public class UMLDiagramEditorUtil { * @generated */ public static void setCharset(IFile file) { - if (file == null) { + if(file == null) { return; } try { @@ -110,8 +110,7 @@ public class UMLDiagramEditorUtil { * @generated */ public static String getUniqueFileName(IPath containerFullPath, String fileName, String extension) { - return DefaultDiagramEditorUtil.getUniqueFileName(containerFullPath, fileName, extension, - DefaultDiagramEditorUtil.EXISTS_IN_WORKSPACE); + return DefaultDiagramEditorUtil.getUniqueFileName(containerFullPath, fileName, extension, DefaultDiagramEditorUtil.EXISTS_IN_WORKSPACE); } /** @@ -122,7 +121,7 @@ public class UMLDiagramEditorUtil { public static void runWizard(Shell shell, Wizard wizard, String settingsKey) { IDialogSettings pluginDialogSettings = UMLDiagramEditorPlugin.getInstance().getDialogSettings(); IDialogSettings wizardDialogSettings = pluginDialogSettings.getSection(settingsKey); - if (wizardDialogSettings == null) { + if(wizardDialogSettings == null) { wizardDialogSettings = pluginDialogSettings.addNewSection(settingsKey); } wizard.setDialogSettings(wizardDialogSettings); @@ -143,37 +142,29 @@ public class UMLDiagramEditorUtil { final Resource diagramResource = editingDomain.getResourceSet().createResource(diagramURI); final Resource modelResource = editingDomain.getResourceSet().createResource(modelURI); final String diagramName = diagramURI.lastSegment(); - AbstractTransactionalCommand command = new AbstractTransactionalCommand(editingDomain, - Messages.UMLDiagramEditorUtil_CreateDiagramCommandLabel, Collections.EMPTY_LIST) { + AbstractTransactionalCommand command = new AbstractTransactionalCommand(editingDomain, Messages.UMLDiagramEditorUtil_CreateDiagramCommandLabel, Collections.EMPTY_LIST) { + @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException { + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { Package model = createInitialModel(); attachModelToResource(model, modelResource); - - Diagram diagram = ViewService.createDiagram(model, PackageEditPart.MODEL_ID, - UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT); - if (diagram != null) { + Diagram diagram = ViewService.createDiagram(model, PackageEditPart.MODEL_ID, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT); + if(diagram != null) { diagramResource.getContents().add(diagram); diagram.setName(diagramName); diagram.setElement(model); } - try { - modelResource.save( - org.eclipse.papyrus.uml.diagram.statemachine.part.UMLDiagramEditorUtil.getSaveOptions()); - diagramResource.save( - org.eclipse.papyrus.uml.diagram.statemachine.part.UMLDiagramEditorUtil.getSaveOptions()); + modelResource.save(org.eclipse.papyrus.uml.diagram.statemachine.part.UMLDiagramEditorUtil.getSaveOptions()); + diagramResource.save(org.eclipse.papyrus.uml.diagram.statemachine.part.UMLDiagramEditorUtil.getSaveOptions()); } catch (IOException e) { - UMLDiagramEditorPlugin.getInstance().logError("Unable to store model and diagram resources", e); //$NON-NLS-1$ } return CommandResult.newOKCommandResult(); } }; try { - OperationHistoryFactory.getOperationHistory().execute(command, new SubProgressMonitor(progressMonitor, 1), - null); + OperationHistoryFactory.getOperationHistory().execute(command, new SubProgressMonitor(progressMonitor, 1), null); } catch (ExecutionException e) { UMLDiagramEditorPlugin.getInstance().logError("Unable to create model and diagram", e); //$NON-NLS-1$ } @@ -207,56 +198,49 @@ public class UMLDiagramEditorUtil { */ public static void selectElementsInDiagram(IDiagramWorkbenchPart diagramPart, List<EditPart> editParts) { diagramPart.getDiagramGraphicalViewer().deselectAll(); - EditPart firstPrimary = null; - for (EditPart nextPart : editParts) { + for(EditPart nextPart : editParts) { diagramPart.getDiagramGraphicalViewer().appendSelection(nextPart); - if (firstPrimary == null && nextPart instanceof IPrimaryEditPart) { + if(firstPrimary == null && nextPart instanceof IPrimaryEditPart) { firstPrimary = nextPart; } } - - if (!editParts.isEmpty()) { - diagramPart.getDiagramGraphicalViewer() - .reveal(firstPrimary != null ? firstPrimary : (EditPart) editParts.get(0)); + if(!editParts.isEmpty()) { + diagramPart.getDiagramGraphicalViewer().reveal(firstPrimary != null ? firstPrimary : (EditPart)editParts.get(0)); } } /** * @generated */ - private static int findElementsInDiagramByID(DiagramEditPart diagramPart, EObject element, - List<EditPart> editPartCollector) { - IDiagramGraphicalViewer viewer = (IDiagramGraphicalViewer) diagramPart.getViewer(); + private static int findElementsInDiagramByID(DiagramEditPart diagramPart, EObject element, List<EditPart> editPartCollector) { + IDiagramGraphicalViewer viewer = (IDiagramGraphicalViewer)diagramPart.getViewer(); final int intialNumOfEditParts = editPartCollector.size(); - - if (element instanceof View) { // support notation element lookup - EditPart editPart = (EditPart) viewer.getEditPartRegistry().get(element); - if (editPart != null) { + if(element instanceof View) { // support notation element lookup + EditPart editPart = (EditPart)viewer.getEditPartRegistry().get(element); + if(editPart != null) { editPartCollector.add(editPart); return 1; } } - String elementID = EMFCoreUtil.getProxyID(element); @SuppressWarnings("unchecked") List<EditPart> associatedParts = viewer.findEditPartsForElement(elementID, IGraphicalEditPart.class); // perform the possible hierarchy disjoint -> take the top-most parts only - for (EditPart nextPart : associatedParts) { + for(EditPart nextPart : associatedParts) { EditPart parentPart = nextPart.getParent(); - while (parentPart != null && !associatedParts.contains(parentPart)) { + while(parentPart != null && !associatedParts.contains(parentPart)) { parentPart = parentPart.getParent(); } - if (parentPart == null) { + if(parentPart == null) { editPartCollector.add(nextPart); } } - - if (intialNumOfEditParts == editPartCollector.size()) { - if (!associatedParts.isEmpty()) { + if(intialNumOfEditParts == editPartCollector.size()) { + if(!associatedParts.isEmpty()) { editPartCollector.add(associatedParts.get(0)); } else { - if (element.eContainer() != null) { + if(element.eContainer() != null) { return findElementsInDiagramByID(diagramPart, element.eContainer(), editPartCollector); } } @@ -267,22 +251,19 @@ public class UMLDiagramEditorUtil { /** * @generated */ - public static View findView(DiagramEditPart diagramEditPart, EObject targetElement, - LazyElement2ViewMap lazyElement2ViewMap) { + public static View findView(DiagramEditPart diagramEditPart, EObject targetElement, LazyElement2ViewMap lazyElement2ViewMap) { boolean hasStructuralURI = false; - if (targetElement.eResource() instanceof XMLResource) { - hasStructuralURI = ((XMLResource) targetElement.eResource()).getID(targetElement) == null; + if(targetElement.eResource() instanceof XMLResource) { + hasStructuralURI = ((XMLResource)targetElement.eResource()).getID(targetElement) == null; } - View view = null; LinkedList<EditPart> editPartHolder = new LinkedList<EditPart>(); - if (hasStructuralURI && !lazyElement2ViewMap.getElement2ViewMap().isEmpty()) { + if(hasStructuralURI && !lazyElement2ViewMap.getElement2ViewMap().isEmpty()) { view = lazyElement2ViewMap.getElement2ViewMap().get(targetElement); - } else if (findElementsInDiagramByID(diagramEditPart, targetElement, editPartHolder) > 0) { + } else if(findElementsInDiagramByID(diagramEditPart, targetElement, editPartHolder) > 0) { EditPart editPart = editPartHolder.get(0); - view = editPart.getModel() instanceof View ? (View) editPart.getModel() : null; + view = editPart.getModel() instanceof View ? (View)editPart.getModel() : null; } - return (view == null) ? diagramEditPart.getDiagramView() : view; } @@ -320,18 +301,17 @@ public class UMLDiagramEditorUtil { * @generated */ public final Map<EObject, View> getElement2ViewMap() { - if (element2ViewMap == null) { + if(element2ViewMap == null) { element2ViewMap = new HashMap<EObject, View>(); // map possible notation elements to itself as these can't be found by view.getElement() - for (EObject element : elementSet) { - if (element instanceof View) { - View view = (View) element; - if (view.getDiagram() == scope.getDiagram()) { + for(EObject element : elementSet) { + if(element instanceof View) { + View view = (View)element; + if(view.getDiagram() == scope.getDiagram()) { element2ViewMap.put(element, view); // take only those that part of our diagram } } } - buildElement2ViewMap(scope, element2ViewMap, elementSet); } return element2ViewMap; @@ -340,28 +320,25 @@ public class UMLDiagramEditorUtil { /** * @generated */ - private static boolean buildElement2ViewMap(View parentView, Map<EObject, View> element2ViewMap, - Set<? extends EObject> elements) { - if (elements.size() == element2ViewMap.size()) { + private static boolean buildElement2ViewMap(View parentView, Map<EObject, View> element2ViewMap, Set<? extends EObject> elements) { + if(elements.size() == element2ViewMap.size()) { return true; } - - if (parentView.isSetElement() && !element2ViewMap.containsKey(parentView.getElement()) - && elements.contains(parentView.getElement())) { + if(parentView.isSetElement() && !element2ViewMap.containsKey(parentView.getElement()) && elements.contains(parentView.getElement())) { element2ViewMap.put(parentView.getElement(), parentView); - if (elements.size() == element2ViewMap.size()) { + if(elements.size() == element2ViewMap.size()) { return true; } } boolean complete = false; - for (Iterator<?> it = parentView.getChildren().iterator(); it.hasNext() && !complete;) { - complete = buildElement2ViewMap((View) it.next(), element2ViewMap, elements); + for(Iterator<?> it = parentView.getChildren().iterator(); it.hasNext() && !complete;) { + complete = buildElement2ViewMap((View)it.next(), element2ViewMap, elements); } - for (Iterator<?> it = parentView.getSourceEdges().iterator(); it.hasNext() && !complete;) { - complete = buildElement2ViewMap((View) it.next(), element2ViewMap, elements); + for(Iterator<?> it = parentView.getSourceEdges().iterator(); it.hasNext() && !complete;) { + complete = buildElement2ViewMap((View)it.next(), element2ViewMap, elements); } - for (Iterator<?> it = parentView.getTargetEdges().iterator(); it.hasNext() && !complete;) { - complete = buildElement2ViewMap((View) it.next(), element2ViewMap, elements); + for(Iterator<?> it = parentView.getTargetEdges().iterator(); it.hasNext() && !complete;) { + complete = buildElement2ViewMap((View)it.next(), element2ViewMap, elements); } return complete; } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramUpdater.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramUpdater.java index c23421950f3..b7b82662598 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramUpdater.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDiagramUpdater.java @@ -97,8 +97,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { @Override public List<UMLNodeDescriptor> getSemanticChildren(View view) { String vid = UMLVisualIDRegistry.getVisualID(view); - if (vid != null) { - switch (vid) { + if(vid != null) { + switch(vid) { case PackageEditPart.VISUAL_ID: return getPackage_StateMachineDiagram_SemanticChildren(view); case StateMachineEditPart.VISUAL_ID: @@ -120,15 +120,15 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLNodeDescriptor> getPackage_StateMachineDiagram_SemanticChildren(View view) { - if (!view.isSetElement()) { + if(!view.isSetElement()) { return Collections.emptyList(); } - Package modelElement = (Package) view.getElement(); + Package modelElement = (Package)view.getElement(); LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>(); - for (Iterator<?> it = modelElement.getPackagedElements().iterator(); it.hasNext();) { - PackageableElement childElement = (PackageableElement) it.next(); + for(Iterator<?> it = modelElement.getPackagedElements().iterator(); it.hasNext();) { + PackageableElement childElement = (PackageableElement)it.next(); String visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); - if (StateMachineEditPart.VISUAL_ID.equals(visualID)) { + if(StateMachineEditPart.VISUAL_ID.equals(visualID)) { result.add(new UMLNodeDescriptor(childElement, visualID)); continue; } @@ -140,19 +140,19 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLNodeDescriptor> getStateMachine_Shape_SemanticChildren(View view) { - if (!view.isSetElement()) { + if(!view.isSetElement()) { return Collections.emptyList(); } - StateMachine modelElement = (StateMachine) view.getElement(); + StateMachine modelElement = (StateMachine)view.getElement(); LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>(); - for (Iterator<?> it = modelElement.getConnectionPoints().iterator(); it.hasNext();) { - Pseudostate childElement = (Pseudostate) it.next(); + for(Iterator<?> it = modelElement.getConnectionPoints().iterator(); it.hasNext();) { + Pseudostate childElement = (Pseudostate)it.next(); String visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); - if (PseudostateEntryPointEditPart.VISUAL_ID.equals(visualID)) { + if(PseudostateEntryPointEditPart.VISUAL_ID.equals(visualID)) { result.add(new UMLNodeDescriptor(childElement, visualID)); continue; } - if (PseudostateExitPointEditPart.VISUAL_ID.equals(visualID)) { + if(PseudostateExitPointEditPart.VISUAL_ID.equals(visualID)) { result.add(new UMLNodeDescriptor(childElement, visualID)); continue; } @@ -164,64 +164,64 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLNodeDescriptor> getState_Shape_SemanticChildren(View view) { - if (!view.isSetElement()) { + if(!view.isSetElement()) { return Collections.emptyList(); } - State modelElement = (State) view.getElement(); + State modelElement = (State)view.getElement(); LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>(); { Behavior childElement = modelElement.getEntry(); String visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); - if (EntryStateBehaviorEditPart.VISUAL_ID.equals(visualID)) { + if(EntryStateBehaviorEditPart.VISUAL_ID.equals(visualID)) { result.add(new UMLNodeDescriptor(childElement, visualID)); } } { Behavior childElement = modelElement.getDoActivity(); String visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); - if (DoActivityStateBehaviorStateEditPart.VISUAL_ID.equals(visualID)) { + if(DoActivityStateBehaviorStateEditPart.VISUAL_ID.equals(visualID)) { result.add(new UMLNodeDescriptor(childElement, visualID)); } } { Behavior childElement = modelElement.getExit(); String visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); - if (ExitStateBehaviorEditPart.VISUAL_ID.equals(visualID)) { + if(ExitStateBehaviorEditPart.VISUAL_ID.equals(visualID)) { result.add(new UMLNodeDescriptor(childElement, visualID)); } } - for (Iterator<?> it = modelElement.getIncomings().iterator(); it.hasNext();) { - Transition childElement = (Transition) it.next(); + for(Iterator<?> it = modelElement.getIncomings().iterator(); it.hasNext();) { + Transition childElement = (Transition)it.next(); String visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); - if (InternalTransitionEditPart.VISUAL_ID.equals(visualID)) { + if(InternalTransitionEditPart.VISUAL_ID.equals(visualID)) { result.add(new UMLNodeDescriptor(childElement, visualID)); continue; } } - for (Iterator<?> it = modelElement.getRegions().iterator(); it.hasNext();) { - Region childElement = (Region) it.next(); + for(Iterator<?> it = modelElement.getRegions().iterator(); it.hasNext();) { + Region childElement = (Region)it.next(); String visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); - if (RegionEditPart.VISUAL_ID.equals(visualID)) { + if(RegionEditPart.VISUAL_ID.equals(visualID)) { result.add(new UMLNodeDescriptor(childElement, visualID)); continue; } } - for (Iterator<?> it = modelElement.getConnectionPoints().iterator(); it.hasNext();) { - Pseudostate childElement = (Pseudostate) it.next(); + for(Iterator<?> it = modelElement.getConnectionPoints().iterator(); it.hasNext();) { + Pseudostate childElement = (Pseudostate)it.next(); String visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); - if (PseudostateEntryPointEditPart.VISUAL_ID.equals(visualID)) { + if(PseudostateEntryPointEditPart.VISUAL_ID.equals(visualID)) { result.add(new UMLNodeDescriptor(childElement, visualID)); continue; } - if (PseudostateExitPointEditPart.VISUAL_ID.equals(visualID)) { + if(PseudostateExitPointEditPart.VISUAL_ID.equals(visualID)) { result.add(new UMLNodeDescriptor(childElement, visualID)); continue; } } - for (Iterator<?> it = modelElement.getConnections().iterator(); it.hasNext();) { - ConnectionPointReference childElement = (ConnectionPointReference) it.next(); + for(Iterator<?> it = modelElement.getConnections().iterator(); it.hasNext();) { + ConnectionPointReference childElement = (ConnectionPointReference)it.next(); String visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); - if (ConnectionPointReferenceEditPart.VISUAL_ID.equals(visualID)) { + if(ConnectionPointReferenceEditPart.VISUAL_ID.equals(visualID)) { result.add(new UMLNodeDescriptor(childElement, visualID)); continue; } @@ -241,31 +241,31 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLNodeDescriptor> getStateMachine_RegionCompartment_SemanticChildren(View view) { - if (false == view.eContainer() instanceof View) { + if(false == view.eContainer() instanceof View) { return Collections.emptyList(); } - View containerView = (View) view.eContainer(); - if (!containerView.isSetElement()) { + View containerView = (View)view.eContainer(); + if(!containerView.isSetElement()) { return Collections.emptyList(); } - StateMachine modelElement = (StateMachine) containerView.getElement(); + StateMachine modelElement = (StateMachine)containerView.getElement(); LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>(); - for (Iterator<?> it = modelElement.getRegions().iterator(); it.hasNext();) { - Region childElement = (Region) it.next(); + for(Iterator<?> it = modelElement.getRegions().iterator(); it.hasNext();) { + Region childElement = (Region)it.next(); String visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); - if (RegionEditPart.VISUAL_ID.equals(visualID)) { + if(RegionEditPart.VISUAL_ID.equals(visualID)) { result.add(new UMLNodeDescriptor(childElement, visualID)); continue; } } - for (Iterator<?> it = modelElement.getConnectionPoints().iterator(); it.hasNext();) { - Pseudostate childElement = (Pseudostate) it.next(); + for(Iterator<?> it = modelElement.getConnectionPoints().iterator(); it.hasNext();) { + Pseudostate childElement = (Pseudostate)it.next(); String visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); - if (PseudostateEntryPointEditPart.VISUAL_ID.equals(visualID)) { + if(PseudostateEntryPointEditPart.VISUAL_ID.equals(visualID)) { result.add(new UMLNodeDescriptor(childElement, visualID)); continue; } - if (PseudostateExitPointEditPart.VISUAL_ID.equals(visualID)) { + if(PseudostateExitPointEditPart.VISUAL_ID.equals(visualID)) { result.add(new UMLNodeDescriptor(childElement, visualID)); continue; } @@ -277,27 +277,27 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLNodeDescriptor> getState_RegionCompartment_SemanticChildren(View view) { - if (false == view.eContainer() instanceof View) { + if(false == view.eContainer() instanceof View) { return Collections.emptyList(); } - View containerView = (View) view.eContainer(); - if (!containerView.isSetElement()) { + View containerView = (View)view.eContainer(); + if(!containerView.isSetElement()) { return Collections.emptyList(); } - State modelElement = (State) containerView.getElement(); + State modelElement = (State)containerView.getElement(); LinkedList<UMLNodeDescriptor> result = new LinkedList<UMLNodeDescriptor>(); - for (Iterator<?> it = modelElement.getRegions().iterator(); it.hasNext();) { - Region childElement = (Region) it.next(); + for(Iterator<?> it = modelElement.getRegions().iterator(); it.hasNext();) { + Region childElement = (Region)it.next(); String visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); - if (RegionEditPart.VISUAL_ID.equals(visualID)) { + if(RegionEditPart.VISUAL_ID.equals(visualID)) { result.add(new UMLNodeDescriptor(childElement, visualID)); continue; } } - for (Iterator<?> it = modelElement.getConnections().iterator(); it.hasNext();) { - ConnectionPointReference childElement = (ConnectionPointReference) it.next(); + for(Iterator<?> it = modelElement.getConnections().iterator(); it.hasNext();) { + ConnectionPointReference childElement = (ConnectionPointReference)it.next(); String visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); - if (ConnectionPointReferenceEditPart.VISUAL_ID.equals(visualID)) { + if(ConnectionPointReferenceEditPart.VISUAL_ID.equals(visualID)) { result.add(new UMLNodeDescriptor(childElement, visualID)); continue; } @@ -311,8 +311,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { @Override public List<UMLLinkDescriptor> getContainedLinks(View view) { String vid = UMLVisualIDRegistry.getVisualID(view); - if (vid != null) { - switch (vid) { + if(vid != null) { + switch(vid) { case PackageEditPart.VISUAL_ID: return getPackage_StateMachineDiagram_ContainedLinks(view); case StateMachineEditPart.VISUAL_ID: @@ -372,8 +372,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { @Override public List<UMLLinkDescriptor> getIncomingLinks(View view) { String vid = UMLVisualIDRegistry.getVisualID(view); - if (vid != null) { - switch (vid) { + if(vid != null) { + switch(vid) { case StateMachineEditPart.VISUAL_ID: return getStateMachine_Shape_IncomingLinks(view); case RegionEditPart.VISUAL_ID: @@ -431,8 +431,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { @Override public List<UMLLinkDescriptor> getOutgoingLinks(View view) { String vid = UMLVisualIDRegistry.getVisualID(view); - if (vid != null) { - switch (vid) { + if(vid != null) { + switch(vid) { case StateMachineEditPart.VISUAL_ID: return getStateMachine_Shape_OutgoingLinks(view); case RegionEditPart.VISUAL_ID: @@ -495,7 +495,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getStateMachine_Shape_ContainedLinks(View view) { - StateMachine modelElement = (StateMachine) view.getElement(); + StateMachine modelElement = (StateMachine)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getContainedTypeModelFacetLinks_Generalization_Edge(modelElement)); return result; @@ -505,7 +505,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getRegion_Shape_ContainedLinks(View view) { - Region modelElement = (Region) view.getElement(); + Region modelElement = (Region)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getContainedTypeModelFacetLinks_Transition_Edge(modelElement)); return result; @@ -606,7 +606,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getComment_Shape_ContainedLinks(View view) { - Comment modelElement = (Comment) view.getElement(); + Comment modelElement = (Comment)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getOutgoingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement)); return result; @@ -616,7 +616,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getConstraint_Shape_ContainedLinks(View view) { - Constraint modelElement = (Constraint) view.getElement(); + Constraint modelElement = (Constraint)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement)); result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement)); @@ -634,7 +634,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getBehavior_EntryBehaviorLabel_ContainedLinks(View view) { - Behavior modelElement = (Behavior) view.getElement(); + Behavior modelElement = (Behavior)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getContainedTypeModelFacetLinks_Generalization_Edge(modelElement)); return result; @@ -644,7 +644,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getBehavior_DoActivityBehaviorLabel_ContainedLinks(View view) { - Behavior modelElement = (Behavior) view.getElement(); + Behavior modelElement = (Behavior)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getContainedTypeModelFacetLinks_Generalization_Edge(modelElement)); return result; @@ -654,7 +654,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getBehavior_ExitBehaviorLabel_ContainedLinks(View view) { - Behavior modelElement = (Behavior) view.getElement(); + Behavior modelElement = (Behavior)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getContainedTypeModelFacetLinks_Generalization_Edge(modelElement)); return result; @@ -678,14 +678,12 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getStateMachine_Shape_IncomingLinks(View view) { - StateMachine modelElement = (StateMachine) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); + StateMachine modelElement = (StateMachine)view.getElement(); + CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getIncomingTypeModelFacetLinks_Generalization_Edge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement, crossReferencer)); return result; } @@ -694,13 +692,11 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getRegion_Shape_IncomingLinks(View view) { - Region modelElement = (Region) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); + Region modelElement = (Region)view.getElement(); + CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement, crossReferencer)); return result; } @@ -709,14 +705,12 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getFinalState_Shape_IncomingLinks(View view) { - FinalState modelElement = (FinalState) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); + FinalState modelElement = (FinalState)view.getElement(); + CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getIncomingTypeModelFacetLinks_Transition_Edge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement, crossReferencer)); return result; } @@ -725,14 +719,12 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getState_Shape_IncomingLinks(View view) { - State modelElement = (State) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); + State modelElement = (State)view.getElement(); + CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getIncomingTypeModelFacetLinks_Transition_Edge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement, crossReferencer)); return result; } @@ -741,14 +733,12 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_InitialShape_IncomingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); + Pseudostate modelElement = (Pseudostate)view.getElement(); + CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getIncomingTypeModelFacetLinks_Transition_Edge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); return result; } @@ -756,14 +746,12 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_JoinShape_IncomingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); + Pseudostate modelElement = (Pseudostate)view.getElement(); + CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getIncomingTypeModelFacetLinks_Transition_Edge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); return result; } @@ -771,14 +759,12 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_ForkShape_IncomingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); + Pseudostate modelElement = (Pseudostate)view.getElement(); + CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getIncomingTypeModelFacetLinks_Transition_Edge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); return result; } @@ -786,14 +772,12 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_ChoiceShape_IncomingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); + Pseudostate modelElement = (Pseudostate)view.getElement(); + CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getIncomingTypeModelFacetLinks_Transition_Edge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); return result; } @@ -801,14 +785,12 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_JunctionShape_IncomingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); + Pseudostate modelElement = (Pseudostate)view.getElement(); + CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getIncomingTypeModelFacetLinks_Transition_Edge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); return result; } @@ -816,14 +798,12 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_ShallowHistoryShape_IncomingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); + Pseudostate modelElement = (Pseudostate)view.getElement(); + CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getIncomingTypeModelFacetLinks_Transition_Edge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); return result; } @@ -831,14 +811,12 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_DeepHistoryShape_IncomingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); + Pseudostate modelElement = (Pseudostate)view.getElement(); + CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getIncomingTypeModelFacetLinks_Transition_Edge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); return result; } @@ -846,14 +824,12 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_TerminateShape_IncomingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); + Pseudostate modelElement = (Pseudostate)view.getElement(); + CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getIncomingTypeModelFacetLinks_Transition_Edge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); return result; } @@ -861,14 +837,12 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_EntryPointShape_IncomingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); + Pseudostate modelElement = (Pseudostate)view.getElement(); + CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getIncomingTypeModelFacetLinks_Transition_Edge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); return result; } @@ -876,14 +850,12 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_ExitPointShape_IncomingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); + Pseudostate modelElement = (Pseudostate)view.getElement(); + CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getIncomingTypeModelFacetLinks_Transition_Edge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); return result; } @@ -891,14 +863,12 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getConnectionPointReference_Shape_IncomingLinks(View view) { - ConnectionPointReference modelElement = (ConnectionPointReference) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); + ConnectionPointReference modelElement = (ConnectionPointReference)view.getElement(); + CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getIncomingTypeModelFacetLinks_Transition_Edge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); return result; } @@ -906,13 +876,11 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getComment_Shape_IncomingLinks(View view) { - Comment modelElement = (Comment) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); + Comment modelElement = (Comment)view.getElement(); + CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); return result; } @@ -920,13 +888,11 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getConstraint_Shape_IncomingLinks(View view) { - Constraint modelElement = (Constraint) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); + Constraint modelElement = (Constraint)view.getElement(); + CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); return result; } @@ -962,13 +928,11 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getTransition_Edge_IncomingLinks(View view) { - Transition modelElement = (Transition) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); + Transition modelElement = (Transition)view.getElement(); + CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement, crossReferencer)); return result; } @@ -977,13 +941,11 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getGeneralization_Edge_IncomingLinks(View view) { - Generalization modelElement = (Generalization) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); + Generalization modelElement = (Generalization)view.getElement(); + CrossReferenceAdapter crossReferencer = CrossReferenceAdapter.getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); return result; } @@ -991,7 +953,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getStateMachine_Shape_OutgoingLinks(View view) { - StateMachine modelElement = (StateMachine) view.getElement(); + StateMachine modelElement = (StateMachine)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getContainedTypeModelFacetLinks_Generalization_Edge(modelElement)); return result; @@ -1008,7 +970,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getFinalState_Shape_OutgoingLinks(View view) { - FinalState modelElement = (FinalState) view.getElement(); + FinalState modelElement = (FinalState)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getOutgoingTypeModelFacetLinks_Transition_Edge(modelElement)); return result; @@ -1018,7 +980,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getState_Shape_OutgoingLinks(View view) { - State modelElement = (State) view.getElement(); + State modelElement = (State)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getOutgoingTypeModelFacetLinks_Transition_Edge(modelElement)); return result; @@ -1028,7 +990,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_InitialShape_OutgoingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); + Pseudostate modelElement = (Pseudostate)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getOutgoingTypeModelFacetLinks_Transition_Edge(modelElement)); return result; @@ -1038,7 +1000,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_JoinShape_OutgoingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); + Pseudostate modelElement = (Pseudostate)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getOutgoingTypeModelFacetLinks_Transition_Edge(modelElement)); return result; @@ -1048,7 +1010,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_ForkShape_OutgoingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); + Pseudostate modelElement = (Pseudostate)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getOutgoingTypeModelFacetLinks_Transition_Edge(modelElement)); return result; @@ -1058,7 +1020,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_ChoiceShape_OutgoingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); + Pseudostate modelElement = (Pseudostate)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getOutgoingTypeModelFacetLinks_Transition_Edge(modelElement)); return result; @@ -1068,7 +1030,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_JunctionShape_OutgoingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); + Pseudostate modelElement = (Pseudostate)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getOutgoingTypeModelFacetLinks_Transition_Edge(modelElement)); return result; @@ -1078,7 +1040,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_ShallowHistoryShape_OutgoingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); + Pseudostate modelElement = (Pseudostate)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getOutgoingTypeModelFacetLinks_Transition_Edge(modelElement)); return result; @@ -1088,7 +1050,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_DeepHistoryShape_OutgoingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); + Pseudostate modelElement = (Pseudostate)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getOutgoingTypeModelFacetLinks_Transition_Edge(modelElement)); return result; @@ -1098,7 +1060,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_TerminateShape_OutgoingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); + Pseudostate modelElement = (Pseudostate)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getOutgoingTypeModelFacetLinks_Transition_Edge(modelElement)); return result; @@ -1108,7 +1070,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_EntryPointShape_OutgoingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); + Pseudostate modelElement = (Pseudostate)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getOutgoingTypeModelFacetLinks_Transition_Edge(modelElement)); return result; @@ -1118,7 +1080,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPseudostate_ExitPointShape_OutgoingLinks(View view) { - Pseudostate modelElement = (Pseudostate) view.getElement(); + Pseudostate modelElement = (Pseudostate)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getOutgoingTypeModelFacetLinks_Transition_Edge(modelElement)); return result; @@ -1128,7 +1090,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getConnectionPointReference_Shape_OutgoingLinks(View view) { - ConnectionPointReference modelElement = (ConnectionPointReference) view.getElement(); + ConnectionPointReference modelElement = (ConnectionPointReference)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getOutgoingTypeModelFacetLinks_Transition_Edge(modelElement)); return result; @@ -1138,7 +1100,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getComment_Shape_OutgoingLinks(View view) { - Comment modelElement = (Comment) view.getElement(); + Comment modelElement = (Comment)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getOutgoingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement)); return result; @@ -1148,7 +1110,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getConstraint_Shape_OutgoingLinks(View view) { - Constraint modelElement = (Constraint) view.getElement(); + Constraint modelElement = (Constraint)view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement)); result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement)); @@ -1202,19 +1164,18 @@ public class UMLDiagramUpdater implements DiagramUpdater { */ protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_Transition_Edge(Region container) { LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); - for (Iterator<?> links = container.getTransitions().iterator(); links.hasNext();) { - EObject linkObject = (EObject) links.next(); - if (false == linkObject instanceof Transition) { + for(Iterator<?> links = container.getTransitions().iterator(); links.hasNext();) { + EObject linkObject = (EObject)links.next(); + if(false == linkObject instanceof Transition) { continue; } - Transition link = (Transition) linkObject; - if (!TransitionEditPart.VISUAL_ID.equals(UMLVisualIDRegistry.getLinkWithClassVisualID(link))) { + Transition link = (Transition)linkObject; + if(!TransitionEditPart.VISUAL_ID.equals(UMLVisualIDRegistry.getLinkWithClassVisualID(link))) { continue; } Vertex dst = link.getTarget(); Vertex src = link.getSource(); - result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Transition_Edge, - TransitionEditPart.VISUAL_ID)); + result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Transition_Edge, TransitionEditPart.VISUAL_ID)); } return result; } @@ -1224,18 +1185,17 @@ public class UMLDiagramUpdater implements DiagramUpdater { */ protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_Generalization_Edge(Classifier container) { LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); - for (Iterator<?> links = container.getGeneralizations().iterator(); links.hasNext();) { - EObject linkObject = (EObject) links.next(); - if (false == linkObject instanceof Generalization) { + for(Iterator<?> links = container.getGeneralizations().iterator(); links.hasNext();) { + EObject linkObject = (EObject)links.next(); + if(false == linkObject instanceof Generalization) { continue; } - Generalization link = (Generalization) linkObject; - if (!GeneralizationEditPart.VISUAL_ID.equals(UMLVisualIDRegistry.getLinkWithClassVisualID(link))) { + Generalization link = (Generalization)linkObject; + if(!GeneralizationEditPart.VISUAL_ID.equals(UMLVisualIDRegistry.getLinkWithClassVisualID(link))) { continue; } Classifier dst = link.getGeneral(); - result.add(new UMLLinkDescriptor(container, dst, link, UMLElementTypes.Generalization_Edge, - GeneralizationEditPart.VISUAL_ID)); + result.add(new UMLLinkDescriptor(container, dst, link, UMLElementTypes.Generalization_Edge, GeneralizationEditPart.VISUAL_ID)); } return result; } @@ -1243,22 +1203,19 @@ public class UMLDiagramUpdater implements DiagramUpdater { /** * @generated */ - protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_Transition_Edge(Vertex target, - CrossReferenceAdapter crossReferencer) { + protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_Transition_Edge(Vertex target, CrossReferenceAdapter crossReferencer) { LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target); - for (EStructuralFeature.Setting setting : settings) { - if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getTransition_Target() - || false == setting.getEObject() instanceof Transition) { + for(EStructuralFeature.Setting setting : settings) { + if(setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getTransition_Target() || false == setting.getEObject() instanceof Transition) { continue; } - Transition link = (Transition) setting.getEObject(); - if (!TransitionEditPart.VISUAL_ID.equals(UMLVisualIDRegistry.getLinkWithClassVisualID(link))) { + Transition link = (Transition)setting.getEObject(); + if(!TransitionEditPart.VISUAL_ID.equals(UMLVisualIDRegistry.getLinkWithClassVisualID(link))) { continue; } Vertex src = link.getSource(); - result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.Transition_Edge, - TransitionEditPart.VISUAL_ID)); + result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.Transition_Edge, TransitionEditPart.VISUAL_ID)); } return result; } @@ -1266,26 +1223,22 @@ public class UMLDiagramUpdater implements DiagramUpdater { /** * @generated */ - protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_Generalization_Edge(Classifier target, - CrossReferenceAdapter crossReferencer) { + protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_Generalization_Edge(Classifier target, CrossReferenceAdapter crossReferencer) { LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target); - for (EStructuralFeature.Setting setting : settings) { - if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getGeneralization_General() - || false == setting.getEObject() instanceof Generalization) { + for(EStructuralFeature.Setting setting : settings) { + if(setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getGeneralization_General() || false == setting.getEObject() instanceof Generalization) { continue; } - Generalization link = (Generalization) setting.getEObject(); - if (!GeneralizationEditPart.VISUAL_ID.equals(UMLVisualIDRegistry.getLinkWithClassVisualID(link))) { + Generalization link = (Generalization)setting.getEObject(); + if(!GeneralizationEditPart.VISUAL_ID.equals(UMLVisualIDRegistry.getLinkWithClassVisualID(link))) { continue; } - if (false == link.eContainer() instanceof Classifier) { + if(false == link.eContainer() instanceof Classifier) { continue; } - Classifier container = (Classifier) link.eContainer(); - result.add(new UMLLinkDescriptor(container, target, link, UMLElementTypes.Generalization_Edge, - GeneralizationEditPart.VISUAL_ID)); - + Classifier container = (Classifier)link.eContainer(); + result.add(new UMLLinkDescriptor(container, target, link, UMLElementTypes.Generalization_Edge, GeneralizationEditPart.VISUAL_ID)); } return result; } @@ -1293,14 +1246,12 @@ public class UMLDiagramUpdater implements DiagramUpdater { /** * @generated */ - protected Collection<UMLLinkDescriptor> getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge( - Element target, CrossReferenceAdapter crossReferencer) { + protected Collection<UMLLinkDescriptor> getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(Element target, CrossReferenceAdapter crossReferencer) { LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target); - for (EStructuralFeature.Setting setting : settings) { - if (setting.getEStructuralFeature() == UMLPackage.eINSTANCE.getComment_AnnotatedElement()) { - result.add(new UMLLinkDescriptor(setting.getEObject(), target, - UMLElementTypes.Comment_AnnotatedElementEdge, CommentAnnotatedElementEditPart.VISUAL_ID)); + for(EStructuralFeature.Setting setting : settings) { + if(setting.getEStructuralFeature() == UMLPackage.eINSTANCE.getComment_AnnotatedElement()) { + result.add(new UMLLinkDescriptor(setting.getEObject(), target, UMLElementTypes.Comment_AnnotatedElementEdge, CommentAnnotatedElementEditPart.VISUAL_ID)); } } return result; @@ -1309,15 +1260,12 @@ public class UMLDiagramUpdater implements DiagramUpdater { /** * @generated */ - protected Collection<UMLLinkDescriptor> getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge( - Element target, CrossReferenceAdapter crossReferencer) { + protected Collection<UMLLinkDescriptor> getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(Element target, CrossReferenceAdapter crossReferencer) { LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target); - for (EStructuralFeature.Setting setting : settings) { - if (setting.getEStructuralFeature() == UMLPackage.eINSTANCE.getConstraint_ConstrainedElement()) { - result.add(new UMLLinkDescriptor(setting.getEObject(), target, - UMLElementTypes.Constraint_ConstrainedElementEdge, - ConstraintConstrainedElementEditPart.VISUAL_ID)); + for(EStructuralFeature.Setting setting : settings) { + if(setting.getEStructuralFeature() == UMLPackage.eINSTANCE.getConstraint_ConstrainedElement()) { + result.add(new UMLLinkDescriptor(setting.getEObject(), target, UMLElementTypes.Constraint_ConstrainedElementEdge, ConstraintConstrainedElementEditPart.VISUAL_ID)); } } return result; @@ -1326,14 +1274,12 @@ public class UMLDiagramUpdater implements DiagramUpdater { /** * @generated */ - protected Collection<UMLLinkDescriptor> getIncomingFeatureModelFacetLinks_Constraint_ContextEdge(Namespace target, - CrossReferenceAdapter crossReferencer) { + protected Collection<UMLLinkDescriptor> getIncomingFeatureModelFacetLinks_Constraint_ContextEdge(Namespace target, CrossReferenceAdapter crossReferencer) { LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target); - for (EStructuralFeature.Setting setting : settings) { - if (setting.getEStructuralFeature() == UMLPackage.eINSTANCE.getConstraint_Context()) { - result.add(new UMLLinkDescriptor(setting.getEObject(), target, UMLElementTypes.Constraint_ContextEdge, - ContextLinkEditPart.VISUAL_ID)); + for(EStructuralFeature.Setting setting : settings) { + if(setting.getEStructuralFeature() == UMLPackage.eINSTANCE.getConstraint_Context()) { + result.add(new UMLLinkDescriptor(setting.getEObject(), target, UMLElementTypes.Constraint_ContextEdge, ContextLinkEditPart.VISUAL_ID)); } } return result; @@ -1347,31 +1293,30 @@ public class UMLDiagramUpdater implements DiagramUpdater { // Find container element for the link. // Climb up by containment hierarchy starting from the source // and return the first element that is instance of the container class. - for (EObject element = source; element != null && container == null; element = element.eContainer()) { - if (element instanceof Region) { - container = (Region) element; + for(EObject element = source; element != null && container == null; element = element.eContainer()) { + if(element instanceof Region) { + container = (Region)element; } } - if (container == null) { + if(container == null) { return Collections.emptyList(); } LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); - for (Iterator<?> links = container.getTransitions().iterator(); links.hasNext();) { - EObject linkObject = (EObject) links.next(); - if (false == linkObject instanceof Transition) { + for(Iterator<?> links = container.getTransitions().iterator(); links.hasNext();) { + EObject linkObject = (EObject)links.next(); + if(false == linkObject instanceof Transition) { continue; } - Transition link = (Transition) linkObject; - if (!TransitionEditPart.VISUAL_ID.equals(UMLVisualIDRegistry.getLinkWithClassVisualID(link))) { + Transition link = (Transition)linkObject; + if(!TransitionEditPart.VISUAL_ID.equals(UMLVisualIDRegistry.getLinkWithClassVisualID(link))) { continue; } Vertex dst = link.getTarget(); Vertex src = link.getSource(); - if (src != source) { + if(src != source) { continue; } - result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Transition_Edge, - TransitionEditPart.VISUAL_ID)); + result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.Transition_Edge, TransitionEditPart.VISUAL_ID)); } return result; } @@ -1379,13 +1324,11 @@ public class UMLDiagramUpdater implements DiagramUpdater { /** * @generated */ - protected Collection<UMLLinkDescriptor> getOutgoingFeatureModelFacetLinks_Comment_AnnotatedElementEdge( - Comment source) { + protected Collection<UMLLinkDescriptor> getOutgoingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(Comment source) { LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); - for (Iterator<?> destinations = source.getAnnotatedElements().iterator(); destinations.hasNext();) { - Element destination = (Element) destinations.next(); - result.add(new UMLLinkDescriptor(source, destination, UMLElementTypes.Comment_AnnotatedElementEdge, - CommentAnnotatedElementEditPart.VISUAL_ID)); + for(Iterator<?> destinations = source.getAnnotatedElements().iterator(); destinations.hasNext();) { + Element destination = (Element)destinations.next(); + result.add(new UMLLinkDescriptor(source, destination, UMLElementTypes.Comment_AnnotatedElementEdge, CommentAnnotatedElementEditPart.VISUAL_ID)); } return result; } @@ -1393,13 +1336,11 @@ public class UMLDiagramUpdater implements DiagramUpdater { /** * @generated */ - protected Collection<UMLLinkDescriptor> getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge( - Constraint source) { + protected Collection<UMLLinkDescriptor> getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(Constraint source) { LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); - for (Iterator<?> destinations = source.getConstrainedElements().iterator(); destinations.hasNext();) { - Element destination = (Element) destinations.next(); - result.add(new UMLLinkDescriptor(source, destination, UMLElementTypes.Constraint_ConstrainedElementEdge, - ConstraintConstrainedElementEditPart.VISUAL_ID)); + for(Iterator<?> destinations = source.getConstrainedElements().iterator(); destinations.hasNext();) { + Element destination = (Element)destinations.next(); + result.add(new UMLLinkDescriptor(source, destination, UMLElementTypes.Constraint_ConstrainedElementEdge, ConstraintConstrainedElementEditPart.VISUAL_ID)); } return result; } @@ -1407,15 +1348,13 @@ public class UMLDiagramUpdater implements DiagramUpdater { /** * @generated */ - protected Collection<UMLLinkDescriptor> getOutgoingFeatureModelFacetLinks_Constraint_ContextEdge( - Constraint source) { + protected Collection<UMLLinkDescriptor> getOutgoingFeatureModelFacetLinks_Constraint_ContextEdge(Constraint source) { LinkedList<UMLLinkDescriptor> result = new LinkedList<UMLLinkDescriptor>(); Namespace destination = source.getContext(); - if (destination == null) { + if(destination == null) { return result; } - result.add(new UMLLinkDescriptor(source, destination, UMLElementTypes.Constraint_ContextEdge, - ContextLinkEditPart.VISUAL_ID)); + result.add(new UMLLinkDescriptor(source, destination, UMLElementTypes.Constraint_ContextEdge, ContextLinkEditPart.VISUAL_ID)); return result; } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDocumentProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDocumentProvider.java index ae1ede3d133..67c40295b6a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDocumentProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLDocumentProvider.java @@ -75,16 +75,12 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi */ @Override protected ElementInfo createElementInfo(Object element) throws CoreException { - if (false == element instanceof FileEditorInput && false == element instanceof URIEditorInput) { - throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, - NLS.bind(Messages.UMLDocumentProvider_IncorrectInputError, - new Object[] { element, "org.eclipse.ui.part.FileEditorInput", //$NON-NLS-1$ - "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ - null)); + if(false == element instanceof FileEditorInput && false == element instanceof URIEditorInput) { + throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, NLS.bind(Messages.UMLDocumentProvider_IncorrectInputError, new Object[]{ element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$ + null)); } - IEditorInput editorInput = (IEditorInput) element; - IDiagramDocument document = (IDiagramDocument) createDocument(editorInput); - + IEditorInput editorInput = (IEditorInput)element; + IDiagramDocument document = (IDiagramDocument)createDocument(editorInput); ResourceSetInfo info = new ResourceSetInfo(document, editorInput); info.setModificationStamp(computeModificationStamp(info)); info.fStatus = null; @@ -96,15 +92,12 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi */ @Override protected IDocument createDocument(Object element) throws CoreException { - if (false == element instanceof FileEditorInput && false == element instanceof URIEditorInput) { - throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, - NLS.bind(Messages.UMLDocumentProvider_IncorrectInputError, - new Object[] { element, "org.eclipse.ui.part.FileEditorInput", //$NON-NLS-1$ - "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ - null)); + if(false == element instanceof FileEditorInput && false == element instanceof URIEditorInput) { + throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, NLS.bind(Messages.UMLDocumentProvider_IncorrectInputError, new Object[]{ element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$ + null)); } IDocument document = createEmptyDocument(); - setDocumentContent(document, (IEditorInput) element); + setDocumentContent(document, (IEditorInput)element); setupDocument(element, document); return document; } @@ -129,11 +122,11 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi */ private long computeModificationStamp(ResourceSetInfo info) { int result = 0; - for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { + for(Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { Resource nextResource = it.next(); IFile file = WorkspaceSynchronizer.getFile(nextResource); - if (file != null) { - if (file.getLocation() != null) { + if(file != null) { + if(file.getLocation() != null) { result += file.getLocation().toFile().lastModified(); } else { result += file.getModificationStamp(); @@ -159,10 +152,7 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi private TransactionalEditingDomain createEditingDomain() { TransactionalEditingDomain editingDomain = DiagramEditingDomainFactory.getInstance().createEditingDomain(); editingDomain.setID("org.eclipse.papyrus.uml.diagram.statemachine.EditingDomain"); //$NON-NLS-1$ - final NotificationFilter diagramResourceModifiedFilter = NotificationFilter - .createNotifierFilter(editingDomain.getResourceSet()) - .and(NotificationFilter.createEventTypeFilter(Notification.ADD)) - .and(NotificationFilter.createFeatureFilter(ResourceSet.class, ResourceSet.RESOURCE_SET__RESOURCES)); + final NotificationFilter diagramResourceModifiedFilter = NotificationFilter.createNotifierFilter(editingDomain.getResourceSet()).and(NotificationFilter.createEventTypeFilter(Notification.ADD)).and(NotificationFilter.createFeatureFilter(ResourceSet.class, ResourceSet.RESOURCE_SET__RESOURCES)); editingDomain.getResourceSet().eAdapters().add(new Adapter() { private Notifier myTarger; @@ -179,10 +169,10 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi @Override public void notifyChanged(Notification notification) { - if (diagramResourceModifiedFilter.matches(notification)) { + if(diagramResourceModifiedFilter.matches(notification)) { Object value = notification.getNewValue(); - if (value instanceof Resource) { - ((Resource) value).setTrackingModification(true); + if(value instanceof Resource) { + ((Resource)value).setTrackingModification(true); } } } @@ -191,9 +181,7 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi public void setTarget(Notifier newTarget) { myTarger = newTarget; } - }); - return editingDomain; } @@ -201,21 +189,21 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi * @generated */ protected void setDocumentContent(IDocument document, IEditorInput element) throws CoreException { - IDiagramDocument diagramDocument = (IDiagramDocument) document; + IDiagramDocument diagramDocument = (IDiagramDocument)document; TransactionalEditingDomain domain = diagramDocument.getEditingDomain(); - if (element instanceof FileEditorInput) { - IStorage storage = ((FileEditorInput) element).getStorage(); + if(element instanceof FileEditorInput) { + IStorage storage = ((FileEditorInput)element).getStorage(); Diagram diagram = DiagramIOUtil.load(domain, storage, true, getProgressMonitor()); document.setContent(diagram); - } else if (element instanceof URIEditorInput) { - URI uri = ((URIEditorInput) element).getURI(); + } else if(element instanceof URIEditorInput) { + URI uri = ((URIEditorInput)element).getURI(); Resource resource = null; try { resource = domain.getResourceSet().getResource(uri.trimFragment(), false); - if (resource == null) { + if(resource == null) { resource = domain.getResourceSet().createResource(uri.trimFragment()); } - if (!resource.isLoaded()) { + if(!resource.isLoaded()) { try { @SuppressWarnings({ "rawtypes", "unchecked" }) Map<?, ?> options = new HashMap(GMFResourceFactory.getDefaultLoadOptions()); @@ -227,16 +215,16 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi throw e; } } - if (uri.fragment() != null) { + if(uri.fragment() != null) { EObject rootElement = resource.getEObject(uri.fragment()); - if (rootElement instanceof Diagram) { + if(rootElement instanceof Diagram) { document.setContent(rootElement); return; } } else { - for (Iterator<EObject> it = resource.getContents().iterator(); it.hasNext();) { + for(Iterator<EObject> it = resource.getContents().iterator(); it.hasNext();) { Object rootElement = it.next(); - if (rootElement instanceof Diagram) { + if(rootElement instanceof Diagram) { document.setContent(rootElement); return; } @@ -245,21 +233,17 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi throw new RuntimeException(Messages.UMLDocumentProvider_NoDiagramInResourceError); } catch (Exception e) { CoreException thrownExcp = null; - if (e instanceof CoreException) { - thrownExcp = (CoreException) e; + if(e instanceof CoreException) { + thrownExcp = (CoreException)e; } else { String msg = e.getLocalizedMessage(); - thrownExcp = new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, - msg != null ? msg : Messages.UMLDocumentProvider_DiagramLoadingError, e)); + thrownExcp = new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, msg != null ? msg : Messages.UMLDocumentProvider_DiagramLoadingError, e)); } throw thrownExcp; } } else { - throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, - NLS.bind(Messages.UMLDocumentProvider_IncorrectInputError, - new Object[] { element, "org.eclipse.ui.part.FileEditorInput", //$NON-NLS-1$ - "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ - null)); + throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, NLS.bind(Messages.UMLDocumentProvider_IncorrectInputError, new Object[]{ element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$ + null)); } } @@ -269,7 +253,7 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi @Override public long getModificationStamp(Object element) { ResourceSetInfo info = getResourceSetInfo(element); - if (info != null) { + if(info != null) { return computeModificationStamp(info); } return super.getModificationStamp(element); @@ -281,9 +265,9 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi @Override public boolean isDeleted(Object element) { IDiagramDocument document = getDiagramDocument(element); - if (document != null) { + if(document != null) { Resource diagramResource = document.getDiagram().eResource(); - if (diagramResource != null) { + if(diagramResource != null) { IFile file = WorkspaceSynchronizer.getFile(diagramResource); return file == null || file.getLocation() == null || !file.getLocation().toFile().exists(); } @@ -295,7 +279,7 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi * @generated */ public ResourceSetInfo getResourceSetInfo(Object editorInput) { - return (ResourceSetInfo) super.getElementInfo(editorInput); + return (ResourceSetInfo)super.getElementInfo(editorInput); } /** @@ -303,8 +287,8 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi */ @Override protected void disposeElementInfo(Object element, ElementInfo info) { - if (info instanceof ResourceSetInfo) { - ResourceSetInfo resourceSetInfo = (ResourceSetInfo) info; + if(info instanceof ResourceSetInfo) { + ResourceSetInfo resourceSetInfo = (ResourceSetInfo)info; resourceSetInfo.dispose(); } super.disposeElementInfo(element, info); @@ -316,19 +300,17 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi @Override protected void doValidateState(Object element, Object computationContext) throws CoreException { ResourceSetInfo info = getResourceSetInfo(element); - if (info != null) { + if(info != null) { LinkedList<IFile> files2Validate = new LinkedList<IFile>(); - for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { + for(Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { Resource nextResource = it.next(); IFile file = WorkspaceSynchronizer.getFile(nextResource); - if (file != null && file.isReadOnly()) { + if(file != null && file.isReadOnly()) { files2Validate.add(file); } } - ResourcesPlugin.getWorkspace().validateEdit(files2Validate.toArray(new IFile[files2Validate.size()]), - computationContext); + ResourcesPlugin.getWorkspace().validateEdit(files2Validate.toArray(new IFile[files2Validate.size()]), computationContext); } - super.doValidateState(element, computationContext); } @@ -338,8 +320,8 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi @Override public boolean isReadOnly(Object element) { ResourceSetInfo info = getResourceSetInfo(element); - if (info != null) { - if (info.isUpdateCache()) { + if(info != null) { + if(info.isUpdateCache()) { try { updateCache(element); } catch (CoreException ex) { @@ -357,14 +339,14 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi */ @Override public boolean isModifiable(Object element) { - if (!isStateValidated(element)) { - if (element instanceof FileEditorInput || element instanceof URIEditorInput) { + if(!isStateValidated(element)) { + if(element instanceof FileEditorInput || element instanceof URIEditorInput) { return true; } } ResourceSetInfo info = getResourceSetInfo(element); - if (info != null) { - if (info.isUpdateCache()) { + if(info != null) { + if(info.isUpdateCache()) { try { updateCache(element); } catch (CoreException ex) { @@ -382,11 +364,11 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi */ protected void updateCache(Object element) throws CoreException { ResourceSetInfo info = getResourceSetInfo(element); - if (info != null) { - for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { + if(info != null) { + for(Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { Resource nextResource = it.next(); IFile file = WorkspaceSynchronizer.getFile(nextResource); - if (file != null && file.isReadOnly()) { + if(file != null && file.isReadOnly()) { info.setReadOnly(true); info.setModifiable(false); return; @@ -404,7 +386,7 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi @Override protected void doUpdateStateCache(Object element) throws CoreException { ResourceSetInfo info = getResourceSetInfo(element); - if (info != null) { + if(info != null) { info.setUpdateCache(true); } super.doUpdateStateCache(element); @@ -416,7 +398,7 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi @Override public boolean isSynchronized(Object element) { ResourceSetInfo info = getResourceSetInfo(element); - if (info != null) { + if(info != null) { return info.isSynchronized(); } return super.isSynchronized(element); @@ -428,12 +410,12 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi @Override protected ISchedulingRule getResetRule(Object element) { ResourceSetInfo info = getResourceSetInfo(element); - if (info != null) { + if(info != null) { LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>(); - for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { + for(Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { Resource nextResource = it.next(); IFile file = WorkspaceSynchronizer.getFile(nextResource); - if (file != null) { + if(file != null) { rules.add(ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(file)); } } @@ -448,12 +430,12 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi @Override protected ISchedulingRule getSaveRule(Object element) { ResourceSetInfo info = getResourceSetInfo(element); - if (info != null) { + if(info != null) { LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>(); - for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { + for(Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { Resource nextResource = it.next(); IFile file = WorkspaceSynchronizer.getFile(nextResource); - if (file != null) { + if(file != null) { rules.add(computeSchedulingRule(file)); } } @@ -468,12 +450,12 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi @Override protected ISchedulingRule getSynchronizeRule(Object element) { ResourceSetInfo info = getResourceSetInfo(element); - if (info != null) { + if(info != null) { LinkedList<ISchedulingRule> rules = new LinkedList<ISchedulingRule>(); - for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { + for(Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { Resource nextResource = it.next(); IFile file = WorkspaceSynchronizer.getFile(nextResource); - if (file != null) { + if(file != null) { rules.add(ResourcesPlugin.getWorkspace().getRuleFactory().refreshRule(file)); } } @@ -488,17 +470,16 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi @Override protected ISchedulingRule getValidateStateRule(Object element) { ResourceSetInfo info = getResourceSetInfo(element); - if (info != null) { + if(info != null) { LinkedList<ISchedulingRule> files = new LinkedList<ISchedulingRule>(); - for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { + for(Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { Resource nextResource = it.next(); IFile file = WorkspaceSynchronizer.getFile(nextResource); - if (file != null) { + if(file != null) { files.add(file); } } - return ResourcesPlugin.getWorkspace().getRuleFactory() - .validateEditRule(files.toArray(new IFile[files.size()])); + return ResourcesPlugin.getWorkspace().getRuleFactory().validateEditRule(files.toArray(new IFile[files.size()])); } return null; } @@ -507,7 +488,7 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi * @generated */ private ISchedulingRule computeSchedulingRule(IResource toCreateOrModify) { - if (toCreateOrModify.exists()) { + if(toCreateOrModify.exists()) { return ResourcesPlugin.getWorkspace().getRuleFactory().modifyRule(toCreateOrModify); } IResource parent = toCreateOrModify; @@ -520,8 +501,7 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi */ toCreateOrModify = parent; parent = toCreateOrModify.getParent(); - } while (parent != null && !parent.exists()); - + } while(parent != null && !parent.exists()); return ResourcesPlugin.getWorkspace().getRuleFactory().createRule(toCreateOrModify); } @@ -531,8 +511,8 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi @Override protected void doSynchronize(Object element, IProgressMonitor monitor) throws CoreException { ResourceSetInfo info = getResourceSetInfo(element); - if (info != null) { - for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { + if(info != null) { + for(Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { Resource nextResource = it.next(); handleElementChanged(info, nextResource, monitor); } @@ -545,31 +525,25 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi * @generated */ @Override - protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) - throws CoreException { + protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException { ResourceSetInfo info = getResourceSetInfo(element); - if (info != null) { - if (!overwrite && !info.isSynchronized()) { - throw new CoreException( - new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, IResourceStatus.OUT_OF_SYNC_LOCAL, - Messages.UMLDocumentProvider_UnsynchronizedFileSaveError, null)); + if(info != null) { + if(!overwrite && !info.isSynchronized()) { + throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, IResourceStatus.OUT_OF_SYNC_LOCAL, Messages.UMLDocumentProvider_UnsynchronizedFileSaveError, null)); } info.stopResourceListening(); fireElementStateChanging(element); try { - monitor.beginTask(Messages.UMLDocumentProvider_SaveDiagramTask, - info.getResourceSet().getResources().size() + 1); //"Saving diagram" - for (Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { + monitor.beginTask(Messages.UMLDocumentProvider_SaveDiagramTask, info.getResourceSet().getResources().size() + 1); //"Saving diagram" + for(Iterator<Resource> it = info.getLoadedResourcesIterator(); it.hasNext();) { Resource nextResource = it.next(); - monitor.setTaskName( - NLS.bind(Messages.UMLDocumentProvider_SaveNextResourceTask, nextResource.getURI())); - if (nextResource.isLoaded() && !info.getEditingDomain().isReadOnly(nextResource)) { + monitor.setTaskName(NLS.bind(Messages.UMLDocumentProvider_SaveNextResourceTask, nextResource.getURI())); + if(nextResource.isLoaded() && !info.getEditingDomain().isReadOnly(nextResource)) { try { nextResource.save(UMLDiagramEditorUtil.getSaveOptions()); } catch (IOException e) { fireElementStateChangeFailed(element); - throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, - EditorStatusCodes.RESOURCE_FAILURE, e.getLocalizedMessage(), null)); + throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, EditorStatusCodes.RESOURCE_FAILURE, e.getLocalizedMessage(), null)); } } monitor.worked(1); @@ -585,37 +559,29 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi } else { URI newResoruceURI; List<IFile> affectedFiles = null; - if (element instanceof FileEditorInput) { - IFile newFile = ((FileEditorInput) element).getFile(); + if(element instanceof FileEditorInput) { + IFile newFile = ((FileEditorInput)element).getFile(); affectedFiles = Collections.singletonList(newFile); newResoruceURI = URI.createPlatformResourceURI(newFile.getFullPath().toString(), true); - } else if (element instanceof URIEditorInput) { - newResoruceURI = ((URIEditorInput) element).getURI(); + } else if(element instanceof URIEditorInput) { + newResoruceURI = ((URIEditorInput)element).getURI(); } else { fireElementStateChangeFailed(element); - throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, - NLS.bind(Messages.UMLDocumentProvider_IncorrectInputError, - new Object[] { element, "org.eclipse.ui.part.FileEditorInput", //$NON-NLS-1$ - "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ - null)); + throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, NLS.bind(Messages.UMLDocumentProvider_IncorrectInputError, new Object[]{ element, "org.eclipse.ui.part.FileEditorInput", "org.eclipse.emf.common.ui.URIEditorInput" }), //$NON-NLS-1$ //$NON-NLS-2$ + null)); } - if (false == document instanceof IDiagramDocument) { + if(false == document instanceof IDiagramDocument) { fireElementStateChangeFailed(element); - throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, - "Incorrect document used: " + document //$NON-NLS-1$ - + " instead of org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument", //$NON-NLS-1$ - null)); + throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, "Incorrect document used: " + document + " instead of org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument", null)); //$NON-NLS-1$ //$NON-NLS-2$ } - IDiagramDocument diagramDocument = (IDiagramDocument) document; - final Resource newResource = diagramDocument.getEditingDomain().getResourceSet() - .createResource(newResoruceURI); + IDiagramDocument diagramDocument = (IDiagramDocument)document; + final Resource newResource = diagramDocument.getEditingDomain().getResourceSet().createResource(newResoruceURI); final Diagram diagramCopy = EcoreUtil.copy(diagramDocument.getDiagram()); try { - new AbstractTransactionalCommand(diagramDocument.getEditingDomain(), - NLS.bind(Messages.UMLDocumentProvider_SaveAsOperation, diagramCopy.getName()), affectedFiles) { + new AbstractTransactionalCommand(diagramDocument.getEditingDomain(), NLS.bind(Messages.UMLDocumentProvider_SaveAsOperation, diagramCopy.getName()), affectedFiles) { + @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException { + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { newResource.getContents().add(diagramCopy); return CommandResult.newOKCommandResult(); } @@ -623,12 +589,10 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi newResource.save(UMLDiagramEditorUtil.getSaveOptions()); } catch (ExecutionException e) { fireElementStateChangeFailed(element); - throw new CoreException( - new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, e.getLocalizedMessage(), null)); + throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, e.getLocalizedMessage(), null)); } catch (IOException e) { fireElementStateChangeFailed(element); - throw new CoreException( - new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, e.getLocalizedMessage(), null)); + throw new CoreException(new Status(IStatus.ERROR, UMLDiagramEditorPlugin.ID, 0, e.getLocalizedMessage(), null)); } newResource.unload(); } @@ -639,17 +603,15 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi */ protected void handleElementChanged(ResourceSetInfo info, Resource changedResource, IProgressMonitor monitor) { IFile file = WorkspaceSynchronizer.getFile(changedResource); - if (file != null) { + if(file != null) { try { file.refreshLocal(IResource.DEPTH_INFINITE, monitor); } catch (CoreException ex) { - UMLDiagramEditorPlugin.getInstance().logError(Messages.UMLDocumentProvider_handleElementContentChanged, - ex); + UMLDiagramEditorPlugin.getInstance().logError(Messages.UMLDocumentProvider_handleElementContentChanged, ex); // Error message to log was initially taken from org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide.internal.l10n.EditorMessages.FileDocumentProvider_handleElementContentChanged } } changedResource.unload(); - fireElementContentAboutToBeReplaced(info.getEditorInput()); removeUnchangedElementListeners(info.getEditorInput(), info); info.fStatus = null; @@ -658,7 +620,7 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi } catch (CoreException e) { info.fStatus = e.getStatus(); } - if (!info.fCanBeSaved) { + if(!info.fCanBeSaved) { info.setModificationStamp(computeModificationStamp(info)); } addUnchangedElementListeners(info.getEditorInput(), info); @@ -669,9 +631,8 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi * @generated */ protected void handleElementMoved(IEditorInput input, URI uri) { - if (input instanceof FileEditorInput) { - IFile newFile = ResourcesPlugin.getWorkspace().getRoot() - .getFile(new Path(URI.decode(uri.path())).removeFirstSegments(1)); + if(input instanceof FileEditorInput) { + IFile newFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(URI.decode(uri.path())).removeFirstSegments(1)); fireElementMoved(input, newFile == null ? null : new FileEditorInput(newFile)); return; } @@ -693,8 +654,8 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi @Override public IDiagramDocument getDiagramDocument(Object element) { IDocument doc = getDocument(element); - if (doc instanceof IDiagramDocument) { - return (IDiagramDocument) doc; + if(doc instanceof IDiagramDocument) { + return (IDiagramDocument)doc; } return null; } @@ -817,7 +778,7 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi public void dispose() { stopResourceListening(); getResourceSet().eAdapters().remove(myResourceSetListener); - for (Iterator<Resource> it = getLoadedResourcesIterator(); it.hasNext();) { + for(Iterator<Resource> it = getLoadedResourcesIterator(); it.hasNext();) { Resource resource = it.next(); resource.unload(); } @@ -919,13 +880,14 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi */ @Override public boolean handleResourceChanged(final Resource resource) { - synchronized (ResourceSetInfo.this) { - if (ResourceSetInfo.this.fCanBeSaved) { + synchronized(ResourceSetInfo.this) { + if(ResourceSetInfo.this.fCanBeSaved) { ResourceSetInfo.this.setUnSynchronized(resource); return true; } } Display.getDefault().asyncExec(new Runnable() { + @Override public void run() { handleElementChanged(ResourceSetInfo.this, resource, null); @@ -939,13 +901,14 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi */ @Override public boolean handleResourceDeleted(Resource resource) { - synchronized (ResourceSetInfo.this) { - if (ResourceSetInfo.this.fCanBeSaved) { + synchronized(ResourceSetInfo.this) { + if(ResourceSetInfo.this.fCanBeSaved) { ResourceSetInfo.this.setUnSynchronized(resource); return true; } } Display.getDefault().asyncExec(new Runnable() { + @Override public void run() { fireElementDeleted(ResourceSetInfo.this.getEditorInput()); @@ -959,14 +922,15 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi */ @Override public boolean handleResourceMoved(Resource resource, final URI newURI) { - synchronized (ResourceSetInfo.this) { - if (ResourceSetInfo.this.fCanBeSaved) { + synchronized(ResourceSetInfo.this) { + if(ResourceSetInfo.this.fCanBeSaved) { ResourceSetInfo.this.setUnSynchronized(resource); return true; } } - if (myDocument.getDiagram().eResource() == resource) { + if(myDocument.getDiagram().eResource() == resource) { Display.getDefault().asyncExec(new Runnable() { + @Override public void run() { handleElementMoved(ResourceSetInfo.this.getEditorInput(), newURI); @@ -1000,9 +964,7 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi */ public ResourceSetModificationListener(ResourceSetInfo info) { myInfo = info; - myModifiedFilter = NotificationFilter.createEventTypeFilter(Notification.SET) - .or(NotificationFilter.createEventTypeFilter(Notification.UNSET)) - .and(NotificationFilter.createFeatureFilter(Resource.class, Resource.RESOURCE__IS_MODIFIED)); + myModifiedFilter = NotificationFilter.createEventTypeFilter(Notification.SET).or(NotificationFilter.createEventTypeFilter(Notification.UNSET)).and(NotificationFilter.createFeatureFilter(Resource.class, Resource.RESOURCE__IS_MODIFIED)); } /** @@ -1010,34 +972,33 @@ public class UMLDocumentProvider extends AbstractDocumentProvider implements IDi */ @Override public void notifyChanged(Notification notification) { - if (notification.getNotifier() instanceof ResourceSet) { + if(notification.getNotifier() instanceof ResourceSet) { super.notifyChanged(notification); } - if (!notification.isTouch() && myModifiedFilter.matches(notification)) { - if (notification.getNotifier() instanceof Resource) { - Resource resource = (Resource) notification.getNotifier(); - if (resource.isLoaded()) { + if(!notification.isTouch() && myModifiedFilter.matches(notification)) { + if(notification.getNotifier() instanceof Resource) { + Resource resource = (Resource)notification.getNotifier(); + if(resource.isLoaded()) { boolean modified = false; - for (Iterator<Resource> it = myInfo.getLoadedResourcesIterator(); it.hasNext() && !modified;) { + for(Iterator<Resource> it = myInfo.getLoadedResourcesIterator(); it.hasNext() && !modified;) { Resource nextResource = it.next(); - if (nextResource.isLoaded()) { + if(nextResource.isLoaded()) { modified = nextResource.isModified(); } } boolean dirtyStateChanged = false; - synchronized (myInfo) { - if (modified != myInfo.fCanBeSaved) { + synchronized(myInfo) { + if(modified != myInfo.fCanBeSaved) { myInfo.fCanBeSaved = modified; dirtyStateChanged = true; } - if (!resource.isModified()) { + if(!resource.isModified()) { myInfo.setSynchronized(resource); } } - if (dirtyStateChanged) { + if(dirtyStateChanged) { fireElementDirtyStateChanged(myInfo.getEditorInput(), modified); - - if (!modified) { + if(!modified) { myInfo.setModificationStamp(computeModificationStamp(myInfo)); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLInitDiagramFileAction.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLInitDiagramFileAction.java index 52599fbe359..c8e9ead54d5 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLInitDiagramFileAction.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLInitDiagramFileAction.java @@ -60,10 +60,10 @@ public class UMLInitDiagramFileAction implements IObjectActionDelegate { public void selectionChanged(IAction action, ISelection selection) { domainModelURI = null; action.setEnabled(false); - if (selection instanceof IStructuredSelection == false || selection.isEmpty()) { + if(selection instanceof IStructuredSelection == false || selection.isEmpty()) { return; } - IFile file = (IFile) ((IStructuredSelection) selection).getFirstElement(); + IFile file = (IFile)((IStructuredSelection)selection).getFirstElement(); domainModelURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true); action.setEnabled(true); } @@ -89,9 +89,8 @@ public class UMLInitDiagramFileAction implements IObjectActionDelegate { } catch (WrappedException ex) { UMLDiagramEditorPlugin.getInstance().logError("Unable to load resource: " + domainModelURI, ex); //$NON-NLS-1$ } - if (diagramRoot == null) { - MessageDialog.openError(getShell(), Messages.InitDiagramFile_ResourceErrorDialogTitle, - Messages.InitDiagramFile_ResourceErrorDialogMessage); + if(diagramRoot == null) { + MessageDialog.openError(getShell(), Messages.InitDiagramFile_ResourceErrorDialogTitle, Messages.InitDiagramFile_ResourceErrorDialogMessage); return; } Wizard wizard = new UMLNewDiagramFileWizard(domainModelURI, diagramRoot, editingDomain); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLLinkDescriptor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLLinkDescriptor.java index 9139fea1cd2..1bd19443e1d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLLinkDescriptor.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLLinkDescriptor.java @@ -30,8 +30,7 @@ public class UMLLinkDescriptor extends UpdaterLinkDescriptor { /** * @generated */ - public UMLLinkDescriptor(EObject source, EObject destination, EObject linkElement, IElementType elementType, - String linkVID) { + public UMLLinkDescriptor(EObject source, EObject destination, EObject linkElement, IElementType elementType, String linkVID) { super(source, destination, linkElement, elementType, linkVID); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLMatchingStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLMatchingStrategy.java index fdfe267e3b4..63b3d4d4b16 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLMatchingStrategy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLMatchingStrategy.java @@ -33,12 +33,11 @@ public class UMLMatchingStrategy implements IEditorMatchingStrategy { } catch (PartInitException e) { return false; } - - if (editorInput.equals(input)) { + if(editorInput.equals(input)) { return true; } - if (editorInput instanceof URIEditorInput && input instanceof URIEditorInput) { - return ((URIEditorInput) editorInput).getURI().equals(((URIEditorInput) input).getURI()); + if(editorInput instanceof URIEditorInput && input instanceof URIEditorInput) { + return ((URIEditorInput)editorInput).getURI().equals(((URIEditorInput)input).getURI()); } return false; } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLNewDiagramFileWizard.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLNewDiagramFileWizard.java index 50ff97f5601..0d9848d2d10 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLNewDiagramFileWizard.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLNewDiagramFileWizard.java @@ -67,32 +67,25 @@ public class UMLNewDiagramFileWizard extends Wizard { assert domainModelURI != null : "Domain model uri must be specified"; //$NON-NLS-1$ assert diagramRoot != null : "Doagram root element must be specified"; //$NON-NLS-1$ assert editingDomain != null : "Editing domain must be specified"; //$NON-NLS-1$ - - myFileCreationPage = new WizardNewFileCreationPage(Messages.UMLNewDiagramFileWizard_CreationPageName, - StructuredSelection.EMPTY); + myFileCreationPage = new WizardNewFileCreationPage(Messages.UMLNewDiagramFileWizard_CreationPageName, StructuredSelection.EMPTY); myFileCreationPage.setTitle(Messages.UMLNewDiagramFileWizard_CreationPageTitle); - myFileCreationPage.setDescription( - NLS.bind(Messages.UMLNewDiagramFileWizard_CreationPageDescription, PackageEditPart.MODEL_ID)); + myFileCreationPage.setDescription(NLS.bind(Messages.UMLNewDiagramFileWizard_CreationPageDescription, PackageEditPart.MODEL_ID)); IPath filePath; String fileName = URI.decode(domainModelURI.trimFileExtension().lastSegment()); - if (domainModelURI.isPlatformResource()) { + if(domainModelURI.isPlatformResource()) { filePath = new Path(domainModelURI.trimSegments(1).toPlatformString(true)); - } else if (domainModelURI.isFile()) { + } else if(domainModelURI.isFile()) { filePath = new Path(domainModelURI.trimSegments(1).toFileString()); } else { // TODO : use some default path throw new IllegalArgumentException("Unsupported URI: " + domainModelURI); //$NON-NLS-1$ } myFileCreationPage.setContainerFullPath(filePath); - myFileCreationPage.setFileName( - UMLDiagramEditorUtil.getUniqueFileName(filePath, fileName, "PapyrusUMLStateMachine_diagram")); //$NON-NLS-1$ - - diagramRootElementSelectionPage = new DiagramRootElementSelectionPage( - Messages.UMLNewDiagramFileWizard_RootSelectionPageName); + myFileCreationPage.setFileName(UMLDiagramEditorUtil.getUniqueFileName(filePath, fileName, "PapyrusUMLStateMachine_diagram")); //$NON-NLS-1$ + diagramRootElementSelectionPage = new DiagramRootElementSelectionPage(Messages.UMLNewDiagramFileWizard_RootSelectionPageName); diagramRootElementSelectionPage.setTitle(Messages.UMLNewDiagramFileWizard_RootSelectionPageTitle); diagramRootElementSelectionPage.setDescription(Messages.UMLNewDiagramFileWizard_RootSelectionPageDescription); diagramRootElementSelectionPage.setModelElement(diagramRoot); - myEditingDomain = editingDomain; } @@ -117,19 +110,15 @@ public class UMLNewDiagramFileWizard extends Wizard { URI diagramModelURI = URI.createPlatformResourceURI(diagramFile.getFullPath().toString(), true); ResourceSet resourceSet = myEditingDomain.getResourceSet(); final Resource diagramResource = resourceSet.createResource(diagramModelURI); - AbstractTransactionalCommand command = new AbstractTransactionalCommand(myEditingDomain, - Messages.UMLNewDiagramFileWizard_InitDiagramCommand, affectedFiles) { + AbstractTransactionalCommand command = new AbstractTransactionalCommand(myEditingDomain, Messages.UMLNewDiagramFileWizard_InitDiagramCommand, affectedFiles) { @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException { - String diagramVID = UMLVisualIDRegistry - .getDiagramVisualID(diagramRootElementSelectionPage.getModelElement()); - if (diagramVID.equals(PackageEditPart.VISUAL_ID)) { + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + String diagramVID = UMLVisualIDRegistry.getDiagramVisualID(diagramRootElementSelectionPage.getModelElement()); + if(diagramVID.equals(PackageEditPart.VISUAL_ID)) { return CommandResult.newErrorCommandResult(Messages.UMLNewDiagramFileWizard_IncorrectRootError); } - Diagram diagram = ViewService.createDiagram(diagramRootElementSelectionPage.getModelElement(), - PackageEditPart.MODEL_ID, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT); + Diagram diagram = ViewService.createDiagram(diagramRootElementSelectionPage.getModelElement(), PackageEditPart.MODEL_ID, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT); diagramResource.getContents().add(diagram); return CommandResult.newOKCommandResult(); } @@ -173,13 +162,11 @@ public class UMLNewDiagramFileWizard extends Wizard { */ @Override protected boolean validatePage() { - if (getModelElement() == null) { + if(getModelElement() == null) { setErrorMessage(Messages.UMLNewDiagramFileWizard_RootSelectionPageNoSelectionMessage); return false; } - boolean result = ViewService.getInstance() - .provides(new CreateDiagramViewOperation(new EObjectAdapter(getModelElement()), - PackageEditPart.MODEL_ID, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT)); + boolean result = ViewService.getInstance().provides(new CreateDiagramViewOperation(new EObjectAdapter(getModelElement()), PackageEditPart.MODEL_ID, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT)); setErrorMessage(result ? null : Messages.UMLNewDiagramFileWizard_RootSelectionPageInvalidSelectionMessage); return result; } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLPaletteFactory.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLPaletteFactory.java index 25ac9c35d72..1d9a841204c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLPaletteFactory.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLPaletteFactory.java @@ -125,7 +125,6 @@ public class UMLPaletteFactory extends PaletteFactory.Adapter { * @generated */ public UMLPaletteFactory() { - } /** @@ -133,61 +132,61 @@ public class UMLPaletteFactory extends PaletteFactory.Adapter { */ @Override public Tool createTool(String toolId) { - if (toolId.equals(STATEMACHINE_CREATENODESGROUP_REGION)) { + if(toolId.equals(STATEMACHINE_CREATENODESGROUP_REGION)) { return createRegionCreationTool(); } - if (toolId.equals(STATEMACHINE_CREATENODESGROUP_STATE)) { + if(toolId.equals(STATEMACHINE_CREATENODESGROUP_STATE)) { return createStateCreationTool(); } - if (toolId.equals(STATEMACHINE_CREATENODESGROUP_INITIAL)) { + if(toolId.equals(STATEMACHINE_CREATENODESGROUP_INITIAL)) { return createInitialCreationTool(); } - if (toolId.equals(STATEMACHINE_CREATENODESGROUP_FINALSTATE)) { + if(toolId.equals(STATEMACHINE_CREATENODESGROUP_FINALSTATE)) { return createFinalStateCreationTool(); } - if (toolId.equals(STATEMACHINE_CREATENODESGROUP_SHALLOWHISTORY)) { + if(toolId.equals(STATEMACHINE_CREATENODESGROUP_SHALLOWHISTORY)) { return createShallowHistoryCreationTool(); } - if (toolId.equals(STATEMACHINE_CREATENODESGROUP_DEEPHISTORY)) { + if(toolId.equals(STATEMACHINE_CREATENODESGROUP_DEEPHISTORY)) { return createDeepHistoryCreationTool(); } - if (toolId.equals(STATEMACHINE_CREATENODESGROUP_FORK)) { + if(toolId.equals(STATEMACHINE_CREATENODESGROUP_FORK)) { return createForkCreationTool(); } - if (toolId.equals(STATEMACHINE_CREATENODESGROUP_JOIN)) { + if(toolId.equals(STATEMACHINE_CREATENODESGROUP_JOIN)) { return createJoinCreationTool(); } - if (toolId.equals(STATEMACHINE_CREATENODESGROUP_CHOICE)) { + if(toolId.equals(STATEMACHINE_CREATENODESGROUP_CHOICE)) { return createChoiceCreationTool(); } - if (toolId.equals(STATEMACHINE_CREATENODESGROUP_JUNCTION)) { + if(toolId.equals(STATEMACHINE_CREATENODESGROUP_JUNCTION)) { return createJunctionCreationTool(); } - if (toolId.equals(STATEMACHINE_CREATENODESGROUP_ENTRYPOINT)) { + if(toolId.equals(STATEMACHINE_CREATENODESGROUP_ENTRYPOINT)) { return createEntryPointCreationTool(); } - if (toolId.equals(STATEMACHINE_CREATENODESGROUP_EXITPOINT)) { + if(toolId.equals(STATEMACHINE_CREATENODESGROUP_EXITPOINT)) { return createExitPointCreationTool(); } - if (toolId.equals(STATEMACHINE_CREATENODESGROUP_TERMINATE)) { + if(toolId.equals(STATEMACHINE_CREATENODESGROUP_TERMINATE)) { return createTerminateCreationTool(); } - if (toolId.equals(STATEMACHINE_CREATENODESGROUP_CONNECTIONPOINTREFERENCE)) { + if(toolId.equals(STATEMACHINE_CREATENODESGROUP_CONNECTIONPOINTREFERENCE)) { return createConnectionPointReferenceCreationTool(); } - if (toolId.equals(STATEMACHINE_CREATENODESGROUP_COMMENT)) { + if(toolId.equals(STATEMACHINE_CREATENODESGROUP_COMMENT)) { return createStateMachineCommentCreationTool(); } - if (toolId.equals(STATEMACHINE_CREATENODESGROUP_CONSTRAINT)) { + if(toolId.equals(STATEMACHINE_CREATENODESGROUP_CONSTRAINT)) { return createConstraintCreationTool(); } - if (toolId.equals(STATEMACHINE_CREATEEDGESGROUP_TRANSITION)) { + if(toolId.equals(STATEMACHINE_CREATEEDGESGROUP_TRANSITION)) { return createTransitionCreationTool(); } - if (toolId.equals(STATEMACHINE_CREATEEDGESGROUP_LINK)) { + if(toolId.equals(STATEMACHINE_CREATEEDGESGROUP_LINK)) { return createCommentlinkCreationTool(); } - if (toolId.equals(STATEMACHINE_CREATEEDGESGROUP_CONTEXTLINK)) { + if(toolId.equals(STATEMACHINE_CREATEEDGESGROUP_CONTEXTLINK)) { return createContextLink3CreationTool(); } // default return: null @@ -199,7 +198,6 @@ public class UMLPaletteFactory extends PaletteFactory.Adapter { */ @Override public Object getTemplate(String templateId) { - // default return: null return null; } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLVisualIDRegistry.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLVisualIDRegistry.java index 678a8cb6da5..2d1ae79e0f5 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLVisualIDRegistry.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/UMLVisualIDRegistry.java @@ -104,8 +104,8 @@ public class UMLVisualIDRegistry { * @generated */ public static String getVisualID(View view) { - if (view instanceof Diagram) { - if (PackageEditPart.MODEL_ID.equals(view.getType())) { + if(view instanceof Diagram) { + if(PackageEditPart.MODEL_ID.equals(view.getType())) { return PackageEditPart.VISUAL_ID; } else { return null; @@ -119,12 +119,12 @@ public class UMLVisualIDRegistry { */ public static String getModelID(View view) { View diagram = view.getDiagram(); - while (view != diagram) { + while(view != diagram) { EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$ - if (annotation != null) { + if(annotation != null) { return annotation.getDetails().get("modelID"); //$NON-NLS-1$ } - view = (View) view.eContainer(); + view = (View)view.eContainer(); } return diagram != null ? diagram.getType() : null; } @@ -147,7 +147,7 @@ public class UMLVisualIDRegistry { * @generated */ public static String getDiagramVisualID(EObject domainElement) { - if (domainElement == null) { + if(domainElement == null) { return null; } return PackageEditPart.VISUAL_ID; @@ -157,145 +157,124 @@ public class UMLVisualIDRegistry { * @generated */ public static String getNodeVisualID(View containerView, EObject domainElement) { - if (domainElement == null) { + if(domainElement == null) { return null; } - String containerModelID = org.eclipse.papyrus.uml.diagram.statemachine.part.UMLVisualIDRegistry - .getModelID(containerView); - if (!PackageEditPart.MODEL_ID.equals(containerModelID)) { + String containerModelID = org.eclipse.papyrus.uml.diagram.statemachine.part.UMLVisualIDRegistry.getModelID(containerView); + if(!PackageEditPart.MODEL_ID.equals(containerModelID)) { return null; } String containerVisualID; - if (PackageEditPart.MODEL_ID.equals(containerModelID)) { - containerVisualID = org.eclipse.papyrus.uml.diagram.statemachine.part.UMLVisualIDRegistry - .getVisualID(containerView); + if(PackageEditPart.MODEL_ID.equals(containerModelID)) { + containerVisualID = org.eclipse.papyrus.uml.diagram.statemachine.part.UMLVisualIDRegistry.getVisualID(containerView); } else { - if (containerView instanceof Diagram) { + if(containerView instanceof Diagram) { containerVisualID = PackageEditPart.VISUAL_ID; } else { return null; } } - if (containerVisualID != null) { - switch (containerVisualID) { + if(containerVisualID != null) { + switch(containerVisualID) { case PackageEditPart.VISUAL_ID: - if (UMLPackage.eINSTANCE.getStateMachine().isSuperTypeOf(domainElement.eClass())) { + if(UMLPackage.eINSTANCE.getStateMachine().isSuperTypeOf(domainElement.eClass())) { return StateMachineEditPart.VISUAL_ID; } break; case StateMachineEditPart.VISUAL_ID: - if (UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) - && isPseudostate_EntryPointShape(containerView, (Pseudostate) domainElement)) { + if(UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) && isPseudostate_EntryPointShape(containerView, (Pseudostate)domainElement)) { return PseudostateEntryPointEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) - && isPseudostate_ExitPointShape(containerView, (Pseudostate) domainElement)) { + if(UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) && isPseudostate_ExitPointShape(containerView, (Pseudostate)domainElement)) { return PseudostateExitPointEditPart.VISUAL_ID; } break; case StateEditPart.VISUAL_ID: - if (UMLPackage.eINSTANCE.getBehavior().isSuperTypeOf(domainElement.eClass()) - && isBehavior_EntryBehaviorLabel((Behavior) domainElement)) { + if(UMLPackage.eINSTANCE.getBehavior().isSuperTypeOf(domainElement.eClass()) && isBehavior_EntryBehaviorLabel((Behavior)domainElement)) { return EntryStateBehaviorEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getBehavior().isSuperTypeOf(domainElement.eClass()) - && isBehavior_DoActivityBehaviorLabel((Behavior) domainElement)) { + if(UMLPackage.eINSTANCE.getBehavior().isSuperTypeOf(domainElement.eClass()) && isBehavior_DoActivityBehaviorLabel((Behavior)domainElement)) { return DoActivityStateBehaviorStateEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getBehavior().isSuperTypeOf(domainElement.eClass()) - && isBehavior_ExitBehaviorLabel((Behavior) domainElement)) { + if(UMLPackage.eINSTANCE.getBehavior().isSuperTypeOf(domainElement.eClass()) && isBehavior_ExitBehaviorLabel((Behavior)domainElement)) { return ExitStateBehaviorEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getTransition().isSuperTypeOf(domainElement.eClass())) { + if(UMLPackage.eINSTANCE.getTransition().isSuperTypeOf(domainElement.eClass())) { return InternalTransitionEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getRegion().isSuperTypeOf(domainElement.eClass())) { + if(UMLPackage.eINSTANCE.getRegion().isSuperTypeOf(domainElement.eClass())) { return RegionEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) - && isPseudostate_EntryPointShape(containerView, (Pseudostate) domainElement)) { + if(UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) && isPseudostate_EntryPointShape(containerView, (Pseudostate)domainElement)) { return PseudostateEntryPointEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) - && isPseudostate_ExitPointShape(containerView, (Pseudostate) domainElement)) { + if(UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) && isPseudostate_ExitPointShape(containerView, (Pseudostate)domainElement)) { return PseudostateExitPointEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getConnectionPointReference().isSuperTypeOf(domainElement.eClass())) { + if(UMLPackage.eINSTANCE.getConnectionPointReference().isSuperTypeOf(domainElement.eClass())) { return ConnectionPointReferenceEditPart.VISUAL_ID; } break; case RegionCompartmentEditPart.VISUAL_ID: - if (UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) - && isPseudostate_InitialShape(containerView, (Pseudostate) domainElement)) { + if(UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) && isPseudostate_InitialShape(containerView, (Pseudostate)domainElement)) { return PseudostateInitialEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) - && isPseudostate_JoinShape(containerView, (Pseudostate) domainElement)) { + if(UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) && isPseudostate_JoinShape(containerView, (Pseudostate)domainElement)) { return PseudostateJoinEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) - && isPseudostate_ForkShape(containerView, (Pseudostate) domainElement)) { + if(UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) && isPseudostate_ForkShape(containerView, (Pseudostate)domainElement)) { return PseudostateForkEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) - && isPseudostate_ChoiceShape(containerView, (Pseudostate) domainElement)) { + if(UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) && isPseudostate_ChoiceShape(containerView, (Pseudostate)domainElement)) { return PseudostateChoiceEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) - && isPseudostate_JunctionShape(containerView, (Pseudostate) domainElement)) { + if(UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) && isPseudostate_JunctionShape(containerView, (Pseudostate)domainElement)) { return PseudostateJunctionEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) - && isPseudostate_ShallowHistoryShape(containerView, (Pseudostate) domainElement)) { + if(UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) && isPseudostate_ShallowHistoryShape(containerView, (Pseudostate)domainElement)) { return PseudostateShallowHistoryEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) - && isPseudostate_DeepHistoryShape(containerView, (Pseudostate) domainElement)) { + if(UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) && isPseudostate_DeepHistoryShape(containerView, (Pseudostate)domainElement)) { return PseudostateDeepHistoryEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) - && isPseudostate_TerminateShape(containerView, (Pseudostate) domainElement)) { + if(UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) && isPseudostate_TerminateShape(containerView, (Pseudostate)domainElement)) { return PseudostateTerminateEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getFinalState().isSuperTypeOf(domainElement.eClass())) { + if(UMLPackage.eINSTANCE.getFinalState().isSuperTypeOf(domainElement.eClass())) { return FinalStateEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getState().isSuperTypeOf(domainElement.eClass())) { + if(UMLPackage.eINSTANCE.getState().isSuperTypeOf(domainElement.eClass())) { return StateEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) - && isPseudostate_EntryPointShape(containerView, (Pseudostate) domainElement)) { + if(UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) && isPseudostate_EntryPointShape(containerView, (Pseudostate)domainElement)) { return PseudostateEntryPointEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) - && isPseudostate_ExitPointShape(containerView, (Pseudostate) domainElement)) { + if(UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) && isPseudostate_ExitPointShape(containerView, (Pseudostate)domainElement)) { return PseudostateExitPointEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getComment().isSuperTypeOf(domainElement.eClass())) { + if(UMLPackage.eINSTANCE.getComment().isSuperTypeOf(domainElement.eClass())) { return CommentEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getConstraint().isSuperTypeOf(domainElement.eClass())) { + if(UMLPackage.eINSTANCE.getConstraint().isSuperTypeOf(domainElement.eClass())) { return ConstraintEditPart.VISUAL_ID; } break; case StateMachineCompartmentEditPart.VISUAL_ID: - if (UMLPackage.eINSTANCE.getRegion().isSuperTypeOf(domainElement.eClass())) { + if(UMLPackage.eINSTANCE.getRegion().isSuperTypeOf(domainElement.eClass())) { return RegionEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) - && isPseudostate_EntryPointShape(containerView, (Pseudostate) domainElement)) { + if(UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) && isPseudostate_EntryPointShape(containerView, (Pseudostate)domainElement)) { return PseudostateEntryPointEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) - && isPseudostate_ExitPointShape(containerView, (Pseudostate) domainElement)) { + if(UMLPackage.eINSTANCE.getPseudostate().isSuperTypeOf(domainElement.eClass()) && isPseudostate_ExitPointShape(containerView, (Pseudostate)domainElement)) { return PseudostateExitPointEditPart.VISUAL_ID; } break; case StateCompartmentEditPart.VISUAL_ID: - if (UMLPackage.eINSTANCE.getRegion().isSuperTypeOf(domainElement.eClass())) { + if(UMLPackage.eINSTANCE.getRegion().isSuperTypeOf(domainElement.eClass())) { return RegionEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getConnectionPointReference().isSuperTypeOf(domainElement.eClass())) { + if(UMLPackage.eINSTANCE.getConnectionPointReference().isSuperTypeOf(domainElement.eClass())) { return ConnectionPointReferenceEditPart.VISUAL_ID; } break; @@ -308,273 +287,271 @@ public class UMLVisualIDRegistry { * @generated */ public static boolean canCreateNode(View containerView, String nodeVisualID) { - String containerModelID = org.eclipse.papyrus.uml.diagram.statemachine.part.UMLVisualIDRegistry - .getModelID(containerView); - if (!PackageEditPart.MODEL_ID.equals(containerModelID)) { + String containerModelID = org.eclipse.papyrus.uml.diagram.statemachine.part.UMLVisualIDRegistry.getModelID(containerView); + if(!PackageEditPart.MODEL_ID.equals(containerModelID)) { return false; } String containerVisualID; - if (PackageEditPart.MODEL_ID.equals(containerModelID)) { - containerVisualID = org.eclipse.papyrus.uml.diagram.statemachine.part.UMLVisualIDRegistry - .getVisualID(containerView); + if(PackageEditPart.MODEL_ID.equals(containerModelID)) { + containerVisualID = org.eclipse.papyrus.uml.diagram.statemachine.part.UMLVisualIDRegistry.getVisualID(containerView); } else { - if (containerView instanceof Diagram) { + if(containerView instanceof Diagram) { containerVisualID = PackageEditPart.VISUAL_ID; } else { return false; } } - if (containerVisualID != null) { - switch (containerVisualID) { + if(containerVisualID != null) { + switch(containerVisualID) { case PackageEditPart.VISUAL_ID: - if (StateMachineEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(StateMachineEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case StateMachineEditPart.VISUAL_ID: - if (StateMachineNameEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(StateMachineNameEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (StateMachineCompartmentEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(StateMachineCompartmentEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateEntryPointEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateEntryPointEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateExitPointEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateExitPointEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case RegionEditPart.VISUAL_ID: - if (RegionCompartmentEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(RegionCompartmentEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case FinalStateEditPart.VISUAL_ID: - if (FinalStateFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(FinalStateFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (FinalStateStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(FinalStateStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case StateEditPart.VISUAL_ID: - if (StateNameEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(StateNameEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (StateFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(StateFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (StateCompartmentEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(StateCompartmentEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (EntryStateBehaviorEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(EntryStateBehaviorEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (DoActivityStateBehaviorStateEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(DoActivityStateBehaviorStateEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (ExitStateBehaviorEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(ExitStateBehaviorEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (InternalTransitionEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(InternalTransitionEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (RegionEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(RegionEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateEntryPointEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateEntryPointEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateExitPointEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateExitPointEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (ConnectionPointReferenceEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(ConnectionPointReferenceEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case PseudostateInitialEditPart.VISUAL_ID: - if (PseudostateInitialFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateInitialFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateInitialStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateInitialStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case PseudostateJoinEditPart.VISUAL_ID: - if (PseudostateJoinFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateJoinFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateJoinStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateJoinStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case PseudostateForkEditPart.VISUAL_ID: - if (PseudostateForkNameEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateForkNameEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateForkStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateForkStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case PseudostateChoiceEditPart.VISUAL_ID: - if (PseudostateChoiceFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateChoiceFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateChoiceStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateChoiceStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case PseudostateJunctionEditPart.VISUAL_ID: - if (PseudostateJunctionFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateJunctionFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateJunctionStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateJunctionStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case PseudostateShallowHistoryEditPart.VISUAL_ID: - if (PseudostateShallowHistoryFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateShallowHistoryFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateShallowHistoryStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateShallowHistoryStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case PseudostateDeepHistoryEditPart.VISUAL_ID: - if (PseudostateDeepHistoryFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateDeepHistoryFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateDeepHistoryStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateDeepHistoryStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case PseudostateTerminateEditPart.VISUAL_ID: - if (PseudostateTerminateFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateTerminateFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateTerminateStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateTerminateStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case PseudostateEntryPointEditPart.VISUAL_ID: - if (PseudostateEntryPointFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateEntryPointFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateEntryPointStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateEntryPointStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case PseudostateExitPointEditPart.VISUAL_ID: - if (PseudostateExitPointFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateExitPointFloatingLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateExitPointStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateExitPointStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case ConnectionPointReferenceEditPart.VISUAL_ID: - if (ConnectionPointReferenceNameEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(ConnectionPointReferenceNameEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (ConnectionPointReferenceStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(ConnectionPointReferenceStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case CommentEditPart.VISUAL_ID: - if (CommentBodyEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(CommentBodyEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case ConstraintEditPart.VISUAL_ID: - if (ConstraintNameLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(ConstraintNameLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (ConstraintBodyEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(ConstraintBodyEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case RegionCompartmentEditPart.VISUAL_ID: - if (PseudostateInitialEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateInitialEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateJoinEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateJoinEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateForkEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateForkEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateChoiceEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateChoiceEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateJunctionEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateJunctionEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateShallowHistoryEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateShallowHistoryEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateDeepHistoryEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateDeepHistoryEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateTerminateEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateTerminateEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (FinalStateEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(FinalStateEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (StateEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(StateEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateEntryPointEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateEntryPointEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateExitPointEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateExitPointEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (CommentEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(CommentEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (ConstraintEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(ConstraintEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case StateMachineCompartmentEditPart.VISUAL_ID: - if (RegionEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(RegionEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateEntryPointEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateEntryPointEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (PseudostateExitPointEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(PseudostateExitPointEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case StateCompartmentEditPart.VISUAL_ID: - if (RegionEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(RegionEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (ConnectionPointReferenceEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(ConnectionPointReferenceEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case TransitionEditPart.VISUAL_ID: - if (TransitionNameEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(TransitionNameEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (TransitionGuardEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(TransitionGuardEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (TransitionStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(TransitionStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case GeneralizationEditPart.VISUAL_ID: - if (GeneralizationStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(GeneralizationStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; case ContextLinkEditPart.VISUAL_ID: - if (ContextLinkAppliedStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + if(ContextLinkAppliedStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; @@ -587,13 +564,13 @@ public class UMLVisualIDRegistry { * @generated */ public static String getLinkWithClassVisualID(EObject domainElement) { - if (domainElement == null) { + if(domainElement == null) { return null; } - if (UMLPackage.eINSTANCE.getTransition().isSuperTypeOf(domainElement.eClass())) { + if(UMLPackage.eINSTANCE.getTransition().isSuperTypeOf(domainElement.eClass())) { return TransitionEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getGeneralization().isSuperTypeOf(domainElement.eClass())) { + if(UMLPackage.eINSTANCE.getGeneralization().isSuperTypeOf(domainElement.eClass())) { return GeneralizationEditPart.VISUAL_ID; } return null; @@ -614,9 +591,9 @@ public class UMLVisualIDRegistry { */ private static boolean isPseudostate_InitialShape(View containerView, Pseudostate domainElement) { // Test if the pseudostate is an initial - if (domainElement instanceof Pseudostate) { - PseudostateKind kind = ((Pseudostate) domainElement).getKind(); - if (kind.equals(PseudostateKind.INITIAL_LITERAL)) + if(domainElement instanceof Pseudostate) { + PseudostateKind kind = ((Pseudostate)domainElement).getKind(); + if(kind.equals(PseudostateKind.INITIAL_LITERAL)) return true; } return false; @@ -627,9 +604,9 @@ public class UMLVisualIDRegistry { */ private static boolean isPseudostate_JoinShape(View containerView, Pseudostate domainElement) { // Test if the pseudostate is a join - if (domainElement instanceof Pseudostate) { - PseudostateKind kind = ((Pseudostate) domainElement).getKind(); - if (kind.equals(PseudostateKind.JOIN_LITERAL)) + if(domainElement instanceof Pseudostate) { + PseudostateKind kind = ((Pseudostate)domainElement).getKind(); + if(kind.equals(PseudostateKind.JOIN_LITERAL)) return true; } return false; @@ -640,9 +617,9 @@ public class UMLVisualIDRegistry { */ private static boolean isPseudostate_ForkShape(View containerView, Pseudostate domainElement) { // Test if the pseudostate is a fork - if (domainElement instanceof Pseudostate) { - PseudostateKind kind = ((Pseudostate) domainElement).getKind(); - if (kind.equals(PseudostateKind.FORK_LITERAL)) + if(domainElement instanceof Pseudostate) { + PseudostateKind kind = ((Pseudostate)domainElement).getKind(); + if(kind.equals(PseudostateKind.FORK_LITERAL)) return true; } return false; @@ -653,9 +630,9 @@ public class UMLVisualIDRegistry { */ private static boolean isPseudostate_ChoiceShape(View containerView, Pseudostate domainElement) { // Test if the pseudostate is a choice - if (domainElement instanceof Pseudostate) { - PseudostateKind kind = ((Pseudostate) domainElement).getKind(); - if (kind.equals(PseudostateKind.CHOICE_LITERAL)) + if(domainElement instanceof Pseudostate) { + PseudostateKind kind = ((Pseudostate)domainElement).getKind(); + if(kind.equals(PseudostateKind.CHOICE_LITERAL)) return true; } return false; @@ -666,9 +643,9 @@ public class UMLVisualIDRegistry { */ private static boolean isPseudostate_JunctionShape(View containerView, Pseudostate domainElement) { // Test if the pseudostate is a junction - if (domainElement instanceof Pseudostate) { - PseudostateKind kind = ((Pseudostate) domainElement).getKind(); - if (kind.equals(PseudostateKind.JUNCTION_LITERAL)) + if(domainElement instanceof Pseudostate) { + PseudostateKind kind = ((Pseudostate)domainElement).getKind(); + if(kind.equals(PseudostateKind.JUNCTION_LITERAL)) return true; } return false; @@ -679,9 +656,9 @@ public class UMLVisualIDRegistry { */ private static boolean isPseudostate_ShallowHistoryShape(View containerView, Pseudostate domainElement) { // Test if the pseudostate is a shallowHistory - if (domainElement instanceof Pseudostate) { - PseudostateKind kind = ((Pseudostate) domainElement).getKind(); - if (kind.equals(PseudostateKind.SHALLOW_HISTORY_LITERAL)) + if(domainElement instanceof Pseudostate) { + PseudostateKind kind = ((Pseudostate)domainElement).getKind(); + if(kind.equals(PseudostateKind.SHALLOW_HISTORY_LITERAL)) return true; } return false; @@ -692,9 +669,9 @@ public class UMLVisualIDRegistry { */ private static boolean isPseudostate_DeepHistoryShape(View containerView, Pseudostate domainElement) { // Test if the pseudostate is a deepHistory - if (domainElement instanceof Pseudostate) { - PseudostateKind kind = ((Pseudostate) domainElement).getKind(); - if (kind.equals(PseudostateKind.DEEP_HISTORY_LITERAL)) + if(domainElement instanceof Pseudostate) { + PseudostateKind kind = ((Pseudostate)domainElement).getKind(); + if(kind.equals(PseudostateKind.DEEP_HISTORY_LITERAL)) return true; } return false; @@ -705,9 +682,9 @@ public class UMLVisualIDRegistry { */ private static boolean isPseudostate_TerminateShape(View containerView, Pseudostate domainElement) { // Test if the pseudostate is a terminate - if (domainElement instanceof Pseudostate) { - PseudostateKind kind = ((Pseudostate) domainElement).getKind(); - if (kind.equals(PseudostateKind.TERMINATE_LITERAL)) + if(domainElement instanceof Pseudostate) { + PseudostateKind kind = ((Pseudostate)domainElement).getKind(); + if(kind.equals(PseudostateKind.TERMINATE_LITERAL)) return true; } return false; @@ -718,9 +695,9 @@ public class UMLVisualIDRegistry { */ private static boolean isPseudostate_EntryPointShape(View containerView, Pseudostate domainElement) { // Test if the pseudostate is an entryPoint - if (domainElement instanceof Pseudostate) { - PseudostateKind kind = ((Pseudostate) domainElement).getKind(); - if (kind.equals(PseudostateKind.ENTRY_POINT_LITERAL)) + if(domainElement instanceof Pseudostate) { + PseudostateKind kind = ((Pseudostate)domainElement).getKind(); + if(kind.equals(PseudostateKind.ENTRY_POINT_LITERAL)) return true; } return false; @@ -731,9 +708,9 @@ public class UMLVisualIDRegistry { */ private static boolean isPseudostate_ExitPointShape(View containerView, Pseudostate domainElement) { // Test if the pseudostate is an exitPoint - if (domainElement instanceof Pseudostate) { - PseudostateKind kind = ((Pseudostate) domainElement).getKind(); - if (kind.equals(PseudostateKind.EXIT_POINT_LITERAL)) + if(domainElement instanceof Pseudostate) { + PseudostateKind kind = ((Pseudostate)domainElement).getKind(); + if(kind.equals(PseudostateKind.EXIT_POINT_LITERAL)) return true; } return false; @@ -743,34 +720,31 @@ public class UMLVisualIDRegistry { * @generated */ private static boolean isBehavior_EntryBehaviorLabel(Behavior domainElement) { - Object result = UMLOCLFactory.getExpression(2, UMLPackage.eINSTANCE.getBehavior(), null) - .evaluate(domainElement); - return result instanceof Boolean && ((Boolean) result).booleanValue(); + Object result = UMLOCLFactory.getExpression(2, UMLPackage.eINSTANCE.getBehavior(), null).evaluate(domainElement); + return result instanceof Boolean && ((Boolean)result).booleanValue(); } /** * @generated */ private static boolean isBehavior_DoActivityBehaviorLabel(Behavior domainElement) { - Object result = UMLOCLFactory.getExpression(3, UMLPackage.eINSTANCE.getBehavior(), null) - .evaluate(domainElement); - return result instanceof Boolean && ((Boolean) result).booleanValue(); + Object result = UMLOCLFactory.getExpression(3, UMLPackage.eINSTANCE.getBehavior(), null).evaluate(domainElement); + return result instanceof Boolean && ((Boolean)result).booleanValue(); } /** * @generated */ private static boolean isBehavior_ExitBehaviorLabel(Behavior domainElement) { - Object result = UMLOCLFactory.getExpression(1, UMLPackage.eINSTANCE.getBehavior(), null) - .evaluate(domainElement); - return result instanceof Boolean && ((Boolean) result).booleanValue(); + Object result = UMLOCLFactory.getExpression(1, UMLPackage.eINSTANCE.getBehavior(), null).evaluate(domainElement); + return result instanceof Boolean && ((Boolean)result).booleanValue(); } /** * @generated */ public static boolean checkNodeVisualID(View containerView, EObject domainElement, String candidate) { - if (candidate == null) { + if(candidate == null) { //unrecognized id is always bad return false; } @@ -782,8 +756,8 @@ public class UMLVisualIDRegistry { * @generated */ public static boolean isCompartmentVisualID(String visualID) { - if (visualID != null) { - switch (visualID) { + if(visualID != null) { + switch(visualID) { case RegionCompartmentEditPart.VISUAL_ID: case StateMachineCompartmentEditPart.VISUAL_ID: case StateCompartmentEditPart.VISUAL_ID: @@ -797,8 +771,8 @@ public class UMLVisualIDRegistry { * @generated */ public static boolean isSemanticLeafVisualID(String visualID) { - if (visualID != null) { - switch (visualID) { + if(visualID != null) { + switch(visualID) { case PackageEditPart.VISUAL_ID: return false; case CommentEditPart.VISUAL_ID: @@ -829,6 +803,7 @@ public class UMLVisualIDRegistry { * @generated */ public static final DiagramStructure TYPED_INSTANCE = new DiagramStructure() { + /** * @generated */ @@ -850,8 +825,7 @@ public class UMLVisualIDRegistry { */ @Override public String getNodeVisualID(View containerView, EObject domainElement) { - return org.eclipse.papyrus.uml.diagram.statemachine.part.UMLVisualIDRegistry.getNodeVisualID(containerView, - domainElement); + return org.eclipse.papyrus.uml.diagram.statemachine.part.UMLVisualIDRegistry.getNodeVisualID(containerView, domainElement); } /** @@ -859,8 +833,7 @@ public class UMLVisualIDRegistry { */ @Override public boolean checkNodeVisualID(View containerView, EObject domainElement, String candidate) { - return org.eclipse.papyrus.uml.diagram.statemachine.part.UMLVisualIDRegistry - .checkNodeVisualID(containerView, domainElement, candidate); + return org.eclipse.papyrus.uml.diagram.statemachine.part.UMLVisualIDRegistry.checkNodeVisualID(containerView, domainElement, candidate); } /** @@ -868,8 +841,7 @@ public class UMLVisualIDRegistry { */ @Override public boolean isCompartmentVisualID(String visualID) { - return org.eclipse.papyrus.uml.diagram.statemachine.part.UMLVisualIDRegistry - .isCompartmentVisualID(visualID); + return org.eclipse.papyrus.uml.diagram.statemachine.part.UMLVisualIDRegistry.isCompartmentVisualID(visualID); } /** @@ -877,8 +849,7 @@ public class UMLVisualIDRegistry { */ @Override public boolean isSemanticLeafVisualID(String visualID) { - return org.eclipse.papyrus.uml.diagram.statemachine.part.UMLVisualIDRegistry - .isSemanticLeafVisualID(visualID); + return org.eclipse.papyrus.uml.diagram.statemachine.part.UMLVisualIDRegistry.isSemanticLeafVisualID(visualID); } }; } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/ValidateAction.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/ValidateAction.java index 5d671f263e4..3e654178560 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/ValidateAction.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/part/ValidateAction.java @@ -74,8 +74,8 @@ public class ValidateAction extends Action { @Override public void run() { IWorkbenchPart workbenchPart = page.getActivePart(); - if (workbenchPart instanceof IDiagramWorkbenchPart) { - final IDiagramWorkbenchPart part = (IDiagramWorkbenchPart) workbenchPart; + if(workbenchPart instanceof IDiagramWorkbenchPart) { + final IDiagramWorkbenchPart part = (IDiagramWorkbenchPart)workbenchPart; try { new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() { @@ -95,11 +95,10 @@ public class ValidateAction extends Action { */ public static void runValidation(View view) { try { - if (UMLDiagramEditorUtil.openDiagram(view.eResource())) { - IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() - .getActiveEditor(); - if (editorPart instanceof IDiagramWorkbenchPart) { - runValidation(((IDiagramWorkbenchPart) editorPart).getDiagramEditPart(), view); + if(UMLDiagramEditorUtil.openDiagram(view.eResource())) { + IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); + if(editorPart instanceof IDiagramWorkbenchPart) { + runValidation(((IDiagramWorkbenchPart)editorPart).getDiagramEditPart(), view); } else { runNonUIValidation(view); } @@ -114,12 +113,10 @@ public class ValidateAction extends Action { */ public static void runNonUIValidation(View view) { Shell shell = Display.getCurrent().getActiveShell(); - if (shell == null) { + if(shell == null) { shell = new Shell(); } - - DiagramEditPart diagramEditPart = OffscreenEditPartFactory.getInstance() - .createDiagramEditPart(view.getDiagram(), shell); + DiagramEditPart diagramEditPart = OffscreenEditPartFactory.getInstance().createDiagramEditPart(view.getDiagram(), shell); runValidation(diagramEditPart, view); } @@ -143,7 +140,7 @@ public class ValidateAction extends Action { * @generated */ private static Diagnostic runEMFValidator(View target) { - if (target.isSetElement() && target.getElement() != null) { + if(target.isSetElement() && target.getElement() != null) { return new Diagnostician() { @Override @@ -160,15 +157,14 @@ public class ValidateAction extends Action { */ private static void validate(DiagramEditPart diagramEditPart, View view) { IFile target = view.eResource() != null ? WorkspaceSynchronizer.getFile(view.eResource()) : null; - if (target != null) { + if(target != null) { UMLMarkerNavigationProvider.deleteMarkers(target); } Diagnostic diagnostic = runEMFValidator(view); createMarkers(target, diagnostic, diagramEditPart); - IBatchValidator validator = (IBatchValidator) ModelValidationService.getInstance() - .newValidator(EvaluationMode.BATCH); + IBatchValidator validator = (IBatchValidator)ModelValidationService.getInstance().newValidator(EvaluationMode.BATCH); validator.setIncludeLiveConstraints(true); - if (view.isSetElement() && view.getElement() != null) { + if(view.isSetElement() && view.getElement() != null) { IStatus status = validator.validate(view.getElement()); createMarkers(target, status, diagramEditPart); } @@ -178,20 +174,16 @@ public class ValidateAction extends Action { * @generated */ private static void createMarkers(IFile target, IStatus validationStatus, DiagramEditPart diagramEditPart) { - if (validationStatus.isOK()) { + if(validationStatus.isOK()) { return; } final IStatus rootStatus = validationStatus; List allStatuses = new ArrayList(); - UMLDiagramEditorUtil.LazyElement2ViewMap element2ViewMap = new UMLDiagramEditorUtil.LazyElement2ViewMap( - diagramEditPart.getDiagramView(), - collectTargetElements(rootStatus, new HashSet<EObject>(), allStatuses)); - for (Iterator it = allStatuses.iterator(); it.hasNext();) { - IConstraintStatus nextStatus = (IConstraintStatus) it.next(); + UMLDiagramEditorUtil.LazyElement2ViewMap element2ViewMap = new UMLDiagramEditorUtil.LazyElement2ViewMap(diagramEditPart.getDiagramView(), collectTargetElements(rootStatus, new HashSet<EObject>(), allStatuses)); + for(Iterator it = allStatuses.iterator(); it.hasNext();) { + IConstraintStatus nextStatus = (IConstraintStatus)it.next(); View view = UMLDiagramEditorUtil.findView(diagramEditPart, nextStatus.getTarget(), element2ViewMap); - addMarker(diagramEditPart.getViewer(), target, view.eResource().getURIFragment(view), - EMFCoreUtil.getQualifiedName(nextStatus.getTarget(), true), nextStatus.getMessage(), - nextStatus.getSeverity()); + addMarker(diagramEditPart.getViewer(), target, view.eResource().getURIFragment(view), EMFCoreUtil.getQualifiedName(nextStatus.getTarget(), true), nextStatus.getMessage(), nextStatus.getSeverity()); } } @@ -199,23 +191,19 @@ public class ValidateAction extends Action { * @generated */ private static void createMarkers(IFile target, Diagnostic emfValidationStatus, DiagramEditPart diagramEditPart) { - if (emfValidationStatus.getSeverity() == Diagnostic.OK) { + if(emfValidationStatus.getSeverity() == Diagnostic.OK) { return; } final Diagnostic rootStatus = emfValidationStatus; List<Diagnostic> allDiagnostics = new ArrayList<Diagnostic>(); - UMLDiagramEditorUtil.LazyElement2ViewMap element2ViewMap = new UMLDiagramEditorUtil.LazyElement2ViewMap( - diagramEditPart.getDiagramView(), - collectTargetElements(rootStatus, new HashSet<EObject>(), allDiagnostics)); - for (Iterator<Diagnostic> it = emfValidationStatus.getChildren().iterator(); it.hasNext();) { + UMLDiagramEditorUtil.LazyElement2ViewMap element2ViewMap = new UMLDiagramEditorUtil.LazyElement2ViewMap(diagramEditPart.getDiagramView(), collectTargetElements(rootStatus, new HashSet<EObject>(), allDiagnostics)); + for(Iterator<Diagnostic> it = emfValidationStatus.getChildren().iterator(); it.hasNext();) { Diagnostic nextDiagnostic = it.next(); List<?> data = nextDiagnostic.getData(); - if (data != null && !data.isEmpty() && data.get(0) instanceof EObject) { - EObject element = (EObject) data.get(0); + if(data != null && !data.isEmpty() && data.get(0) instanceof EObject) { + EObject element = (EObject)data.get(0); View view = UMLDiagramEditorUtil.findView(diagramEditPart, element, element2ViewMap); - addMarker(diagramEditPart.getViewer(), target, view.eResource().getURIFragment(view), - EMFCoreUtil.getQualifiedName(element, true), nextDiagnostic.getMessage(), - diagnosticToStatusSeverity(nextDiagnostic.getSeverity())); + addMarker(diagramEditPart.getViewer(), target, view.eResource().getURIFragment(view), EMFCoreUtil.getQualifiedName(element, true), nextDiagnostic.getMessage(), diagnosticToStatusSeverity(nextDiagnostic.getSeverity())); } } } @@ -223,9 +211,8 @@ public class ValidateAction extends Action { /** * @generated */ - private static void addMarker(EditPartViewer viewer, IFile target, String elementId, String location, - String message, int statusSeverity) { - if (target == null) { + private static void addMarker(EditPartViewer viewer, IFile target, String elementId, String location, String message, int statusSeverity) { + if(target == null) { return; } UMLMarkerNavigationProvider.addMarker(target, elementId, location, message, statusSeverity); @@ -235,13 +222,13 @@ public class ValidateAction extends Action { * @generated */ private static int diagnosticToStatusSeverity(int diagnosticSeverity) { - if (diagnosticSeverity == Diagnostic.OK) { + if(diagnosticSeverity == Diagnostic.OK) { return IStatus.OK; - } else if (diagnosticSeverity == Diagnostic.INFO) { + } else if(diagnosticSeverity == Diagnostic.INFO) { return IStatus.INFO; - } else if (diagnosticSeverity == Diagnostic.WARNING) { + } else if(diagnosticSeverity == Diagnostic.WARNING) { return IStatus.WARNING; - } else if (diagnosticSeverity == Diagnostic.ERROR || diagnosticSeverity == Diagnostic.CANCEL) { + } else if(diagnosticSeverity == Diagnostic.ERROR || diagnosticSeverity == Diagnostic.CANCEL) { return IStatus.ERROR; } return IStatus.INFO; @@ -250,15 +237,14 @@ public class ValidateAction extends Action { /** * @generated */ - private static Set<EObject> collectTargetElements(IStatus status, Set<EObject> targetElementCollector, - List<IConstraintStatus> allConstraintStatuses) { - if (status instanceof IConstraintStatus) { - targetElementCollector.add(((IConstraintStatus) status).getTarget()); - allConstraintStatuses.add((IConstraintStatus) status); + private static Set<EObject> collectTargetElements(IStatus status, Set<EObject> targetElementCollector, List<IConstraintStatus> allConstraintStatuses) { + if(status instanceof IConstraintStatus) { + targetElementCollector.add(((IConstraintStatus)status).getTarget()); + allConstraintStatuses.add((IConstraintStatus)status); } - if (status.isMultiStatus()) { + if(status.isMultiStatus()) { IStatus[] children = status.getChildren(); - for (int i = 0; i < children.length; i++) { + for(int i = 0; i < children.length; i++) { collectTargetElements(children[i], targetElementCollector, allConstraintStatuses); } } @@ -268,17 +254,16 @@ public class ValidateAction extends Action { /** * @generated */ - private static Set<EObject> collectTargetElements(Diagnostic diagnostic, Set<EObject> targetElementCollector, - List<Diagnostic> allDiagnostics) { + private static Set<EObject> collectTargetElements(Diagnostic diagnostic, Set<EObject> targetElementCollector, List<Diagnostic> allDiagnostics) { List<?> data = diagnostic.getData(); EObject target = null; - if (data != null && !data.isEmpty() && data.get(0) instanceof EObject) { - target = (EObject) data.get(0); + if(data != null && !data.isEmpty() && data.get(0) instanceof EObject) { + target = (EObject)data.get(0); targetElementCollector.add(target); allDiagnostics.add(diagnostic); } - if (diagnostic.getChildren() != null && !diagnostic.getChildren().isEmpty()) { - for (Iterator<Diagnostic> it = diagnostic.getChildren().iterator(); it.hasNext();) { + if(diagnostic.getChildren() != null && !diagnostic.getChildren().isEmpty()) { + for(Iterator<Diagnostic> it = diagnostic.getChildren().iterator(); it.hasNext();) { collectTargetElements(it.next(), targetElementCollector, allDiagnostics); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/preferences/DiagramPreferenceInitializer.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/preferences/DiagramPreferenceInitializer.java index adff6599962..0f4b834e53c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/preferences/DiagramPreferenceInitializer.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/preferences/DiagramPreferenceInitializer.java @@ -31,7 +31,6 @@ public class DiagramPreferenceInitializer extends AbstractPreferenceInitializer DiagramConnectionsPreferencePage.initDefaults(store); DiagramPrintingPreferencePage.initDefaults(store); DiagramRulersAndGridPreferencePage.initDefaults(store); - } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/ElementInitializers.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/ElementInitializers.java index e4f8e7c7cf1..aac07e162db 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/ElementInitializers.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/ElementInitializers.java @@ -44,14 +44,14 @@ public class ElementInitializers { public void init_StateMachine_Shape(StateMachine instance) { try { Object value_0 = name_StateMachine_Shape(instance); - if (value_0 != null) { - instance.setName((String) value_0); + if(value_0 != null) { + instance.setName((String)value_0); } Region newInstance_1_0 = UMLFactory.eINSTANCE.createRegion(); instance.getRegions().add(newInstance_1_0); Object value_1_0_0 = name_region_StateMachine_Shape(newInstance_1_0); - if (value_1_0_0 != null) { - newInstance_1_0.setName((String) value_1_0_0); + if(value_1_0_0 != null) { + newInstance_1_0.setName((String)value_1_0_0); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -64,8 +64,8 @@ public class ElementInitializers { public void init_Region_Shape(Region instance) { try { Object value_0 = name_Region_Shape(instance); - if (value_0 != null) { - instance.setName((String) value_0); + if(value_0 != null) { + instance.setName((String)value_0); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -78,8 +78,8 @@ public class ElementInitializers { public void init_FinalState_Shape(FinalState instance) { try { Object value_0 = name_FinalState_Shape(instance); - if (value_0 != null) { - instance.setName((String) value_0); + if(value_0 != null) { + instance.setName((String)value_0); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -92,8 +92,8 @@ public class ElementInitializers { public void init_State_Shape(State instance) { try { Object value_0 = name_State_Shape(instance); - if (value_0 != null) { - instance.setName((String) value_0); + if(value_0 != null) { + instance.setName((String)value_0); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -106,14 +106,13 @@ public class ElementInitializers { public void init_Pseudostate_InitialShape(Pseudostate instance) { try { Object value_0 = kind_Pseudostate_InitialShape(instance); - if (value_0 != null) { - + if(value_0 != null) { value_0 = UMLAbstractExpression.performCast(value_0, UMLPackage.eINSTANCE.getPseudostateKind()); - instance.setKind((PseudostateKind) value_0); + instance.setKind((PseudostateKind)value_0); } Object value_1 = name_Pseudostate_InitialShape(instance); - if (value_1 != null) { - instance.setName((String) value_1); + if(value_1 != null) { + instance.setName((String)value_1); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -126,14 +125,13 @@ public class ElementInitializers { public void init_Pseudostate_JoinShape(Pseudostate instance) { try { Object value_0 = kind_Pseudostate_JoinShape(instance); - if (value_0 != null) { - + if(value_0 != null) { value_0 = UMLAbstractExpression.performCast(value_0, UMLPackage.eINSTANCE.getPseudostateKind()); - instance.setKind((PseudostateKind) value_0); + instance.setKind((PseudostateKind)value_0); } Object value_1 = name_Pseudostate_JoinShape(instance); - if (value_1 != null) { - instance.setName((String) value_1); + if(value_1 != null) { + instance.setName((String)value_1); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -146,14 +144,13 @@ public class ElementInitializers { public void init_Pseudostate_ForkShape(Pseudostate instance) { try { Object value_0 = kind_Pseudostate_ForkShape(instance); - if (value_0 != null) { - + if(value_0 != null) { value_0 = UMLAbstractExpression.performCast(value_0, UMLPackage.eINSTANCE.getPseudostateKind()); - instance.setKind((PseudostateKind) value_0); + instance.setKind((PseudostateKind)value_0); } Object value_1 = name_Pseudostate_ForkShape(instance); - if (value_1 != null) { - instance.setName((String) value_1); + if(value_1 != null) { + instance.setName((String)value_1); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -166,14 +163,13 @@ public class ElementInitializers { public void init_Pseudostate_ChoiceShape(Pseudostate instance) { try { Object value_0 = kind_Pseudostate_ChoiceShape(instance); - if (value_0 != null) { - + if(value_0 != null) { value_0 = UMLAbstractExpression.performCast(value_0, UMLPackage.eINSTANCE.getPseudostateKind()); - instance.setKind((PseudostateKind) value_0); + instance.setKind((PseudostateKind)value_0); } Object value_1 = name_Pseudostate_ChoiceShape(instance); - if (value_1 != null) { - instance.setName((String) value_1); + if(value_1 != null) { + instance.setName((String)value_1); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -186,14 +182,13 @@ public class ElementInitializers { public void init_Pseudostate_JunctionShape(Pseudostate instance) { try { Object value_0 = kind_Pseudostate_JunctionShape(instance); - if (value_0 != null) { - + if(value_0 != null) { value_0 = UMLAbstractExpression.performCast(value_0, UMLPackage.eINSTANCE.getPseudostateKind()); - instance.setKind((PseudostateKind) value_0); + instance.setKind((PseudostateKind)value_0); } Object value_1 = name_Pseudostate_JunctionShape(instance); - if (value_1 != null) { - instance.setName((String) value_1); + if(value_1 != null) { + instance.setName((String)value_1); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -206,14 +201,13 @@ public class ElementInitializers { public void init_Pseudostate_ShallowHistoryShape(Pseudostate instance) { try { Object value_0 = kind_Pseudostate_ShallowHistoryShape(instance); - if (value_0 != null) { - + if(value_0 != null) { value_0 = UMLAbstractExpression.performCast(value_0, UMLPackage.eINSTANCE.getPseudostateKind()); - instance.setKind((PseudostateKind) value_0); + instance.setKind((PseudostateKind)value_0); } Object value_1 = name_Pseudostate_ShallowHistoryShape(instance); - if (value_1 != null) { - instance.setName((String) value_1); + if(value_1 != null) { + instance.setName((String)value_1); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -226,14 +220,13 @@ public class ElementInitializers { public void init_Pseudostate_DeepHistoryShape(Pseudostate instance) { try { Object value_0 = kind_Pseudostate_DeepHistoryShape(instance); - if (value_0 != null) { - + if(value_0 != null) { value_0 = UMLAbstractExpression.performCast(value_0, UMLPackage.eINSTANCE.getPseudostateKind()); - instance.setKind((PseudostateKind) value_0); + instance.setKind((PseudostateKind)value_0); } Object value_1 = name_Pseudostate_DeepHistoryShape(instance); - if (value_1 != null) { - instance.setName((String) value_1); + if(value_1 != null) { + instance.setName((String)value_1); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -246,14 +239,13 @@ public class ElementInitializers { public void init_Pseudostate_TerminateShape(Pseudostate instance) { try { Object value_0 = kind_Pseudostate_TerminateShape(instance); - if (value_0 != null) { - + if(value_0 != null) { value_0 = UMLAbstractExpression.performCast(value_0, UMLPackage.eINSTANCE.getPseudostateKind()); - instance.setKind((PseudostateKind) value_0); + instance.setKind((PseudostateKind)value_0); } Object value_1 = name_Pseudostate_TerminateShape(instance); - if (value_1 != null) { - instance.setName((String) value_1); + if(value_1 != null) { + instance.setName((String)value_1); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -266,14 +258,13 @@ public class ElementInitializers { public void init_Pseudostate_EntryPointShape(Pseudostate instance) { try { Object value_0 = kind_Pseudostate_EntryPointShape(instance); - if (value_0 != null) { - + if(value_0 != null) { value_0 = UMLAbstractExpression.performCast(value_0, UMLPackage.eINSTANCE.getPseudostateKind()); - instance.setKind((PseudostateKind) value_0); + instance.setKind((PseudostateKind)value_0); } Object value_1 = name_Pseudostate_EntryPointShape(instance); - if (value_1 != null) { - instance.setName((String) value_1); + if(value_1 != null) { + instance.setName((String)value_1); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -286,14 +277,13 @@ public class ElementInitializers { public void init_Pseudostate_ExitPointShape(Pseudostate instance) { try { Object value_0 = kind_Pseudostate_ExitPointShape(instance); - if (value_0 != null) { - + if(value_0 != null) { value_0 = UMLAbstractExpression.performCast(value_0, UMLPackage.eINSTANCE.getPseudostateKind()); - instance.setKind((PseudostateKind) value_0); + instance.setKind((PseudostateKind)value_0); } Object value_1 = name_Pseudostate_ExitPointShape(instance); - if (value_1 != null) { - instance.setName((String) value_1); + if(value_1 != null) { + instance.setName((String)value_1); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -306,8 +296,8 @@ public class ElementInitializers { public void init_ConnectionPointReference_Shape(ConnectionPointReference instance) { try { Object value_0 = name_ConnectionPointReference_Shape(instance); - if (value_0 != null) { - instance.setName((String) value_0); + if(value_0 != null) { + instance.setName((String)value_0); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -320,8 +310,8 @@ public class ElementInitializers { public void init_Comment_Shape(Comment instance) { try { Object value_0 = body_Comment_Shape(instance); - if (value_0 != null) { - instance.setBody((String) value_0); + if(value_0 != null) { + instance.setBody((String)value_0); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -334,12 +324,12 @@ public class ElementInitializers { public void init_Constraint_Shape(Constraint instance) { try { Object value_0 = name_Constraint_Shape(instance); - if (value_0 != null) { - instance.setName((String) value_0); + if(value_0 != null) { + instance.setName((String)value_0); } Object value_1 = specification_Constraint_Shape(instance); - if (value_1 != null) { - instance.setSpecification((ValueSpecification) value_1); + if(value_1 != null) { + instance.setSpecification((ValueSpecification)value_1); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -352,8 +342,8 @@ public class ElementInitializers { public void init_Transition_InternalTransitionLabel(Transition instance) { try { Object value_0 = name_Transition_InternalTransitionLabel(instance); - if (value_0 != null) { - instance.setName((String) value_0); + if(value_0 != null) { + instance.setName((String)value_0); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -366,8 +356,8 @@ public class ElementInitializers { public void init_Transition_Edge(Transition instance) { try { Object value_0 = name_Transition_Edge(instance); - if (value_0 != null) { - instance.setName((String) value_0); + if(value_0 != null) { + instance.setName((String)value_0); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -598,7 +588,7 @@ public class ElementInitializers { */ public static ElementInitializers getInstance() { ElementInitializers cached = UMLDiagramEditorPlugin.getInstance().getElementInitializers(); - if (cached == null) { + if(cached == null) { UMLDiagramEditorPlugin.getInstance().setElementInitializers(cached = new ElementInitializers()); } return cached; diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLElementTypes.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLElementTypes.java index 092abbd7c29..e2a79b90788 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLElementTypes.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLElementTypes.java @@ -73,8 +73,7 @@ public class UMLElementTypes { /** * @generated */ - private static DiagramElementTypeImages elementTypeImages = new DiagramElementTypeImages( - UMLDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory()); + private static DiagramElementTypeImages elementTypeImages = new DiagramElementTypeImages(UMLDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory()); /** * @generated @@ -84,14 +83,12 @@ public class UMLElementTypes { /** * @generated */ - public static final IElementType Package_StateMachineDiagram = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Package_StateMachineDiagram"); //$NON-NLS-1$ + public static final IElementType Package_StateMachineDiagram = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Package_StateMachineDiagram"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType StateMachine_Shape = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.StateMachine_Shape"); //$NON-NLS-1$ + public static final IElementType StateMachine_Shape = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.StateMachine_Shape"); //$NON-NLS-1$ /** * @generated @@ -101,8 +98,7 @@ public class UMLElementTypes { /** * @generated */ - public static final IElementType FinalState_Shape = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.FinalState_Shape"); //$NON-NLS-1$ + public static final IElementType FinalState_Shape = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.FinalState_Shape"); //$NON-NLS-1$ /** * @generated @@ -112,134 +108,112 @@ public class UMLElementTypes { /** * @generated */ - public static final IElementType Pseudostate_InitialShape = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Pseudostate_InitialShape"); //$NON-NLS-1$ + public static final IElementType Pseudostate_InitialShape = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Pseudostate_InitialShape"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Pseudostate_JoinShape = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Pseudostate_JoinShape"); //$NON-NLS-1$ + public static final IElementType Pseudostate_JoinShape = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Pseudostate_JoinShape"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Pseudostate_ForkShape = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Pseudostate_ForkShape"); //$NON-NLS-1$ + public static final IElementType Pseudostate_ForkShape = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Pseudostate_ForkShape"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Pseudostate_ChoiceShape = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Pseudostate_ChoiceShape"); //$NON-NLS-1$ + public static final IElementType Pseudostate_ChoiceShape = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Pseudostate_ChoiceShape"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Pseudostate_JunctionShape = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Pseudostate_JunctionShape"); //$NON-NLS-1$ + public static final IElementType Pseudostate_JunctionShape = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Pseudostate_JunctionShape"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Pseudostate_ShallowHistoryShape = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Pseudostate_ShallowHistoryShape"); //$NON-NLS-1$ + public static final IElementType Pseudostate_ShallowHistoryShape = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Pseudostate_ShallowHistoryShape"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Pseudostate_DeepHistoryShape = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Pseudostate_DeepHistoryShape"); //$NON-NLS-1$ + public static final IElementType Pseudostate_DeepHistoryShape = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Pseudostate_DeepHistoryShape"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Pseudostate_TerminateShape = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Pseudostate_TerminateShape"); //$NON-NLS-1$ + public static final IElementType Pseudostate_TerminateShape = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Pseudostate_TerminateShape"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Pseudostate_EntryPointShape = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Pseudostate_EntryPointShape"); //$NON-NLS-1$ + public static final IElementType Pseudostate_EntryPointShape = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Pseudostate_EntryPointShape"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Pseudostate_ExitPointShape = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Pseudostate_ExitPointShape"); //$NON-NLS-1$ + public static final IElementType Pseudostate_ExitPointShape = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Pseudostate_ExitPointShape"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType ConnectionPointReference_Shape = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.ConnectionPointReference_Shape"); //$NON-NLS-1$ + public static final IElementType ConnectionPointReference_Shape = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.ConnectionPointReference_Shape"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Comment_Shape = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Comment_Shape"); //$NON-NLS-1$ + public static final IElementType Comment_Shape = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Comment_Shape"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Constraint_Shape = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Constraint_Shape"); //$NON-NLS-1$ + public static final IElementType Constraint_Shape = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Constraint_Shape"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Transition_InternalTransitionLabel = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Transition_InternalTransitionLabel"); //$NON-NLS-1$ + public static final IElementType Transition_InternalTransitionLabel = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Transition_InternalTransitionLabel"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Behavior_EntryBehaviorLabel = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Behavior_EntryBehaviorLabel"); //$NON-NLS-1$ + public static final IElementType Behavior_EntryBehaviorLabel = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Behavior_EntryBehaviorLabel"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Behavior_DoActivityBehaviorLabel = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Behavior_DoActivityBehaviorLabel"); //$NON-NLS-1$ + public static final IElementType Behavior_DoActivityBehaviorLabel = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Behavior_DoActivityBehaviorLabel"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Behavior_ExitBehaviorLabel = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Behavior_ExitBehaviorLabel"); //$NON-NLS-1$ + public static final IElementType Behavior_ExitBehaviorLabel = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Behavior_ExitBehaviorLabel"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Transition_Edge = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Transition_Edge"); //$NON-NLS-1$ + public static final IElementType Transition_Edge = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Transition_Edge"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Generalization_Edge = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Generalization_Edge"); //$NON-NLS-1$ + public static final IElementType Generalization_Edge = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Generalization_Edge"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Comment_AnnotatedElementEdge = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Comment_AnnotatedElementEdge"); //$NON-NLS-1$ + public static final IElementType Comment_AnnotatedElementEdge = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Comment_AnnotatedElementEdge"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Constraint_ConstrainedElementEdge = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Constraint_ConstrainedElementEdge"); //$NON-NLS-1$ + public static final IElementType Constraint_ConstrainedElementEdge = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Constraint_ConstrainedElementEdge"); //$NON-NLS-1$ /** * @generated */ - public static final IElementType Constraint_ContextEdge = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.Constraint_ContextEdge"); //$NON-NLS-1$ + public static final IElementType Constraint_ContextEdge = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Constraint_ContextEdge"); //$NON-NLS-1$ /** * @generated @@ -276,61 +250,34 @@ public class UMLElementTypes { */ public static synchronized ENamedElement getElement(IAdaptable hint) { Object type = hint.getAdapter(IElementType.class); - if (elements == null) { + if(elements == null) { elements = new IdentityHashMap<IElementType, ENamedElement>(); - elements.put(Package_StateMachineDiagram, UMLPackage.eINSTANCE.getPackage()); - elements.put(StateMachine_Shape, UMLPackage.eINSTANCE.getStateMachine()); - elements.put(Region_Shape, UMLPackage.eINSTANCE.getRegion()); - elements.put(FinalState_Shape, UMLPackage.eINSTANCE.getFinalState()); - elements.put(State_Shape, UMLPackage.eINSTANCE.getState()); - elements.put(Pseudostate_InitialShape, UMLPackage.eINSTANCE.getPseudostate()); - elements.put(Pseudostate_JoinShape, UMLPackage.eINSTANCE.getPseudostate()); - elements.put(Pseudostate_ForkShape, UMLPackage.eINSTANCE.getPseudostate()); - elements.put(Pseudostate_ChoiceShape, UMLPackage.eINSTANCE.getPseudostate()); - elements.put(Pseudostate_JunctionShape, UMLPackage.eINSTANCE.getPseudostate()); - elements.put(Pseudostate_ShallowHistoryShape, UMLPackage.eINSTANCE.getPseudostate()); - elements.put(Pseudostate_DeepHistoryShape, UMLPackage.eINSTANCE.getPseudostate()); - elements.put(Pseudostate_TerminateShape, UMLPackage.eINSTANCE.getPseudostate()); - elements.put(Pseudostate_EntryPointShape, UMLPackage.eINSTANCE.getPseudostate()); - elements.put(Pseudostate_ExitPointShape, UMLPackage.eINSTANCE.getPseudostate()); - elements.put(ConnectionPointReference_Shape, UMLPackage.eINSTANCE.getConnectionPointReference()); - elements.put(Comment_Shape, UMLPackage.eINSTANCE.getComment()); - elements.put(Constraint_Shape, UMLPackage.eINSTANCE.getConstraint()); - elements.put(Transition_InternalTransitionLabel, UMLPackage.eINSTANCE.getTransition()); - elements.put(Behavior_EntryBehaviorLabel, UMLPackage.eINSTANCE.getBehavior()); - elements.put(Behavior_DoActivityBehaviorLabel, UMLPackage.eINSTANCE.getBehavior()); - elements.put(Behavior_ExitBehaviorLabel, UMLPackage.eINSTANCE.getBehavior()); - elements.put(Transition_Edge, UMLPackage.eINSTANCE.getTransition()); - elements.put(Generalization_Edge, UMLPackage.eINSTANCE.getGeneralization()); - elements.put(Comment_AnnotatedElementEdge, UMLPackage.eINSTANCE.getComment_AnnotatedElement()); - elements.put(Constraint_ConstrainedElementEdge, UMLPackage.eINSTANCE.getConstraint_ConstrainedElement()); - elements.put(Constraint_ContextEdge, UMLPackage.eINSTANCE.getConstraint_Context()); } return elements.get(type); @@ -347,8 +294,8 @@ public class UMLElementTypes { * @generated */ public static IElementType getElementType(String visualID) { - if (visualID != null) { - switch (visualID) { + if(visualID != null) { + switch(visualID) { case PackageEditPart.VISUAL_ID: return Package_StateMachineDiagram; case StateMachineEditPart.VISUAL_ID: @@ -412,7 +359,7 @@ public class UMLElementTypes { * @generated */ public static synchronized boolean isKnownElementType(IElementType elementType) { - if (KNOWN_ELEMENT_TYPES == null) { + if(KNOWN_ELEMENT_TYPES == null) { KNOWN_ELEMENT_TYPES = new HashSet<IElementType>(); KNOWN_ELEMENT_TYPES.add(Package_StateMachineDiagram); KNOWN_ELEMENT_TYPES.add(StateMachine_Shape); @@ -442,16 +389,13 @@ public class UMLElementTypes { KNOWN_ELEMENT_TYPES.add(Constraint_ConstrainedElementEdge); KNOWN_ELEMENT_TYPES.add(Constraint_ContextEdge); } - boolean result = KNOWN_ELEMENT_TYPES.contains(elementType); - - if (!result) { + if(!result) { IElementType[] supertypes = elementType.getAllSuperTypes(); - for (int i = 0; !result && (i < supertypes.length); i++) { + for(int i = 0; !result && (i < supertypes.length); i++) { result = KNOWN_ELEMENT_TYPES.contains(supertypes[i]); } } - return result; } @@ -465,8 +409,7 @@ public class UMLElementTypes { */ @Override public boolean isKnownElementType(IElementType elementType) { - return org.eclipse.papyrus.uml.diagram.statemachine.providers.UMLElementTypes - .isKnownElementType(elementType); + return org.eclipse.papyrus.uml.diagram.statemachine.providers.UMLElementTypes.isKnownElementType(elementType); } /** @@ -482,8 +425,7 @@ public class UMLElementTypes { */ @Override public ENamedElement getDefiningNamedElement(IAdaptable elementTypeAdapter) { - return org.eclipse.papyrus.uml.diagram.statemachine.providers.UMLElementTypes - .getElement(elementTypeAdapter); + return org.eclipse.papyrus.uml.diagram.statemachine.providers.UMLElementTypes.getElement(elementTypeAdapter); } }; @@ -492,14 +434,12 @@ public class UMLElementTypes { */ public static boolean isKindOf(IElementType subtype, IElementType supertype) { boolean result = subtype == supertype; - - if (!result) { + if(!result) { IElementType[] supertypes = subtype.getAllSuperTypes(); - for (int i = 0; !result && (i < supertypes.length); i++) { + for(int i = 0; !result && (i < supertypes.length); i++) { result = supertype == supertypes[i]; } } - return result; } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLMarkerNavigationProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLMarkerNavigationProvider.java index 3888e05e6ca..c8ad68a6c52 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLMarkerNavigationProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLMarkerNavigationProvider.java @@ -42,18 +42,18 @@ public class UMLMarkerNavigationProvider extends AbstractModelMarkerNavigationPr @Override protected void doGotoMarker(IMarker marker) { String elementId = marker.getAttribute(org.eclipse.gmf.runtime.common.core.resources.IMarker.ELEMENT_ID, null); - if (elementId == null || !(getEditor() instanceof DiagramEditor)) { + if(elementId == null || !(getEditor() instanceof DiagramEditor)) { return; } - DiagramEditor editor = (DiagramEditor) getEditor(); + DiagramEditor editor = (DiagramEditor)getEditor(); Map<?, ?> editPartRegistry = editor.getDiagramGraphicalViewer().getEditPartRegistry(); EObject targetView = editor.getDiagram().eResource().getEObject(elementId); - if (targetView == null) { + if(targetView == null) { return; } - EditPart targetEditPart = (EditPart) editPartRegistry.get(targetView); - if (targetEditPart != null) { - UMLDiagramEditorUtil.selectElementsInDiagram(editor, Arrays.asList(new EditPart[] { targetEditPart })); + EditPart targetEditPart = (EditPart)editPartRegistry.get(targetView); + if(targetEditPart != null) { + UMLDiagramEditorUtil.selectElementsInDiagram(editor, Arrays.asList(new EditPart[]{ targetEditPart })); } } @@ -79,9 +79,9 @@ public class UMLMarkerNavigationProvider extends AbstractModelMarkerNavigationPr marker.setAttribute(IMarker.LOCATION, location); marker.setAttribute(org.eclipse.gmf.runtime.common.core.resources.IMarker.ELEMENT_ID, elementId); int markerSeverity = IMarker.SEVERITY_INFO; - if (statusSeverity == IStatus.WARNING) { + if(statusSeverity == IStatus.WARNING) { markerSeverity = IMarker.SEVERITY_WARNING; - } else if (statusSeverity == IStatus.ERROR || statusSeverity == IStatus.CANCEL) { + } else if(statusSeverity == IStatus.ERROR || statusSeverity == IStatus.CANCEL) { markerSeverity = IMarker.SEVERITY_ERROR; } marker.setAttribute(IMarker.SEVERITY, markerSeverity); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLParserProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLParserProvider.java index 7373ccc6237..752fb31e582 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLParserProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLParserProvider.java @@ -87,8 +87,8 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getStateMachine_NameLabel_Parser() { - if (stateMachine_NameLabel_Parser == null) { - EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }; + if(stateMachine_NameLabel_Parser == null) { + EAttribute[] features = new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }; MessageFormatParser parser = new MessageFormatParser(features); stateMachine_NameLabel_Parser = parser; } @@ -104,8 +104,8 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getFinalState_FloatingNameLabel_Parser() { - if (finalState_FloatingNameLabel_Parser == null) { - EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }; + if(finalState_FloatingNameLabel_Parser == null) { + EAttribute[] features = new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }; MessageFormatParser parser = new MessageFormatParser(features); finalState_FloatingNameLabel_Parser = parser; } @@ -121,7 +121,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getFinalState_StereotypeLabel_Parser() { - if (finalState_StereotypeLabel_Parser == null) { + if(finalState_StereotypeLabel_Parser == null) { finalState_StereotypeLabel_Parser = new AppliedStereotypeParser(); } return finalState_StereotypeLabel_Parser; @@ -136,8 +136,8 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getState_NameLabel_Parser() { - if (state_NameLabel_Parser == null) { - EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }; + if(state_NameLabel_Parser == null) { + EAttribute[] features = new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }; MessageFormatParser parser = new MessageFormatParser(features); state_NameLabel_Parser = parser; } @@ -153,8 +153,8 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getState_FloatingNameLabel_Parser() { - if (state_FloatingNameLabel_Parser == null) { - EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }; + if(state_FloatingNameLabel_Parser == null) { + EAttribute[] features = new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }; MessageFormatParser parser = new MessageFormatParser(features); state_FloatingNameLabel_Parser = parser; } @@ -170,8 +170,8 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_InitialFloatingNameLabel_Parser() { - if (pseudostate_InitialFloatingNameLabel_Parser == null) { - EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }; + if(pseudostate_InitialFloatingNameLabel_Parser == null) { + EAttribute[] features = new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }; MessageFormatParser parser = new MessageFormatParser(features); pseudostate_InitialFloatingNameLabel_Parser = parser; } @@ -187,7 +187,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_InitialStereotypeLabel_Parser() { - if (pseudostate_InitialStereotypeLabel_Parser == null) { + if(pseudostate_InitialStereotypeLabel_Parser == null) { pseudostate_InitialStereotypeLabel_Parser = new AppliedStereotypeParser(); } return pseudostate_InitialStereotypeLabel_Parser; @@ -202,8 +202,8 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_JoinFloatingNameLabel_Parser() { - if (pseudostate_JoinFloatingNameLabel_Parser == null) { - EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }; + if(pseudostate_JoinFloatingNameLabel_Parser == null) { + EAttribute[] features = new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }; MessageFormatParser parser = new MessageFormatParser(features); pseudostate_JoinFloatingNameLabel_Parser = parser; } @@ -219,7 +219,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_JoinStereotypeLabel_Parser() { - if (pseudostate_JoinStereotypeLabel_Parser == null) { + if(pseudostate_JoinStereotypeLabel_Parser == null) { pseudostate_JoinStereotypeLabel_Parser = new AppliedStereotypeParser(); } return pseudostate_JoinStereotypeLabel_Parser; @@ -234,8 +234,8 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_ForkFloatingNameLabel_Parser() { - if (pseudostate_ForkFloatingNameLabel_Parser == null) { - EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }; + if(pseudostate_ForkFloatingNameLabel_Parser == null) { + EAttribute[] features = new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }; MessageFormatParser parser = new MessageFormatParser(features); pseudostate_ForkFloatingNameLabel_Parser = parser; } @@ -251,7 +251,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_ForkStereotypeLabel_Parser() { - if (pseudostate_ForkStereotypeLabel_Parser == null) { + if(pseudostate_ForkStereotypeLabel_Parser == null) { pseudostate_ForkStereotypeLabel_Parser = new AppliedStereotypeParser(); } return pseudostate_ForkStereotypeLabel_Parser; @@ -266,8 +266,8 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_ChoiceFloatingNameLabel_Parser() { - if (pseudostate_ChoiceFloatingNameLabel_Parser == null) { - EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }; + if(pseudostate_ChoiceFloatingNameLabel_Parser == null) { + EAttribute[] features = new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }; MessageFormatParser parser = new MessageFormatParser(features); pseudostate_ChoiceFloatingNameLabel_Parser = parser; } @@ -283,7 +283,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_ChoiceStereotypeLabel_Parser() { - if (pseudostate_ChoiceStereotypeLabel_Parser == null) { + if(pseudostate_ChoiceStereotypeLabel_Parser == null) { pseudostate_ChoiceStereotypeLabel_Parser = new AppliedStereotypeParser(); } return pseudostate_ChoiceStereotypeLabel_Parser; @@ -298,8 +298,8 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_JunctionFloatingNameLabel_Parser() { - if (pseudostate_JunctionFloatingNameLabel_Parser == null) { - EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }; + if(pseudostate_JunctionFloatingNameLabel_Parser == null) { + EAttribute[] features = new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }; MessageFormatParser parser = new MessageFormatParser(features); pseudostate_JunctionFloatingNameLabel_Parser = parser; } @@ -315,7 +315,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_JunctionStereotypeLabel_Parser() { - if (pseudostate_JunctionStereotypeLabel_Parser == null) { + if(pseudostate_JunctionStereotypeLabel_Parser == null) { pseudostate_JunctionStereotypeLabel_Parser = new AppliedStereotypeParser(); } return pseudostate_JunctionStereotypeLabel_Parser; @@ -330,8 +330,8 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_ShallowHistoryFloatingNameLabel_Parser() { - if (pseudostate_ShallowHistoryFloatingNameLabel_Parser == null) { - EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }; + if(pseudostate_ShallowHistoryFloatingNameLabel_Parser == null) { + EAttribute[] features = new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }; MessageFormatParser parser = new MessageFormatParser(features); pseudostate_ShallowHistoryFloatingNameLabel_Parser = parser; } @@ -347,7 +347,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_ShallowHistoryStereotypeLabel_Parser() { - if (pseudostate_ShallowHistoryStereotypeLabel_Parser == null) { + if(pseudostate_ShallowHistoryStereotypeLabel_Parser == null) { pseudostate_ShallowHistoryStereotypeLabel_Parser = new AppliedStereotypeParser(); } return pseudostate_ShallowHistoryStereotypeLabel_Parser; @@ -362,8 +362,8 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_DeepHistoryFloatingNameLabel_Parser() { - if (pseudostate_DeepHistoryFloatingNameLabel_Parser == null) { - EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }; + if(pseudostate_DeepHistoryFloatingNameLabel_Parser == null) { + EAttribute[] features = new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }; MessageFormatParser parser = new MessageFormatParser(features); pseudostate_DeepHistoryFloatingNameLabel_Parser = parser; } @@ -379,7 +379,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_DeepHistoryStereotypeLabel_Parser() { - if (pseudostate_DeepHistoryStereotypeLabel_Parser == null) { + if(pseudostate_DeepHistoryStereotypeLabel_Parser == null) { pseudostate_DeepHistoryStereotypeLabel_Parser = new AppliedStereotypeParser(); } return pseudostate_DeepHistoryStereotypeLabel_Parser; @@ -394,8 +394,8 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_TerminateFloatingNameLabel_Parser() { - if (pseudostate_TerminateFloatingNameLabel_Parser == null) { - EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }; + if(pseudostate_TerminateFloatingNameLabel_Parser == null) { + EAttribute[] features = new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }; MessageFormatParser parser = new MessageFormatParser(features); pseudostate_TerminateFloatingNameLabel_Parser = parser; } @@ -411,7 +411,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_TerminateStereotypeLabel_Parser() { - if (pseudostate_TerminateStereotypeLabel_Parser == null) { + if(pseudostate_TerminateStereotypeLabel_Parser == null) { pseudostate_TerminateStereotypeLabel_Parser = new AppliedStereotypeParser(); } return pseudostate_TerminateStereotypeLabel_Parser; @@ -426,8 +426,8 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_EntryPointFloatingNameLabel_Parser() { - if (pseudostate_EntryPointFloatingNameLabel_Parser == null) { - EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }; + if(pseudostate_EntryPointFloatingNameLabel_Parser == null) { + EAttribute[] features = new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }; MessageFormatParser parser = new MessageFormatParser(features); pseudostate_EntryPointFloatingNameLabel_Parser = parser; } @@ -443,7 +443,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_EntryPointStereotypeLabel_Parser() { - if (pseudostate_EntryPointStereotypeLabel_Parser == null) { + if(pseudostate_EntryPointStereotypeLabel_Parser == null) { pseudostate_EntryPointStereotypeLabel_Parser = new AppliedStereotypeParser(); } return pseudostate_EntryPointStereotypeLabel_Parser; @@ -458,8 +458,8 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_ExitPointFloatingNameLabel_Parser() { - if (pseudostate_ExitPointFloatingNameLabel_Parser == null) { - EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }; + if(pseudostate_ExitPointFloatingNameLabel_Parser == null) { + EAttribute[] features = new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }; MessageFormatParser parser = new MessageFormatParser(features); pseudostate_ExitPointFloatingNameLabel_Parser = parser; } @@ -475,7 +475,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getPseudostate_ExitPointStereotypeLabel_Parser() { - if (pseudostate_ExitPointStereotypeLabel_Parser == null) { + if(pseudostate_ExitPointStereotypeLabel_Parser == null) { pseudostate_ExitPointStereotypeLabel_Parser = new AppliedStereotypeParser(); } return pseudostate_ExitPointStereotypeLabel_Parser; @@ -490,8 +490,8 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getConnectionPointReference_NameLabel_Parser() { - if (connectionPointReference_NameLabel_Parser == null) { - EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }; + if(connectionPointReference_NameLabel_Parser == null) { + EAttribute[] features = new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }; MessageFormatParser parser = new MessageFormatParser(features); connectionPointReference_NameLabel_Parser = parser; } @@ -507,7 +507,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getConnectionPointReference_StereotypeLabel_Parser() { - if (connectionPointReference_StereotypeLabel_Parser == null) { + if(connectionPointReference_StereotypeLabel_Parser == null) { connectionPointReference_StereotypeLabel_Parser = new AppliedStereotypeParser(); } return connectionPointReference_StereotypeLabel_Parser; @@ -522,7 +522,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getComment_BodyLabel_Parser() { - if (comment_BodyLabel_Parser == null) { + if(comment_BodyLabel_Parser == null) { comment_BodyLabel_Parser = new CommentParser(); } return comment_BodyLabel_Parser; @@ -537,8 +537,8 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getConstraint_NameLabel_Parser() { - if (constraint_NameLabel_Parser == null) { - EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }; + if(constraint_NameLabel_Parser == null) { + EAttribute[] features = new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }; MessageFormatParser parser = new MessageFormatParser(features); constraint_NameLabel_Parser = parser; } @@ -554,7 +554,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getConstraint_BodyLabel_Parser() { - if (constraint_BodyLabel_Parser == null) { + if(constraint_BodyLabel_Parser == null) { constraint_BodyLabel_Parser = new ConstraintParser(); } return constraint_BodyLabel_Parser; @@ -569,7 +569,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getTransition_InternalTransitionLabel_Parser() { - if (transition_InternalTransitionLabel_Parser == null) { + if(transition_InternalTransitionLabel_Parser == null) { transition_InternalTransitionLabel_Parser = new InternalTransitionParser(); } return transition_InternalTransitionLabel_Parser; @@ -584,7 +584,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getBehavior_EntryBehaviorLabel_Parser() { - if (behavior_EntryBehaviorLabel_Parser == null) { + if(behavior_EntryBehaviorLabel_Parser == null) { behavior_EntryBehaviorLabel_Parser = new EntryStateBehaviorParser(); } return behavior_EntryBehaviorLabel_Parser; @@ -599,7 +599,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getBehavior_DoActivityBehaviorLabel_Parser() { - if (behavior_DoActivityBehaviorLabel_Parser == null) { + if(behavior_DoActivityBehaviorLabel_Parser == null) { behavior_DoActivityBehaviorLabel_Parser = new DoActivityStateBehaviorParser(); } return behavior_DoActivityBehaviorLabel_Parser; @@ -614,7 +614,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getBehavior_ExitBehaviorLabel_Parser() { - if (behavior_ExitBehaviorLabel_Parser == null) { + if(behavior_ExitBehaviorLabel_Parser == null) { behavior_ExitBehaviorLabel_Parser = new ExitStateBehaviorParser(); } return behavior_ExitBehaviorLabel_Parser; @@ -629,8 +629,8 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getTransition_NameLabel_Parser() { - if (transition_NameLabel_Parser == null) { - EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }; + if(transition_NameLabel_Parser == null) { + EAttribute[] features = new EAttribute[]{ UMLPackage.eINSTANCE.getNamedElement_Name() }; MessageFormatParser parser = new MessageFormatParser(features); transition_NameLabel_Parser = parser; } @@ -646,7 +646,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getTransition_GuardLabel_Parser() { - if (transition_GuardLabel_Parser == null) { + if(transition_GuardLabel_Parser == null) { transition_GuardLabel_Parser = new TransitionPropertiesParser(); } return transition_GuardLabel_Parser; @@ -661,7 +661,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getTransition_StereotypeLabel_Parser() { - if (transition_StereotypeLabel_Parser == null) { + if(transition_StereotypeLabel_Parser == null) { transition_StereotypeLabel_Parser = new AppliedStereotypeParser(); } return transition_StereotypeLabel_Parser; @@ -676,8 +676,8 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ private IParser getGeneralization_StereotypeLabel_Parser() { - if (generalization_StereotypeLabel_Parser == null) { - EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getGeneralization_IsSubstitutable() }; + if(generalization_StereotypeLabel_Parser == null) { + EAttribute[] features = new EAttribute[]{ UMLPackage.eINSTANCE.getGeneralization_IsSubstitutable() }; MessageFormatParser parser = new MessageFormatParser(features); parser.setViewPattern("<<{0}>>"); //$NON-NLS-1$ parser.setEditorPattern("<<{0}>>"); //$NON-NLS-1$ @@ -691,84 +691,68 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid * @generated */ protected IParser getParser(String visualID) { - if (visualID != null) { - switch (visualID) { + if(visualID != null) { + switch(visualID) { case StateMachineNameEditPart.VISUAL_ID: return getStateMachine_NameLabel_Parser(); - case FinalStateFloatingLabelEditPart.VISUAL_ID: return getFinalState_FloatingNameLabel_Parser(); case FinalStateStereotypeEditPart.VISUAL_ID: return getFinalState_StereotypeLabel_Parser(); - case StateNameEditPart.VISUAL_ID: return getState_NameLabel_Parser(); case StateFloatingLabelEditPart.VISUAL_ID: return getState_FloatingNameLabel_Parser(); - case PseudostateInitialFloatingLabelEditPart.VISUAL_ID: return getPseudostate_InitialFloatingNameLabel_Parser(); case PseudostateInitialStereotypeEditPart.VISUAL_ID: return getPseudostate_InitialStereotypeLabel_Parser(); - case PseudostateJoinFloatingLabelEditPart.VISUAL_ID: return getPseudostate_JoinFloatingNameLabel_Parser(); case PseudostateJoinStereotypeEditPart.VISUAL_ID: return getPseudostate_JoinStereotypeLabel_Parser(); - case PseudostateForkNameEditPart.VISUAL_ID: return getPseudostate_ForkFloatingNameLabel_Parser(); case PseudostateForkStereotypeEditPart.VISUAL_ID: return getPseudostate_ForkStereotypeLabel_Parser(); - case PseudostateChoiceFloatingLabelEditPart.VISUAL_ID: return getPseudostate_ChoiceFloatingNameLabel_Parser(); case PseudostateChoiceStereotypeEditPart.VISUAL_ID: return getPseudostate_ChoiceStereotypeLabel_Parser(); - case PseudostateJunctionFloatingLabelEditPart.VISUAL_ID: return getPseudostate_JunctionFloatingNameLabel_Parser(); case PseudostateJunctionStereotypeEditPart.VISUAL_ID: return getPseudostate_JunctionStereotypeLabel_Parser(); - case PseudostateShallowHistoryFloatingLabelEditPart.VISUAL_ID: return getPseudostate_ShallowHistoryFloatingNameLabel_Parser(); case PseudostateShallowHistoryStereotypeEditPart.VISUAL_ID: return getPseudostate_ShallowHistoryStereotypeLabel_Parser(); - case PseudostateDeepHistoryFloatingLabelEditPart.VISUAL_ID: return getPseudostate_DeepHistoryFloatingNameLabel_Parser(); case PseudostateDeepHistoryStereotypeEditPart.VISUAL_ID: return getPseudostate_DeepHistoryStereotypeLabel_Parser(); - case PseudostateTerminateFloatingLabelEditPart.VISUAL_ID: return getPseudostate_TerminateFloatingNameLabel_Parser(); case PseudostateTerminateStereotypeEditPart.VISUAL_ID: return getPseudostate_TerminateStereotypeLabel_Parser(); - case PseudostateEntryPointFloatingLabelEditPart.VISUAL_ID: return getPseudostate_EntryPointFloatingNameLabel_Parser(); case PseudostateEntryPointStereotypeEditPart.VISUAL_ID: return getPseudostate_EntryPointStereotypeLabel_Parser(); - case PseudostateExitPointFloatingLabelEditPart.VISUAL_ID: return getPseudostate_ExitPointFloatingNameLabel_Parser(); case PseudostateExitPointStereotypeEditPart.VISUAL_ID: return getPseudostate_ExitPointStereotypeLabel_Parser(); - case ConnectionPointReferenceNameEditPart.VISUAL_ID: return getConnectionPointReference_NameLabel_Parser(); case ConnectionPointReferenceStereotypeEditPart.VISUAL_ID: return getConnectionPointReference_StereotypeLabel_Parser(); - case CommentBodyEditPart.VISUAL_ID: return getComment_BodyLabel_Parser(); - case ConstraintNameLabelEditPart.VISUAL_ID: return getConstraint_NameLabel_Parser(); case ConstraintBodyEditPart.VISUAL_ID: return getConstraint_BodyLabel_Parser(); - case InternalTransitionEditPart.VISUAL_ID: return getTransition_InternalTransitionLabel_Parser(); case EntryStateBehaviorEditPart.VISUAL_ID: @@ -783,10 +767,8 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid return getTransition_GuardLabel_Parser(); case TransitionStereotypeEditPart.VISUAL_ID: return getTransition_StereotypeLabel_Parser(); - case GeneralizationStereotypeEditPart.VISUAL_ID: return getGeneralization_StereotypeLabel_Parser(); - } } return null; @@ -806,12 +788,12 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid */ @Override public IParser getParser(IAdaptable hint) { - String vid = (String) hint.getAdapter(String.class); - if (vid != null) { + String vid = (String)hint.getAdapter(String.class); + if(vid != null) { return getParser(UMLVisualIDRegistry.getVisualID(vid)); } - View view = (View) hint.getAdapter(View.class); - if (view != null) { + View view = (View)hint.getAdapter(View.class); + if(view != null) { return getParser(UMLVisualIDRegistry.getVisualID(view)); } return null; @@ -822,9 +804,9 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid */ @Override public boolean provides(IOperation operation) { - if (operation instanceof GetParserOperation) { - IAdaptable hint = ((GetParserOperation) operation).getHint(); - if (UMLElementTypes.getElement(hint) == null) { + if(operation instanceof GetParserOperation) { + IAdaptable hint = ((GetParserOperation)operation).getHint(); + if(UMLElementTypes.getElement(hint) == null) { return false; } return getParser(hint) != null; @@ -856,7 +838,7 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid */ @Override public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) { - if (IElementType.class.equals(adapter)) { + if(IElementType.class.equals(adapter)) { return elementType; } return super.getAdapter(adapter); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLValidationDecoratorProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLValidationDecoratorProvider.java index a450009fb9c..71811a94bec 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLValidationDecoratorProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLValidationDecoratorProvider.java @@ -37,20 +37,20 @@ public class UMLValidationDecoratorProvider extends ValidationDecoratorProvider */ @Override public void createDecorators(IDecoratorTarget decoratorTarget) { - EditPart editPart = (EditPart) decoratorTarget.getAdapter(EditPart.class); - if (editPart instanceof GraphicalEditPart || editPart instanceof AbstractConnectionEditPart) { + EditPart editPart = (EditPart)decoratorTarget.getAdapter(EditPart.class); + if(editPart instanceof GraphicalEditPart || editPart instanceof AbstractConnectionEditPart) { Object model = editPart.getModel(); - if ((model instanceof View)) { - View view = (View) model; - if (!(view instanceof Edge) && !view.isSetElement()) { + if((model instanceof View)) { + View view = (View)model; + if(!(view instanceof Edge) && !view.isSetElement()) { return; } } EditDomain ed = editPart.getViewer().getEditDomain(); - if (!(ed instanceof DiagramEditDomain)) { + if(!(ed instanceof DiagramEditDomain)) { return; } - if (((DiagramEditDomain) ed).getEditorPart() instanceof UMLDiagramEditor) { + if(((DiagramEditDomain)ed).getEditorPart() instanceof UMLDiagramEditor) { decoratorTarget.installDecorator(KEY, new StatusDecorator(decoratorTarget)); } } @@ -61,11 +61,11 @@ public class UMLValidationDecoratorProvider extends ValidationDecoratorProvider */ @Override public boolean provides(IOperation operation) { - if (!(operation instanceof CreateDecoratorsOperation)) { + if(!(operation instanceof CreateDecoratorsOperation)) { return false; } - IDecoratorTarget decoratorTarget = ((CreateDecoratorsOperation) operation).getDecoratorTarget(); - View view = (View) decoratorTarget.getAdapter(View.class); + IDecoratorTarget decoratorTarget = ((CreateDecoratorsOperation)operation).getDecoratorTarget(); + View view = (View)decoratorTarget.getAdapter(View.class); return view != null && PackageEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(view)); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLValidationProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLValidationProvider.java index 9e5461b63ca..818f50e91b0 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLValidationProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLValidationProvider.java @@ -41,6 +41,7 @@ public class UMLValidationProvider { public static void runWithConstraints(TransactionalEditingDomain editingDomain, Runnable operation) { final Runnable op = operation; Runnable task = new Runnable() { + @Override public void run() { try { @@ -51,7 +52,7 @@ public class UMLValidationProvider { } } }; - if (editingDomain != null) { + if(editingDomain != null) { try { editingDomain.runExclusive(task); } catch (Exception e) { @@ -66,11 +67,11 @@ public class UMLValidationProvider { * @generated */ static boolean isInDefaultEditorContext(Object object) { - if (shouldConstraintsBePrivate() && !constraintsActive) { + if(shouldConstraintsBePrivate() && !constraintsActive) { return false; } - if (object instanceof View) { - return constraintsActive && PackageEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID((View) object)); + if(object instanceof View) { + return constraintsActive && PackageEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID((View)object)); } return true; } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLViewProvider.java index c60a1e853ed..8277b5d99fc 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLViewProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLViewProvider.java @@ -136,16 +136,16 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { */ @Override public final boolean provides(IOperation operation) { - if (operation instanceof CreateViewForKindOperation) { - return provides((CreateViewForKindOperation) operation); + if(operation instanceof CreateViewForKindOperation) { + return provides((CreateViewForKindOperation)operation); } assert operation instanceof CreateViewOperation; - if (operation instanceof CreateDiagramViewOperation) { - return provides((CreateDiagramViewOperation) operation); - } else if (operation instanceof CreateEdgeViewOperation) { - return provides((CreateEdgeViewOperation) operation); - } else if (operation instanceof CreateNodeViewOperation) { - return provides((CreateNodeViewOperation) operation); + if(operation instanceof CreateDiagramViewOperation) { + return provides((CreateDiagramViewOperation)operation); + } else if(operation instanceof CreateEdgeViewOperation) { + return provides((CreateEdgeViewOperation)operation); + } else if(operation instanceof CreateNodeViewOperation) { + return provides((CreateNodeViewOperation)operation); } return false; } @@ -160,18 +160,15 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { if (op.getViewKind() == Edge.class) return getEdgeViewClass(op.getSemanticAdapter(), op.getContainerView(), op.getSemanticHint()) != null; */ - // check Diagram Type should be the class diagram String modelID = UMLVisualIDRegistry.getModelID(op.getContainerView()); - if (!getDiagramProvidedId().equals(modelID)) { + if(!getDiagramProvidedId().equals(modelID)) { return false; } - String visualID = UMLVisualIDRegistry.getVisualID(op.getSemanticHint()); - if (Node.class.isAssignableFrom(op.getViewKind())) { + if(Node.class.isAssignableFrom(op.getViewKind())) { return UMLVisualIDRegistry.canCreateNode(op.getContainerView(), visualID); } - return true; } @@ -194,49 +191,46 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { * @generated */ protected boolean provides(CreateDiagramViewOperation op) { - return PackageEditPart.MODEL_ID.equals(op.getSemanticHint()) - && UMLVisualIDRegistry.getDiagramVisualID(getSemanticElement(op.getSemanticAdapter())) != null; + return PackageEditPart.MODEL_ID.equals(op.getSemanticHint()) && UMLVisualIDRegistry.getDiagramVisualID(getSemanticElement(op.getSemanticAdapter())) != null; } /** * @generated */ protected boolean provides(CreateNodeViewOperation op) { - if (op.getContainerView() == null) { + if(op.getContainerView() == null) { return false; } IElementType elementType = getSemanticElementType(op.getSemanticAdapter()); EObject domainElement = getSemanticElement(op.getSemanticAdapter()); String visualID; - if (op.getSemanticHint() == null) { + if(op.getSemanticHint() == null) { // Semantic hint is not specified. Can be a result of call from CanonicalEditPolicy. // In this situation there should be NO elementType, visualID will be determined // by VisualIDRegistry.getNodeVisualID() for domainElement. - if (elementType != null || domainElement == null) { + if(elementType != null || domainElement == null) { return false; } visualID = UMLVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement); } else { visualID = UMLVisualIDRegistry.getVisualID(op.getSemanticHint()); - if (elementType != null) { - - if (!UMLElementTypes.isKnownElementType(elementType) || (!(elementType instanceof IHintedType))) { + if(elementType != null) { + if(!UMLElementTypes.isKnownElementType(elementType) || (!(elementType instanceof IHintedType))) { return false; // foreign element type } - - String elementTypeHint = ((IHintedType) elementType).getSemanticHint(); - if (!op.getSemanticHint().equals(elementTypeHint)) { + String elementTypeHint = ((IHintedType)elementType).getSemanticHint(); + if(!op.getSemanticHint().equals(elementTypeHint)) { return false; // if semantic hint is specified it should be the same as in element type } //if (domainElement != null && !visualID.equals(org.eclipse.papyrus.uml.diagram.statemachine.part.UMLVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement))) { // return false; // visual id for node EClass should match visual id from element type //} } else { - if (!PackageEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(op.getContainerView()))) { + if(!PackageEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(op.getContainerView()))) { return false; // foreign diagram } - if (visualID != null) { - switch (visualID) { + if(visualID != null) { + switch(visualID) { case StateMachineEditPart.VISUAL_ID: case RegionEditPart.VISUAL_ID: case FinalStateEditPart.VISUAL_ID: @@ -258,8 +252,7 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { case DoActivityStateBehaviorStateEditPart.VISUAL_ID: case ExitStateBehaviorEditPart.VISUAL_ID: case InternalTransitionEditPart.VISUAL_ID: - if (domainElement == null || !visualID - .equals(UMLVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement))) { + if(domainElement == null || !visualID.equals(UMLVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement))) { return false; // visual id in semantic hint should match visual id for domain element } break; @@ -269,7 +262,6 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { } } } - return UMLVisualIDRegistry.canCreateNode(op.getContainerView(), visualID); } @@ -279,14 +271,13 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { protected boolean provides(CreateEdgeViewOperation op) { IElementType elementType = getSemanticElementType(op.getSemanticAdapter()); //RS: add code for extended types creation - if (elementType instanceof IExtendedHintedElementType) { + if(elementType instanceof IExtendedHintedElementType) { IElementType closestNonExtendedType = ElementTypeUtils.getClosestDiagramType(elementType); - if (!UMLElementTypes.isKnownElementType(closestNonExtendedType) - || (!(closestNonExtendedType instanceof IHintedType))) { + if(!UMLElementTypes.isKnownElementType(closestNonExtendedType) || (!(closestNonExtendedType instanceof IHintedType))) { return false; // foreign element type. } } else { - if (!UMLElementTypes.isKnownElementType(elementType) || (!(elementType instanceof IHintedType))) { + if(!UMLElementTypes.isKnownElementType(elementType) || (!(elementType instanceof IHintedType))) { return false; // foreign element type } } @@ -294,9 +285,8 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { // return false; // foreign element type //} // END R.S. - String elementTypeHint = ((IHintedType) elementType).getSemanticHint(); - if (elementTypeHint == null - || (op.getSemanticHint() != null && !elementTypeHint.equals(op.getSemanticHint()))) { + String elementTypeHint = ((IHintedType)elementType).getSemanticHint(); + if(elementTypeHint == null || (op.getSemanticHint() != null && !elementTypeHint.equals(op.getSemanticHint()))) { return false; // our hint is visual id and must be specified, and it should be the same as in element type } //String visualID = org.eclipse.papyrus.uml.diagram.statemachine.part.UMLVisualIDRegistry.getVisualID(elementTypeHint); @@ -326,17 +316,16 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { * @generated */ @Override - public Node createNode(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, - boolean persisted, PreferencesHint preferencesHint) { + public Node createNode(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) { final EObject domainElement = getSemanticElement(semanticAdapter); final String visualID; - if (semanticHint == null) { + if(semanticHint == null) { visualID = UMLVisualIDRegistry.getNodeVisualID(containerView, domainElement); } else { visualID = UMLVisualIDRegistry.getVisualID(semanticHint); } - if (visualID != null) { - switch (visualID) { + if(visualID != null) { + switch(visualID) { case StateMachineEditPart.VISUAL_ID: return createStateMachine_Shape(domainElement, containerView, index, persisted, preferencesHint); case RegionEditPart.VISUAL_ID: @@ -356,39 +345,29 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { case PseudostateJunctionEditPart.VISUAL_ID: return createPseudostate_JunctionShape(domainElement, containerView, index, persisted, preferencesHint); case PseudostateShallowHistoryEditPart.VISUAL_ID: - return createPseudostate_ShallowHistoryShape(domainElement, containerView, index, persisted, - preferencesHint); + return createPseudostate_ShallowHistoryShape(domainElement, containerView, index, persisted, preferencesHint); case PseudostateDeepHistoryEditPart.VISUAL_ID: - return createPseudostate_DeepHistoryShape(domainElement, containerView, index, persisted, - preferencesHint); + return createPseudostate_DeepHistoryShape(domainElement, containerView, index, persisted, preferencesHint); case PseudostateTerminateEditPart.VISUAL_ID: - return createPseudostate_TerminateShape(domainElement, containerView, index, persisted, - preferencesHint); + return createPseudostate_TerminateShape(domainElement, containerView, index, persisted, preferencesHint); case PseudostateEntryPointEditPart.VISUAL_ID: - return createPseudostate_EntryPointShape(domainElement, containerView, index, persisted, - preferencesHint); + return createPseudostate_EntryPointShape(domainElement, containerView, index, persisted, preferencesHint); case PseudostateExitPointEditPart.VISUAL_ID: - return createPseudostate_ExitPointShape(domainElement, containerView, index, persisted, - preferencesHint); + return createPseudostate_ExitPointShape(domainElement, containerView, index, persisted, preferencesHint); case ConnectionPointReferenceEditPart.VISUAL_ID: - return createConnectionPointReference_Shape(domainElement, containerView, index, persisted, - preferencesHint); + return createConnectionPointReference_Shape(domainElement, containerView, index, persisted, preferencesHint); case CommentEditPart.VISUAL_ID: return createComment_Shape(domainElement, containerView, index, persisted, preferencesHint); case ConstraintEditPart.VISUAL_ID: return createConstraint_Shape(domainElement, containerView, index, persisted, preferencesHint); case InternalTransitionEditPart.VISUAL_ID: - return createTransition_InternalTransitionLabel(domainElement, containerView, index, persisted, - preferencesHint); + return createTransition_InternalTransitionLabel(domainElement, containerView, index, persisted, preferencesHint); case EntryStateBehaviorEditPart.VISUAL_ID: - return createBehavior_EntryBehaviorLabel(domainElement, containerView, index, persisted, - preferencesHint); + return createBehavior_EntryBehaviorLabel(domainElement, containerView, index, persisted, preferencesHint); case DoActivityStateBehaviorStateEditPart.VISUAL_ID: - return createBehavior_DoActivityBehaviorLabel(domainElement, containerView, index, persisted, - preferencesHint); + return createBehavior_DoActivityBehaviorLabel(domainElement, containerView, index, persisted, preferencesHint); case ExitStateBehaviorEditPart.VISUAL_ID: - return createBehavior_ExitBehaviorLabel(domainElement, containerView, index, persisted, - preferencesHint); + return createBehavior_ExitBehaviorLabel(domainElement, containerView, index, persisted, preferencesHint); } } // can't happen, provided #provides(CreateNodeViewOperation) is correct @@ -399,19 +378,16 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { * @generated */ @Override - public Edge createEdge(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, - boolean persisted, PreferencesHint preferencesHint) { + public Edge createEdge(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) { IElementType elementType = getSemanticElementType(semanticAdapter); - String elementTypeHint = ((IHintedType) elementType).getSemanticHint(); + String elementTypeHint = ((IHintedType)elementType).getSemanticHint(); String vid = UMLVisualIDRegistry.getVisualID(elementTypeHint); - if (vid != null) { - switch (vid) { + if(vid != null) { + switch(vid) { case TransitionEditPart.VISUAL_ID: - return createTransition_Edge(getSemanticElement(semanticAdapter), containerView, index, persisted, - preferencesHint); + return createTransition_Edge(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint); case GeneralizationEditPart.VISUAL_ID: - return createGeneralization_Edge(getSemanticElement(semanticAdapter), containerView, index, persisted, - preferencesHint); + return createGeneralization_Edge(getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint); case CommentAnnotatedElementEditPart.VISUAL_ID: return createComment_AnnotatedElementEdge(containerView, index, persisted, preferencesHint); case ConstraintConstrainedElementEditPart.VISUAL_ID: @@ -427,8 +403,7 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createStateMachine_Shape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { + public Node createStateMachine_Shape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(UMLVisualIDRegistry.getType(StateMachineEditPart.VISUAL_ID)); @@ -436,13 +411,10 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { node.setElement(domainElement); stampShortcut(containerView, node); // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "StateMachine"); - Node stateMachine_NameLabel = createLabel(node, - UMLVisualIDRegistry.getType(StateMachineNameEditPart.VISUAL_ID)); - createCompartment(node, UMLVisualIDRegistry.getType(StateMachineCompartmentEditPart.VISUAL_ID), false, false, - false, false); + Node stateMachine_NameLabel = createLabel(node, UMLVisualIDRegistry.getType(StateMachineNameEditPart.VISUAL_ID)); + createCompartment(node, UMLVisualIDRegistry.getType(StateMachineCompartmentEditPart.VISUAL_ID), false, false, false, false); PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "StateMachine"); return node; } @@ -450,19 +422,16 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createRegion_Shape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { + public Node createRegion_Shape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(UMLVisualIDRegistry.getType(RegionEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Region"); - createCompartment(node, UMLVisualIDRegistry.getType(RegionCompartmentEditPart.VISUAL_ID), false, false, false, - false); + createCompartment(node, UMLVisualIDRegistry.getType(RegionCompartmentEditPart.VISUAL_ID), false, false, false, false); PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "Region"); return node; } @@ -470,27 +439,23 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createFinalState_Shape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { + public Node createFinalState_Shape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(UMLVisualIDRegistry.getType(FinalStateEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "FinalState"); - Node finalState_FloatingNameLabel = createLabel(node, - UMLVisualIDRegistry.getType(FinalStateFloatingLabelEditPart.VISUAL_ID)); + Node finalState_FloatingNameLabel = createLabel(node, UMLVisualIDRegistry.getType(FinalStateFloatingLabelEditPart.VISUAL_ID)); finalState_FloatingNameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location finalState_FloatingNameLabel_Location = (Location) finalState_FloatingNameLabel.getLayoutConstraint(); + Location finalState_FloatingNameLabel_Location = (Location)finalState_FloatingNameLabel.getLayoutConstraint(); finalState_FloatingNameLabel_Location.setX(25); finalState_FloatingNameLabel_Location.setY(3); - Node finalState_StereotypeLabel = createLabel(node, - UMLVisualIDRegistry.getType(FinalStateStereotypeEditPart.VISUAL_ID)); + Node finalState_StereotypeLabel = createLabel(node, UMLVisualIDRegistry.getType(FinalStateStereotypeEditPart.VISUAL_ID)); finalState_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location finalState_StereotypeLabel_Location = (Location) finalState_StereotypeLabel.getLayoutConstraint(); + Location finalState_StereotypeLabel_Location = (Location)finalState_StereotypeLabel.getLayoutConstraint(); finalState_StereotypeLabel_Location.setX(25); finalState_StereotypeLabel_Location.setY(-10); return node; @@ -499,26 +464,22 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createState_Shape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { + public Node createState_Shape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(UMLVisualIDRegistry.getType(StateEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "State"); Node state_NameLabel = createLabel(node, UMLVisualIDRegistry.getType(StateNameEditPart.VISUAL_ID)); - Node state_FloatingNameLabel = createLabel(node, - UMLVisualIDRegistry.getType(StateFloatingLabelEditPart.VISUAL_ID)); + Node state_FloatingNameLabel = createLabel(node, UMLVisualIDRegistry.getType(StateFloatingLabelEditPart.VISUAL_ID)); state_FloatingNameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location state_FloatingNameLabel_Location = (Location) state_FloatingNameLabel.getLayoutConstraint(); + Location state_FloatingNameLabel_Location = (Location)state_FloatingNameLabel.getLayoutConstraint(); state_FloatingNameLabel_Location.setX(40); state_FloatingNameLabel_Location.setY(0); - createCompartment(node, UMLVisualIDRegistry.getType(StateCompartmentEditPart.VISUAL_ID), false, false, false, - false); + createCompartment(node, UMLVisualIDRegistry.getType(StateCompartmentEditPart.VISUAL_ID), false, false, false, false); PreferenceInitializerForElementHelper.initCompartmentsStatusFromPrefs(node, prefStore, "State"); return node; } @@ -526,29 +487,23 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createPseudostate_InitialShape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { + public Node createPseudostate_InitialShape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(UMLVisualIDRegistry.getType(PseudostateInitialEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Pseudostate"); - Node pseudostate_InitialFloatingNameLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateInitialFloatingLabelEditPart.VISUAL_ID)); + Node pseudostate_InitialFloatingNameLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateInitialFloatingLabelEditPart.VISUAL_ID)); pseudostate_InitialFloatingNameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_InitialFloatingNameLabel_Location = (Location) pseudostate_InitialFloatingNameLabel - .getLayoutConstraint(); + Location pseudostate_InitialFloatingNameLabel_Location = (Location)pseudostate_InitialFloatingNameLabel.getLayoutConstraint(); pseudostate_InitialFloatingNameLabel_Location.setX(25); pseudostate_InitialFloatingNameLabel_Location.setY(3); - Node pseudostate_InitialStereotypeLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateInitialStereotypeEditPart.VISUAL_ID)); + Node pseudostate_InitialStereotypeLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateInitialStereotypeEditPart.VISUAL_ID)); pseudostate_InitialStereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_InitialStereotypeLabel_Location = (Location) pseudostate_InitialStereotypeLabel - .getLayoutConstraint(); + Location pseudostate_InitialStereotypeLabel_Location = (Location)pseudostate_InitialStereotypeLabel.getLayoutConstraint(); pseudostate_InitialStereotypeLabel_Location.setX(25); pseudostate_InitialStereotypeLabel_Location.setY(-10); return node; @@ -557,29 +512,23 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createPseudostate_JoinShape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { + public Node createPseudostate_JoinShape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(UMLVisualIDRegistry.getType(PseudostateJoinEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Pseudostate"); - Node pseudostate_JoinFloatingNameLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateJoinFloatingLabelEditPart.VISUAL_ID)); + Node pseudostate_JoinFloatingNameLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateJoinFloatingLabelEditPart.VISUAL_ID)); pseudostate_JoinFloatingNameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_JoinFloatingNameLabel_Location = (Location) pseudostate_JoinFloatingNameLabel - .getLayoutConstraint(); + Location pseudostate_JoinFloatingNameLabel_Location = (Location)pseudostate_JoinFloatingNameLabel.getLayoutConstraint(); pseudostate_JoinFloatingNameLabel_Location.setX(25); pseudostate_JoinFloatingNameLabel_Location.setY(3); - Node pseudostate_JoinStereotypeLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateJoinStereotypeEditPart.VISUAL_ID)); + Node pseudostate_JoinStereotypeLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateJoinStereotypeEditPart.VISUAL_ID)); pseudostate_JoinStereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_JoinStereotypeLabel_Location = (Location) pseudostate_JoinStereotypeLabel - .getLayoutConstraint(); + Location pseudostate_JoinStereotypeLabel_Location = (Location)pseudostate_JoinStereotypeLabel.getLayoutConstraint(); pseudostate_JoinStereotypeLabel_Location.setX(25); pseudostate_JoinStereotypeLabel_Location.setY(-10); return node; @@ -588,29 +537,23 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createPseudostate_ForkShape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { + public Node createPseudostate_ForkShape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(UMLVisualIDRegistry.getType(PseudostateForkEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Pseudostate"); - Node pseudostate_ForkFloatingNameLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateForkNameEditPart.VISUAL_ID)); + Node pseudostate_ForkFloatingNameLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateForkNameEditPart.VISUAL_ID)); pseudostate_ForkFloatingNameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_ForkFloatingNameLabel_Location = (Location) pseudostate_ForkFloatingNameLabel - .getLayoutConstraint(); + Location pseudostate_ForkFloatingNameLabel_Location = (Location)pseudostate_ForkFloatingNameLabel.getLayoutConstraint(); pseudostate_ForkFloatingNameLabel_Location.setX(25); pseudostate_ForkFloatingNameLabel_Location.setY(3); - Node pseudostate_ForkStereotypeLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateForkStereotypeEditPart.VISUAL_ID)); + Node pseudostate_ForkStereotypeLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateForkStereotypeEditPart.VISUAL_ID)); pseudostate_ForkStereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_ForkStereotypeLabel_Location = (Location) pseudostate_ForkStereotypeLabel - .getLayoutConstraint(); + Location pseudostate_ForkStereotypeLabel_Location = (Location)pseudostate_ForkStereotypeLabel.getLayoutConstraint(); pseudostate_ForkStereotypeLabel_Location.setX(25); pseudostate_ForkStereotypeLabel_Location.setY(-10); return node; @@ -619,29 +562,23 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createPseudostate_ChoiceShape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { + public Node createPseudostate_ChoiceShape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(UMLVisualIDRegistry.getType(PseudostateChoiceEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Pseudostate"); - Node pseudostate_ChoiceFloatingNameLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateChoiceFloatingLabelEditPart.VISUAL_ID)); + Node pseudostate_ChoiceFloatingNameLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateChoiceFloatingLabelEditPart.VISUAL_ID)); pseudostate_ChoiceFloatingNameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_ChoiceFloatingNameLabel_Location = (Location) pseudostate_ChoiceFloatingNameLabel - .getLayoutConstraint(); + Location pseudostate_ChoiceFloatingNameLabel_Location = (Location)pseudostate_ChoiceFloatingNameLabel.getLayoutConstraint(); pseudostate_ChoiceFloatingNameLabel_Location.setX(50); pseudostate_ChoiceFloatingNameLabel_Location.setY(3); - Node pseudostate_ChoiceStereotypeLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateChoiceStereotypeEditPart.VISUAL_ID)); + Node pseudostate_ChoiceStereotypeLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateChoiceStereotypeEditPart.VISUAL_ID)); pseudostate_ChoiceStereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_ChoiceStereotypeLabel_Location = (Location) pseudostate_ChoiceStereotypeLabel - .getLayoutConstraint(); + Location pseudostate_ChoiceStereotypeLabel_Location = (Location)pseudostate_ChoiceStereotypeLabel.getLayoutConstraint(); pseudostate_ChoiceStereotypeLabel_Location.setX(25); pseudostate_ChoiceStereotypeLabel_Location.setY(-10); return node; @@ -650,29 +587,23 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createPseudostate_JunctionShape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { + public Node createPseudostate_JunctionShape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(UMLVisualIDRegistry.getType(PseudostateJunctionEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Pseudostate"); - Node pseudostate_JunctionFloatingNameLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateJunctionFloatingLabelEditPart.VISUAL_ID)); + Node pseudostate_JunctionFloatingNameLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateJunctionFloatingLabelEditPart.VISUAL_ID)); pseudostate_JunctionFloatingNameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_JunctionFloatingNameLabel_Location = (Location) pseudostate_JunctionFloatingNameLabel - .getLayoutConstraint(); + Location pseudostate_JunctionFloatingNameLabel_Location = (Location)pseudostate_JunctionFloatingNameLabel.getLayoutConstraint(); pseudostate_JunctionFloatingNameLabel_Location.setX(25); pseudostate_JunctionFloatingNameLabel_Location.setY(3); - Node pseudostate_JunctionStereotypeLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateJunctionStereotypeEditPart.VISUAL_ID)); + Node pseudostate_JunctionStereotypeLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateJunctionStereotypeEditPart.VISUAL_ID)); pseudostate_JunctionStereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_JunctionStereotypeLabel_Location = (Location) pseudostate_JunctionStereotypeLabel - .getLayoutConstraint(); + Location pseudostate_JunctionStereotypeLabel_Location = (Location)pseudostate_JunctionStereotypeLabel.getLayoutConstraint(); pseudostate_JunctionStereotypeLabel_Location.setX(25); pseudostate_JunctionStereotypeLabel_Location.setY(-10); return node; @@ -681,29 +612,23 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createPseudostate_ShallowHistoryShape(EObject domainElement, View containerView, int index, - boolean persisted, PreferencesHint preferencesHint) { + public Node createPseudostate_ShallowHistoryShape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(UMLVisualIDRegistry.getType(PseudostateShallowHistoryEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Pseudostate"); - Node pseudostate_ShallowHistoryFloatingNameLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateShallowHistoryFloatingLabelEditPart.VISUAL_ID)); + Node pseudostate_ShallowHistoryFloatingNameLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateShallowHistoryFloatingLabelEditPart.VISUAL_ID)); pseudostate_ShallowHistoryFloatingNameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_ShallowHistoryFloatingNameLabel_Location = (Location) pseudostate_ShallowHistoryFloatingNameLabel - .getLayoutConstraint(); + Location pseudostate_ShallowHistoryFloatingNameLabel_Location = (Location)pseudostate_ShallowHistoryFloatingNameLabel.getLayoutConstraint(); pseudostate_ShallowHistoryFloatingNameLabel_Location.setX(25); pseudostate_ShallowHistoryFloatingNameLabel_Location.setY(3); - Node pseudostate_ShallowHistoryStereotypeLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateShallowHistoryStereotypeEditPart.VISUAL_ID)); + Node pseudostate_ShallowHistoryStereotypeLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateShallowHistoryStereotypeEditPart.VISUAL_ID)); pseudostate_ShallowHistoryStereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_ShallowHistoryStereotypeLabel_Location = (Location) pseudostate_ShallowHistoryStereotypeLabel - .getLayoutConstraint(); + Location pseudostate_ShallowHistoryStereotypeLabel_Location = (Location)pseudostate_ShallowHistoryStereotypeLabel.getLayoutConstraint(); pseudostate_ShallowHistoryStereotypeLabel_Location.setX(25); pseudostate_ShallowHistoryStereotypeLabel_Location.setY(-10); return node; @@ -712,29 +637,23 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createPseudostate_DeepHistoryShape(EObject domainElement, View containerView, int index, - boolean persisted, PreferencesHint preferencesHint) { + public Node createPseudostate_DeepHistoryShape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(UMLVisualIDRegistry.getType(PseudostateDeepHistoryEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Pseudostate"); - Node pseudostate_DeepHistoryFloatingNameLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateDeepHistoryFloatingLabelEditPart.VISUAL_ID)); + Node pseudostate_DeepHistoryFloatingNameLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateDeepHistoryFloatingLabelEditPart.VISUAL_ID)); pseudostate_DeepHistoryFloatingNameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_DeepHistoryFloatingNameLabel_Location = (Location) pseudostate_DeepHistoryFloatingNameLabel - .getLayoutConstraint(); + Location pseudostate_DeepHistoryFloatingNameLabel_Location = (Location)pseudostate_DeepHistoryFloatingNameLabel.getLayoutConstraint(); pseudostate_DeepHistoryFloatingNameLabel_Location.setX(25); pseudostate_DeepHistoryFloatingNameLabel_Location.setY(3); - Node pseudostate_DeepHistoryStereotypeLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateDeepHistoryStereotypeEditPart.VISUAL_ID)); + Node pseudostate_DeepHistoryStereotypeLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateDeepHistoryStereotypeEditPart.VISUAL_ID)); pseudostate_DeepHistoryStereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_DeepHistoryStereotypeLabel_Location = (Location) pseudostate_DeepHistoryStereotypeLabel - .getLayoutConstraint(); + Location pseudostate_DeepHistoryStereotypeLabel_Location = (Location)pseudostate_DeepHistoryStereotypeLabel.getLayoutConstraint(); pseudostate_DeepHistoryStereotypeLabel_Location.setX(25); pseudostate_DeepHistoryStereotypeLabel_Location.setY(-10); return node; @@ -743,29 +662,23 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createPseudostate_TerminateShape(EObject domainElement, View containerView, int index, - boolean persisted, PreferencesHint preferencesHint) { + public Node createPseudostate_TerminateShape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(UMLVisualIDRegistry.getType(PseudostateTerminateEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Pseudostate"); - Node pseudostate_TerminateFloatingNameLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateTerminateFloatingLabelEditPart.VISUAL_ID)); + Node pseudostate_TerminateFloatingNameLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateTerminateFloatingLabelEditPart.VISUAL_ID)); pseudostate_TerminateFloatingNameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_TerminateFloatingNameLabel_Location = (Location) pseudostate_TerminateFloatingNameLabel - .getLayoutConstraint(); + Location pseudostate_TerminateFloatingNameLabel_Location = (Location)pseudostate_TerminateFloatingNameLabel.getLayoutConstraint(); pseudostate_TerminateFloatingNameLabel_Location.setX(25); pseudostate_TerminateFloatingNameLabel_Location.setY(3); - Node pseudostate_TerminateStereotypeLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateTerminateStereotypeEditPart.VISUAL_ID)); + Node pseudostate_TerminateStereotypeLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateTerminateStereotypeEditPart.VISUAL_ID)); pseudostate_TerminateStereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_TerminateStereotypeLabel_Location = (Location) pseudostate_TerminateStereotypeLabel - .getLayoutConstraint(); + Location pseudostate_TerminateStereotypeLabel_Location = (Location)pseudostate_TerminateStereotypeLabel.getLayoutConstraint(); pseudostate_TerminateStereotypeLabel_Location.setX(25); pseudostate_TerminateStereotypeLabel_Location.setY(-10); return node; @@ -774,29 +687,23 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createPseudostate_EntryPointShape(EObject domainElement, View containerView, int index, - boolean persisted, PreferencesHint preferencesHint) { + public Node createPseudostate_EntryPointShape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(UMLVisualIDRegistry.getType(PseudostateEntryPointEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Pseudostate"); - Node pseudostate_EntryPointFloatingNameLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateEntryPointFloatingLabelEditPart.VISUAL_ID)); + Node pseudostate_EntryPointFloatingNameLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateEntryPointFloatingLabelEditPart.VISUAL_ID)); pseudostate_EntryPointFloatingNameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_EntryPointFloatingNameLabel_Location = (Location) pseudostate_EntryPointFloatingNameLabel - .getLayoutConstraint(); + Location pseudostate_EntryPointFloatingNameLabel_Location = (Location)pseudostate_EntryPointFloatingNameLabel.getLayoutConstraint(); pseudostate_EntryPointFloatingNameLabel_Location.setX(25); pseudostate_EntryPointFloatingNameLabel_Location.setY(3); - Node pseudostate_EntryPointStereotypeLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateEntryPointStereotypeEditPart.VISUAL_ID)); + Node pseudostate_EntryPointStereotypeLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateEntryPointStereotypeEditPart.VISUAL_ID)); pseudostate_EntryPointStereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_EntryPointStereotypeLabel_Location = (Location) pseudostate_EntryPointStereotypeLabel - .getLayoutConstraint(); + Location pseudostate_EntryPointStereotypeLabel_Location = (Location)pseudostate_EntryPointStereotypeLabel.getLayoutConstraint(); pseudostate_EntryPointStereotypeLabel_Location.setX(25); pseudostate_EntryPointStereotypeLabel_Location.setY(-10); PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(node, prefStore, "Pseudostate"); @@ -806,29 +713,23 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createPseudostate_ExitPointShape(EObject domainElement, View containerView, int index, - boolean persisted, PreferencesHint preferencesHint) { + public Node createPseudostate_ExitPointShape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(UMLVisualIDRegistry.getType(PseudostateExitPointEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Pseudostate"); - Node pseudostate_ExitPointFloatingNameLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateExitPointFloatingLabelEditPart.VISUAL_ID)); + Node pseudostate_ExitPointFloatingNameLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateExitPointFloatingLabelEditPart.VISUAL_ID)); pseudostate_ExitPointFloatingNameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_ExitPointFloatingNameLabel_Location = (Location) pseudostate_ExitPointFloatingNameLabel - .getLayoutConstraint(); + Location pseudostate_ExitPointFloatingNameLabel_Location = (Location)pseudostate_ExitPointFloatingNameLabel.getLayoutConstraint(); pseudostate_ExitPointFloatingNameLabel_Location.setX(25); pseudostate_ExitPointFloatingNameLabel_Location.setY(3); - Node pseudostate_ExitPointStereotypeLabel = createLabel(node, - UMLVisualIDRegistry.getType(PseudostateExitPointStereotypeEditPart.VISUAL_ID)); + Node pseudostate_ExitPointStereotypeLabel = createLabel(node, UMLVisualIDRegistry.getType(PseudostateExitPointStereotypeEditPart.VISUAL_ID)); pseudostate_ExitPointStereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location pseudostate_ExitPointStereotypeLabel_Location = (Location) pseudostate_ExitPointStereotypeLabel - .getLayoutConstraint(); + Location pseudostate_ExitPointStereotypeLabel_Location = (Location)pseudostate_ExitPointStereotypeLabel.getLayoutConstraint(); pseudostate_ExitPointStereotypeLabel_Location.setX(25); pseudostate_ExitPointStereotypeLabel_Location.setY(-10); PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(node, prefStore, "Pseudostate"); @@ -838,29 +739,23 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createConnectionPointReference_Shape(EObject domainElement, View containerView, int index, - boolean persisted, PreferencesHint preferencesHint) { + public Node createConnectionPointReference_Shape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(UMLVisualIDRegistry.getType(ConnectionPointReferenceEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "ConnectionPointReference"); - Node connectionPointReference_NameLabel = createLabel(node, - UMLVisualIDRegistry.getType(ConnectionPointReferenceNameEditPart.VISUAL_ID)); + Node connectionPointReference_NameLabel = createLabel(node, UMLVisualIDRegistry.getType(ConnectionPointReferenceNameEditPart.VISUAL_ID)); connectionPointReference_NameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location connectionPointReference_NameLabel_Location = (Location) connectionPointReference_NameLabel - .getLayoutConstraint(); + Location connectionPointReference_NameLabel_Location = (Location)connectionPointReference_NameLabel.getLayoutConstraint(); connectionPointReference_NameLabel_Location.setX(25); connectionPointReference_NameLabel_Location.setY(3); - Node connectionPointReference_StereotypeLabel = createLabel(node, - UMLVisualIDRegistry.getType(ConnectionPointReferenceStereotypeEditPart.VISUAL_ID)); + Node connectionPointReference_StereotypeLabel = createLabel(node, UMLVisualIDRegistry.getType(ConnectionPointReferenceStereotypeEditPart.VISUAL_ID)); connectionPointReference_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location connectionPointReference_StereotypeLabel_Location = (Location) connectionPointReference_StereotypeLabel - .getLayoutConstraint(); + Location connectionPointReference_StereotypeLabel_Location = (Location)connectionPointReference_StereotypeLabel.getLayoutConstraint(); connectionPointReference_StereotypeLabel_Location.setX(25); connectionPointReference_StereotypeLabel_Location.setY(-10); PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(node, prefStore, "ConnectionPointReference"); @@ -870,8 +765,7 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createComment_Shape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { + public Node createComment_Shape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.getStyles().add(NotationFactory.eINSTANCE.createHintedDiagramLinkStyle()); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); @@ -879,8 +773,7 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Comment"); Node comment_BodyLabel = createLabel(node, UMLVisualIDRegistry.getType(CommentBodyEditPart.VISUAL_ID)); return node; @@ -889,19 +782,16 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createConstraint_Shape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { + public Node createConstraint_Shape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(UMLVisualIDRegistry.getType(ConstraintEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Constraint"); - Node constraint_NameLabel = createLabel(node, - UMLVisualIDRegistry.getType(ConstraintNameLabelEditPart.VISUAL_ID)); + Node constraint_NameLabel = createLabel(node, UMLVisualIDRegistry.getType(ConstraintNameLabelEditPart.VISUAL_ID)); Node constraint_BodyLabel = createLabel(node, UMLVisualIDRegistry.getType(ConstraintBodyEditPart.VISUAL_ID)); return node; } @@ -909,15 +799,13 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createTransition_InternalTransitionLabel(EObject domainElement, View containerView, int index, - boolean persisted, PreferencesHint preferencesHint) { + public Node createTransition_InternalTransitionLabel(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Node node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); node.setType(UMLVisualIDRegistry.getType(InternalTransitionEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); - - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "InternalTransition"); return node; } @@ -925,15 +813,13 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createBehavior_EntryBehaviorLabel(EObject domainElement, View containerView, int index, - boolean persisted, PreferencesHint preferencesHint) { + public Node createBehavior_EntryBehaviorLabel(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Node node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); node.setType(UMLVisualIDRegistry.getType(EntryStateBehaviorEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); - - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "EntryStateBehavior"); return node; } @@ -941,15 +827,13 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createBehavior_DoActivityBehaviorLabel(EObject domainElement, View containerView, int index, - boolean persisted, PreferencesHint preferencesHint) { + public Node createBehavior_DoActivityBehaviorLabel(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Node node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); node.setType(UMLVisualIDRegistry.getType(DoActivityStateBehaviorStateEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); - - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "DoActivityStateBehavior"); return node; } @@ -957,15 +841,13 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createBehavior_ExitBehaviorLabel(EObject domainElement, View containerView, int index, - boolean persisted, PreferencesHint preferencesHint) { + public Node createBehavior_ExitBehaviorLabel(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Node node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); node.setType(UMLVisualIDRegistry.getType(ExitStateBehaviorEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); - - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "ExitStateBehavior"); return node; } @@ -973,8 +855,7 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Edge createTransition_Edge(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { + public Edge createTransition_Edge(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Connector edge = NotationFactory.eINSTANCE.createConnector(); edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); @@ -987,8 +868,7 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { edge.setType(UMLVisualIDRegistry.getType(TransitionEditPart.VISUAL_ID)); edge.setElement(domainElement); // initializePreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "Transition"); //org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE)); //if (routing != null) { @@ -998,21 +878,18 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { transition_NameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); Node transition_GuardLabel = createLabel(edge, UMLVisualIDRegistry.getType(TransitionGuardEditPart.VISUAL_ID)); transition_GuardLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Node transition_StereotypeLabel = createLabel(edge, - UMLVisualIDRegistry.getType(TransitionStereotypeEditPart.VISUAL_ID)); + Node transition_StereotypeLabel = createLabel(edge, UMLVisualIDRegistry.getType(TransitionStereotypeEditPart.VISUAL_ID)); transition_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location transition_StereotypeLabel_Location = (Location) transition_StereotypeLabel.getLayoutConstraint(); + Location transition_StereotypeLabel_Location = (Location)transition_StereotypeLabel.getLayoutConstraint(); transition_StereotypeLabel_Location.setX(0); transition_StereotypeLabel_Location.setY(60); - return edge; } /** * @generated */ - public Edge createGeneralization_Edge(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { + public Edge createGeneralization_Edge(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Connector edge = NotationFactory.eINSTANCE.createConnector(); edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); @@ -1025,29 +902,24 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { edge.setType(UMLVisualIDRegistry.getType(GeneralizationEditPart.VISUAL_ID)); edge.setElement(domainElement); // initializePreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "Generalization"); //org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE)); //if (routing != null) { // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing); //} - Node generalization_StereotypeLabel = createLabel(edge, - UMLVisualIDRegistry.getType(GeneralizationStereotypeEditPart.VISUAL_ID)); + Node generalization_StereotypeLabel = createLabel(edge, UMLVisualIDRegistry.getType(GeneralizationStereotypeEditPart.VISUAL_ID)); generalization_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location generalization_StereotypeLabel_Location = (Location) generalization_StereotypeLabel - .getLayoutConstraint(); + Location generalization_StereotypeLabel_Location = (Location)generalization_StereotypeLabel.getLayoutConstraint(); generalization_StereotypeLabel_Location.setX(0); generalization_StereotypeLabel_Location.setY(40); - return edge; } /** * @generated */ - public Edge createComment_AnnotatedElementEdge(View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { + public Edge createComment_AnnotatedElementEdge(View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Connector edge = NotationFactory.eINSTANCE.createConnector(); edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); @@ -1060,21 +932,18 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { edge.setType(UMLVisualIDRegistry.getType(CommentAnnotatedElementEditPart.VISUAL_ID)); edge.setElement(null); // initializePreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); //org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE)); //if (routing != null) { // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing); //} - return edge; } /** * @generated */ - public Edge createConstraint_ConstrainedElementEdge(View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { + public Edge createConstraint_ConstrainedElementEdge(View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Connector edge = NotationFactory.eINSTANCE.createConnector(); edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); @@ -1087,21 +956,18 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { edge.setType(UMLVisualIDRegistry.getType(ConstraintConstrainedElementEditPart.VISUAL_ID)); edge.setElement(null); // initializePreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); //org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE)); //if (routing != null) { // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing); //} - return edge; } /** * @generated */ - public Edge createConstraint_ContextEdge(View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { + public Edge createConstraint_ContextEdge(View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Connector edge = NotationFactory.eINSTANCE.createConnector(); edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); @@ -1114,16 +980,13 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { edge.setType(UMLVisualIDRegistry.getType(ContextLinkEditPart.VISUAL_ID)); edge.setElement(null); // initializePreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - + final IPreferenceStore prefStore = (IPreferenceStore)preferencesHint.getPreferenceStore(); //org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE)); //if (routing != null) { // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing); //} - Node constraint_KeywordLabel = createLabel(edge, - UMLVisualIDRegistry.getType(ContextLinkAppliedStereotypeEditPart.VISUAL_ID)); + Node constraint_KeywordLabel = createLabel(edge, UMLVisualIDRegistry.getType(ContextLinkAppliedStereotypeEditPart.VISUAL_ID)); constraint_KeywordLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - return edge; } @@ -1131,7 +994,7 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { * @generated */ protected void stampShortcut(View containerView, Node target) { - if (!PackageEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(containerView))) { + if(!PackageEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(containerView))) { EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation(); shortcutAnnotation.setSource("Shortcut"); //$NON-NLS-1$ shortcutAnnotation.getDetails().put("modelID", PackageEditPart.MODEL_ID); //$NON-NLS-1$ @@ -1152,23 +1015,20 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - protected Node createCompartment(View owner, String hint, boolean canCollapse, boolean hasTitle, boolean canSort, - boolean canFilter) { + protected Node createCompartment(View owner, String hint, boolean canCollapse, boolean hasTitle, boolean canSort, boolean canFilter) { //SemanticListCompartment rv = NotationFactory.eINSTANCE.createSemanticListCompartment(); //rv.setShowTitle(showTitle); //rv.setCollapsed(isCollapsed); Node rv = NotationFactory.eINSTANCE.createBasicCompartment(); - rv.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - - if (hasTitle) { + if(hasTitle) { TitleStyle ts = NotationFactory.eINSTANCE.createTitleStyle(); rv.getStyles().add(ts); } - if (canSort) { + if(canSort) { rv.getStyles().add(NotationFactory.eINSTANCE.createSortingStyle()); } - if (canFilter) { + if(canFilter) { rv.getStyles().add(NotationFactory.eINSTANCE.createFilteringStyle()); } rv.setType(hint); @@ -1180,11 +1040,11 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { * @generated */ protected EObject getSemanticElement(IAdaptable semanticAdapter) { - if (semanticAdapter == null) { + if(semanticAdapter == null) { return null; } - EObject eObject = (EObject) semanticAdapter.getAdapter(EObject.class); - if (eObject != null) { + EObject eObject = (EObject)semanticAdapter.getAdapter(EObject.class); + if(eObject != null) { return EMFCoreUtil.resolve(TransactionUtil.getEditingDomain(eObject), eObject); } return null; @@ -1194,29 +1054,25 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { * @generated */ protected IElementType getSemanticElementType(IAdaptable semanticAdapter) { - if (semanticAdapter == null) { + if(semanticAdapter == null) { return null; } - return (IElementType) semanticAdapter.getAdapter(IElementType.class); + return (IElementType)semanticAdapter.getAdapter(IElementType.class); } /** * @generated */ private void initFontStyleFromPrefs(View view, final IPreferenceStore store, String elementName) { - String fontConstant = PreferencesConstantsHelper.getElementConstant(elementName, - PreferencesConstantsHelper.FONT); - String fontColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, - PreferencesConstantsHelper.COLOR_FONT); - - FontStyle viewFontStyle = (FontStyle) view.getStyle(NotationPackage.Literals.FONT_STYLE); - if (viewFontStyle != null) { + String fontConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.FONT); + String fontColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.COLOR_FONT); + FontStyle viewFontStyle = (FontStyle)view.getStyle(NotationPackage.Literals.FONT_STYLE); + if(viewFontStyle != null) { FontData fontData = PreferenceConverter.getFontData(store, fontConstant); viewFontStyle.setFontName(fontData.getName()); viewFontStyle.setFontHeight(fontData.getHeight()); viewFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); viewFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); - org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(store, fontColorConstant); viewFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue()); } @@ -1226,35 +1082,24 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { * @generated */ private void initForegroundFromPrefs(View view, final IPreferenceStore store, String elementName) { - String lineColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, - PreferencesConstantsHelper.COLOR_LINE); + String lineColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.COLOR_LINE); org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor(store, lineColorConstant); - ViewUtil.setStructuralFeatureValue(view, NotationPackage.eINSTANCE.getLineStyle_LineColor(), - FigureUtilities.RGBToInteger(lineRGB)); + ViewUtil.setStructuralFeatureValue(view, NotationPackage.eINSTANCE.getLineStyle_LineColor(), FigureUtilities.RGBToInteger(lineRGB)); } /** * @generated */ private void initBackgroundFromPrefs(View view, final IPreferenceStore store, String elementName) { - String fillColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, - PreferencesConstantsHelper.COLOR_FILL); - String gradientColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, - PreferencesConstantsHelper.COLOR_GRADIENT); - String gradientPolicyConstant = PreferencesConstantsHelper.getElementConstant(elementName, - PreferencesConstantsHelper.GRADIENT_POLICY); - + String fillColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.COLOR_FILL); + String gradientColorConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.COLOR_GRADIENT); + String gradientPolicyConstant = PreferencesConstantsHelper.getElementConstant(elementName, PreferencesConstantsHelper.GRADIENT_POLICY); org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor(store, fillColorConstant); - ViewUtil.setStructuralFeatureValue(view, NotationPackage.eINSTANCE.getFillStyle_FillColor(), - FigureUtilities.RGBToInteger(fillRGB)); - - FillStyle fillStyle = (FillStyle) view.getStyle(NotationPackage.Literals.FILL_STYLE); - fillStyle.setFillColor(FigureUtilities.RGBToInteger(fillRGB).intValue()); - - ; - if (store.getBoolean(gradientPolicyConstant)) { - GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter( - store.getString(gradientColorConstant)); + ViewUtil.setStructuralFeatureValue(view, NotationPackage.eINSTANCE.getFillStyle_FillColor(), FigureUtilities.RGBToInteger(fillRGB)); + FillStyle fillStyle = (FillStyle)view.getStyle(NotationPackage.Literals.FILL_STYLE); + fillStyle.setFillColor(FigureUtilities.RGBToInteger(fillRGB).intValue());; + if(store.getBoolean(gradientPolicyConstant)) { + GradientPreferenceConverter gradientPreferenceConverter = new GradientPreferenceConverter(store.getString(gradientColorConstant)); fillStyle.setGradient(gradientPreferenceConverter.getGradientData()); fillStyle.setTransparency(gradientPreferenceConverter.getTransparency()); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLVisualTypeProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLVisualTypeProvider.java index 063c8a34173..d0351628a53 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLVisualTypeProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/providers/UMLVisualTypeProvider.java @@ -36,13 +36,11 @@ public class UMLVisualTypeProvider extends AbstractVisualTypeProvider { @Override public IElementType getElementType(Diagram diagram, String viewType) { IElementType result = null; - try { result = UMLElementTypes.getElementType(viewType); } catch (NumberFormatException e) { // Not supported by this diagram } - return result; } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/sheet/UMLSheetLabelProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/sheet/UMLSheetLabelProvider.java index b8d2947e21c..e3281247abe 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/sheet/UMLSheetLabelProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/sheet/UMLSheetLabelProvider.java @@ -49,8 +49,8 @@ public class UMLSheetLabelProvider extends BaseLabelProvider implements ILabelPr * @generated */ private Object unwrap(Object element) { - if (element instanceof IStructuredSelection) { - return ((IStructuredSelection) element).getFirstElement(); + if(element instanceof IStructuredSelection) { + return ((IStructuredSelection)element).getFirstElement(); } return element; } @@ -59,11 +59,11 @@ public class UMLSheetLabelProvider extends BaseLabelProvider implements ILabelPr * @generated */ private View getView(Object element) { - if (element instanceof View) { - return (View) element; + if(element instanceof View) { + return (View)element; } - if (element instanceof IAdaptable) { - return (View) ((IAdaptable) element).getAdapter(View.class); + if(element instanceof IAdaptable) { + return (View)((IAdaptable)element).getAdapter(View.class); } return null; } @@ -73,13 +73,13 @@ public class UMLSheetLabelProvider extends BaseLabelProvider implements ILabelPr */ private IElementType getElementType(View view) { // For intermediate views climb up the containment hierarchy to find the one associated with an element type. - while (view != null) { + while(view != null) { String vid = UMLVisualIDRegistry.getVisualID(view); IElementType etype = UMLElementTypes.getElementType(vid); - if (etype != null) { + if(etype != null) { return etype; } - view = view.eContainer() instanceof View ? (View) view.eContainer() : null; + view = view.eContainer() instanceof View ? (View)view.eContainer() : null; } return null; } |