diff options
author | Eike Stepper | 2012-07-19 08:22:04 +0000 |
---|---|---|
committer | Eike Stepper | 2012-07-19 08:22:04 +0000 |
commit | 1460904fd3c193ffaf809913b2983a400fce9d94 (patch) | |
tree | 72f3a17b75fedba3ae1060df1d32c9c7889be954 /plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts | |
parent | 5f360965ae87478e0681899bf310a210cafc2c44 (diff) | |
download | cdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.gz cdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.xz cdo-1460904fd3c193ffaf809913b2983a400fce9d94.zip |
Fix line endings in master (dos2unix)
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts')
18 files changed, 5877 insertions, 5877 deletions
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AAttribute2EditPart.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AAttribute2EditPart.java index 00a7190eb0..5efa0b8025 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AAttribute2EditPart.java +++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AAttribute2EditPart.java @@ -1,684 +1,684 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- *
- */
-package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts;
-
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AAttribute2ItemSemanticEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextNonResizableEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextSelectionEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreElementTypes;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreParserProvider;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RunnableWithResult;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.gef.AccessibleEditPart;
-import org.eclipse.gef.DragTracker;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.requests.DirectEditRequest;
-import org.eclipse.gef.requests.SelectionRequest;
-import org.eclipse.gef.tools.DirectEditManager;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
-import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx;
-import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.gmf.runtime.notation.FontStyle;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @generated
- */
-public class AAttribute2EditPart extends CompartmentEditPart implements ITextAwareEditPart
-{
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 3003;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * @generated
- */
- public AAttribute2EditPart(View view)
- {
- super(view);
- }
-
- /**
- * @generated
- */
- public DragTracker getDragTracker(Request request)
- {
- if (request instanceof SelectionRequest && ((SelectionRequest)request).getLastButtonPressed() == 3)
- {
- return null;
- }
- return new DragEditPartsTrackerEx(this);
- }
-
- /**
- * @generated
- */
- protected void createDefaultEditPolicies()
- {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AAttribute2ItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new AcoreTextNonResizableEditPolicy());
- installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure)
- {
- if (figure instanceof WrappingLabel)
- {
- return ((WrappingLabel)figure).getText();
- }
- else
- {
- return ((Label)figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text)
- {
- if (figure instanceof WrappingLabel)
- {
- ((WrappingLabel)figure).setText(text);
- }
- else
- {
- ((Label)figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure)
- {
- if (figure instanceof WrappingLabel)
- {
- return ((WrappingLabel)figure).getIcon();
- }
- else
- {
- return ((Label)figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon)
- {
- if (figure instanceof WrappingLabel)
- {
- ((WrappingLabel)figure).setIcon(icon);
- }
- else
- {
- ((Label)figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure)
- {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- protected List getModelChildren()
- {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint)
- {
- return null;
- }
-
- /**
- * @generated
- */
- protected EObject getParserElement()
- {
- return resolveSemanticElement();
- }
-
- /**
- * @generated
- */
- protected Image getLabelIcon()
- {
- return null;
- }
-
- /**
- * @generated
- */
- protected String getLabelText()
- {
- String text = null;
- EObject parserElement = getParserElement();
- if (parserElement != null && getParser() != null)
- {
- text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue());
- }
- if (text == null || text.length() == 0)
- {
- text = defaultText;
- }
- return text;
- }
-
- /**
- * @generated
- */
- public void setLabelText(String text)
- {
- setLabelTextHelper(getFigure(), text);
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback();
- }
- }
-
- /**
- * @generated
- */
- public String getEditText()
- {
- if (getParserElement() == null || getParser() == null)
- {
- return ""; //$NON-NLS-1$
- }
- return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue());
- }
-
- /**
- * @generated
- */
- protected boolean isEditable()
- {
- return getParser() != null;
- }
-
- /**
- * @generated
- */
- public ICellEditorValidator getEditTextValidator()
- {
- return new ICellEditorValidator()
- {
-
- public String isValid(final Object value)
- {
- if (value instanceof String)
- {
- final EObject element = getParserElement();
- final IParser parser = getParser();
- try
- {
- IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl()
- {
-
- public void run()
- {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value));
- }
- });
- return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage();
- }
- catch (InterruptedException ie)
- {
- ie.printStackTrace();
- }
- }
-
- // shouldn't get here
- return null;
- }
- };
- }
-
- /**
- * @generated
- */
- public IContentAssistProcessor getCompletionProcessor()
- {
- if (getParserElement() == null || getParser() == null)
- {
- return null;
- }
- return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
- }
-
- /**
- * @generated
- */
- public ParserOptions getParserOptions()
- {
- return ParserOptions.NONE;
- }
-
- /**
- * @generated
- */
- public IParser getParser()
- {
- if (parser == null)
- {
- parser = AcoreParserProvider.getParser(AcoreElementTypes.AAttribute_3003, getParserElement(),
- AcoreVisualIDRegistry
- .getType(org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AAttribute2EditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager()
- {
- if (manager == null)
- {
- setManager(new TextDirectEditManager(this, TextDirectEditManager.getTextCellEditorClass(this),
- AcoreEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager)
- {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit()
- {
- getManager().show();
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation)
- {
- if (getManager().getClass() == TextDirectEditManager.class)
- {
- ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter)
- {
- if (getManager() instanceof TextDirectEditManager)
- {
- ((TextDirectEditManager)getManager()).show(initialCharacter);
- }
- else
- {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- protected void performDirectEditRequest(Request request)
- {
- final Request theRequest = request;
- try
- {
- getEditingDomain().runExclusive(new Runnable()
- {
-
- public void run()
- {
- if (isActive() && isEditable())
- {
- if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character)
- {
- Character initialChar = (Character)theRequest.getExtendedData().get(
- RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- }
- else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText())))
- {
- DirectEditRequest editRequest = (DirectEditRequest)theRequest;
- performDirectEdit(editRequest.getLocation());
- }
- else
- {
- performDirectEdit();
- }
- }
- }
- });
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- protected void refreshVisuals()
- {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel()
- {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback();
- }
- }
-
- /**
- * @generated
- */
- protected void refreshUnderline()
- {
- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel)
- {
- ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline());
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough()
- {
- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel)
- {
- ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- 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));
- setFont(fontData);
- }
- }
-
- /**
- * @generated
- */
- protected void setFontColor(Color color)
- {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- protected void addSemanticListeners()
- {
- 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$
- }
- }
- else
- {
- super.addSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- protected void removeSemanticListeners()
- {
- if (parserElements != null)
- {
- for (int i = 0; i < parserElements.size(); i++)
- {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- }
- else
- {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- protected AccessibleEditPart getAccessibleEditPart()
- {
- if (accessibleEP == null)
- {
- accessibleEP = new AccessibleGraphicalEditPart()
- {
-
- public void getName(AccessibleEvent e)
- {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView()
- {
- return getPrimaryView();
- }
-
- /**
- * @generated
- */
- protected void addNotationalListeners()
- {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- protected void removeNotationalListeners()
- {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- protected void handleNotificationEvent(Notification event)
- {
- Object feature = event.getFeature();
- 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))
- {
- refreshUnderline();
- }
- 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))
- {
- refreshFont();
- }
- else
- {
- if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue()))
- {
- refreshLabel();
- }
- if (getParser() instanceof ISemanticParser)
- {
- ISemanticParser modelParser = (ISemanticParser)getParser();
- if (modelParser.areSemanticElementsAffected(null, event))
- {
- removeSemanticListeners();
- if (resolveSemanticElement() != null)
- {
- addSemanticListeners();
- }
- refreshLabel();
- }
- }
- }
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- protected IFigure createFigure()
- {
- IFigure label = createFigurePrim();
- defaultText = getLabelTextHelper(label);
- return label;
- }
-
- /**
- * @generated
- */
- protected IFigure createFigurePrim()
- {
- return new WrappingLabel();
- }
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + * + */ +package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts; + +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AAttribute2ItemSemanticEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextNonResizableEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextSelectionEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreElementTypes; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreParserProvider; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.RunnableWithResult; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.gef.AccessibleEditPart; +import org.eclipse.gef.DragTracker; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.Request; +import org.eclipse.gef.requests.DirectEditRequest; +import org.eclipse.gef.requests.SelectionRequest; +import org.eclipse.gef.tools.DirectEditManager; +import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; +import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; +import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus; +import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; +import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; +import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; +import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx; +import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; +import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; +import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; +import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; +import org.eclipse.gmf.runtime.notation.FontStyle; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.jface.text.contentassist.IContentAssistProcessor; +import org.eclipse.jface.viewers.ICellEditorValidator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.accessibility.AccessibleEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.Image; + +import java.util.Collections; +import java.util.List; + +/** + * @generated + */ +public class AAttribute2EditPart extends CompartmentEditPart implements ITextAwareEditPart +{ + + /** + * @generated + */ + public static final int VISUAL_ID = 3003; + + /** + * @generated + */ + private DirectEditManager manager; + + /** + * @generated + */ + private IParser parser; + + /** + * @generated + */ + private List parserElements; + + /** + * @generated + */ + private String defaultText; + + /** + * @generated + */ + public AAttribute2EditPart(View view) + { + super(view); + } + + /** + * @generated + */ + public DragTracker getDragTracker(Request request) + { + if (request instanceof SelectionRequest && ((SelectionRequest)request).getLastButtonPressed() == 3) + { + return null; + } + return new DragEditPartsTrackerEx(this); + } + + /** + * @generated + */ + protected void createDefaultEditPolicies() + { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AAttribute2ItemSemanticEditPolicy()); + installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new AcoreTextNonResizableEditPolicy()); + installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy()); + installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); + } + + /** + * @generated + */ + protected String getLabelTextHelper(IFigure figure) + { + if (figure instanceof WrappingLabel) + { + return ((WrappingLabel)figure).getText(); + } + else + { + return ((Label)figure).getText(); + } + } + + /** + * @generated + */ + protected void setLabelTextHelper(IFigure figure, String text) + { + if (figure instanceof WrappingLabel) + { + ((WrappingLabel)figure).setText(text); + } + else + { + ((Label)figure).setText(text); + } + } + + /** + * @generated + */ + protected Image getLabelIconHelper(IFigure figure) + { + if (figure instanceof WrappingLabel) + { + return ((WrappingLabel)figure).getIcon(); + } + else + { + return ((Label)figure).getIcon(); + } + } + + /** + * @generated + */ + protected void setLabelIconHelper(IFigure figure, Image icon) + { + if (figure instanceof WrappingLabel) + { + ((WrappingLabel)figure).setIcon(icon); + } + else + { + ((Label)figure).setIcon(icon); + } + } + + /** + * @generated + */ + public void setLabel(IFigure figure) + { + unregisterVisuals(); + setFigure(figure); + defaultText = getLabelTextHelper(figure); + registerVisuals(); + refreshVisuals(); + } + + /** + * @generated + */ + protected List getModelChildren() + { + return Collections.EMPTY_LIST; + } + + /** + * @generated + */ + public IGraphicalEditPart getChildBySemanticHint(String semanticHint) + { + return null; + } + + /** + * @generated + */ + protected EObject getParserElement() + { + return resolveSemanticElement(); + } + + /** + * @generated + */ + protected Image getLabelIcon() + { + return null; + } + + /** + * @generated + */ + protected String getLabelText() + { + String text = null; + EObject parserElement = getParserElement(); + if (parserElement != null && getParser() != null) + { + text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + } + if (text == null || text.length() == 0) + { + text = defaultText; + } + return text; + } + + /** + * @generated + */ + public void setLabelText(String text) + { + setLabelTextHelper(getFigure(), text); + Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); + if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + } + Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); + if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + } + } + + /** + * @generated + */ + public String getEditText() + { + if (getParserElement() == null || getParser() == null) + { + return ""; //$NON-NLS-1$ + } + return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + } + + /** + * @generated + */ + protected boolean isEditable() + { + return getParser() != null; + } + + /** + * @generated + */ + public ICellEditorValidator getEditTextValidator() + { + return new ICellEditorValidator() + { + + public String isValid(final Object value) + { + if (value instanceof String) + { + final EObject element = getParserElement(); + final IParser parser = getParser(); + try + { + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl() + { + + public void run() + { + setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); + } + }); + return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage(); + } + catch (InterruptedException ie) + { + ie.printStackTrace(); + } + } + + // shouldn't get here + return null; + } + }; + } + + /** + * @generated + */ + public IContentAssistProcessor getCompletionProcessor() + { + if (getParserElement() == null || getParser() == null) + { + return null; + } + return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + } + + /** + * @generated + */ + public ParserOptions getParserOptions() + { + return ParserOptions.NONE; + } + + /** + * @generated + */ + public IParser getParser() + { + if (parser == null) + { + parser = AcoreParserProvider.getParser(AcoreElementTypes.AAttribute_3003, getParserElement(), + AcoreVisualIDRegistry + .getType(org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AAttribute2EditPart.VISUAL_ID)); + } + return parser; + } + + /** + * @generated + */ + protected DirectEditManager getManager() + { + if (manager == null) + { + setManager(new TextDirectEditManager(this, TextDirectEditManager.getTextCellEditorClass(this), + AcoreEditPartFactory.getTextCellEditorLocator(this))); + } + return manager; + } + + /** + * @generated + */ + protected void setManager(DirectEditManager manager) + { + this.manager = manager; + } + + /** + * @generated + */ + protected void performDirectEdit() + { + getManager().show(); + } + + /** + * @generated + */ + protected void performDirectEdit(Point eventLocation) + { + if (getManager().getClass() == TextDirectEditManager.class) + { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + } + } + + /** + * @generated + */ + private void performDirectEdit(char initialCharacter) + { + if (getManager() instanceof TextDirectEditManager) + { + ((TextDirectEditManager)getManager()).show(initialCharacter); + } + else + { + performDirectEdit(); + } + } + + /** + * @generated + */ + protected void performDirectEditRequest(Request request) + { + final Request theRequest = request; + try + { + getEditingDomain().runExclusive(new Runnable() + { + + public void run() + { + if (isActive() && isEditable()) + { + if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) + { + Character initialChar = (Character)theRequest.getExtendedData().get( + RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + performDirectEdit(initialChar.charValue()); + } + else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) + { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; + performDirectEdit(editRequest.getLocation()); + } + else + { + performDirectEdit(); + } + } + } + }); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + + /** + * @generated + */ + protected void refreshVisuals() + { + super.refreshVisuals(); + refreshLabel(); + refreshFont(); + refreshFontColor(); + refreshUnderline(); + refreshStrikeThrough(); + } + + /** + * @generated + */ + protected void refreshLabel() + { + setLabelTextHelper(getFigure(), getLabelText()); + setLabelIconHelper(getFigure(), getLabelIcon()); + Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); + if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + } + Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); + if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + } + } + + /** + * @generated + */ + protected void refreshUnderline() + { + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) + { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + } + } + + /** + * @generated + */ + protected void refreshStrikeThrough() + { + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) + { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + } + } + + /** + * @generated + */ + 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)); + setFont(fontData); + } + } + + /** + * @generated + */ + protected void setFontColor(Color color) + { + getFigure().setForegroundColor(color); + } + + /** + * @generated + */ + protected void addSemanticListeners() + { + 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$ + } + } + else + { + super.addSemanticListeners(); + } + } + + /** + * @generated + */ + protected void removeSemanticListeners() + { + if (parserElements != null) + { + for (int i = 0; i < parserElements.size(); i++) + { + removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ + } + } + else + { + super.removeSemanticListeners(); + } + } + + /** + * @generated + */ + protected AccessibleEditPart getAccessibleEditPart() + { + if (accessibleEP == null) + { + accessibleEP = new AccessibleGraphicalEditPart() + { + + public void getName(AccessibleEvent e) + { + e.result = getLabelTextHelper(getFigure()); + } + }; + } + return accessibleEP; + } + + /** + * @generated + */ + private View getFontStyleOwnerView() + { + return getPrimaryView(); + } + + /** + * @generated + */ + protected void addNotationalListeners() + { + super.addNotationalListeners(); + addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$ + } + + /** + * @generated + */ + protected void removeNotationalListeners() + { + super.removeNotationalListeners(); + removeListenerFilter("PrimaryView"); //$NON-NLS-1$ + } + + /** + * @generated + */ + protected void handleNotificationEvent(Notification event) + { + Object feature = event.getFeature(); + 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)) + { + refreshUnderline(); + } + 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)) + { + refreshFont(); + } + else + { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) + { + refreshLabel(); + } + if (getParser() instanceof ISemanticParser) + { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) + { + removeSemanticListeners(); + if (resolveSemanticElement() != null) + { + addSemanticListeners(); + } + refreshLabel(); + } + } + } + super.handleNotificationEvent(event); + } + + /** + * @generated + */ + protected IFigure createFigure() + { + IFigure label = createFigurePrim(); + defaultText = getLabelTextHelper(label); + return label; + } + + /** + * @generated + */ + protected IFigure createFigurePrim() + { + return new WrappingLabel(); + } + +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AAttributeEditPart.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AAttributeEditPart.java index a1e62535a9..18c8876534 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AAttributeEditPart.java +++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AAttributeEditPart.java @@ -1,684 +1,684 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- *
- */
-package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts;
-
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AAttributeItemSemanticEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextNonResizableEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextSelectionEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreElementTypes;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreParserProvider;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RunnableWithResult;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.gef.AccessibleEditPart;
-import org.eclipse.gef.DragTracker;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.requests.DirectEditRequest;
-import org.eclipse.gef.requests.SelectionRequest;
-import org.eclipse.gef.tools.DirectEditManager;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
-import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx;
-import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.gmf.runtime.notation.FontStyle;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @generated
- */
-public class AAttributeEditPart extends CompartmentEditPart implements ITextAwareEditPart
-{
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 3001;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * @generated
- */
- public AAttributeEditPart(View view)
- {
- super(view);
- }
-
- /**
- * @generated
- */
- public DragTracker getDragTracker(Request request)
- {
- if (request instanceof SelectionRequest && ((SelectionRequest)request).getLastButtonPressed() == 3)
- {
- return null;
- }
- return new DragEditPartsTrackerEx(this);
- }
-
- /**
- * @generated
- */
- protected void createDefaultEditPolicies()
- {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AAttributeItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new AcoreTextNonResizableEditPolicy());
- installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure)
- {
- if (figure instanceof WrappingLabel)
- {
- return ((WrappingLabel)figure).getText();
- }
- else
- {
- return ((Label)figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text)
- {
- if (figure instanceof WrappingLabel)
- {
- ((WrappingLabel)figure).setText(text);
- }
- else
- {
- ((Label)figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure)
- {
- if (figure instanceof WrappingLabel)
- {
- return ((WrappingLabel)figure).getIcon();
- }
- else
- {
- return ((Label)figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon)
- {
- if (figure instanceof WrappingLabel)
- {
- ((WrappingLabel)figure).setIcon(icon);
- }
- else
- {
- ((Label)figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure)
- {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- protected List getModelChildren()
- {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint)
- {
- return null;
- }
-
- /**
- * @generated
- */
- protected EObject getParserElement()
- {
- return resolveSemanticElement();
- }
-
- /**
- * @generated
- */
- protected Image getLabelIcon()
- {
- return null;
- }
-
- /**
- * @generated
- */
- protected String getLabelText()
- {
- String text = null;
- EObject parserElement = getParserElement();
- if (parserElement != null && getParser() != null)
- {
- text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue());
- }
- if (text == null || text.length() == 0)
- {
- text = defaultText;
- }
- return text;
- }
-
- /**
- * @generated
- */
- public void setLabelText(String text)
- {
- setLabelTextHelper(getFigure(), text);
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback();
- }
- }
-
- /**
- * @generated
- */
- public String getEditText()
- {
- if (getParserElement() == null || getParser() == null)
- {
- return ""; //$NON-NLS-1$
- }
- return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue());
- }
-
- /**
- * @generated
- */
- protected boolean isEditable()
- {
- return getParser() != null;
- }
-
- /**
- * @generated
- */
- public ICellEditorValidator getEditTextValidator()
- {
- return new ICellEditorValidator()
- {
-
- public String isValid(final Object value)
- {
- if (value instanceof String)
- {
- final EObject element = getParserElement();
- final IParser parser = getParser();
- try
- {
- IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl()
- {
-
- public void run()
- {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value));
- }
- });
- return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage();
- }
- catch (InterruptedException ie)
- {
- ie.printStackTrace();
- }
- }
-
- // shouldn't get here
- return null;
- }
- };
- }
-
- /**
- * @generated
- */
- public IContentAssistProcessor getCompletionProcessor()
- {
- if (getParserElement() == null || getParser() == null)
- {
- return null;
- }
- return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
- }
-
- /**
- * @generated
- */
- public ParserOptions getParserOptions()
- {
- return ParserOptions.NONE;
- }
-
- /**
- * @generated
- */
- public IParser getParser()
- {
- if (parser == null)
- {
- parser = AcoreParserProvider.getParser(AcoreElementTypes.AAttribute_3001, getParserElement(),
- AcoreVisualIDRegistry
- .getType(org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AAttributeEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager()
- {
- if (manager == null)
- {
- setManager(new TextDirectEditManager(this, TextDirectEditManager.getTextCellEditorClass(this),
- AcoreEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager)
- {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit()
- {
- getManager().show();
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation)
- {
- if (getManager().getClass() == TextDirectEditManager.class)
- {
- ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter)
- {
- if (getManager() instanceof TextDirectEditManager)
- {
- ((TextDirectEditManager)getManager()).show(initialCharacter);
- }
- else
- {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- protected void performDirectEditRequest(Request request)
- {
- final Request theRequest = request;
- try
- {
- getEditingDomain().runExclusive(new Runnable()
- {
-
- public void run()
- {
- if (isActive() && isEditable())
- {
- if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character)
- {
- Character initialChar = (Character)theRequest.getExtendedData().get(
- RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- }
- else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText())))
- {
- DirectEditRequest editRequest = (DirectEditRequest)theRequest;
- performDirectEdit(editRequest.getLocation());
- }
- else
- {
- performDirectEdit();
- }
- }
- }
- });
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- protected void refreshVisuals()
- {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel()
- {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback();
- }
- }
-
- /**
- * @generated
- */
- protected void refreshUnderline()
- {
- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel)
- {
- ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline());
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough()
- {
- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel)
- {
- ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- 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));
- setFont(fontData);
- }
- }
-
- /**
- * @generated
- */
- protected void setFontColor(Color color)
- {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- protected void addSemanticListeners()
- {
- 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$
- }
- }
- else
- {
- super.addSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- protected void removeSemanticListeners()
- {
- if (parserElements != null)
- {
- for (int i = 0; i < parserElements.size(); i++)
- {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- }
- else
- {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- protected AccessibleEditPart getAccessibleEditPart()
- {
- if (accessibleEP == null)
- {
- accessibleEP = new AccessibleGraphicalEditPart()
- {
-
- public void getName(AccessibleEvent e)
- {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView()
- {
- return getPrimaryView();
- }
-
- /**
- * @generated
- */
- protected void addNotationalListeners()
- {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- protected void removeNotationalListeners()
- {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- protected void handleNotificationEvent(Notification event)
- {
- Object feature = event.getFeature();
- 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))
- {
- refreshUnderline();
- }
- 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))
- {
- refreshFont();
- }
- else
- {
- if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue()))
- {
- refreshLabel();
- }
- if (getParser() instanceof ISemanticParser)
- {
- ISemanticParser modelParser = (ISemanticParser)getParser();
- if (modelParser.areSemanticElementsAffected(null, event))
- {
- removeSemanticListeners();
- if (resolveSemanticElement() != null)
- {
- addSemanticListeners();
- }
- refreshLabel();
- }
- }
- }
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- protected IFigure createFigure()
- {
- IFigure label = createFigurePrim();
- defaultText = getLabelTextHelper(label);
- return label;
- }
-
- /**
- * @generated
- */
- protected IFigure createFigurePrim()
- {
- return new WrappingLabel();
- }
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + * + */ +package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts; + +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AAttributeItemSemanticEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextNonResizableEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextSelectionEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreElementTypes; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreParserProvider; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.RunnableWithResult; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.gef.AccessibleEditPart; +import org.eclipse.gef.DragTracker; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.Request; +import org.eclipse.gef.requests.DirectEditRequest; +import org.eclipse.gef.requests.SelectionRequest; +import org.eclipse.gef.tools.DirectEditManager; +import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; +import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; +import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus; +import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; +import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; +import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; +import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx; +import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; +import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; +import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; +import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; +import org.eclipse.gmf.runtime.notation.FontStyle; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.jface.text.contentassist.IContentAssistProcessor; +import org.eclipse.jface.viewers.ICellEditorValidator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.accessibility.AccessibleEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.Image; + +import java.util.Collections; +import java.util.List; + +/** + * @generated + */ +public class AAttributeEditPart extends CompartmentEditPart implements ITextAwareEditPart +{ + + /** + * @generated + */ + public static final int VISUAL_ID = 3001; + + /** + * @generated + */ + private DirectEditManager manager; + + /** + * @generated + */ + private IParser parser; + + /** + * @generated + */ + private List parserElements; + + /** + * @generated + */ + private String defaultText; + + /** + * @generated + */ + public AAttributeEditPart(View view) + { + super(view); + } + + /** + * @generated + */ + public DragTracker getDragTracker(Request request) + { + if (request instanceof SelectionRequest && ((SelectionRequest)request).getLastButtonPressed() == 3) + { + return null; + } + return new DragEditPartsTrackerEx(this); + } + + /** + * @generated + */ + protected void createDefaultEditPolicies() + { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AAttributeItemSemanticEditPolicy()); + installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new AcoreTextNonResizableEditPolicy()); + installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy()); + installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); + } + + /** + * @generated + */ + protected String getLabelTextHelper(IFigure figure) + { + if (figure instanceof WrappingLabel) + { + return ((WrappingLabel)figure).getText(); + } + else + { + return ((Label)figure).getText(); + } + } + + /** + * @generated + */ + protected void setLabelTextHelper(IFigure figure, String text) + { + if (figure instanceof WrappingLabel) + { + ((WrappingLabel)figure).setText(text); + } + else + { + ((Label)figure).setText(text); + } + } + + /** + * @generated + */ + protected Image getLabelIconHelper(IFigure figure) + { + if (figure instanceof WrappingLabel) + { + return ((WrappingLabel)figure).getIcon(); + } + else + { + return ((Label)figure).getIcon(); + } + } + + /** + * @generated + */ + protected void setLabelIconHelper(IFigure figure, Image icon) + { + if (figure instanceof WrappingLabel) + { + ((WrappingLabel)figure).setIcon(icon); + } + else + { + ((Label)figure).setIcon(icon); + } + } + + /** + * @generated + */ + public void setLabel(IFigure figure) + { + unregisterVisuals(); + setFigure(figure); + defaultText = getLabelTextHelper(figure); + registerVisuals(); + refreshVisuals(); + } + + /** + * @generated + */ + protected List getModelChildren() + { + return Collections.EMPTY_LIST; + } + + /** + * @generated + */ + public IGraphicalEditPart getChildBySemanticHint(String semanticHint) + { + return null; + } + + /** + * @generated + */ + protected EObject getParserElement() + { + return resolveSemanticElement(); + } + + /** + * @generated + */ + protected Image getLabelIcon() + { + return null; + } + + /** + * @generated + */ + protected String getLabelText() + { + String text = null; + EObject parserElement = getParserElement(); + if (parserElement != null && getParser() != null) + { + text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + } + if (text == null || text.length() == 0) + { + text = defaultText; + } + return text; + } + + /** + * @generated + */ + public void setLabelText(String text) + { + setLabelTextHelper(getFigure(), text); + Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); + if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + } + Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); + if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + } + } + + /** + * @generated + */ + public String getEditText() + { + if (getParserElement() == null || getParser() == null) + { + return ""; //$NON-NLS-1$ + } + return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + } + + /** + * @generated + */ + protected boolean isEditable() + { + return getParser() != null; + } + + /** + * @generated + */ + public ICellEditorValidator getEditTextValidator() + { + return new ICellEditorValidator() + { + + public String isValid(final Object value) + { + if (value instanceof String) + { + final EObject element = getParserElement(); + final IParser parser = getParser(); + try + { + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl() + { + + public void run() + { + setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); + } + }); + return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage(); + } + catch (InterruptedException ie) + { + ie.printStackTrace(); + } + } + + // shouldn't get here + return null; + } + }; + } + + /** + * @generated + */ + public IContentAssistProcessor getCompletionProcessor() + { + if (getParserElement() == null || getParser() == null) + { + return null; + } + return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + } + + /** + * @generated + */ + public ParserOptions getParserOptions() + { + return ParserOptions.NONE; + } + + /** + * @generated + */ + public IParser getParser() + { + if (parser == null) + { + parser = AcoreParserProvider.getParser(AcoreElementTypes.AAttribute_3001, getParserElement(), + AcoreVisualIDRegistry + .getType(org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AAttributeEditPart.VISUAL_ID)); + } + return parser; + } + + /** + * @generated + */ + protected DirectEditManager getManager() + { + if (manager == null) + { + setManager(new TextDirectEditManager(this, TextDirectEditManager.getTextCellEditorClass(this), + AcoreEditPartFactory.getTextCellEditorLocator(this))); + } + return manager; + } + + /** + * @generated + */ + protected void setManager(DirectEditManager manager) + { + this.manager = manager; + } + + /** + * @generated + */ + protected void performDirectEdit() + { + getManager().show(); + } + + /** + * @generated + */ + protected void performDirectEdit(Point eventLocation) + { + if (getManager().getClass() == TextDirectEditManager.class) + { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + } + } + + /** + * @generated + */ + private void performDirectEdit(char initialCharacter) + { + if (getManager() instanceof TextDirectEditManager) + { + ((TextDirectEditManager)getManager()).show(initialCharacter); + } + else + { + performDirectEdit(); + } + } + + /** + * @generated + */ + protected void performDirectEditRequest(Request request) + { + final Request theRequest = request; + try + { + getEditingDomain().runExclusive(new Runnable() + { + + public void run() + { + if (isActive() && isEditable()) + { + if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) + { + Character initialChar = (Character)theRequest.getExtendedData().get( + RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + performDirectEdit(initialChar.charValue()); + } + else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) + { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; + performDirectEdit(editRequest.getLocation()); + } + else + { + performDirectEdit(); + } + } + } + }); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + + /** + * @generated + */ + protected void refreshVisuals() + { + super.refreshVisuals(); + refreshLabel(); + refreshFont(); + refreshFontColor(); + refreshUnderline(); + refreshStrikeThrough(); + } + + /** + * @generated + */ + protected void refreshLabel() + { + setLabelTextHelper(getFigure(), getLabelText()); + setLabelIconHelper(getFigure(), getLabelIcon()); + Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); + if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + } + Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); + if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + } + } + + /** + * @generated + */ + protected void refreshUnderline() + { + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) + { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + } + } + + /** + * @generated + */ + protected void refreshStrikeThrough() + { + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) + { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + } + } + + /** + * @generated + */ + 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)); + setFont(fontData); + } + } + + /** + * @generated + */ + protected void setFontColor(Color color) + { + getFigure().setForegroundColor(color); + } + + /** + * @generated + */ + protected void addSemanticListeners() + { + 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$ + } + } + else + { + super.addSemanticListeners(); + } + } + + /** + * @generated + */ + protected void removeSemanticListeners() + { + if (parserElements != null) + { + for (int i = 0; i < parserElements.size(); i++) + { + removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ + } + } + else + { + super.removeSemanticListeners(); + } + } + + /** + * @generated + */ + protected AccessibleEditPart getAccessibleEditPart() + { + if (accessibleEP == null) + { + accessibleEP = new AccessibleGraphicalEditPart() + { + + public void getName(AccessibleEvent e) + { + e.result = getLabelTextHelper(getFigure()); + } + }; + } + return accessibleEP; + } + + /** + * @generated + */ + private View getFontStyleOwnerView() + { + return getPrimaryView(); + } + + /** + * @generated + */ + protected void addNotationalListeners() + { + super.addNotationalListeners(); + addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$ + } + + /** + * @generated + */ + protected void removeNotationalListeners() + { + super.removeNotationalListeners(); + removeListenerFilter("PrimaryView"); //$NON-NLS-1$ + } + + /** + * @generated + */ + protected void handleNotificationEvent(Notification event) + { + Object feature = event.getFeature(); + 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)) + { + refreshUnderline(); + } + 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)) + { + refreshFont(); + } + else + { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) + { + refreshLabel(); + } + if (getParser() instanceof ISemanticParser) + { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) + { + removeSemanticListeners(); + if (resolveSemanticElement() != null) + { + addSemanticListeners(); + } + refreshLabel(); + } + } + } + super.handleNotificationEvent(event); + } + + /** + * @generated + */ + protected IFigure createFigure() + { + IFigure label = createFigurePrim(); + defaultText = getLabelTextHelper(label); + return label; + } + + /** + * @generated + */ + protected IFigure createFigurePrim() + { + return new WrappingLabel(); + } + +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassAAttributeCompartmentEditPart.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassAAttributeCompartmentEditPart.java index e3c72b0585..d6296a1592 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassAAttributeCompartmentEditPart.java +++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassAAttributeCompartmentEditPart.java @@ -1,94 +1,94 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- *
- */
-package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts;
-
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassAAttributeCompartmentCanonicalEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassAAttributeCompartmentItemSemanticEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.Messages;
-
-import org.eclipse.emf.common.notify.Notification;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
-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.ResizableCompartmentFigure;
-import org.eclipse.gmf.runtime.notation.View;
-
-/**
- * @generated
- */
-public class AClassAAttributeCompartmentEditPart extends ListCompartmentEditPart
-{
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 7003;
-
- /**
- * @generated
- */
- public AClassAAttributeCompartmentEditPart(View view)
- {
- super(view);
- }
-
- /**
- * @generated
- */
- protected boolean hasModelChildrenChanged(Notification evt)
- {
- return false;
- }
-
- /**
- * @generated
- */
- public String getCompartmentName()
- {
- return Messages.AClassAAttributeCompartmentEditPart_title;
- }
-
- /**
- * @generated
- */
- public IFigure createFigure()
- {
- ResizableCompartmentFigure result = (ResizableCompartmentFigure)super.createFigure();
- result.setTitleVisibility(false);
- return result;
- }
-
- /**
- * @generated
- */
- protected void createDefaultEditPolicies()
- {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AClassAAttributeCompartmentItemSemanticEditPolicy());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new AClassAAttributeCompartmentCanonicalEditPolicy());
- }
-
- /**
- * @generated
- */
- protected void setRatio(Double ratio)
- {
- // nothing to do -- parent layout does not accept Double constraints as ratio
- // super.setRatio(ratio);
- }
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + * + */ +package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts; + +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassAAttributeCompartmentCanonicalEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassAAttributeCompartmentItemSemanticEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.Messages; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy; +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.ResizableCompartmentFigure; +import org.eclipse.gmf.runtime.notation.View; + +/** + * @generated + */ +public class AClassAAttributeCompartmentEditPart extends ListCompartmentEditPart +{ + + /** + * @generated + */ + public static final int VISUAL_ID = 7003; + + /** + * @generated + */ + public AClassAAttributeCompartmentEditPart(View view) + { + super(view); + } + + /** + * @generated + */ + protected boolean hasModelChildrenChanged(Notification evt) + { + return false; + } + + /** + * @generated + */ + public String getCompartmentName() + { + return Messages.AClassAAttributeCompartmentEditPart_title; + } + + /** + * @generated + */ + public IFigure createFigure() + { + ResizableCompartmentFigure result = (ResizableCompartmentFigure)super.createFigure(); + result.setTitleVisibility(false); + return result; + } + + /** + * @generated + */ + protected void createDefaultEditPolicies() + { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AClassAAttributeCompartmentItemSemanticEditPolicy()); + installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationEditPolicy()); + installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy()); + installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new AClassAAttributeCompartmentCanonicalEditPolicy()); + } + + /** + * @generated + */ + protected void setRatio(Double ratio) + { + // nothing to do -- parent layout does not accept Double constraints as ratio + // super.setRatio(ratio); + } + +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassAOperationClassCompartmentEditPart.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassAOperationClassCompartmentEditPart.java index f0834ad306..30ba4f2546 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassAOperationClassCompartmentEditPart.java +++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassAOperationClassCompartmentEditPart.java @@ -1,94 +1,94 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- *
- */
-package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts;
-
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassAOperationClassCompartmentCanonicalEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassAOperationClassCompartmentItemSemanticEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.Messages;
-
-import org.eclipse.emf.common.notify.Notification;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
-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.ResizableCompartmentFigure;
-import org.eclipse.gmf.runtime.notation.View;
-
-/**
- * @generated
- */
-public class AClassAOperationClassCompartmentEditPart extends ListCompartmentEditPart
-{
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 7004;
-
- /**
- * @generated
- */
- public AClassAOperationClassCompartmentEditPart(View view)
- {
- super(view);
- }
-
- /**
- * @generated
- */
- protected boolean hasModelChildrenChanged(Notification evt)
- {
- return false;
- }
-
- /**
- * @generated
- */
- public String getCompartmentName()
- {
- return Messages.AClassAOperationClassCompartmentEditPart_title;
- }
-
- /**
- * @generated
- */
- public IFigure createFigure()
- {
- ResizableCompartmentFigure result = (ResizableCompartmentFigure)super.createFigure();
- result.setTitleVisibility(false);
- return result;
- }
-
- /**
- * @generated
- */
- protected void createDefaultEditPolicies()
- {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AClassAOperationClassCompartmentItemSemanticEditPolicy());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new AClassAOperationClassCompartmentCanonicalEditPolicy());
- }
-
- /**
- * @generated
- */
- protected void setRatio(Double ratio)
- {
- // nothing to do -- parent layout does not accept Double constraints as ratio
- // super.setRatio(ratio);
- }
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + * + */ +package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts; + +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassAOperationClassCompartmentCanonicalEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassAOperationClassCompartmentItemSemanticEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.Messages; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy; +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.ResizableCompartmentFigure; +import org.eclipse.gmf.runtime.notation.View; + +/** + * @generated + */ +public class AClassAOperationClassCompartmentEditPart extends ListCompartmentEditPart +{ + + /** + * @generated + */ + public static final int VISUAL_ID = 7004; + + /** + * @generated + */ + public AClassAOperationClassCompartmentEditPart(View view) + { + super(view); + } + + /** + * @generated + */ + protected boolean hasModelChildrenChanged(Notification evt) + { + return false; + } + + /** + * @generated + */ + public String getCompartmentName() + { + return Messages.AClassAOperationClassCompartmentEditPart_title; + } + + /** + * @generated + */ + public IFigure createFigure() + { + ResizableCompartmentFigure result = (ResizableCompartmentFigure)super.createFigure(); + result.setTitleVisibility(false); + return result; + } + + /** + * @generated + */ + protected void createDefaultEditPolicies() + { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AClassAOperationClassCompartmentItemSemanticEditPolicy()); + installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationEditPolicy()); + installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy()); + installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new AClassAOperationClassCompartmentCanonicalEditPolicy()); + } + + /** + * @generated + */ + protected void setRatio(Double ratio) + { + // nothing to do -- parent layout does not accept Double constraints as ratio + // super.setRatio(ratio); + } + +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassAggregationsEditPart.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassAggregationsEditPart.java index e653c4ab8e..61ed40ebe7 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassAggregationsEditPart.java +++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassAggregationsEditPart.java @@ -1,118 +1,118 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- *
- */
-package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts;
-
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassAggregationsItemSemanticEditPolicy;
-
-import org.eclipse.draw2d.Connection;
-import org.eclipse.draw2d.PolygonDecoration;
-import org.eclipse.draw2d.RotatableDecoration;
-import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class AClassAggregationsEditPart extends ConnectionNodeEditPart implements ITreeBranchEditPart
-{
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 4004;
-
- /**
- * @generated
- */
- public AClassAggregationsEditPart(View view)
- {
- super(view);
- }
-
- /**
- * @generated
- */
- protected void createDefaultEditPolicies()
- {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AClassAggregationsItemSemanticEditPolicy());
- }
-
- /**
- * Creates figure for this edit part. Body of this method does not depend on settings in generation model so you may
- * safely remove <i>generated</i> tag and modify it.
- *
- * @generated
- */
-
- protected Connection createConnectionFigure()
- {
- return new AClassAggregationClassesFigure();
- }
-
- /**
- * @generated
- */
- public AClassAggregationClassesFigure getPrimaryShape()
- {
- return (AClassAggregationClassesFigure)getFigure();
- }
-
- /**
- * @generated
- */
- public class AClassAggregationClassesFigure extends PolylineConnectionEx
- {
-
- /**
- * @generated
- */
- public AClassAggregationClassesFigure()
- {
- this.setLineWidth(1);
-
- setTargetDecoration(createTargetDecoration());
- }
-
- /**
- * @generated
- */
- private RotatableDecoration createTargetDecoration()
- {
- PolygonDecoration df = new PolygonDecoration();
- df.setFill(true);
- df.setLineWidth(1);
- df.setBackgroundColor(DF_BACK);
- PointList pl = new PointList();
- pl.addPoint(getMapMode().DPtoLP(-2), getMapMode().DPtoLP(2));
- pl.addPoint(getMapMode().DPtoLP(0), getMapMode().DPtoLP(0));
- pl.addPoint(getMapMode().DPtoLP(-2), getMapMode().DPtoLP(-2));
- pl.addPoint(getMapMode().DPtoLP(-4), getMapMode().DPtoLP(0));
- pl.addPoint(getMapMode().DPtoLP(-2), getMapMode().DPtoLP(2));
- df.setTemplate(pl);
- df.setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3));
- return df;
- }
-
- }
-
- /**
- * @generated
- */
- static final Color DF_BACK = new Color(null, 255, 255, 255);
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + * + */ +package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts; + +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassAggregationsItemSemanticEditPolicy; + +import org.eclipse.draw2d.Connection; +import org.eclipse.draw2d.PolygonDecoration; +import org.eclipse.draw2d.RotatableDecoration; +import org.eclipse.draw2d.geometry.PointList; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.swt.graphics.Color; + +/** + * @generated + */ +public class AClassAggregationsEditPart extends ConnectionNodeEditPart implements ITreeBranchEditPart +{ + + /** + * @generated + */ + public static final int VISUAL_ID = 4004; + + /** + * @generated + */ + public AClassAggregationsEditPart(View view) + { + super(view); + } + + /** + * @generated + */ + protected void createDefaultEditPolicies() + { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AClassAggregationsItemSemanticEditPolicy()); + } + + /** + * Creates figure for this edit part. Body of this method does not depend on settings in generation model so you may + * safely remove <i>generated</i> tag and modify it. + * + * @generated + */ + + protected Connection createConnectionFigure() + { + return new AClassAggregationClassesFigure(); + } + + /** + * @generated + */ + public AClassAggregationClassesFigure getPrimaryShape() + { + return (AClassAggregationClassesFigure)getFigure(); + } + + /** + * @generated + */ + public class AClassAggregationClassesFigure extends PolylineConnectionEx + { + + /** + * @generated + */ + public AClassAggregationClassesFigure() + { + this.setLineWidth(1); + + setTargetDecoration(createTargetDecoration()); + } + + /** + * @generated + */ + private RotatableDecoration createTargetDecoration() + { + PolygonDecoration df = new PolygonDecoration(); + df.setFill(true); + df.setLineWidth(1); + df.setBackgroundColor(DF_BACK); + PointList pl = new PointList(); + pl.addPoint(getMapMode().DPtoLP(-2), getMapMode().DPtoLP(2)); + pl.addPoint(getMapMode().DPtoLP(0), getMapMode().DPtoLP(0)); + pl.addPoint(getMapMode().DPtoLP(-2), getMapMode().DPtoLP(-2)); + pl.addPoint(getMapMode().DPtoLP(-4), getMapMode().DPtoLP(0)); + pl.addPoint(getMapMode().DPtoLP(-2), getMapMode().DPtoLP(2)); + df.setTemplate(pl); + df.setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3)); + return df; + } + + } + + /** + * @generated + */ + static final Color DF_BACK = new Color(null, 255, 255, 255); + +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassAssociationsEditPart.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassAssociationsEditPart.java index 60be995495..fee580220e 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassAssociationsEditPart.java +++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassAssociationsEditPart.java @@ -1,70 +1,70 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- *
- */
-package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts;
-
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassAssociationsItemSemanticEditPolicy;
-
-import org.eclipse.draw2d.Connection;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;
-import org.eclipse.gmf.runtime.notation.View;
-
-/**
- * @generated
- */
-public class AClassAssociationsEditPart extends ConnectionNodeEditPart implements ITreeBranchEditPart
-{
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 4003;
-
- /**
- * @generated
- */
- public AClassAssociationsEditPart(View view)
- {
- super(view);
- }
-
- /**
- * @generated
- */
- protected void createDefaultEditPolicies()
- {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AClassAssociationsItemSemanticEditPolicy());
- }
-
- /**
- * Creates figure for this edit part. Body of this method does not depend on settings in generation model so you may
- * safely remove <i>generated</i> tag and modify it.
- *
- * @generated
- */
- protected Connection createConnectionFigure()
- {
- return new PolylineConnectionEx();
- }
-
- /**
- * @generated
- */
- public PolylineConnectionEx getPrimaryShape()
- {
- return (PolylineConnectionEx)getFigure();
- }
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + * + */ +package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts; + +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassAssociationsItemSemanticEditPolicy; + +import org.eclipse.draw2d.Connection; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx; +import org.eclipse.gmf.runtime.notation.View; + +/** + * @generated + */ +public class AClassAssociationsEditPart extends ConnectionNodeEditPart implements ITreeBranchEditPart +{ + + /** + * @generated + */ + public static final int VISUAL_ID = 4003; + + /** + * @generated + */ + public AClassAssociationsEditPart(View view) + { + super(view); + } + + /** + * @generated + */ + protected void createDefaultEditPolicies() + { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AClassAssociationsItemSemanticEditPolicy()); + } + + /** + * Creates figure for this edit part. Body of this method does not depend on settings in generation model so you may + * safely remove <i>generated</i> tag and modify it. + * + * @generated + */ + protected Connection createConnectionFigure() + { + return new PolylineConnectionEx(); + } + + /** + * @generated + */ + public PolylineConnectionEx getPrimaryShape() + { + return (PolylineConnectionEx)getFigure(); + } + +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassCompositionsEditPart.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassCompositionsEditPart.java index 35ce2cbbfb..1a45bcf342 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassCompositionsEditPart.java +++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassCompositionsEditPart.java @@ -1,118 +1,118 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- *
- */
-package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts;
-
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassCompositionsItemSemanticEditPolicy;
-
-import org.eclipse.draw2d.Connection;
-import org.eclipse.draw2d.PolygonDecoration;
-import org.eclipse.draw2d.RotatableDecoration;
-import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class AClassCompositionsEditPart extends ConnectionNodeEditPart implements ITreeBranchEditPart
-{
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 4005;
-
- /**
- * @generated
- */
- public AClassCompositionsEditPart(View view)
- {
- super(view);
- }
-
- /**
- * @generated
- */
- protected void createDefaultEditPolicies()
- {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AClassCompositionsItemSemanticEditPolicy());
- }
-
- /**
- * Creates figure for this edit part. Body of this method does not depend on settings in generation model so you may
- * safely remove <i>generated</i> tag and modify it.
- *
- * @generated
- */
-
- protected Connection createConnectionFigure()
- {
- return new AClassCompositionClassesFigure();
- }
-
- /**
- * @generated
- */
- public AClassCompositionClassesFigure getPrimaryShape()
- {
- return (AClassCompositionClassesFigure)getFigure();
- }
-
- /**
- * @generated
- */
- public class AClassCompositionClassesFigure extends PolylineConnectionEx
- {
-
- /**
- * @generated
- */
- public AClassCompositionClassesFigure()
- {
- this.setLineWidth(1);
-
- setTargetDecoration(createTargetDecoration());
- }
-
- /**
- * @generated
- */
- private RotatableDecoration createTargetDecoration()
- {
- PolygonDecoration df = new PolygonDecoration();
- df.setFill(true);
- df.setLineWidth(1);
- df.setBackgroundColor(DF_BACK);
- PointList pl = new PointList();
- pl.addPoint(getMapMode().DPtoLP(-2), getMapMode().DPtoLP(2));
- pl.addPoint(getMapMode().DPtoLP(0), getMapMode().DPtoLP(0));
- pl.addPoint(getMapMode().DPtoLP(-2), getMapMode().DPtoLP(-2));
- pl.addPoint(getMapMode().DPtoLP(-4), getMapMode().DPtoLP(0));
- pl.addPoint(getMapMode().DPtoLP(-2), getMapMode().DPtoLP(2));
- df.setTemplate(pl);
- df.setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3));
- return df;
- }
-
- }
-
- /**
- * @generated
- */
- static final Color DF_BACK = new Color(null, 0, 0, 0);
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + * + */ +package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts; + +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassCompositionsItemSemanticEditPolicy; + +import org.eclipse.draw2d.Connection; +import org.eclipse.draw2d.PolygonDecoration; +import org.eclipse.draw2d.RotatableDecoration; +import org.eclipse.draw2d.geometry.PointList; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.swt.graphics.Color; + +/** + * @generated + */ +public class AClassCompositionsEditPart extends ConnectionNodeEditPart implements ITreeBranchEditPart +{ + + /** + * @generated + */ + public static final int VISUAL_ID = 4005; + + /** + * @generated + */ + public AClassCompositionsEditPart(View view) + { + super(view); + } + + /** + * @generated + */ + protected void createDefaultEditPolicies() + { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AClassCompositionsItemSemanticEditPolicy()); + } + + /** + * Creates figure for this edit part. Body of this method does not depend on settings in generation model so you may + * safely remove <i>generated</i> tag and modify it. + * + * @generated + */ + + protected Connection createConnectionFigure() + { + return new AClassCompositionClassesFigure(); + } + + /** + * @generated + */ + public AClassCompositionClassesFigure getPrimaryShape() + { + return (AClassCompositionClassesFigure)getFigure(); + } + + /** + * @generated + */ + public class AClassCompositionClassesFigure extends PolylineConnectionEx + { + + /** + * @generated + */ + public AClassCompositionClassesFigure() + { + this.setLineWidth(1); + + setTargetDecoration(createTargetDecoration()); + } + + /** + * @generated + */ + private RotatableDecoration createTargetDecoration() + { + PolygonDecoration df = new PolygonDecoration(); + df.setFill(true); + df.setLineWidth(1); + df.setBackgroundColor(DF_BACK); + PointList pl = new PointList(); + pl.addPoint(getMapMode().DPtoLP(-2), getMapMode().DPtoLP(2)); + pl.addPoint(getMapMode().DPtoLP(0), getMapMode().DPtoLP(0)); + pl.addPoint(getMapMode().DPtoLP(-2), getMapMode().DPtoLP(-2)); + pl.addPoint(getMapMode().DPtoLP(-4), getMapMode().DPtoLP(0)); + pl.addPoint(getMapMode().DPtoLP(-2), getMapMode().DPtoLP(2)); + df.setTemplate(pl); + df.setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3)); + return df; + } + + } + + /** + * @generated + */ + static final Color DF_BACK = new Color(null, 0, 0, 0); + +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassEditPart.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassEditPart.java index f89f752bf4..2a8a510fcd 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassEditPart.java +++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassEditPart.java @@ -1,582 +1,582 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- *
- */
-package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts;
-
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassItemSemanticEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextSelectionEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreElementTypes;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.RectangleFigure;
-import org.eclipse.draw2d.Shape;
-import org.eclipse.draw2d.StackLayout;
-import org.eclipse.draw2d.ToolbarLayout;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.editpolicies.LayoutEditPolicy;
-import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ConstrainedToolbarLayoutEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
-import org.eclipse.gmf.runtime.emf.type.core.IElementType;
-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.swt.graphics.Color;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * @generated
- */
-public class AClassEditPart extends ShapeNodeEditPart
-{
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 2002;
-
- /**
- * @generated
- */
- protected IFigure contentPane;
-
- /**
- * @generated
- */
- protected IFigure primaryShape;
-
- /**
- * @generated
- */
- public AClassEditPart(View view)
- {
- super(view);
- }
-
- /**
- * @generated
- */
- protected void createDefaultEditPolicies()
- {
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationEditPolicy());
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AClassItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
- // 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);
- }
-
- /**
- * @generated
- */
- protected LayoutEditPolicy createLayoutEditPolicy()
- {
-
- ConstrainedToolbarLayoutEditPolicy lep = new ConstrainedToolbarLayoutEditPolicy()
- {
-
- protected EditPolicy createChildEditPolicy(EditPart child)
- {
- if (child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE) == null)
- {
- if (child instanceof ITextAwareEditPart)
- {
- return new AcoreTextSelectionEditPolicy();
- }
- }
- return super.createChildEditPolicy(child);
- }
- };
- return lep;
- }
-
- /**
- * @generated
- */
- protected IFigure createNodeShape()
- {
- AClassFigure figure = new AClassFigure();
- return primaryShape = figure;
- }
-
- /**
- * @generated
- */
- public AClassFigure getPrimaryShape()
- {
- return (AClassFigure)primaryShape;
- }
-
- /**
- * @generated
- */
- protected boolean addFixedChild(EditPart childEditPart)
- {
- if (childEditPart instanceof AClassNameEditPart)
- {
- ((AClassNameEditPart)childEditPart).setLabel(getPrimaryShape().getFigureAClassNameFigure());
- return true;
- }
- if (childEditPart instanceof AClassAAttributeCompartmentEditPart)
- {
- IFigure pane = getPrimaryShape().getFigureClassAttributes();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((AClassAAttributeCompartmentEditPart)childEditPart).getFigure());
- return true;
- }
- if (childEditPart instanceof AClassAOperationClassCompartmentEditPart)
- {
- IFigure pane = getPrimaryShape().getFigureClassOperations();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.add(((AClassAOperationClassCompartmentEditPart)childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected boolean removeFixedChild(EditPart childEditPart)
- {
- if (childEditPart instanceof AClassNameEditPart)
- {
- return true;
- }
- if (childEditPart instanceof AClassAAttributeCompartmentEditPart)
- {
- IFigure pane = getPrimaryShape().getFigureClassAttributes();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.remove(((AClassAAttributeCompartmentEditPart)childEditPart).getFigure());
- return true;
- }
- if (childEditPart instanceof AClassAOperationClassCompartmentEditPart)
- {
- IFigure pane = getPrimaryShape().getFigureClassOperations();
- setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way
- pane.remove(((AClassAOperationClassCompartmentEditPart)childEditPart).getFigure());
- return true;
- }
- return false;
- }
-
- /**
- * @generated
- */
- protected void addChildVisual(EditPart childEditPart, int index)
- {
- if (addFixedChild(childEditPart))
- {
- return;
- }
- super.addChildVisual(childEditPart, -1);
- }
-
- /**
- * @generated
- */
- protected void removeChildVisual(EditPart childEditPart)
- {
- if (removeFixedChild(childEditPart))
- {
- return;
- }
- super.removeChildVisual(childEditPart);
- }
-
- /**
- * @generated
- */
- protected IFigure getContentPaneFor(IGraphicalEditPart editPart)
- {
- if (editPart instanceof AClassAAttributeCompartmentEditPart)
- {
- return getPrimaryShape().getFigureClassAttributes();
- }
- if (editPart instanceof AClassAOperationClassCompartmentEditPart)
- {
- return getPrimaryShape().getFigureClassOperations();
- }
- return getContentPane();
- }
-
- /**
- * @generated
- */
- protected NodeFigure createNodePlate()
- {
- DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(40, 40);
- return result;
- }
-
- /**
- * Creates figure for this edit part. Body of this method does not depend on settings in generation model so you may
- * safely remove <i>generated</i> tag and modify it.
- *
- * @generated
- */
- protected NodeFigure createNodeFigure()
- {
- NodeFigure figure = createNodePlate();
- figure.setLayoutManager(new StackLayout());
- IFigure shape = createNodeShape();
- figure.add(shape);
- contentPane = setupContentPane(shape);
- return figure;
- }
-
- /**
- * Default implementation treats passed figure as content pane. Respects layout one may have set for generated figure.
- *
- * @param nodeShape
- * instance of generated figure class
- * @generated
- */
- protected IFigure setupContentPane(IFigure nodeShape)
- {
- if (nodeShape.getLayoutManager() == null)
- {
- ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout();
- layout.setSpacing(5);
- nodeShape.setLayoutManager(layout);
- }
- return nodeShape; // use nodeShape itself as contentPane
- }
-
- /**
- * @generated
- */
- public IFigure getContentPane()
- {
- if (contentPane != null)
- {
- return contentPane;
- }
- return super.getContentPane();
- }
-
- /**
- * @generated
- */
- protected void setForegroundColor(Color color)
- {
- if (primaryShape != null)
- {
- primaryShape.setForegroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- protected void setBackgroundColor(Color color)
- {
- if (primaryShape != null)
- {
- primaryShape.setBackgroundColor(color);
- }
- }
-
- /**
- * @generated
- */
- protected void setLineWidth(int width)
- {
- if (primaryShape instanceof Shape)
- {
- ((Shape)primaryShape).setLineWidth(width);
- }
- }
-
- /**
- * @generated
- */
- protected void setLineType(int style)
- {
- if (primaryShape instanceof Shape)
- {
- ((Shape)primaryShape).setLineStyle(style);
- }
- }
-
- /**
- * @generated
- */
- public EditPart getPrimaryChildEditPart()
- {
- return getChildBySemanticHint(AcoreVisualIDRegistry.getType(AClassNameEditPart.VISUAL_ID));
- }
-
- /**
- * @generated
- */
- public List<IElementType> getMARelTypesOnSource()
- {
- ArrayList<IElementType> types = new ArrayList<IElementType>(5);
- types.add(AcoreElementTypes.AClassSubClasses_4001);
- types.add(AcoreElementTypes.AClassImplementedInterfaces_4002);
- types.add(AcoreElementTypes.AClassAssociations_4003);
- types.add(AcoreElementTypes.AClassAggregations_4004);
- types.add(AcoreElementTypes.AClassCompositions_4005);
- return types;
- }
-
- /**
- * @generated
- */
- public List<IElementType> getMARelTypesOnSourceAndTarget(IGraphicalEditPart targetEditPart)
- {
- LinkedList<IElementType> types = new LinkedList<IElementType>();
- if (targetEditPart instanceof org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart)
- {
- types.add(AcoreElementTypes.AClassSubClasses_4001);
- }
- if (targetEditPart instanceof AInterfaceEditPart)
- {
- types.add(AcoreElementTypes.AClassImplementedInterfaces_4002);
- }
- if (targetEditPart instanceof org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart)
- {
- types.add(AcoreElementTypes.AClassAssociations_4003);
- }
- if (targetEditPart instanceof org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart)
- {
- types.add(AcoreElementTypes.AClassAggregations_4004);
- }
- if (targetEditPart instanceof org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart)
- {
- types.add(AcoreElementTypes.AClassCompositions_4005);
- }
- return types;
- }
-
- /**
- * @generated
- */
- public List<IElementType> getMATypesForTarget(IElementType relationshipType)
- {
- LinkedList<IElementType> types = new LinkedList<IElementType>();
- if (relationshipType == AcoreElementTypes.AClassSubClasses_4001)
- {
- types.add(AcoreElementTypes.AClass_2002);
- }
- else if (relationshipType == AcoreElementTypes.AClassImplementedInterfaces_4002)
- {
- types.add(AcoreElementTypes.AInterface_2001);
- }
- else if (relationshipType == AcoreElementTypes.AClassAssociations_4003)
- {
- types.add(AcoreElementTypes.AClass_2002);
- }
- else if (relationshipType == AcoreElementTypes.AClassAggregations_4004)
- {
- types.add(AcoreElementTypes.AClass_2002);
- }
- else if (relationshipType == AcoreElementTypes.AClassCompositions_4005)
- {
- types.add(AcoreElementTypes.AClass_2002);
- }
- return types;
- }
-
- /**
- * @generated
- */
- public List<IElementType> getMARelTypesOnTarget()
- {
- ArrayList<IElementType> types = new ArrayList<IElementType>(4);
- types.add(AcoreElementTypes.AClassSubClasses_4001);
- types.add(AcoreElementTypes.AClassAssociations_4003);
- types.add(AcoreElementTypes.AClassAggregations_4004);
- types.add(AcoreElementTypes.AClassCompositions_4005);
- return types;
- }
-
- /**
- * @generated
- */
- public List<IElementType> getMATypesForSource(IElementType relationshipType)
- {
- LinkedList<IElementType> types = new LinkedList<IElementType>();
- if (relationshipType == AcoreElementTypes.AClassSubClasses_4001)
- {
- types.add(AcoreElementTypes.AClass_2002);
- }
- else if (relationshipType == AcoreElementTypes.AClassAssociations_4003)
- {
- types.add(AcoreElementTypes.AClass_2002);
- }
- else if (relationshipType == AcoreElementTypes.AClassAggregations_4004)
- {
- types.add(AcoreElementTypes.AClass_2002);
- }
- else if (relationshipType == AcoreElementTypes.AClassCompositions_4005)
- {
- types.add(AcoreElementTypes.AClass_2002);
- }
- return types;
- }
-
- /**
- * @generated
- */
- public EditPart getTargetEditPart(Request request)
- {
- if (request instanceof CreateViewAndElementRequest)
- {
- CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest)request).getViewAndElementDescriptor()
- .getCreateElementRequestAdapter();
- IElementType type = (IElementType)adapter.getAdapter(IElementType.class);
- if (type == AcoreElementTypes.AAttribute_3003)
- {
- return getChildBySemanticHint(AcoreVisualIDRegistry.getType(AClassAAttributeCompartmentEditPart.VISUAL_ID));
- }
- if (type == AcoreElementTypes.AOperation_3004)
- {
- return getChildBySemanticHint(AcoreVisualIDRegistry.getType(AClassAOperationClassCompartmentEditPart.VISUAL_ID));
- }
- }
- return super.getTargetEditPart(request);
- }
-
- /**
- * @generated
- */
- public class AClassFigure extends RectangleFigure
- {
-
- /**
- * @generated
- */
- private RectangleFigure fFigureClassAttributes;
-
- /**
- * @generated
- */
- private WrappingLabel fFigureAClassNameFigure;
-
- /**
- * @generated
- */
- private RectangleFigure fFigureClassOperations;
-
- /**
- * @generated
- */
- public AClassFigure()
- {
-
- ToolbarLayout layoutThis = new ToolbarLayout();
- layoutThis.setStretchMinorAxis(true);
- layoutThis.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
-
- layoutThis.setSpacing(0);
- layoutThis.setVertical(true);
-
- this.setLayoutManager(layoutThis);
-
- this.setLineWidth(1);
- this.setBackgroundColor(THIS_BACK);
- createContents();
- }
-
- /**
- * @generated
- */
- private void createContents()
- {
-
- fFigureAClassNameFigure = new WrappingLabel();
- fFigureAClassNameFigure.setText("<...>");
-
- this.add(fFigureAClassNameFigure);
-
- fFigureClassAttributes = new RectangleFigure();
- fFigureClassAttributes.setLineWidth(1);
-
- this.add(fFigureClassAttributes);
- fFigureClassAttributes.setLayoutManager(new StackLayout());
-
- fFigureClassOperations = new RectangleFigure();
- fFigureClassOperations.setLineWidth(1);
-
- this.add(fFigureClassOperations);
- fFigureClassOperations.setLayoutManager(new StackLayout());
-
- }
-
- /**
- * @generated
- */
- private boolean myUseLocalCoordinates = false;
-
- /**
- * @generated
- */
- protected boolean useLocalCoordinates()
- {
- return myUseLocalCoordinates;
- }
-
- /**
- * @generated
- */
- protected void setUseLocalCoordinates(boolean useLocalCoordinates)
- {
- myUseLocalCoordinates = useLocalCoordinates;
- }
-
- /**
- * @generated
- */
- public RectangleFigure getFigureClassAttributes()
- {
- return fFigureClassAttributes;
- }
-
- /**
- * @generated
- */
- public WrappingLabel getFigureAClassNameFigure()
- {
- return fFigureAClassNameFigure;
- }
-
- /**
- * @generated
- */
- public RectangleFigure getFigureClassOperations()
- {
- return fFigureClassOperations;
- }
-
- }
-
- /**
- * @generated
- */
- static final Color THIS_BACK = new Color(null, 230, 230, 255);
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + * + */ +package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts; + +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassItemSemanticEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextSelectionEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreElementTypes; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.RectangleFigure; +import org.eclipse.draw2d.Shape; +import org.eclipse.draw2d.StackLayout; +import org.eclipse.draw2d.ToolbarLayout; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.Request; +import org.eclipse.gef.editpolicies.LayoutEditPolicy; +import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ConstrainedToolbarLayoutEditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest; +import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout; +import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +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.swt.graphics.Color; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * @generated + */ +public class AClassEditPart extends ShapeNodeEditPart +{ + + /** + * @generated + */ + public static final int VISUAL_ID = 2002; + + /** + * @generated + */ + protected IFigure contentPane; + + /** + * @generated + */ + protected IFigure primaryShape; + + /** + * @generated + */ + public AClassEditPart(View view) + { + super(view); + } + + /** + * @generated + */ + protected void createDefaultEditPolicies() + { + installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationEditPolicy()); + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AClassItemSemanticEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); + // 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); + } + + /** + * @generated + */ + protected LayoutEditPolicy createLayoutEditPolicy() + { + + ConstrainedToolbarLayoutEditPolicy lep = new ConstrainedToolbarLayoutEditPolicy() + { + + protected EditPolicy createChildEditPolicy(EditPart child) + { + if (child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE) == null) + { + if (child instanceof ITextAwareEditPart) + { + return new AcoreTextSelectionEditPolicy(); + } + } + return super.createChildEditPolicy(child); + } + }; + return lep; + } + + /** + * @generated + */ + protected IFigure createNodeShape() + { + AClassFigure figure = new AClassFigure(); + return primaryShape = figure; + } + + /** + * @generated + */ + public AClassFigure getPrimaryShape() + { + return (AClassFigure)primaryShape; + } + + /** + * @generated + */ + protected boolean addFixedChild(EditPart childEditPart) + { + if (childEditPart instanceof AClassNameEditPart) + { + ((AClassNameEditPart)childEditPart).setLabel(getPrimaryShape().getFigureAClassNameFigure()); + return true; + } + if (childEditPart instanceof AClassAAttributeCompartmentEditPart) + { + IFigure pane = getPrimaryShape().getFigureClassAttributes(); + setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way + pane.add(((AClassAAttributeCompartmentEditPart)childEditPart).getFigure()); + return true; + } + if (childEditPart instanceof AClassAOperationClassCompartmentEditPart) + { + IFigure pane = getPrimaryShape().getFigureClassOperations(); + setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way + pane.add(((AClassAOperationClassCompartmentEditPart)childEditPart).getFigure()); + return true; + } + return false; + } + + /** + * @generated + */ + protected boolean removeFixedChild(EditPart childEditPart) + { + if (childEditPart instanceof AClassNameEditPart) + { + return true; + } + if (childEditPart instanceof AClassAAttributeCompartmentEditPart) + { + IFigure pane = getPrimaryShape().getFigureClassAttributes(); + setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way + pane.remove(((AClassAAttributeCompartmentEditPart)childEditPart).getFigure()); + return true; + } + if (childEditPart instanceof AClassAOperationClassCompartmentEditPart) + { + IFigure pane = getPrimaryShape().getFigureClassOperations(); + setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way + pane.remove(((AClassAOperationClassCompartmentEditPart)childEditPart).getFigure()); + return true; + } + return false; + } + + /** + * @generated + */ + protected void addChildVisual(EditPart childEditPart, int index) + { + if (addFixedChild(childEditPart)) + { + return; + } + super.addChildVisual(childEditPart, -1); + } + + /** + * @generated + */ + protected void removeChildVisual(EditPart childEditPart) + { + if (removeFixedChild(childEditPart)) + { + return; + } + super.removeChildVisual(childEditPart); + } + + /** + * @generated + */ + protected IFigure getContentPaneFor(IGraphicalEditPart editPart) + { + if (editPart instanceof AClassAAttributeCompartmentEditPart) + { + return getPrimaryShape().getFigureClassAttributes(); + } + if (editPart instanceof AClassAOperationClassCompartmentEditPart) + { + return getPrimaryShape().getFigureClassOperations(); + } + return getContentPane(); + } + + /** + * @generated + */ + protected NodeFigure createNodePlate() + { + DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(40, 40); + return result; + } + + /** + * Creates figure for this edit part. Body of this method does not depend on settings in generation model so you may + * safely remove <i>generated</i> tag and modify it. + * + * @generated + */ + protected NodeFigure createNodeFigure() + { + NodeFigure figure = createNodePlate(); + figure.setLayoutManager(new StackLayout()); + IFigure shape = createNodeShape(); + figure.add(shape); + contentPane = setupContentPane(shape); + return figure; + } + + /** + * Default implementation treats passed figure as content pane. Respects layout one may have set for generated figure. + * + * @param nodeShape + * instance of generated figure class + * @generated + */ + protected IFigure setupContentPane(IFigure nodeShape) + { + if (nodeShape.getLayoutManager() == null) + { + ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); + layout.setSpacing(5); + nodeShape.setLayoutManager(layout); + } + return nodeShape; // use nodeShape itself as contentPane + } + + /** + * @generated + */ + public IFigure getContentPane() + { + if (contentPane != null) + { + return contentPane; + } + return super.getContentPane(); + } + + /** + * @generated + */ + protected void setForegroundColor(Color color) + { + if (primaryShape != null) + { + primaryShape.setForegroundColor(color); + } + } + + /** + * @generated + */ + protected void setBackgroundColor(Color color) + { + if (primaryShape != null) + { + primaryShape.setBackgroundColor(color); + } + } + + /** + * @generated + */ + protected void setLineWidth(int width) + { + if (primaryShape instanceof Shape) + { + ((Shape)primaryShape).setLineWidth(width); + } + } + + /** + * @generated + */ + protected void setLineType(int style) + { + if (primaryShape instanceof Shape) + { + ((Shape)primaryShape).setLineStyle(style); + } + } + + /** + * @generated + */ + public EditPart getPrimaryChildEditPart() + { + return getChildBySemanticHint(AcoreVisualIDRegistry.getType(AClassNameEditPart.VISUAL_ID)); + } + + /** + * @generated + */ + public List<IElementType> getMARelTypesOnSource() + { + ArrayList<IElementType> types = new ArrayList<IElementType>(5); + types.add(AcoreElementTypes.AClassSubClasses_4001); + types.add(AcoreElementTypes.AClassImplementedInterfaces_4002); + types.add(AcoreElementTypes.AClassAssociations_4003); + types.add(AcoreElementTypes.AClassAggregations_4004); + types.add(AcoreElementTypes.AClassCompositions_4005); + return types; + } + + /** + * @generated + */ + public List<IElementType> getMARelTypesOnSourceAndTarget(IGraphicalEditPart targetEditPart) + { + LinkedList<IElementType> types = new LinkedList<IElementType>(); + if (targetEditPart instanceof org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart) + { + types.add(AcoreElementTypes.AClassSubClasses_4001); + } + if (targetEditPart instanceof AInterfaceEditPart) + { + types.add(AcoreElementTypes.AClassImplementedInterfaces_4002); + } + if (targetEditPart instanceof org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart) + { + types.add(AcoreElementTypes.AClassAssociations_4003); + } + if (targetEditPart instanceof org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart) + { + types.add(AcoreElementTypes.AClassAggregations_4004); + } + if (targetEditPart instanceof org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart) + { + types.add(AcoreElementTypes.AClassCompositions_4005); + } + return types; + } + + /** + * @generated + */ + public List<IElementType> getMATypesForTarget(IElementType relationshipType) + { + LinkedList<IElementType> types = new LinkedList<IElementType>(); + if (relationshipType == AcoreElementTypes.AClassSubClasses_4001) + { + types.add(AcoreElementTypes.AClass_2002); + } + else if (relationshipType == AcoreElementTypes.AClassImplementedInterfaces_4002) + { + types.add(AcoreElementTypes.AInterface_2001); + } + else if (relationshipType == AcoreElementTypes.AClassAssociations_4003) + { + types.add(AcoreElementTypes.AClass_2002); + } + else if (relationshipType == AcoreElementTypes.AClassAggregations_4004) + { + types.add(AcoreElementTypes.AClass_2002); + } + else if (relationshipType == AcoreElementTypes.AClassCompositions_4005) + { + types.add(AcoreElementTypes.AClass_2002); + } + return types; + } + + /** + * @generated + */ + public List<IElementType> getMARelTypesOnTarget() + { + ArrayList<IElementType> types = new ArrayList<IElementType>(4); + types.add(AcoreElementTypes.AClassSubClasses_4001); + types.add(AcoreElementTypes.AClassAssociations_4003); + types.add(AcoreElementTypes.AClassAggregations_4004); + types.add(AcoreElementTypes.AClassCompositions_4005); + return types; + } + + /** + * @generated + */ + public List<IElementType> getMATypesForSource(IElementType relationshipType) + { + LinkedList<IElementType> types = new LinkedList<IElementType>(); + if (relationshipType == AcoreElementTypes.AClassSubClasses_4001) + { + types.add(AcoreElementTypes.AClass_2002); + } + else if (relationshipType == AcoreElementTypes.AClassAssociations_4003) + { + types.add(AcoreElementTypes.AClass_2002); + } + else if (relationshipType == AcoreElementTypes.AClassAggregations_4004) + { + types.add(AcoreElementTypes.AClass_2002); + } + else if (relationshipType == AcoreElementTypes.AClassCompositions_4005) + { + types.add(AcoreElementTypes.AClass_2002); + } + return types; + } + + /** + * @generated + */ + public EditPart getTargetEditPart(Request request) + { + if (request instanceof CreateViewAndElementRequest) + { + CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest)request).getViewAndElementDescriptor() + .getCreateElementRequestAdapter(); + IElementType type = (IElementType)adapter.getAdapter(IElementType.class); + if (type == AcoreElementTypes.AAttribute_3003) + { + return getChildBySemanticHint(AcoreVisualIDRegistry.getType(AClassAAttributeCompartmentEditPart.VISUAL_ID)); + } + if (type == AcoreElementTypes.AOperation_3004) + { + return getChildBySemanticHint(AcoreVisualIDRegistry.getType(AClassAOperationClassCompartmentEditPart.VISUAL_ID)); + } + } + return super.getTargetEditPart(request); + } + + /** + * @generated + */ + public class AClassFigure extends RectangleFigure + { + + /** + * @generated + */ + private RectangleFigure fFigureClassAttributes; + + /** + * @generated + */ + private WrappingLabel fFigureAClassNameFigure; + + /** + * @generated + */ + private RectangleFigure fFigureClassOperations; + + /** + * @generated + */ + public AClassFigure() + { + + ToolbarLayout layoutThis = new ToolbarLayout(); + layoutThis.setStretchMinorAxis(true); + layoutThis.setMinorAlignment(ToolbarLayout.ALIGN_CENTER); + + layoutThis.setSpacing(0); + layoutThis.setVertical(true); + + this.setLayoutManager(layoutThis); + + this.setLineWidth(1); + this.setBackgroundColor(THIS_BACK); + createContents(); + } + + /** + * @generated + */ + private void createContents() + { + + fFigureAClassNameFigure = new WrappingLabel(); + fFigureAClassNameFigure.setText("<...>"); + + this.add(fFigureAClassNameFigure); + + fFigureClassAttributes = new RectangleFigure(); + fFigureClassAttributes.setLineWidth(1); + + this.add(fFigureClassAttributes); + fFigureClassAttributes.setLayoutManager(new StackLayout()); + + fFigureClassOperations = new RectangleFigure(); + fFigureClassOperations.setLineWidth(1); + + this.add(fFigureClassOperations); + fFigureClassOperations.setLayoutManager(new StackLayout()); + + } + + /** + * @generated + */ + private boolean myUseLocalCoordinates = false; + + /** + * @generated + */ + protected boolean useLocalCoordinates() + { + return myUseLocalCoordinates; + } + + /** + * @generated + */ + protected void setUseLocalCoordinates(boolean useLocalCoordinates) + { + myUseLocalCoordinates = useLocalCoordinates; + } + + /** + * @generated + */ + public RectangleFigure getFigureClassAttributes() + { + return fFigureClassAttributes; + } + + /** + * @generated + */ + public WrappingLabel getFigureAClassNameFigure() + { + return fFigureAClassNameFigure; + } + + /** + * @generated + */ + public RectangleFigure getFigureClassOperations() + { + return fFigureClassOperations; + } + + } + + /** + * @generated + */ + static final Color THIS_BACK = new Color(null, 230, 230, 255); + +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassImplementedInterfacesEditPart.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassImplementedInterfacesEditPart.java index a84dde0894..b06a705897 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassImplementedInterfacesEditPart.java +++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassImplementedInterfacesEditPart.java @@ -1,103 +1,103 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- *
- */
-package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts;
-
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassImplementedInterfacesItemSemanticEditPolicy;
-
-import org.eclipse.draw2d.Connection;
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.PolylineDecoration;
-import org.eclipse.draw2d.RotatableDecoration;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;
-import org.eclipse.gmf.runtime.notation.View;
-
-/**
- * @generated
- */
-public class AClassImplementedInterfacesEditPart extends ConnectionNodeEditPart implements ITreeBranchEditPart
-{
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 4002;
-
- /**
- * @generated
- */
- public AClassImplementedInterfacesEditPart(View view)
- {
- super(view);
- }
-
- /**
- * @generated
- */
- protected void createDefaultEditPolicies()
- {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AClassImplementedInterfacesItemSemanticEditPolicy());
- }
-
- /**
- * Creates figure for this edit part. Body of this method does not depend on settings in generation model so you may
- * safely remove <i>generated</i> tag and modify it.
- *
- * @generated
- */
-
- protected Connection createConnectionFigure()
- {
- return new AClassImplementedInterfacesFigure();
- }
-
- /**
- * @generated
- */
- public AClassImplementedInterfacesFigure getPrimaryShape()
- {
- return (AClassImplementedInterfacesFigure)getFigure();
- }
-
- /**
- * @generated
- */
- public class AClassImplementedInterfacesFigure extends PolylineConnectionEx
- {
-
- /**
- * @generated
- */
- public AClassImplementedInterfacesFigure()
- {
- this.setLineWidth(1);
- this.setLineStyle(Graphics.LINE_DASH);
-
- setTargetDecoration(createTargetDecoration());
- }
-
- /**
- * @generated
- */
- private RotatableDecoration createTargetDecoration()
- {
- PolylineDecoration df = new PolylineDecoration();
- df.setLineWidth(1);
- return df;
- }
-
- }
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + * + */ +package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts; + +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassImplementedInterfacesItemSemanticEditPolicy; + +import org.eclipse.draw2d.Connection; +import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.PolylineDecoration; +import org.eclipse.draw2d.RotatableDecoration; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx; +import org.eclipse.gmf.runtime.notation.View; + +/** + * @generated + */ +public class AClassImplementedInterfacesEditPart extends ConnectionNodeEditPart implements ITreeBranchEditPart +{ + + /** + * @generated + */ + public static final int VISUAL_ID = 4002; + + /** + * @generated + */ + public AClassImplementedInterfacesEditPart(View view) + { + super(view); + } + + /** + * @generated + */ + protected void createDefaultEditPolicies() + { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AClassImplementedInterfacesItemSemanticEditPolicy()); + } + + /** + * Creates figure for this edit part. Body of this method does not depend on settings in generation model so you may + * safely remove <i>generated</i> tag and modify it. + * + * @generated + */ + + protected Connection createConnectionFigure() + { + return new AClassImplementedInterfacesFigure(); + } + + /** + * @generated + */ + public AClassImplementedInterfacesFigure getPrimaryShape() + { + return (AClassImplementedInterfacesFigure)getFigure(); + } + + /** + * @generated + */ + public class AClassImplementedInterfacesFigure extends PolylineConnectionEx + { + + /** + * @generated + */ + public AClassImplementedInterfacesFigure() + { + this.setLineWidth(1); + this.setLineStyle(Graphics.LINE_DASH); + + setTargetDecoration(createTargetDecoration()); + } + + /** + * @generated + */ + private RotatableDecoration createTargetDecoration() + { + PolylineDecoration df = new PolylineDecoration(); + df.setLineWidth(1); + return df; + } + + } + +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassNameEditPart.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassNameEditPart.java index 4e6fe0771f..8c607a34ff 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassNameEditPart.java +++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassNameEditPart.java @@ -1,685 +1,685 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- *
- */
-package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts;
-
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextSelectionEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreElementTypes;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreParserProvider;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RunnableWithResult;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.gef.AccessibleEditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
-import org.eclipse.gef.handles.MoveHandle;
-import org.eclipse.gef.handles.NonResizableHandleKit;
-import org.eclipse.gef.requests.DirectEditRequest;
-import org.eclipse.gef.tools.DirectEditManager;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
-import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.gmf.runtime.notation.FontStyle;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @generated
- */
-public class AClassNameEditPart extends CompartmentEditPart implements ITextAwareEditPart
-{
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 5002;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * @generated
- */
- public AClassNameEditPart(View view)
- {
- super(view);
- }
-
- /**
- * @generated
- */
- protected void createDefaultEditPolicies()
- {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new AcoreTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicy()
- {
-
- protected List createSelectionHandles()
- {
- List handles = new ArrayList();
- NonResizableHandleKit.addMoveHandle((GraphicalEditPart)getHost(), handles);
- ((MoveHandle)handles.get(0)).setBorder(null);
- return handles;
- }
-
- public Command getCommand(Request request)
- {
- return null;
- }
-
- public boolean understandsRequest(Request request)
- {
- return false;
- }
- });
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure)
- {
- if (figure instanceof WrappingLabel)
- {
- return ((WrappingLabel)figure).getText();
- }
- else
- {
- return ((Label)figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text)
- {
- if (figure instanceof WrappingLabel)
- {
- ((WrappingLabel)figure).setText(text);
- }
- else
- {
- ((Label)figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure)
- {
- if (figure instanceof WrappingLabel)
- {
- return ((WrappingLabel)figure).getIcon();
- }
- else
- {
- return ((Label)figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon)
- {
- if (figure instanceof WrappingLabel)
- {
- ((WrappingLabel)figure).setIcon(icon);
- }
- else
- {
- ((Label)figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(WrappingLabel figure)
- {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- protected List getModelChildren()
- {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint)
- {
- return null;
- }
-
- /**
- * @generated
- */
- protected EObject getParserElement()
- {
- return resolveSemanticElement();
- }
-
- /**
- * @generated
- */
- protected Image getLabelIcon()
- {
- EObject parserElement = getParserElement();
- if (parserElement == null)
- {
- return null;
- }
- return AcoreElementTypes.getImage(parserElement.eClass());
- }
-
- /**
- * @generated
- */
- protected String getLabelText()
- {
- String text = null;
- EObject parserElement = getParserElement();
- if (parserElement != null && getParser() != null)
- {
- text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue());
- }
- if (text == null || text.length() == 0)
- {
- text = defaultText;
- }
- return text;
- }
-
- /**
- * @generated
- */
- public void setLabelText(String text)
- {
- setLabelTextHelper(getFigure(), text);
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback();
- }
- }
-
- /**
- * @generated
- */
- public String getEditText()
- {
- if (getParserElement() == null || getParser() == null)
- {
- return ""; //$NON-NLS-1$
- }
- return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue());
- }
-
- /**
- * @generated
- */
- protected boolean isEditable()
- {
- return getParser() != null;
- }
-
- /**
- * @generated
- */
- public ICellEditorValidator getEditTextValidator()
- {
- return new ICellEditorValidator()
- {
-
- public String isValid(final Object value)
- {
- if (value instanceof String)
- {
- final EObject element = getParserElement();
- final IParser parser = getParser();
- try
- {
- IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl()
- {
-
- public void run()
- {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value));
- }
- });
- return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage();
- }
- catch (InterruptedException ie)
- {
- ie.printStackTrace();
- }
- }
-
- // shouldn't get here
- return null;
- }
- };
- }
-
- /**
- * @generated
- */
- public IContentAssistProcessor getCompletionProcessor()
- {
- if (getParserElement() == null || getParser() == null)
- {
- return null;
- }
- return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
- }
-
- /**
- * @generated
- */
- public ParserOptions getParserOptions()
- {
- return ParserOptions.NONE;
- }
-
- /**
- * @generated
- */
- public IParser getParser()
- {
- if (parser == null)
- {
- parser = AcoreParserProvider.getParser(AcoreElementTypes.AClass_2002, getParserElement(), AcoreVisualIDRegistry
- .getType(org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassNameEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager()
- {
- if (manager == null)
- {
- setManager(new TextDirectEditManager(this, TextDirectEditManager.getTextCellEditorClass(this),
- AcoreEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager)
- {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit()
- {
- getManager().show();
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation)
- {
- if (getManager().getClass() == TextDirectEditManager.class)
- {
- ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter)
- {
- if (getManager() instanceof TextDirectEditManager)
- {
- ((TextDirectEditManager)getManager()).show(initialCharacter);
- }
- else
- {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- protected void performDirectEditRequest(Request request)
- {
- final Request theRequest = request;
- try
- {
- getEditingDomain().runExclusive(new Runnable()
- {
-
- public void run()
- {
- if (isActive() && isEditable())
- {
- if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character)
- {
- Character initialChar = (Character)theRequest.getExtendedData().get(
- RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- }
- else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText())))
- {
- DirectEditRequest editRequest = (DirectEditRequest)theRequest;
- performDirectEdit(editRequest.getLocation());
- }
- else
- {
- performDirectEdit();
- }
- }
- }
- });
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- protected void refreshVisuals()
- {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel()
- {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback();
- }
- }
-
- /**
- * @generated
- */
- protected void refreshUnderline()
- {
- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel)
- {
- ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline());
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough()
- {
- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel)
- {
- ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- 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));
- setFont(fontData);
- }
- }
-
- /**
- * @generated
- */
- protected void setFontColor(Color color)
- {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- protected void addSemanticListeners()
- {
- 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$
- }
- }
- else
- {
- super.addSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- protected void removeSemanticListeners()
- {
- if (parserElements != null)
- {
- for (int i = 0; i < parserElements.size(); i++)
- {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- }
- else
- {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- protected AccessibleEditPart getAccessibleEditPart()
- {
- if (accessibleEP == null)
- {
- accessibleEP = new AccessibleGraphicalEditPart()
- {
-
- public void getName(AccessibleEvent e)
- {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView()
- {
- return getPrimaryView();
- }
-
- /**
- * @generated
- */
- protected void addNotationalListeners()
- {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- protected void removeNotationalListeners()
- {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- protected void handleNotificationEvent(Notification event)
- {
- Object feature = event.getFeature();
- 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))
- {
- refreshUnderline();
- }
- 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))
- {
- refreshFont();
- }
- else
- {
- if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue()))
- {
- refreshLabel();
- }
- if (getParser() instanceof ISemanticParser)
- {
- ISemanticParser modelParser = (ISemanticParser)getParser();
- if (modelParser.areSemanticElementsAffected(null, event))
- {
- removeSemanticListeners();
- if (resolveSemanticElement() != null)
- {
- addSemanticListeners();
- }
- refreshLabel();
- }
- }
- }
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- protected IFigure createFigure()
- {
- // Parent should assign one using setLabel() method
- return null;
- }
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + * + */ +package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts; + +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextSelectionEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreElementTypes; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreParserProvider; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.RunnableWithResult; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.gef.AccessibleEditPart; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.editpolicies.NonResizableEditPolicy; +import org.eclipse.gef.handles.MoveHandle; +import org.eclipse.gef.handles.NonResizableHandleKit; +import org.eclipse.gef.requests.DirectEditRequest; +import org.eclipse.gef.tools.DirectEditManager; +import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; +import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; +import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus; +import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; +import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; +import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; +import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; +import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; +import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; +import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; +import org.eclipse.gmf.runtime.notation.FontStyle; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.jface.text.contentassist.IContentAssistProcessor; +import org.eclipse.jface.viewers.ICellEditorValidator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.accessibility.AccessibleEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.Image; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * @generated + */ +public class AClassNameEditPart extends CompartmentEditPart implements ITextAwareEditPart +{ + + /** + * @generated + */ + public static final int VISUAL_ID = 5002; + + /** + * @generated + */ + private DirectEditManager manager; + + /** + * @generated + */ + private IParser parser; + + /** + * @generated + */ + private List parserElements; + + /** + * @generated + */ + private String defaultText; + + /** + * @generated + */ + public AClassNameEditPart(View view) + { + super(view); + } + + /** + * @generated + */ + protected void createDefaultEditPolicies() + { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new AcoreTextSelectionEditPolicy()); + installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); + installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicy() + { + + protected List createSelectionHandles() + { + List handles = new ArrayList(); + NonResizableHandleKit.addMoveHandle((GraphicalEditPart)getHost(), handles); + ((MoveHandle)handles.get(0)).setBorder(null); + return handles; + } + + public Command getCommand(Request request) + { + return null; + } + + public boolean understandsRequest(Request request) + { + return false; + } + }); + } + + /** + * @generated + */ + protected String getLabelTextHelper(IFigure figure) + { + if (figure instanceof WrappingLabel) + { + return ((WrappingLabel)figure).getText(); + } + else + { + return ((Label)figure).getText(); + } + } + + /** + * @generated + */ + protected void setLabelTextHelper(IFigure figure, String text) + { + if (figure instanceof WrappingLabel) + { + ((WrappingLabel)figure).setText(text); + } + else + { + ((Label)figure).setText(text); + } + } + + /** + * @generated + */ + protected Image getLabelIconHelper(IFigure figure) + { + if (figure instanceof WrappingLabel) + { + return ((WrappingLabel)figure).getIcon(); + } + else + { + return ((Label)figure).getIcon(); + } + } + + /** + * @generated + */ + protected void setLabelIconHelper(IFigure figure, Image icon) + { + if (figure instanceof WrappingLabel) + { + ((WrappingLabel)figure).setIcon(icon); + } + else + { + ((Label)figure).setIcon(icon); + } + } + + /** + * @generated + */ + public void setLabel(WrappingLabel figure) + { + unregisterVisuals(); + setFigure(figure); + defaultText = getLabelTextHelper(figure); + registerVisuals(); + refreshVisuals(); + } + + /** + * @generated + */ + protected List getModelChildren() + { + return Collections.EMPTY_LIST; + } + + /** + * @generated + */ + public IGraphicalEditPart getChildBySemanticHint(String semanticHint) + { + return null; + } + + /** + * @generated + */ + protected EObject getParserElement() + { + return resolveSemanticElement(); + } + + /** + * @generated + */ + protected Image getLabelIcon() + { + EObject parserElement = getParserElement(); + if (parserElement == null) + { + return null; + } + return AcoreElementTypes.getImage(parserElement.eClass()); + } + + /** + * @generated + */ + protected String getLabelText() + { + String text = null; + EObject parserElement = getParserElement(); + if (parserElement != null && getParser() != null) + { + text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + } + if (text == null || text.length() == 0) + { + text = defaultText; + } + return text; + } + + /** + * @generated + */ + public void setLabelText(String text) + { + setLabelTextHelper(getFigure(), text); + Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); + if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + } + Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); + if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + } + } + + /** + * @generated + */ + public String getEditText() + { + if (getParserElement() == null || getParser() == null) + { + return ""; //$NON-NLS-1$ + } + return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + } + + /** + * @generated + */ + protected boolean isEditable() + { + return getParser() != null; + } + + /** + * @generated + */ + public ICellEditorValidator getEditTextValidator() + { + return new ICellEditorValidator() + { + + public String isValid(final Object value) + { + if (value instanceof String) + { + final EObject element = getParserElement(); + final IParser parser = getParser(); + try + { + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl() + { + + public void run() + { + setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); + } + }); + return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage(); + } + catch (InterruptedException ie) + { + ie.printStackTrace(); + } + } + + // shouldn't get here + return null; + } + }; + } + + /** + * @generated + */ + public IContentAssistProcessor getCompletionProcessor() + { + if (getParserElement() == null || getParser() == null) + { + return null; + } + return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + } + + /** + * @generated + */ + public ParserOptions getParserOptions() + { + return ParserOptions.NONE; + } + + /** + * @generated + */ + public IParser getParser() + { + if (parser == null) + { + parser = AcoreParserProvider.getParser(AcoreElementTypes.AClass_2002, getParserElement(), AcoreVisualIDRegistry + .getType(org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassNameEditPart.VISUAL_ID)); + } + return parser; + } + + /** + * @generated + */ + protected DirectEditManager getManager() + { + if (manager == null) + { + setManager(new TextDirectEditManager(this, TextDirectEditManager.getTextCellEditorClass(this), + AcoreEditPartFactory.getTextCellEditorLocator(this))); + } + return manager; + } + + /** + * @generated + */ + protected void setManager(DirectEditManager manager) + { + this.manager = manager; + } + + /** + * @generated + */ + protected void performDirectEdit() + { + getManager().show(); + } + + /** + * @generated + */ + protected void performDirectEdit(Point eventLocation) + { + if (getManager().getClass() == TextDirectEditManager.class) + { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + } + } + + /** + * @generated + */ + private void performDirectEdit(char initialCharacter) + { + if (getManager() instanceof TextDirectEditManager) + { + ((TextDirectEditManager)getManager()).show(initialCharacter); + } + else + { + performDirectEdit(); + } + } + + /** + * @generated + */ + protected void performDirectEditRequest(Request request) + { + final Request theRequest = request; + try + { + getEditingDomain().runExclusive(new Runnable() + { + + public void run() + { + if (isActive() && isEditable()) + { + if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) + { + Character initialChar = (Character)theRequest.getExtendedData().get( + RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + performDirectEdit(initialChar.charValue()); + } + else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) + { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; + performDirectEdit(editRequest.getLocation()); + } + else + { + performDirectEdit(); + } + } + } + }); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + + /** + * @generated + */ + protected void refreshVisuals() + { + super.refreshVisuals(); + refreshLabel(); + refreshFont(); + refreshFontColor(); + refreshUnderline(); + refreshStrikeThrough(); + } + + /** + * @generated + */ + protected void refreshLabel() + { + setLabelTextHelper(getFigure(), getLabelText()); + setLabelIconHelper(getFigure(), getLabelIcon()); + Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); + if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + } + Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); + if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + } + } + + /** + * @generated + */ + protected void refreshUnderline() + { + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) + { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + } + } + + /** + * @generated + */ + protected void refreshStrikeThrough() + { + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) + { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + } + } + + /** + * @generated + */ + 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)); + setFont(fontData); + } + } + + /** + * @generated + */ + protected void setFontColor(Color color) + { + getFigure().setForegroundColor(color); + } + + /** + * @generated + */ + protected void addSemanticListeners() + { + 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$ + } + } + else + { + super.addSemanticListeners(); + } + } + + /** + * @generated + */ + protected void removeSemanticListeners() + { + if (parserElements != null) + { + for (int i = 0; i < parserElements.size(); i++) + { + removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ + } + } + else + { + super.removeSemanticListeners(); + } + } + + /** + * @generated + */ + protected AccessibleEditPart getAccessibleEditPart() + { + if (accessibleEP == null) + { + accessibleEP = new AccessibleGraphicalEditPart() + { + + public void getName(AccessibleEvent e) + { + e.result = getLabelTextHelper(getFigure()); + } + }; + } + return accessibleEP; + } + + /** + * @generated + */ + private View getFontStyleOwnerView() + { + return getPrimaryView(); + } + + /** + * @generated + */ + protected void addNotationalListeners() + { + super.addNotationalListeners(); + addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$ + } + + /** + * @generated + */ + protected void removeNotationalListeners() + { + super.removeNotationalListeners(); + removeListenerFilter("PrimaryView"); //$NON-NLS-1$ + } + + /** + * @generated + */ + protected void handleNotificationEvent(Notification event) + { + Object feature = event.getFeature(); + 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)) + { + refreshUnderline(); + } + 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)) + { + refreshFont(); + } + else + { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) + { + refreshLabel(); + } + if (getParser() instanceof ISemanticParser) + { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) + { + removeSemanticListeners(); + if (resolveSemanticElement() != null) + { + addSemanticListeners(); + } + refreshLabel(); + } + } + } + super.handleNotificationEvent(event); + } + + /** + * @generated + */ + protected IFigure createFigure() + { + // Parent should assign one using setLabel() method + return null; + } + +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassSubClassesEditPart.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassSubClassesEditPart.java index 0f8cce2904..c12e510b9a 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassSubClassesEditPart.java +++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AClassSubClassesEditPart.java @@ -1,117 +1,117 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- *
- */
-package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts;
-
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassSubClassesItemSemanticEditPolicy;
-
-import org.eclipse.draw2d.Connection;
-import org.eclipse.draw2d.PolygonDecoration;
-import org.eclipse.draw2d.RotatableDecoration;
-import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @generated
- */
-public class AClassSubClassesEditPart extends ConnectionNodeEditPart implements ITreeBranchEditPart
-{
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 4001;
-
- /**
- * @generated
- */
- public AClassSubClassesEditPart(View view)
- {
- super(view);
- }
-
- /**
- * @generated
- */
- protected void createDefaultEditPolicies()
- {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AClassSubClassesItemSemanticEditPolicy());
- }
-
- /**
- * Creates figure for this edit part. Body of this method does not depend on settings in generation model so you may
- * safely remove <i>generated</i> tag and modify it.
- *
- * @generated
- */
-
- protected Connection createConnectionFigure()
- {
- return new AClassSubClassesFigure();
- }
-
- /**
- * @generated
- */
- public AClassSubClassesFigure getPrimaryShape()
- {
- return (AClassSubClassesFigure)getFigure();
- }
-
- /**
- * @generated
- */
- public class AClassSubClassesFigure extends PolylineConnectionEx
- {
-
- /**
- * @generated
- */
- public AClassSubClassesFigure()
- {
- this.setLineWidth(1);
-
- setTargetDecoration(createTargetDecoration());
- }
-
- /**
- * @generated
- */
- private RotatableDecoration createTargetDecoration()
- {
- PolygonDecoration df = new PolygonDecoration();
- df.setFill(true);
- df.setLineWidth(1);
- df.setBackgroundColor(DF_BACK);
- PointList pl = new PointList();
- pl.addPoint(getMapMode().DPtoLP(-2), getMapMode().DPtoLP(2));
- pl.addPoint(getMapMode().DPtoLP(0), getMapMode().DPtoLP(0));
- pl.addPoint(getMapMode().DPtoLP(-2), getMapMode().DPtoLP(-2));
- pl.addPoint(getMapMode().DPtoLP(-2), getMapMode().DPtoLP(2));
- df.setTemplate(pl);
- df.setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3));
- return df;
- }
-
- }
-
- /**
- * @generated
- */
- static final Color DF_BACK = new Color(null, 255, 255, 255);
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + * + */ +package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts; + +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AClassSubClassesItemSemanticEditPolicy; + +import org.eclipse.draw2d.Connection; +import org.eclipse.draw2d.PolygonDecoration; +import org.eclipse.draw2d.RotatableDecoration; +import org.eclipse.draw2d.geometry.PointList; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.swt.graphics.Color; + +/** + * @generated + */ +public class AClassSubClassesEditPart extends ConnectionNodeEditPart implements ITreeBranchEditPart +{ + + /** + * @generated + */ + public static final int VISUAL_ID = 4001; + + /** + * @generated + */ + public AClassSubClassesEditPart(View view) + { + super(view); + } + + /** + * @generated + */ + protected void createDefaultEditPolicies() + { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AClassSubClassesItemSemanticEditPolicy()); + } + + /** + * Creates figure for this edit part. Body of this method does not depend on settings in generation model so you may + * safely remove <i>generated</i> tag and modify it. + * + * @generated + */ + + protected Connection createConnectionFigure() + { + return new AClassSubClassesFigure(); + } + + /** + * @generated + */ + public AClassSubClassesFigure getPrimaryShape() + { + return (AClassSubClassesFigure)getFigure(); + } + + /** + * @generated + */ + public class AClassSubClassesFigure extends PolylineConnectionEx + { + + /** + * @generated + */ + public AClassSubClassesFigure() + { + this.setLineWidth(1); + + setTargetDecoration(createTargetDecoration()); + } + + /** + * @generated + */ + private RotatableDecoration createTargetDecoration() + { + PolygonDecoration df = new PolygonDecoration(); + df.setFill(true); + df.setLineWidth(1); + df.setBackgroundColor(DF_BACK); + PointList pl = new PointList(); + pl.addPoint(getMapMode().DPtoLP(-2), getMapMode().DPtoLP(2)); + pl.addPoint(getMapMode().DPtoLP(0), getMapMode().DPtoLP(0)); + pl.addPoint(getMapMode().DPtoLP(-2), getMapMode().DPtoLP(-2)); + pl.addPoint(getMapMode().DPtoLP(-2), getMapMode().DPtoLP(2)); + df.setTemplate(pl); + df.setScale(getMapMode().DPtoLP(7), getMapMode().DPtoLP(3)); + return df; + } + + } + + /** + * @generated + */ + static final Color DF_BACK = new Color(null, 255, 255, 255); + +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/ACoreRootEditPart.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/ACoreRootEditPart.java index 894fe7d2a4..3b36f7bf7c 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/ACoreRootEditPart.java +++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/ACoreRootEditPart.java @@ -1,56 +1,56 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- *
- */
-package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts;
-
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.ACoreRootCanonicalEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.ACoreRootItemSemanticEditPolicy;
-
-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.notation.View;
-
-/**
- * @generated
- */
-public class ACoreRootEditPart extends DiagramEditPart
-{
-
- /**
- * @generated
- */
- public final static String MODEL_ID = "Acore"; //$NON-NLS-1$
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 1000;
-
- /**
- * @generated
- */
- public ACoreRootEditPart(View view)
- {
- super(view);
- }
-
- /**
- * @generated
- */
- protected void createDefaultEditPolicies()
- {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ACoreRootItemSemanticEditPolicy());
- installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new ACoreRootCanonicalEditPolicy());
- // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.POPUPBAR_ROLE);
- }
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + * + */ +package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts; + +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.ACoreRootCanonicalEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.ACoreRootItemSemanticEditPolicy; + +import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.notation.View; + +/** + * @generated + */ +public class ACoreRootEditPart extends DiagramEditPart +{ + + /** + * @generated + */ + public final static String MODEL_ID = "Acore"; //$NON-NLS-1$ + + /** + * @generated + */ + public static final int VISUAL_ID = 1000; + + /** + * @generated + */ + public ACoreRootEditPart(View view) + { + super(view); + } + + /** + * @generated + */ + protected void createDefaultEditPolicies() + { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new ACoreRootItemSemanticEditPolicy()); + installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new ACoreRootCanonicalEditPolicy()); + // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.POPUPBAR_ROLE); + } + +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AInterfaceAAttributeInterfaceCompartmentEditPart.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AInterfaceAAttributeInterfaceCompartmentEditPart.java index e4f7c1f34f..f3fd856c6e 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AInterfaceAAttributeInterfaceCompartmentEditPart.java +++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AInterfaceAAttributeInterfaceCompartmentEditPart.java @@ -1,95 +1,95 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- *
- */
-package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts;
-
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AInterfaceAAttributeInterfaceCompartmentCanonicalEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AInterfaceAAttributeInterfaceCompartmentItemSemanticEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.Messages;
-
-import org.eclipse.emf.common.notify.Notification;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
-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.ResizableCompartmentFigure;
-import org.eclipse.gmf.runtime.notation.View;
-
-/**
- * @generated
- */
-public class AInterfaceAAttributeInterfaceCompartmentEditPart extends ListCompartmentEditPart
-{
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 7001;
-
- /**
- * @generated
- */
- public AInterfaceAAttributeInterfaceCompartmentEditPart(View view)
- {
- super(view);
- }
-
- /**
- * @generated
- */
- protected boolean hasModelChildrenChanged(Notification evt)
- {
- return false;
- }
-
- /**
- * @generated
- */
- public String getCompartmentName()
- {
- return Messages.AInterfaceAAttributeInterfaceCompartmentEditPart_title;
- }
-
- /**
- * @generated
- */
- public IFigure createFigure()
- {
- ResizableCompartmentFigure result = (ResizableCompartmentFigure)super.createFigure();
- result.setTitleVisibility(false);
- return result;
- }
-
- /**
- * @generated
- */
- protected void createDefaultEditPolicies()
- {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE,
- new AInterfaceAAttributeInterfaceCompartmentItemSemanticEditPolicy());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new AInterfaceAAttributeInterfaceCompartmentCanonicalEditPolicy());
- }
-
- /**
- * @generated
- */
- protected void setRatio(Double ratio)
- {
- // nothing to do -- parent layout does not accept Double constraints as ratio
- // super.setRatio(ratio);
- }
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + * + */ +package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts; + +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AInterfaceAAttributeInterfaceCompartmentCanonicalEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AInterfaceAAttributeInterfaceCompartmentItemSemanticEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.Messages; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy; +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.ResizableCompartmentFigure; +import org.eclipse.gmf.runtime.notation.View; + +/** + * @generated + */ +public class AInterfaceAAttributeInterfaceCompartmentEditPart extends ListCompartmentEditPart +{ + + /** + * @generated + */ + public static final int VISUAL_ID = 7001; + + /** + * @generated + */ + public AInterfaceAAttributeInterfaceCompartmentEditPart(View view) + { + super(view); + } + + /** + * @generated + */ + protected boolean hasModelChildrenChanged(Notification evt) + { + return false; + } + + /** + * @generated + */ + public String getCompartmentName() + { + return Messages.AInterfaceAAttributeInterfaceCompartmentEditPart_title; + } + + /** + * @generated + */ + public IFigure createFigure() + { + ResizableCompartmentFigure result = (ResizableCompartmentFigure)super.createFigure(); + result.setTitleVisibility(false); + return result; + } + + /** + * @generated + */ + protected void createDefaultEditPolicies() + { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, + new AInterfaceAAttributeInterfaceCompartmentItemSemanticEditPolicy()); + installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationEditPolicy()); + installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy()); + installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new AInterfaceAAttributeInterfaceCompartmentCanonicalEditPolicy()); + } + + /** + * @generated + */ + protected void setRatio(Double ratio) + { + // nothing to do -- parent layout does not accept Double constraints as ratio + // super.setRatio(ratio); + } + +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AInterfaceAOperationInterfaceCompartmentEditPart.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AInterfaceAOperationInterfaceCompartmentEditPart.java index 88c34562f6..300676d832 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AInterfaceAOperationInterfaceCompartmentEditPart.java +++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AInterfaceAOperationInterfaceCompartmentEditPart.java @@ -1,95 +1,95 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- *
- */
-package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts;
-
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AInterfaceAOperationInterfaceCompartmentCanonicalEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AInterfaceAOperationInterfaceCompartmentItemSemanticEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.Messages;
-
-import org.eclipse.emf.common.notify.Notification;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
-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.ResizableCompartmentFigure;
-import org.eclipse.gmf.runtime.notation.View;
-
-/**
- * @generated
- */
-public class AInterfaceAOperationInterfaceCompartmentEditPart extends ListCompartmentEditPart
-{
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 7002;
-
- /**
- * @generated
- */
- public AInterfaceAOperationInterfaceCompartmentEditPart(View view)
- {
- super(view);
- }
-
- /**
- * @generated
- */
- protected boolean hasModelChildrenChanged(Notification evt)
- {
- return false;
- }
-
- /**
- * @generated
- */
- public String getCompartmentName()
- {
- return Messages.AInterfaceAOperationInterfaceCompartmentEditPart_title;
- }
-
- /**
- * @generated
- */
- public IFigure createFigure()
- {
- ResizableCompartmentFigure result = (ResizableCompartmentFigure)super.createFigure();
- result.setTitleVisibility(false);
- return result;
- }
-
- /**
- * @generated
- */
- protected void createDefaultEditPolicies()
- {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE,
- new AInterfaceAOperationInterfaceCompartmentItemSemanticEditPolicy());
- installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationEditPolicy());
- installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy());
- installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new AInterfaceAOperationInterfaceCompartmentCanonicalEditPolicy());
- }
-
- /**
- * @generated
- */
- protected void setRatio(Double ratio)
- {
- // nothing to do -- parent layout does not accept Double constraints as ratio
- // super.setRatio(ratio);
- }
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + * + */ +package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts; + +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AInterfaceAOperationInterfaceCompartmentCanonicalEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AInterfaceAOperationInterfaceCompartmentItemSemanticEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.Messages; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy; +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.ResizableCompartmentFigure; +import org.eclipse.gmf.runtime.notation.View; + +/** + * @generated + */ +public class AInterfaceAOperationInterfaceCompartmentEditPart extends ListCompartmentEditPart +{ + + /** + * @generated + */ + public static final int VISUAL_ID = 7002; + + /** + * @generated + */ + public AInterfaceAOperationInterfaceCompartmentEditPart(View view) + { + super(view); + } + + /** + * @generated + */ + protected boolean hasModelChildrenChanged(Notification evt) + { + return false; + } + + /** + * @generated + */ + public String getCompartmentName() + { + return Messages.AInterfaceAOperationInterfaceCompartmentEditPart_title; + } + + /** + * @generated + */ + public IFigure createFigure() + { + ResizableCompartmentFigure result = (ResizableCompartmentFigure)super.createFigure(); + result.setTitleVisibility(false); + return result; + } + + /** + * @generated + */ + protected void createDefaultEditPolicies() + { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, + new AInterfaceAOperationInterfaceCompartmentItemSemanticEditPolicy()); + installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationEditPolicy()); + installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy()); + installEditPolicy(EditPolicyRoles.CANONICAL_ROLE, new AInterfaceAOperationInterfaceCompartmentCanonicalEditPolicy()); + } + + /** + * @generated + */ + protected void setRatio(Double ratio) + { + // nothing to do -- parent layout does not accept Double constraints as ratio + // super.setRatio(ratio); + } + +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AInterfaceNameEditPart.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AInterfaceNameEditPart.java index 654df5b58e..99b0633216 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AInterfaceNameEditPart.java +++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AInterfaceNameEditPart.java @@ -1,686 +1,686 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- *
- */
-package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts;
-
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextSelectionEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreElementTypes;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreParserProvider;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RunnableWithResult;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.gef.AccessibleEditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
-import org.eclipse.gef.handles.MoveHandle;
-import org.eclipse.gef.handles.NonResizableHandleKit;
-import org.eclipse.gef.requests.DirectEditRequest;
-import org.eclipse.gef.tools.DirectEditManager;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
-import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.gmf.runtime.notation.FontStyle;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @generated
- */
-public class AInterfaceNameEditPart extends CompartmentEditPart implements ITextAwareEditPart
-{
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 5001;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * @generated
- */
- public AInterfaceNameEditPart(View view)
- {
- super(view);
- }
-
- /**
- * @generated
- */
- protected void createDefaultEditPolicies()
- {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new AcoreTextSelectionEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicy()
- {
-
- protected List createSelectionHandles()
- {
- List handles = new ArrayList();
- NonResizableHandleKit.addMoveHandle((GraphicalEditPart)getHost(), handles);
- ((MoveHandle)handles.get(0)).setBorder(null);
- return handles;
- }
-
- public Command getCommand(Request request)
- {
- return null;
- }
-
- public boolean understandsRequest(Request request)
- {
- return false;
- }
- });
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure)
- {
- if (figure instanceof WrappingLabel)
- {
- return ((WrappingLabel)figure).getText();
- }
- else
- {
- return ((Label)figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text)
- {
- if (figure instanceof WrappingLabel)
- {
- ((WrappingLabel)figure).setText(text);
- }
- else
- {
- ((Label)figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure)
- {
- if (figure instanceof WrappingLabel)
- {
- return ((WrappingLabel)figure).getIcon();
- }
- else
- {
- return ((Label)figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon)
- {
- if (figure instanceof WrappingLabel)
- {
- ((WrappingLabel)figure).setIcon(icon);
- }
- else
- {
- ((Label)figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(WrappingLabel figure)
- {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- protected List getModelChildren()
- {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint)
- {
- return null;
- }
-
- /**
- * @generated
- */
- protected EObject getParserElement()
- {
- return resolveSemanticElement();
- }
-
- /**
- * @generated
- */
- protected Image getLabelIcon()
- {
- EObject parserElement = getParserElement();
- if (parserElement == null)
- {
- return null;
- }
- return AcoreElementTypes.getImage(parserElement.eClass());
- }
-
- /**
- * @generated
- */
- protected String getLabelText()
- {
- String text = null;
- EObject parserElement = getParserElement();
- if (parserElement != null && getParser() != null)
- {
- text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue());
- }
- if (text == null || text.length() == 0)
- {
- text = defaultText;
- }
- return text;
- }
-
- /**
- * @generated
- */
- public void setLabelText(String text)
- {
- setLabelTextHelper(getFigure(), text);
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback();
- }
- }
-
- /**
- * @generated
- */
- public String getEditText()
- {
- if (getParserElement() == null || getParser() == null)
- {
- return ""; //$NON-NLS-1$
- }
- return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue());
- }
-
- /**
- * @generated
- */
- protected boolean isEditable()
- {
- return getParser() != null;
- }
-
- /**
- * @generated
- */
- public ICellEditorValidator getEditTextValidator()
- {
- return new ICellEditorValidator()
- {
-
- public String isValid(final Object value)
- {
- if (value instanceof String)
- {
- final EObject element = getParserElement();
- final IParser parser = getParser();
- try
- {
- IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl()
- {
-
- public void run()
- {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value));
- }
- });
- return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage();
- }
- catch (InterruptedException ie)
- {
- ie.printStackTrace();
- }
- }
-
- // shouldn't get here
- return null;
- }
- };
- }
-
- /**
- * @generated
- */
- public IContentAssistProcessor getCompletionProcessor()
- {
- if (getParserElement() == null || getParser() == null)
- {
- return null;
- }
- return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
- }
-
- /**
- * @generated
- */
- public ParserOptions getParserOptions()
- {
- return ParserOptions.NONE;
- }
-
- /**
- * @generated
- */
- public IParser getParser()
- {
- if (parser == null)
- {
- parser = AcoreParserProvider.getParser(AcoreElementTypes.AInterface_2001, getParserElement(),
- AcoreVisualIDRegistry
- .getType(org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AInterfaceNameEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager()
- {
- if (manager == null)
- {
- setManager(new TextDirectEditManager(this, TextDirectEditManager.getTextCellEditorClass(this),
- AcoreEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager)
- {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit()
- {
- getManager().show();
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation)
- {
- if (getManager().getClass() == TextDirectEditManager.class)
- {
- ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter)
- {
- if (getManager() instanceof TextDirectEditManager)
- {
- ((TextDirectEditManager)getManager()).show(initialCharacter);
- }
- else
- {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- protected void performDirectEditRequest(Request request)
- {
- final Request theRequest = request;
- try
- {
- getEditingDomain().runExclusive(new Runnable()
- {
-
- public void run()
- {
- if (isActive() && isEditable())
- {
- if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character)
- {
- Character initialChar = (Character)theRequest.getExtendedData().get(
- RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- }
- else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText())))
- {
- DirectEditRequest editRequest = (DirectEditRequest)theRequest;
- performDirectEdit(editRequest.getLocation());
- }
- else
- {
- performDirectEdit();
- }
- }
- }
- });
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- protected void refreshVisuals()
- {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel()
- {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback();
- }
- }
-
- /**
- * @generated
- */
- protected void refreshUnderline()
- {
- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel)
- {
- ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline());
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough()
- {
- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel)
- {
- ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- 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));
- setFont(fontData);
- }
- }
-
- /**
- * @generated
- */
- protected void setFontColor(Color color)
- {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- protected void addSemanticListeners()
- {
- 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$
- }
- }
- else
- {
- super.addSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- protected void removeSemanticListeners()
- {
- if (parserElements != null)
- {
- for (int i = 0; i < parserElements.size(); i++)
- {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- }
- else
- {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- protected AccessibleEditPart getAccessibleEditPart()
- {
- if (accessibleEP == null)
- {
- accessibleEP = new AccessibleGraphicalEditPart()
- {
-
- public void getName(AccessibleEvent e)
- {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView()
- {
- return getPrimaryView();
- }
-
- /**
- * @generated
- */
- protected void addNotationalListeners()
- {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- protected void removeNotationalListeners()
- {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- protected void handleNotificationEvent(Notification event)
- {
- Object feature = event.getFeature();
- 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))
- {
- refreshUnderline();
- }
- 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))
- {
- refreshFont();
- }
- else
- {
- if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue()))
- {
- refreshLabel();
- }
- if (getParser() instanceof ISemanticParser)
- {
- ISemanticParser modelParser = (ISemanticParser)getParser();
- if (modelParser.areSemanticElementsAffected(null, event))
- {
- removeSemanticListeners();
- if (resolveSemanticElement() != null)
- {
- addSemanticListeners();
- }
- refreshLabel();
- }
- }
- }
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- protected IFigure createFigure()
- {
- // Parent should assign one using setLabel() method
- return null;
- }
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + * + */ +package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts; + +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextSelectionEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreElementTypes; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreParserProvider; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.RunnableWithResult; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.gef.AccessibleEditPart; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.editpolicies.NonResizableEditPolicy; +import org.eclipse.gef.handles.MoveHandle; +import org.eclipse.gef.handles.NonResizableHandleKit; +import org.eclipse.gef.requests.DirectEditRequest; +import org.eclipse.gef.tools.DirectEditManager; +import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; +import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; +import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus; +import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; +import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; +import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; +import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; +import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; +import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; +import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; +import org.eclipse.gmf.runtime.notation.FontStyle; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.jface.text.contentassist.IContentAssistProcessor; +import org.eclipse.jface.viewers.ICellEditorValidator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.accessibility.AccessibleEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.Image; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * @generated + */ +public class AInterfaceNameEditPart extends CompartmentEditPart implements ITextAwareEditPart +{ + + /** + * @generated + */ + public static final int VISUAL_ID = 5001; + + /** + * @generated + */ + private DirectEditManager manager; + + /** + * @generated + */ + private IParser parser; + + /** + * @generated + */ + private List parserElements; + + /** + * @generated + */ + private String defaultText; + + /** + * @generated + */ + public AInterfaceNameEditPart(View view) + { + super(view); + } + + /** + * @generated + */ + protected void createDefaultEditPolicies() + { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new AcoreTextSelectionEditPolicy()); + installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); + installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicy() + { + + protected List createSelectionHandles() + { + List handles = new ArrayList(); + NonResizableHandleKit.addMoveHandle((GraphicalEditPart)getHost(), handles); + ((MoveHandle)handles.get(0)).setBorder(null); + return handles; + } + + public Command getCommand(Request request) + { + return null; + } + + public boolean understandsRequest(Request request) + { + return false; + } + }); + } + + /** + * @generated + */ + protected String getLabelTextHelper(IFigure figure) + { + if (figure instanceof WrappingLabel) + { + return ((WrappingLabel)figure).getText(); + } + else + { + return ((Label)figure).getText(); + } + } + + /** + * @generated + */ + protected void setLabelTextHelper(IFigure figure, String text) + { + if (figure instanceof WrappingLabel) + { + ((WrappingLabel)figure).setText(text); + } + else + { + ((Label)figure).setText(text); + } + } + + /** + * @generated + */ + protected Image getLabelIconHelper(IFigure figure) + { + if (figure instanceof WrappingLabel) + { + return ((WrappingLabel)figure).getIcon(); + } + else + { + return ((Label)figure).getIcon(); + } + } + + /** + * @generated + */ + protected void setLabelIconHelper(IFigure figure, Image icon) + { + if (figure instanceof WrappingLabel) + { + ((WrappingLabel)figure).setIcon(icon); + } + else + { + ((Label)figure).setIcon(icon); + } + } + + /** + * @generated + */ + public void setLabel(WrappingLabel figure) + { + unregisterVisuals(); + setFigure(figure); + defaultText = getLabelTextHelper(figure); + registerVisuals(); + refreshVisuals(); + } + + /** + * @generated + */ + protected List getModelChildren() + { + return Collections.EMPTY_LIST; + } + + /** + * @generated + */ + public IGraphicalEditPart getChildBySemanticHint(String semanticHint) + { + return null; + } + + /** + * @generated + */ + protected EObject getParserElement() + { + return resolveSemanticElement(); + } + + /** + * @generated + */ + protected Image getLabelIcon() + { + EObject parserElement = getParserElement(); + if (parserElement == null) + { + return null; + } + return AcoreElementTypes.getImage(parserElement.eClass()); + } + + /** + * @generated + */ + protected String getLabelText() + { + String text = null; + EObject parserElement = getParserElement(); + if (parserElement != null && getParser() != null) + { + text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + } + if (text == null || text.length() == 0) + { + text = defaultText; + } + return text; + } + + /** + * @generated + */ + public void setLabelText(String text) + { + setLabelTextHelper(getFigure(), text); + Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); + if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + } + Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); + if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + } + } + + /** + * @generated + */ + public String getEditText() + { + if (getParserElement() == null || getParser() == null) + { + return ""; //$NON-NLS-1$ + } + return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + } + + /** + * @generated + */ + protected boolean isEditable() + { + return getParser() != null; + } + + /** + * @generated + */ + public ICellEditorValidator getEditTextValidator() + { + return new ICellEditorValidator() + { + + public String isValid(final Object value) + { + if (value instanceof String) + { + final EObject element = getParserElement(); + final IParser parser = getParser(); + try + { + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl() + { + + public void run() + { + setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); + } + }); + return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage(); + } + catch (InterruptedException ie) + { + ie.printStackTrace(); + } + } + + // shouldn't get here + return null; + } + }; + } + + /** + * @generated + */ + public IContentAssistProcessor getCompletionProcessor() + { + if (getParserElement() == null || getParser() == null) + { + return null; + } + return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + } + + /** + * @generated + */ + public ParserOptions getParserOptions() + { + return ParserOptions.NONE; + } + + /** + * @generated + */ + public IParser getParser() + { + if (parser == null) + { + parser = AcoreParserProvider.getParser(AcoreElementTypes.AInterface_2001, getParserElement(), + AcoreVisualIDRegistry + .getType(org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AInterfaceNameEditPart.VISUAL_ID)); + } + return parser; + } + + /** + * @generated + */ + protected DirectEditManager getManager() + { + if (manager == null) + { + setManager(new TextDirectEditManager(this, TextDirectEditManager.getTextCellEditorClass(this), + AcoreEditPartFactory.getTextCellEditorLocator(this))); + } + return manager; + } + + /** + * @generated + */ + protected void setManager(DirectEditManager manager) + { + this.manager = manager; + } + + /** + * @generated + */ + protected void performDirectEdit() + { + getManager().show(); + } + + /** + * @generated + */ + protected void performDirectEdit(Point eventLocation) + { + if (getManager().getClass() == TextDirectEditManager.class) + { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + } + } + + /** + * @generated + */ + private void performDirectEdit(char initialCharacter) + { + if (getManager() instanceof TextDirectEditManager) + { + ((TextDirectEditManager)getManager()).show(initialCharacter); + } + else + { + performDirectEdit(); + } + } + + /** + * @generated + */ + protected void performDirectEditRequest(Request request) + { + final Request theRequest = request; + try + { + getEditingDomain().runExclusive(new Runnable() + { + + public void run() + { + if (isActive() && isEditable()) + { + if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) + { + Character initialChar = (Character)theRequest.getExtendedData().get( + RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + performDirectEdit(initialChar.charValue()); + } + else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) + { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; + performDirectEdit(editRequest.getLocation()); + } + else + { + performDirectEdit(); + } + } + } + }); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + + /** + * @generated + */ + protected void refreshVisuals() + { + super.refreshVisuals(); + refreshLabel(); + refreshFont(); + refreshFontColor(); + refreshUnderline(); + refreshStrikeThrough(); + } + + /** + * @generated + */ + protected void refreshLabel() + { + setLabelTextHelper(getFigure(), getLabelText()); + setLabelIconHelper(getFigure(), getLabelIcon()); + Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); + if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + } + Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); + if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + } + } + + /** + * @generated + */ + protected void refreshUnderline() + { + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) + { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + } + } + + /** + * @generated + */ + protected void refreshStrikeThrough() + { + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) + { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + } + } + + /** + * @generated + */ + 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)); + setFont(fontData); + } + } + + /** + * @generated + */ + protected void setFontColor(Color color) + { + getFigure().setForegroundColor(color); + } + + /** + * @generated + */ + protected void addSemanticListeners() + { + 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$ + } + } + else + { + super.addSemanticListeners(); + } + } + + /** + * @generated + */ + protected void removeSemanticListeners() + { + if (parserElements != null) + { + for (int i = 0; i < parserElements.size(); i++) + { + removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ + } + } + else + { + super.removeSemanticListeners(); + } + } + + /** + * @generated + */ + protected AccessibleEditPart getAccessibleEditPart() + { + if (accessibleEP == null) + { + accessibleEP = new AccessibleGraphicalEditPart() + { + + public void getName(AccessibleEvent e) + { + e.result = getLabelTextHelper(getFigure()); + } + }; + } + return accessibleEP; + } + + /** + * @generated + */ + private View getFontStyleOwnerView() + { + return getPrimaryView(); + } + + /** + * @generated + */ + protected void addNotationalListeners() + { + super.addNotationalListeners(); + addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$ + } + + /** + * @generated + */ + protected void removeNotationalListeners() + { + super.removeNotationalListeners(); + removeListenerFilter("PrimaryView"); //$NON-NLS-1$ + } + + /** + * @generated + */ + protected void handleNotificationEvent(Notification event) + { + Object feature = event.getFeature(); + 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)) + { + refreshUnderline(); + } + 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)) + { + refreshFont(); + } + else + { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) + { + refreshLabel(); + } + if (getParser() instanceof ISemanticParser) + { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) + { + removeSemanticListeners(); + if (resolveSemanticElement() != null) + { + addSemanticListeners(); + } + refreshLabel(); + } + } + } + super.handleNotificationEvent(event); + } + + /** + * @generated + */ + protected IFigure createFigure() + { + // Parent should assign one using setLabel() method + return null; + } + +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AOperation2EditPart.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AOperation2EditPart.java index 0b5e1198e7..825351a549 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AOperation2EditPart.java +++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AOperation2EditPart.java @@ -1,684 +1,684 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- *
- */
-package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts;
-
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AOperation2ItemSemanticEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextNonResizableEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextSelectionEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreElementTypes;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreParserProvider;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RunnableWithResult;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.gef.AccessibleEditPart;
-import org.eclipse.gef.DragTracker;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.requests.DirectEditRequest;
-import org.eclipse.gef.requests.SelectionRequest;
-import org.eclipse.gef.tools.DirectEditManager;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
-import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx;
-import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.gmf.runtime.notation.FontStyle;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @generated
- */
-public class AOperation2EditPart extends CompartmentEditPart implements ITextAwareEditPart
-{
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 3004;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * @generated
- */
- public AOperation2EditPart(View view)
- {
- super(view);
- }
-
- /**
- * @generated
- */
- public DragTracker getDragTracker(Request request)
- {
- if (request instanceof SelectionRequest && ((SelectionRequest)request).getLastButtonPressed() == 3)
- {
- return null;
- }
- return new DragEditPartsTrackerEx(this);
- }
-
- /**
- * @generated
- */
- protected void createDefaultEditPolicies()
- {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AOperation2ItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new AcoreTextNonResizableEditPolicy());
- installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure)
- {
- if (figure instanceof WrappingLabel)
- {
- return ((WrappingLabel)figure).getText();
- }
- else
- {
- return ((Label)figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text)
- {
- if (figure instanceof WrappingLabel)
- {
- ((WrappingLabel)figure).setText(text);
- }
- else
- {
- ((Label)figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure)
- {
- if (figure instanceof WrappingLabel)
- {
- return ((WrappingLabel)figure).getIcon();
- }
- else
- {
- return ((Label)figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon)
- {
- if (figure instanceof WrappingLabel)
- {
- ((WrappingLabel)figure).setIcon(icon);
- }
- else
- {
- ((Label)figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure)
- {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- protected List getModelChildren()
- {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint)
- {
- return null;
- }
-
- /**
- * @generated
- */
- protected EObject getParserElement()
- {
- return resolveSemanticElement();
- }
-
- /**
- * @generated
- */
- protected Image getLabelIcon()
- {
- return null;
- }
-
- /**
- * @generated
- */
- protected String getLabelText()
- {
- String text = null;
- EObject parserElement = getParserElement();
- if (parserElement != null && getParser() != null)
- {
- text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue());
- }
- if (text == null || text.length() == 0)
- {
- text = defaultText;
- }
- return text;
- }
-
- /**
- * @generated
- */
- public void setLabelText(String text)
- {
- setLabelTextHelper(getFigure(), text);
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback();
- }
- }
-
- /**
- * @generated
- */
- public String getEditText()
- {
- if (getParserElement() == null || getParser() == null)
- {
- return ""; //$NON-NLS-1$
- }
- return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue());
- }
-
- /**
- * @generated
- */
- protected boolean isEditable()
- {
- return getParser() != null;
- }
-
- /**
- * @generated
- */
- public ICellEditorValidator getEditTextValidator()
- {
- return new ICellEditorValidator()
- {
-
- public String isValid(final Object value)
- {
- if (value instanceof String)
- {
- final EObject element = getParserElement();
- final IParser parser = getParser();
- try
- {
- IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl()
- {
-
- public void run()
- {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value));
- }
- });
- return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage();
- }
- catch (InterruptedException ie)
- {
- ie.printStackTrace();
- }
- }
-
- // shouldn't get here
- return null;
- }
- };
- }
-
- /**
- * @generated
- */
- public IContentAssistProcessor getCompletionProcessor()
- {
- if (getParserElement() == null || getParser() == null)
- {
- return null;
- }
- return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
- }
-
- /**
- * @generated
- */
- public ParserOptions getParserOptions()
- {
- return ParserOptions.NONE;
- }
-
- /**
- * @generated
- */
- public IParser getParser()
- {
- if (parser == null)
- {
- parser = AcoreParserProvider.getParser(AcoreElementTypes.AOperation_3004, getParserElement(),
- AcoreVisualIDRegistry
- .getType(org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AOperation2EditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager()
- {
- if (manager == null)
- {
- setManager(new TextDirectEditManager(this, TextDirectEditManager.getTextCellEditorClass(this),
- AcoreEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager)
- {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit()
- {
- getManager().show();
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation)
- {
- if (getManager().getClass() == TextDirectEditManager.class)
- {
- ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter)
- {
- if (getManager() instanceof TextDirectEditManager)
- {
- ((TextDirectEditManager)getManager()).show(initialCharacter);
- }
- else
- {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- protected void performDirectEditRequest(Request request)
- {
- final Request theRequest = request;
- try
- {
- getEditingDomain().runExclusive(new Runnable()
- {
-
- public void run()
- {
- if (isActive() && isEditable())
- {
- if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character)
- {
- Character initialChar = (Character)theRequest.getExtendedData().get(
- RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- }
- else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText())))
- {
- DirectEditRequest editRequest = (DirectEditRequest)theRequest;
- performDirectEdit(editRequest.getLocation());
- }
- else
- {
- performDirectEdit();
- }
- }
- }
- });
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- protected void refreshVisuals()
- {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel()
- {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback();
- }
- }
-
- /**
- * @generated
- */
- protected void refreshUnderline()
- {
- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel)
- {
- ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline());
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough()
- {
- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel)
- {
- ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- 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));
- setFont(fontData);
- }
- }
-
- /**
- * @generated
- */
- protected void setFontColor(Color color)
- {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- protected void addSemanticListeners()
- {
- 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$
- }
- }
- else
- {
- super.addSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- protected void removeSemanticListeners()
- {
- if (parserElements != null)
- {
- for (int i = 0; i < parserElements.size(); i++)
- {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- }
- else
- {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- protected AccessibleEditPart getAccessibleEditPart()
- {
- if (accessibleEP == null)
- {
- accessibleEP = new AccessibleGraphicalEditPart()
- {
-
- public void getName(AccessibleEvent e)
- {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView()
- {
- return getPrimaryView();
- }
-
- /**
- * @generated
- */
- protected void addNotationalListeners()
- {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- protected void removeNotationalListeners()
- {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- protected void handleNotificationEvent(Notification event)
- {
- Object feature = event.getFeature();
- 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))
- {
- refreshUnderline();
- }
- 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))
- {
- refreshFont();
- }
- else
- {
- if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue()))
- {
- refreshLabel();
- }
- if (getParser() instanceof ISemanticParser)
- {
- ISemanticParser modelParser = (ISemanticParser)getParser();
- if (modelParser.areSemanticElementsAffected(null, event))
- {
- removeSemanticListeners();
- if (resolveSemanticElement() != null)
- {
- addSemanticListeners();
- }
- refreshLabel();
- }
- }
- }
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- protected IFigure createFigure()
- {
- IFigure label = createFigurePrim();
- defaultText = getLabelTextHelper(label);
- return label;
- }
-
- /**
- * @generated
- */
- protected IFigure createFigurePrim()
- {
- return new WrappingLabel();
- }
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + * + */ +package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts; + +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AOperation2ItemSemanticEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextNonResizableEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextSelectionEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreElementTypes; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreParserProvider; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.RunnableWithResult; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.gef.AccessibleEditPart; +import org.eclipse.gef.DragTracker; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.Request; +import org.eclipse.gef.requests.DirectEditRequest; +import org.eclipse.gef.requests.SelectionRequest; +import org.eclipse.gef.tools.DirectEditManager; +import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; +import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; +import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus; +import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; +import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; +import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; +import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx; +import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; +import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; +import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; +import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; +import org.eclipse.gmf.runtime.notation.FontStyle; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.jface.text.contentassist.IContentAssistProcessor; +import org.eclipse.jface.viewers.ICellEditorValidator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.accessibility.AccessibleEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.Image; + +import java.util.Collections; +import java.util.List; + +/** + * @generated + */ +public class AOperation2EditPart extends CompartmentEditPart implements ITextAwareEditPart +{ + + /** + * @generated + */ + public static final int VISUAL_ID = 3004; + + /** + * @generated + */ + private DirectEditManager manager; + + /** + * @generated + */ + private IParser parser; + + /** + * @generated + */ + private List parserElements; + + /** + * @generated + */ + private String defaultText; + + /** + * @generated + */ + public AOperation2EditPart(View view) + { + super(view); + } + + /** + * @generated + */ + public DragTracker getDragTracker(Request request) + { + if (request instanceof SelectionRequest && ((SelectionRequest)request).getLastButtonPressed() == 3) + { + return null; + } + return new DragEditPartsTrackerEx(this); + } + + /** + * @generated + */ + protected void createDefaultEditPolicies() + { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AOperation2ItemSemanticEditPolicy()); + installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new AcoreTextNonResizableEditPolicy()); + installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy()); + installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); + } + + /** + * @generated + */ + protected String getLabelTextHelper(IFigure figure) + { + if (figure instanceof WrappingLabel) + { + return ((WrappingLabel)figure).getText(); + } + else + { + return ((Label)figure).getText(); + } + } + + /** + * @generated + */ + protected void setLabelTextHelper(IFigure figure, String text) + { + if (figure instanceof WrappingLabel) + { + ((WrappingLabel)figure).setText(text); + } + else + { + ((Label)figure).setText(text); + } + } + + /** + * @generated + */ + protected Image getLabelIconHelper(IFigure figure) + { + if (figure instanceof WrappingLabel) + { + return ((WrappingLabel)figure).getIcon(); + } + else + { + return ((Label)figure).getIcon(); + } + } + + /** + * @generated + */ + protected void setLabelIconHelper(IFigure figure, Image icon) + { + if (figure instanceof WrappingLabel) + { + ((WrappingLabel)figure).setIcon(icon); + } + else + { + ((Label)figure).setIcon(icon); + } + } + + /** + * @generated + */ + public void setLabel(IFigure figure) + { + unregisterVisuals(); + setFigure(figure); + defaultText = getLabelTextHelper(figure); + registerVisuals(); + refreshVisuals(); + } + + /** + * @generated + */ + protected List getModelChildren() + { + return Collections.EMPTY_LIST; + } + + /** + * @generated + */ + public IGraphicalEditPart getChildBySemanticHint(String semanticHint) + { + return null; + } + + /** + * @generated + */ + protected EObject getParserElement() + { + return resolveSemanticElement(); + } + + /** + * @generated + */ + protected Image getLabelIcon() + { + return null; + } + + /** + * @generated + */ + protected String getLabelText() + { + String text = null; + EObject parserElement = getParserElement(); + if (parserElement != null && getParser() != null) + { + text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + } + if (text == null || text.length() == 0) + { + text = defaultText; + } + return text; + } + + /** + * @generated + */ + public void setLabelText(String text) + { + setLabelTextHelper(getFigure(), text); + Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); + if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + } + Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); + if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + } + } + + /** + * @generated + */ + public String getEditText() + { + if (getParserElement() == null || getParser() == null) + { + return ""; //$NON-NLS-1$ + } + return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + } + + /** + * @generated + */ + protected boolean isEditable() + { + return getParser() != null; + } + + /** + * @generated + */ + public ICellEditorValidator getEditTextValidator() + { + return new ICellEditorValidator() + { + + public String isValid(final Object value) + { + if (value instanceof String) + { + final EObject element = getParserElement(); + final IParser parser = getParser(); + try + { + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl() + { + + public void run() + { + setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); + } + }); + return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage(); + } + catch (InterruptedException ie) + { + ie.printStackTrace(); + } + } + + // shouldn't get here + return null; + } + }; + } + + /** + * @generated + */ + public IContentAssistProcessor getCompletionProcessor() + { + if (getParserElement() == null || getParser() == null) + { + return null; + } + return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + } + + /** + * @generated + */ + public ParserOptions getParserOptions() + { + return ParserOptions.NONE; + } + + /** + * @generated + */ + public IParser getParser() + { + if (parser == null) + { + parser = AcoreParserProvider.getParser(AcoreElementTypes.AOperation_3004, getParserElement(), + AcoreVisualIDRegistry + .getType(org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AOperation2EditPart.VISUAL_ID)); + } + return parser; + } + + /** + * @generated + */ + protected DirectEditManager getManager() + { + if (manager == null) + { + setManager(new TextDirectEditManager(this, TextDirectEditManager.getTextCellEditorClass(this), + AcoreEditPartFactory.getTextCellEditorLocator(this))); + } + return manager; + } + + /** + * @generated + */ + protected void setManager(DirectEditManager manager) + { + this.manager = manager; + } + + /** + * @generated + */ + protected void performDirectEdit() + { + getManager().show(); + } + + /** + * @generated + */ + protected void performDirectEdit(Point eventLocation) + { + if (getManager().getClass() == TextDirectEditManager.class) + { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + } + } + + /** + * @generated + */ + private void performDirectEdit(char initialCharacter) + { + if (getManager() instanceof TextDirectEditManager) + { + ((TextDirectEditManager)getManager()).show(initialCharacter); + } + else + { + performDirectEdit(); + } + } + + /** + * @generated + */ + protected void performDirectEditRequest(Request request) + { + final Request theRequest = request; + try + { + getEditingDomain().runExclusive(new Runnable() + { + + public void run() + { + if (isActive() && isEditable()) + { + if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) + { + Character initialChar = (Character)theRequest.getExtendedData().get( + RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + performDirectEdit(initialChar.charValue()); + } + else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) + { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; + performDirectEdit(editRequest.getLocation()); + } + else + { + performDirectEdit(); + } + } + } + }); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + + /** + * @generated + */ + protected void refreshVisuals() + { + super.refreshVisuals(); + refreshLabel(); + refreshFont(); + refreshFontColor(); + refreshUnderline(); + refreshStrikeThrough(); + } + + /** + * @generated + */ + protected void refreshLabel() + { + setLabelTextHelper(getFigure(), getLabelText()); + setLabelIconHelper(getFigure(), getLabelIcon()); + Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); + if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + } + Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); + if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + } + } + + /** + * @generated + */ + protected void refreshUnderline() + { + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) + { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + } + } + + /** + * @generated + */ + protected void refreshStrikeThrough() + { + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) + { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + } + } + + /** + * @generated + */ + 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)); + setFont(fontData); + } + } + + /** + * @generated + */ + protected void setFontColor(Color color) + { + getFigure().setForegroundColor(color); + } + + /** + * @generated + */ + protected void addSemanticListeners() + { + 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$ + } + } + else + { + super.addSemanticListeners(); + } + } + + /** + * @generated + */ + protected void removeSemanticListeners() + { + if (parserElements != null) + { + for (int i = 0; i < parserElements.size(); i++) + { + removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ + } + } + else + { + super.removeSemanticListeners(); + } + } + + /** + * @generated + */ + protected AccessibleEditPart getAccessibleEditPart() + { + if (accessibleEP == null) + { + accessibleEP = new AccessibleGraphicalEditPart() + { + + public void getName(AccessibleEvent e) + { + e.result = getLabelTextHelper(getFigure()); + } + }; + } + return accessibleEP; + } + + /** + * @generated + */ + private View getFontStyleOwnerView() + { + return getPrimaryView(); + } + + /** + * @generated + */ + protected void addNotationalListeners() + { + super.addNotationalListeners(); + addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$ + } + + /** + * @generated + */ + protected void removeNotationalListeners() + { + super.removeNotationalListeners(); + removeListenerFilter("PrimaryView"); //$NON-NLS-1$ + } + + /** + * @generated + */ + protected void handleNotificationEvent(Notification event) + { + Object feature = event.getFeature(); + 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)) + { + refreshUnderline(); + } + 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)) + { + refreshFont(); + } + else + { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) + { + refreshLabel(); + } + if (getParser() instanceof ISemanticParser) + { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) + { + removeSemanticListeners(); + if (resolveSemanticElement() != null) + { + addSemanticListeners(); + } + refreshLabel(); + } + } + } + super.handleNotificationEvent(event); + } + + /** + * @generated + */ + protected IFigure createFigure() + { + IFigure label = createFigurePrim(); + defaultText = getLabelTextHelper(label); + return label; + } + + /** + * @generated + */ + protected IFigure createFigurePrim() + { + return new WrappingLabel(); + } + +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AOperationEditPart.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AOperationEditPart.java index ed434cb013..6fde23c2b2 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AOperationEditPart.java +++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AOperationEditPart.java @@ -1,684 +1,684 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- *
- */
-package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts;
-
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AOperationItemSemanticEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextNonResizableEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextSelectionEditPolicy;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreElementTypes;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreParserProvider;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.RunnableWithResult;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.geometry.Point;
-import org.eclipse.gef.AccessibleEditPart;
-import org.eclipse.gef.DragTracker;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.requests.DirectEditRequest;
-import org.eclipse.gef.requests.SelectionRequest;
-import org.eclipse.gef.tools.DirectEditManager;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
-import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
-import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy;
-import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
-import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
-import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx;
-import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
-import org.eclipse.gmf.runtime.notation.FontStyle;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.viewers.ICellEditorValidator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @generated
- */
-public class AOperationEditPart extends CompartmentEditPart implements ITextAwareEditPart
-{
-
- /**
- * @generated
- */
- public static final int VISUAL_ID = 3002;
-
- /**
- * @generated
- */
- private DirectEditManager manager;
-
- /**
- * @generated
- */
- private IParser parser;
-
- /**
- * @generated
- */
- private List parserElements;
-
- /**
- * @generated
- */
- private String defaultText;
-
- /**
- * @generated
- */
- public AOperationEditPart(View view)
- {
- super(view);
- }
-
- /**
- * @generated
- */
- public DragTracker getDragTracker(Request request)
- {
- if (request instanceof SelectionRequest && ((SelectionRequest)request).getLastButtonPressed() == 3)
- {
- return null;
- }
- return new DragEditPartsTrackerEx(this);
- }
-
- /**
- * @generated
- */
- protected void createDefaultEditPolicies()
- {
- super.createDefaultEditPolicies();
- installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AOperationItemSemanticEditPolicy());
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new AcoreTextNonResizableEditPolicy());
- installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy());
- installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
- }
-
- /**
- * @generated
- */
- protected String getLabelTextHelper(IFigure figure)
- {
- if (figure instanceof WrappingLabel)
- {
- return ((WrappingLabel)figure).getText();
- }
- else
- {
- return ((Label)figure).getText();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelTextHelper(IFigure figure, String text)
- {
- if (figure instanceof WrappingLabel)
- {
- ((WrappingLabel)figure).setText(text);
- }
- else
- {
- ((Label)figure).setText(text);
- }
- }
-
- /**
- * @generated
- */
- protected Image getLabelIconHelper(IFigure figure)
- {
- if (figure instanceof WrappingLabel)
- {
- return ((WrappingLabel)figure).getIcon();
- }
- else
- {
- return ((Label)figure).getIcon();
- }
- }
-
- /**
- * @generated
- */
- protected void setLabelIconHelper(IFigure figure, Image icon)
- {
- if (figure instanceof WrappingLabel)
- {
- ((WrappingLabel)figure).setIcon(icon);
- }
- else
- {
- ((Label)figure).setIcon(icon);
- }
- }
-
- /**
- * @generated
- */
- public void setLabel(IFigure figure)
- {
- unregisterVisuals();
- setFigure(figure);
- defaultText = getLabelTextHelper(figure);
- registerVisuals();
- refreshVisuals();
- }
-
- /**
- * @generated
- */
- protected List getModelChildren()
- {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @generated
- */
- public IGraphicalEditPart getChildBySemanticHint(String semanticHint)
- {
- return null;
- }
-
- /**
- * @generated
- */
- protected EObject getParserElement()
- {
- return resolveSemanticElement();
- }
-
- /**
- * @generated
- */
- protected Image getLabelIcon()
- {
- return null;
- }
-
- /**
- * @generated
- */
- protected String getLabelText()
- {
- String text = null;
- EObject parserElement = getParserElement();
- if (parserElement != null && getParser() != null)
- {
- text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue());
- }
- if (text == null || text.length() == 0)
- {
- text = defaultText;
- }
- return text;
- }
-
- /**
- * @generated
- */
- public void setLabelText(String text)
- {
- setLabelTextHelper(getFigure(), text);
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback();
- }
- }
-
- /**
- * @generated
- */
- public String getEditText()
- {
- if (getParserElement() == null || getParser() == null)
- {
- return ""; //$NON-NLS-1$
- }
- return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue());
- }
-
- /**
- * @generated
- */
- protected boolean isEditable()
- {
- return getParser() != null;
- }
-
- /**
- * @generated
- */
- public ICellEditorValidator getEditTextValidator()
- {
- return new ICellEditorValidator()
- {
-
- public String isValid(final Object value)
- {
- if (value instanceof String)
- {
- final EObject element = getParserElement();
- final IParser parser = getParser();
- try
- {
- IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl()
- {
-
- public void run()
- {
- setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value));
- }
- });
- return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage();
- }
- catch (InterruptedException ie)
- {
- ie.printStackTrace();
- }
- }
-
- // shouldn't get here
- return null;
- }
- };
- }
-
- /**
- * @generated
- */
- public IContentAssistProcessor getCompletionProcessor()
- {
- if (getParserElement() == null || getParser() == null)
- {
- return null;
- }
- return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement()));
- }
-
- /**
- * @generated
- */
- public ParserOptions getParserOptions()
- {
- return ParserOptions.NONE;
- }
-
- /**
- * @generated
- */
- public IParser getParser()
- {
- if (parser == null)
- {
- parser = AcoreParserProvider.getParser(AcoreElementTypes.AOperation_3002, getParserElement(),
- AcoreVisualIDRegistry
- .getType(org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AOperationEditPart.VISUAL_ID));
- }
- return parser;
- }
-
- /**
- * @generated
- */
- protected DirectEditManager getManager()
- {
- if (manager == null)
- {
- setManager(new TextDirectEditManager(this, TextDirectEditManager.getTextCellEditorClass(this),
- AcoreEditPartFactory.getTextCellEditorLocator(this)));
- }
- return manager;
- }
-
- /**
- * @generated
- */
- protected void setManager(DirectEditManager manager)
- {
- this.manager = manager;
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit()
- {
- getManager().show();
- }
-
- /**
- * @generated
- */
- protected void performDirectEdit(Point eventLocation)
- {
- if (getManager().getClass() == TextDirectEditManager.class)
- {
- ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint());
- }
- }
-
- /**
- * @generated
- */
- private void performDirectEdit(char initialCharacter)
- {
- if (getManager() instanceof TextDirectEditManager)
- {
- ((TextDirectEditManager)getManager()).show(initialCharacter);
- }
- else
- {
- performDirectEdit();
- }
- }
-
- /**
- * @generated
- */
- protected void performDirectEditRequest(Request request)
- {
- final Request theRequest = request;
- try
- {
- getEditingDomain().runExclusive(new Runnable()
- {
-
- public void run()
- {
- if (isActive() && isEditable())
- {
- if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character)
- {
- Character initialChar = (Character)theRequest.getExtendedData().get(
- RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
- performDirectEdit(initialChar.charValue());
- }
- else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText())))
- {
- DirectEditRequest editRequest = (DirectEditRequest)theRequest;
- performDirectEdit(editRequest.getLocation());
- }
- else
- {
- performDirectEdit();
- }
- }
- }
- });
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- }
-
- /**
- * @generated
- */
- protected void refreshVisuals()
- {
- super.refreshVisuals();
- refreshLabel();
- refreshFont();
- refreshFontColor();
- refreshUnderline();
- refreshStrikeThrough();
- }
-
- /**
- * @generated
- */
- protected void refreshLabel()
- {
- setLabelTextHelper(getFigure(), getLabelText());
- setLabelIconHelper(getFigure(), getLabelIcon());
- Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
- if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback();
- }
- Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE);
- if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy)
- {
- ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback();
- }
- }
-
- /**
- * @generated
- */
- protected void refreshUnderline()
- {
- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel)
- {
- ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline());
- }
- }
-
- /**
- * @generated
- */
- protected void refreshStrikeThrough()
- {
- FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle());
- if (style != null && getFigure() instanceof WrappingLabel)
- {
- ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough());
- }
- }
-
- /**
- * @generated
- */
- 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));
- setFont(fontData);
- }
- }
-
- /**
- * @generated
- */
- protected void setFontColor(Color color)
- {
- getFigure().setForegroundColor(color);
- }
-
- /**
- * @generated
- */
- protected void addSemanticListeners()
- {
- 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$
- }
- }
- else
- {
- super.addSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- protected void removeSemanticListeners()
- {
- if (parserElements != null)
- {
- for (int i = 0; i < parserElements.size(); i++)
- {
- removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
- }
- }
- else
- {
- super.removeSemanticListeners();
- }
- }
-
- /**
- * @generated
- */
- protected AccessibleEditPart getAccessibleEditPart()
- {
- if (accessibleEP == null)
- {
- accessibleEP = new AccessibleGraphicalEditPart()
- {
-
- public void getName(AccessibleEvent e)
- {
- e.result = getLabelTextHelper(getFigure());
- }
- };
- }
- return accessibleEP;
- }
-
- /**
- * @generated
- */
- private View getFontStyleOwnerView()
- {
- return getPrimaryView();
- }
-
- /**
- * @generated
- */
- protected void addNotationalListeners()
- {
- super.addNotationalListeners();
- addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- protected void removeNotationalListeners()
- {
- super.removeNotationalListeners();
- removeListenerFilter("PrimaryView"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- protected void handleNotificationEvent(Notification event)
- {
- Object feature = event.getFeature();
- 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))
- {
- refreshUnderline();
- }
- 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))
- {
- refreshFont();
- }
- else
- {
- if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue()))
- {
- refreshLabel();
- }
- if (getParser() instanceof ISemanticParser)
- {
- ISemanticParser modelParser = (ISemanticParser)getParser();
- if (modelParser.areSemanticElementsAffected(null, event))
- {
- removeSemanticListeners();
- if (resolveSemanticElement() != null)
- {
- addSemanticListeners();
- }
- refreshLabel();
- }
- }
- }
- super.handleNotificationEvent(event);
- }
-
- /**
- * @generated
- */
- protected IFigure createFigure()
- {
- IFigure label = createFigurePrim();
- defaultText = getLabelTextHelper(label);
- return label;
- }
-
- /**
- * @generated
- */
- protected IFigure createFigurePrim()
- {
- return new WrappingLabel();
- }
-
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + * + */ +package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts; + +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AOperationItemSemanticEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextNonResizableEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.policies.AcoreTextSelectionEditPolicy; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreElementTypes; +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreParserProvider; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.RunnableWithResult; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.gef.AccessibleEditPart; +import org.eclipse.gef.DragTracker; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.Request; +import org.eclipse.gef.requests.DirectEditRequest; +import org.eclipse.gef.requests.SelectionRequest; +import org.eclipse.gef.tools.DirectEditManager; +import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; +import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; +import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus; +import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; +import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; +import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; +import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx; +import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; +import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; +import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; +import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; +import org.eclipse.gmf.runtime.notation.FontStyle; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.jface.text.contentassist.IContentAssistProcessor; +import org.eclipse.jface.viewers.ICellEditorValidator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.accessibility.AccessibleEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.Image; + +import java.util.Collections; +import java.util.List; + +/** + * @generated + */ +public class AOperationEditPart extends CompartmentEditPart implements ITextAwareEditPart +{ + + /** + * @generated + */ + public static final int VISUAL_ID = 3002; + + /** + * @generated + */ + private DirectEditManager manager; + + /** + * @generated + */ + private IParser parser; + + /** + * @generated + */ + private List parserElements; + + /** + * @generated + */ + private String defaultText; + + /** + * @generated + */ + public AOperationEditPart(View view) + { + super(view); + } + + /** + * @generated + */ + public DragTracker getDragTracker(Request request) + { + if (request instanceof SelectionRequest && ((SelectionRequest)request).getLastButtonPressed() == 3) + { + return null; + } + return new DragEditPartsTrackerEx(this); + } + + /** + * @generated + */ + protected void createDefaultEditPolicies() + { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new AOperationItemSemanticEditPolicy()); + installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new AcoreTextNonResizableEditPolicy()); + installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy()); + installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); + } + + /** + * @generated + */ + protected String getLabelTextHelper(IFigure figure) + { + if (figure instanceof WrappingLabel) + { + return ((WrappingLabel)figure).getText(); + } + else + { + return ((Label)figure).getText(); + } + } + + /** + * @generated + */ + protected void setLabelTextHelper(IFigure figure, String text) + { + if (figure instanceof WrappingLabel) + { + ((WrappingLabel)figure).setText(text); + } + else + { + ((Label)figure).setText(text); + } + } + + /** + * @generated + */ + protected Image getLabelIconHelper(IFigure figure) + { + if (figure instanceof WrappingLabel) + { + return ((WrappingLabel)figure).getIcon(); + } + else + { + return ((Label)figure).getIcon(); + } + } + + /** + * @generated + */ + protected void setLabelIconHelper(IFigure figure, Image icon) + { + if (figure instanceof WrappingLabel) + { + ((WrappingLabel)figure).setIcon(icon); + } + else + { + ((Label)figure).setIcon(icon); + } + } + + /** + * @generated + */ + public void setLabel(IFigure figure) + { + unregisterVisuals(); + setFigure(figure); + defaultText = getLabelTextHelper(figure); + registerVisuals(); + refreshVisuals(); + } + + /** + * @generated + */ + protected List getModelChildren() + { + return Collections.EMPTY_LIST; + } + + /** + * @generated + */ + public IGraphicalEditPart getChildBySemanticHint(String semanticHint) + { + return null; + } + + /** + * @generated + */ + protected EObject getParserElement() + { + return resolveSemanticElement(); + } + + /** + * @generated + */ + protected Image getLabelIcon() + { + return null; + } + + /** + * @generated + */ + protected String getLabelText() + { + String text = null; + EObject parserElement = getParserElement(); + if (parserElement != null && getParser() != null) + { + text = getParser().getPrintString(new EObjectAdapter(parserElement), getParserOptions().intValue()); + } + if (text == null || text.length() == 0) + { + text = defaultText; + } + return text; + } + + /** + * @generated + */ + public void setLabelText(String text) + { + setLabelTextHelper(getFigure(), text); + Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); + if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + } + Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); + if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + } + } + + /** + * @generated + */ + public String getEditText() + { + if (getParserElement() == null || getParser() == null) + { + return ""; //$NON-NLS-1$ + } + return getParser().getEditString(new EObjectAdapter(getParserElement()), getParserOptions().intValue()); + } + + /** + * @generated + */ + protected boolean isEditable() + { + return getParser() != null; + } + + /** + * @generated + */ + public ICellEditorValidator getEditTextValidator() + { + return new ICellEditorValidator() + { + + public String isValid(final Object value) + { + if (value instanceof String) + { + final EObject element = getParserElement(); + final IParser parser = getParser(); + try + { + IParserEditStatus valid = (IParserEditStatus)getEditingDomain().runExclusive(new RunnableWithResult.Impl() + { + + public void run() + { + setResult(parser.isValidEditString(new EObjectAdapter(element), (String)value)); + } + }); + return valid.getCode() == ParserEditStatus.EDITABLE ? null : valid.getMessage(); + } + catch (InterruptedException ie) + { + ie.printStackTrace(); + } + } + + // shouldn't get here + return null; + } + }; + } + + /** + * @generated + */ + public IContentAssistProcessor getCompletionProcessor() + { + if (getParserElement() == null || getParser() == null) + { + return null; + } + return getParser().getCompletionProcessor(new EObjectAdapter(getParserElement())); + } + + /** + * @generated + */ + public ParserOptions getParserOptions() + { + return ParserOptions.NONE; + } + + /** + * @generated + */ + public IParser getParser() + { + if (parser == null) + { + parser = AcoreParserProvider.getParser(AcoreElementTypes.AOperation_3002, getParserElement(), + AcoreVisualIDRegistry + .getType(org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AOperationEditPart.VISUAL_ID)); + } + return parser; + } + + /** + * @generated + */ + protected DirectEditManager getManager() + { + if (manager == null) + { + setManager(new TextDirectEditManager(this, TextDirectEditManager.getTextCellEditorClass(this), + AcoreEditPartFactory.getTextCellEditorLocator(this))); + } + return manager; + } + + /** + * @generated + */ + protected void setManager(DirectEditManager manager) + { + this.manager = manager; + } + + /** + * @generated + */ + protected void performDirectEdit() + { + getManager().show(); + } + + /** + * @generated + */ + protected void performDirectEdit(Point eventLocation) + { + if (getManager().getClass() == TextDirectEditManager.class) + { + ((TextDirectEditManager)getManager()).show(eventLocation.getSWTPoint()); + } + } + + /** + * @generated + */ + private void performDirectEdit(char initialCharacter) + { + if (getManager() instanceof TextDirectEditManager) + { + ((TextDirectEditManager)getManager()).show(initialCharacter); + } + else + { + performDirectEdit(); + } + } + + /** + * @generated + */ + protected void performDirectEditRequest(Request request) + { + final Request theRequest = request; + try + { + getEditingDomain().runExclusive(new Runnable() + { + + public void run() + { + if (isActive() && isEditable()) + { + if (theRequest.getExtendedData().get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) + { + Character initialChar = (Character)theRequest.getExtendedData().get( + RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); + performDirectEdit(initialChar.charValue()); + } + else if ((theRequest instanceof DirectEditRequest) && (getEditText().equals(getLabelText()))) + { + DirectEditRequest editRequest = (DirectEditRequest)theRequest; + performDirectEdit(editRequest.getLocation()); + } + else + { + performDirectEdit(); + } + } + } + }); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + + /** + * @generated + */ + protected void refreshVisuals() + { + super.refreshVisuals(); + refreshLabel(); + refreshFont(); + refreshFontColor(); + refreshUnderline(); + refreshStrikeThrough(); + } + + /** + * @generated + */ + protected void refreshLabel() + { + setLabelTextHelper(getFigure(), getLabelText()); + setLabelIconHelper(getFigure(), getLabelIcon()); + Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); + if (pdEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)pdEditPolicy).refreshFeedback(); + } + Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); + if (sfEditPolicy instanceof AcoreTextSelectionEditPolicy) + { + ((AcoreTextSelectionEditPolicy)sfEditPolicy).refreshFeedback(); + } + } + + /** + * @generated + */ + protected void refreshUnderline() + { + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) + { + ((WrappingLabel)getFigure()).setTextUnderline(style.isUnderline()); + } + } + + /** + * @generated + */ + protected void refreshStrikeThrough() + { + FontStyle style = (FontStyle)getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); + if (style != null && getFigure() instanceof WrappingLabel) + { + ((WrappingLabel)getFigure()).setTextStrikeThrough(style.isStrikeThrough()); + } + } + + /** + * @generated + */ + 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)); + setFont(fontData); + } + } + + /** + * @generated + */ + protected void setFontColor(Color color) + { + getFigure().setForegroundColor(color); + } + + /** + * @generated + */ + protected void addSemanticListeners() + { + 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$ + } + } + else + { + super.addSemanticListeners(); + } + } + + /** + * @generated + */ + protected void removeSemanticListeners() + { + if (parserElements != null) + { + for (int i = 0; i < parserElements.size(); i++) + { + removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ + } + } + else + { + super.removeSemanticListeners(); + } + } + + /** + * @generated + */ + protected AccessibleEditPart getAccessibleEditPart() + { + if (accessibleEP == null) + { + accessibleEP = new AccessibleGraphicalEditPart() + { + + public void getName(AccessibleEvent e) + { + e.result = getLabelTextHelper(getFigure()); + } + }; + } + return accessibleEP; + } + + /** + * @generated + */ + private View getFontStyleOwnerView() + { + return getPrimaryView(); + } + + /** + * @generated + */ + protected void addNotationalListeners() + { + super.addNotationalListeners(); + addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$ + } + + /** + * @generated + */ + protected void removeNotationalListeners() + { + super.removeNotationalListeners(); + removeListenerFilter("PrimaryView"); //$NON-NLS-1$ + } + + /** + * @generated + */ + protected void handleNotificationEvent(Notification event) + { + Object feature = event.getFeature(); + 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)) + { + refreshUnderline(); + } + 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)) + { + refreshFont(); + } + else + { + if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) + { + refreshLabel(); + } + if (getParser() instanceof ISemanticParser) + { + ISemanticParser modelParser = (ISemanticParser)getParser(); + if (modelParser.areSemanticElementsAffected(null, event)) + { + removeSemanticListeners(); + if (resolveSemanticElement() != null) + { + addSemanticListeners(); + } + refreshLabel(); + } + } + } + super.handleNotificationEvent(event); + } + + /** + * @generated + */ + protected IFigure createFigure() + { + IFigure label = createFigurePrim(); + defaultText = getLabelTextHelper(label); + return label; + } + + /** + * @generated + */ + protected IFigure createFigurePrim() + { + return new WrappingLabel(); + } + +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AcoreEditPartFactory.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AcoreEditPartFactory.java index ff0403cbf1..9f98f5e35c 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AcoreEditPartFactory.java +++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/edit/parts/AcoreEditPartFactory.java @@ -1,228 +1,228 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Martin Fluegge - initial API and implementation
- *
- */
-package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts;
-
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry;
-
-import org.eclipse.draw2d.FigureUtilities;
-import org.eclipse.draw2d.Label;
-import org.eclipse.draw2d.geometry.Dimension;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPartFactory;
-import org.eclipse.gef.tools.CellEditorLocator;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * @generated
- */
-public class AcoreEditPartFactory implements EditPartFactory
-{
-
- /**
- * @generated
- */
- public EditPart createEditPart(EditPart context, Object model)
- {
- if (model instanceof View)
- {
- View view = (View)model;
- switch (AcoreVisualIDRegistry.getVisualID(view))
- {
-
- case ACoreRootEditPart.VISUAL_ID:
- return new ACoreRootEditPart(view);
-
- case AInterfaceEditPart.VISUAL_ID:
- return new AInterfaceEditPart(view);
-
- case AInterfaceNameEditPart.VISUAL_ID:
- return new AInterfaceNameEditPart(view);
-
- case AClassEditPart.VISUAL_ID:
- return new AClassEditPart(view);
-
- case AClassNameEditPart.VISUAL_ID:
- return new AClassNameEditPart(view);
-
- case AAttributeEditPart.VISUAL_ID:
- return new AAttributeEditPart(view);
-
- case AOperationEditPart.VISUAL_ID:
- return new AOperationEditPart(view);
-
- case AAttribute2EditPart.VISUAL_ID:
- return new AAttribute2EditPart(view);
-
- case AOperation2EditPart.VISUAL_ID:
- return new AOperation2EditPart(view);
-
- case AInterfaceAAttributeInterfaceCompartmentEditPart.VISUAL_ID:
- return new AInterfaceAAttributeInterfaceCompartmentEditPart(view);
-
- case AInterfaceAOperationInterfaceCompartmentEditPart.VISUAL_ID:
- return new AInterfaceAOperationInterfaceCompartmentEditPart(view);
-
- case AClassAAttributeCompartmentEditPart.VISUAL_ID:
- return new AClassAAttributeCompartmentEditPart(view);
-
- case AClassAOperationClassCompartmentEditPart.VISUAL_ID:
- return new AClassAOperationClassCompartmentEditPart(view);
-
- case AClassSubClassesEditPart.VISUAL_ID:
- return new AClassSubClassesEditPart(view);
-
- case AClassImplementedInterfacesEditPart.VISUAL_ID:
- return new AClassImplementedInterfacesEditPart(view);
-
- case AClassAssociationsEditPart.VISUAL_ID:
- return new AClassAssociationsEditPart(view);
-
- case AClassAggregationsEditPart.VISUAL_ID:
- return new AClassAggregationsEditPart(view);
-
- case AClassCompositionsEditPart.VISUAL_ID:
- return new AClassCompositionsEditPart(view);
-
- }
- }
- return createUnrecognizedEditPart(context, model);
- }
-
- /**
- * @generated
- */
- private EditPart createUnrecognizedEditPart(EditPart context, Object model)
- {
- // Handle creation of unrecognized child node EditParts here
- return null;
- }
-
- /**
- * @generated
- */
- public static CellEditorLocator getTextCellEditorLocator(ITextAwareEditPart source)
- {
- if (source.getFigure() instanceof WrappingLabel)
- return new TextCellEditorLocator((WrappingLabel)source.getFigure());
- else
- {
- return new LabelCellEditorLocator((Label)source.getFigure());
- }
- }
-
- /**
- * @generated
- */
- static private class TextCellEditorLocator implements CellEditorLocator
- {
-
- /**
- * @generated
- */
- private WrappingLabel wrapLabel;
-
- /**
- * @generated
- */
- public TextCellEditorLocator(WrappingLabel wrapLabel)
- {
- this.wrapLabel = wrapLabel;
- }
-
- /**
- * @generated
- */
- public WrappingLabel getWrapLabel()
- {
- return wrapLabel;
- }
-
- /**
- * @generated
- */
- public void relocate(CellEditor celleditor)
- {
- Text text = (Text)celleditor.getControl();
- Rectangle rect = getWrapLabel().getTextBounds().getCopy();
- getWrapLabel().translateToAbsolute(rect);
- if (!text.getFont().isDisposed())
- {
- if (getWrapLabel().isTextWrapOn() && getWrapLabel().getText().length() > 0)
- {
- rect.setSize(new Dimension(text.computeSize(rect.width, SWT.DEFAULT)));
- }
- else
- {
- int avr = FigureUtilities.getFontMetrics(text.getFont()).getAverageCharWidth();
- rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT, SWT.DEFAULT)).expand(avr * 2, 0));
- }
- }
- if (!rect.equals(new Rectangle(text.getBounds())))
- {
- text.setBounds(rect.x, rect.y, rect.width, rect.height);
- }
- }
- }
-
- /**
- * @generated
- */
- private static class LabelCellEditorLocator implements CellEditorLocator
- {
-
- /**
- * @generated
- */
- private Label label;
-
- /**
- * @generated
- */
- public LabelCellEditorLocator(Label label)
- {
- this.label = label;
- }
-
- /**
- * @generated
- */
- public Label getLabel()
- {
- return label;
- }
-
- /**
- * @generated
- */
- public void relocate(CellEditor celleditor)
- {
- Text text = (Text)celleditor.getControl();
- Rectangle rect = getLabel().getTextBounds().getCopy();
- getLabel().translateToAbsolute(rect);
- if (!text.getFont().isDisposed())
- {
- int avr = FigureUtilities.getFontMetrics(text.getFont()).getAverageCharWidth();
- rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT, SWT.DEFAULT)).expand(avr * 2, 0));
- }
- if (!rect.equals(new Rectangle(text.getBounds())))
- {
- text.setBounds(rect.x, rect.y, rect.width, rect.height);
- }
- }
- }
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + * + */ +package org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts; + +import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry; + +import org.eclipse.draw2d.FigureUtilities; +import org.eclipse.draw2d.Label; +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.EditPartFactory; +import org.eclipse.gef.tools.CellEditorLocator; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; +import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Text; + +/** + * @generated + */ +public class AcoreEditPartFactory implements EditPartFactory +{ + + /** + * @generated + */ + public EditPart createEditPart(EditPart context, Object model) + { + if (model instanceof View) + { + View view = (View)model; + switch (AcoreVisualIDRegistry.getVisualID(view)) + { + + case ACoreRootEditPart.VISUAL_ID: + return new ACoreRootEditPart(view); + + case AInterfaceEditPart.VISUAL_ID: + return new AInterfaceEditPart(view); + + case AInterfaceNameEditPart.VISUAL_ID: + return new AInterfaceNameEditPart(view); + + case AClassEditPart.VISUAL_ID: + return new AClassEditPart(view); + + case AClassNameEditPart.VISUAL_ID: + return new AClassNameEditPart(view); + + case AAttributeEditPart.VISUAL_ID: + return new AAttributeEditPart(view); + + case AOperationEditPart.VISUAL_ID: + return new AOperationEditPart(view); + + case AAttribute2EditPart.VISUAL_ID: + return new AAttribute2EditPart(view); + + case AOperation2EditPart.VISUAL_ID: + return new AOperation2EditPart(view); + + case AInterfaceAAttributeInterfaceCompartmentEditPart.VISUAL_ID: + return new AInterfaceAAttributeInterfaceCompartmentEditPart(view); + + case AInterfaceAOperationInterfaceCompartmentEditPart.VISUAL_ID: + return new AInterfaceAOperationInterfaceCompartmentEditPart(view); + + case AClassAAttributeCompartmentEditPart.VISUAL_ID: + return new AClassAAttributeCompartmentEditPart(view); + + case AClassAOperationClassCompartmentEditPart.VISUAL_ID: + return new AClassAOperationClassCompartmentEditPart(view); + + case AClassSubClassesEditPart.VISUAL_ID: + return new AClassSubClassesEditPart(view); + + case AClassImplementedInterfacesEditPart.VISUAL_ID: + return new AClassImplementedInterfacesEditPart(view); + + case AClassAssociationsEditPart.VISUAL_ID: + return new AClassAssociationsEditPart(view); + + case AClassAggregationsEditPart.VISUAL_ID: + return new AClassAggregationsEditPart(view); + + case AClassCompositionsEditPart.VISUAL_ID: + return new AClassCompositionsEditPart(view); + + } + } + return createUnrecognizedEditPart(context, model); + } + + /** + * @generated + */ + private EditPart createUnrecognizedEditPart(EditPart context, Object model) + { + // Handle creation of unrecognized child node EditParts here + return null; + } + + /** + * @generated + */ + public static CellEditorLocator getTextCellEditorLocator(ITextAwareEditPart source) + { + if (source.getFigure() instanceof WrappingLabel) + return new TextCellEditorLocator((WrappingLabel)source.getFigure()); + else + { + return new LabelCellEditorLocator((Label)source.getFigure()); + } + } + + /** + * @generated + */ + static private class TextCellEditorLocator implements CellEditorLocator + { + + /** + * @generated + */ + private WrappingLabel wrapLabel; + + /** + * @generated + */ + public TextCellEditorLocator(WrappingLabel wrapLabel) + { + this.wrapLabel = wrapLabel; + } + + /** + * @generated + */ + public WrappingLabel getWrapLabel() + { + return wrapLabel; + } + + /** + * @generated + */ + public void relocate(CellEditor celleditor) + { + Text text = (Text)celleditor.getControl(); + Rectangle rect = getWrapLabel().getTextBounds().getCopy(); + getWrapLabel().translateToAbsolute(rect); + if (!text.getFont().isDisposed()) + { + if (getWrapLabel().isTextWrapOn() && getWrapLabel().getText().length() > 0) + { + rect.setSize(new Dimension(text.computeSize(rect.width, SWT.DEFAULT))); + } + else + { + int avr = FigureUtilities.getFontMetrics(text.getFont()).getAverageCharWidth(); + rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT, SWT.DEFAULT)).expand(avr * 2, 0)); + } + } + if (!rect.equals(new Rectangle(text.getBounds()))) + { + text.setBounds(rect.x, rect.y, rect.width, rect.height); + } + } + } + + /** + * @generated + */ + private static class LabelCellEditorLocator implements CellEditorLocator + { + + /** + * @generated + */ + private Label label; + + /** + * @generated + */ + public LabelCellEditorLocator(Label label) + { + this.label = label; + } + + /** + * @generated + */ + public Label getLabel() + { + return label; + } + + /** + * @generated + */ + public void relocate(CellEditor celleditor) + { + Text text = (Text)celleditor.getControl(); + Rectangle rect = getLabel().getTextBounds().getCopy(); + getLabel().translateToAbsolute(rect); + if (!text.getFont().isDisposed()) + { + int avr = FigureUtilities.getFontMetrics(text.getFont()).getAverageCharWidth(); + rect.setSize(new Dimension(text.computeSize(SWT.DEFAULT, SWT.DEFAULT)).expand(avr * 2, 0)); + } + if (!rect.equals(new Rectangle(text.getBounds()))) + { + text.setBounds(rect.x, rect.y, rect.width, rect.height); + } + } + } +} |