diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance')
9 files changed, 761 insertions, 761 deletions
diff --git a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/DawnAppearancer.java b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/DawnAppearancer.java index e0bb80736e..bbbea2c18d 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/DawnAppearancer.java +++ b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/DawnAppearancer.java @@ -1,97 +1,97 @@ -/*
- * 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.gmf.appearance;
-
-import org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer;
-import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper;
-import org.eclipse.emf.cdo.dawn.ui.stylizer.DawnElementStylizerRegistry;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.gef.util.EditPartUtilities;
-
-/**
- * @author Martin Fluegge
- * @since 2.0
- */
-public class DawnAppearancer
-{
- public static final int DEFAULT_BORDER_THICKNESS = 2;
-
- public static final int DEFAULT_LINE_THICKNESS = 3;
-
- public static final int TYPE_CONFLICT_NONE = -1;
-
- public static final int TYPE_CONFLICT_LOCALLY_DELETED = 0;
-
- public static final int TYPE_CONFLICT_REMOTELY_DELETED = 1;
-
- public static final int TYPE_CONFLICT_REMOTELY_AND_LOCALLY_CHANGED = 2;
-
- public static final int TYPE_LOCKED_LOCALLY = 3;
-
- public static final int TYPE_LOCKED_GLOBALLY = 4;
-
- /**
- * @since 2.0
- */
- public static void setEditPartConflicted(EditPart editPart, int type)
- {
- DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance.getStylizer(editPart);
- if (stylizer != null)
- {
- stylizer.setConflicted(editPart, type);
- }
- }
-
- /**
- * @since 2.0
- */
- public static void setEditPartDefaultAllChildren(EditPart editPart)
- {
- setEditPartDefault(editPart);
-
- for (Object child : EditPartUtilities.getAllChildren((GraphicalEditPart)editPart))
- {
- setEditPartDefaultAllChildren((EditPart)child);
- }
- }
-
- /**
- * @since 2.0
- */
- public static void setEditPartDefault(EditPart editPart)
- {
- DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance.getStylizer(editPart);
- if (stylizer != null)
- {
- stylizer.setDefault(editPart);
- }
- }
-
- /**
- * @since 2.0
- */
- public static void setEditPartLocked(final EditPart editPart, final int type)
- {
- final DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance.getStylizer(editPart);
- if (stylizer != null)
- {
- DawnEditorHelper.getDisplay().syncExec(new Runnable()
- {
- public void run()
- {
- stylizer.setLocked(editPart, type);
- }
- });
- }
- }
-}
+/* + * 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.gmf.appearance; + +import org.eclipse.emf.cdo.dawn.appearance.DawnElementStylizer; +import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper; +import org.eclipse.emf.cdo.dawn.ui.stylizer.DawnElementStylizerRegistry; + +import org.eclipse.gef.EditPart; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.util.EditPartUtilities; + +/** + * @author Martin Fluegge + * @since 2.0 + */ +public class DawnAppearancer +{ + public static final int DEFAULT_BORDER_THICKNESS = 2; + + public static final int DEFAULT_LINE_THICKNESS = 3; + + public static final int TYPE_CONFLICT_NONE = -1; + + public static final int TYPE_CONFLICT_LOCALLY_DELETED = 0; + + public static final int TYPE_CONFLICT_REMOTELY_DELETED = 1; + + public static final int TYPE_CONFLICT_REMOTELY_AND_LOCALLY_CHANGED = 2; + + public static final int TYPE_LOCKED_LOCALLY = 3; + + public static final int TYPE_LOCKED_GLOBALLY = 4; + + /** + * @since 2.0 + */ + public static void setEditPartConflicted(EditPart editPart, int type) + { + DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance.getStylizer(editPart); + if (stylizer != null) + { + stylizer.setConflicted(editPart, type); + } + } + + /** + * @since 2.0 + */ + public static void setEditPartDefaultAllChildren(EditPart editPart) + { + setEditPartDefault(editPart); + + for (Object child : EditPartUtilities.getAllChildren((GraphicalEditPart)editPart)) + { + setEditPartDefaultAllChildren((EditPart)child); + } + } + + /** + * @since 2.0 + */ + public static void setEditPartDefault(EditPart editPart) + { + DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance.getStylizer(editPart); + if (stylizer != null) + { + stylizer.setDefault(editPart); + } + } + + /** + * @since 2.0 + */ + public static void setEditPartLocked(final EditPart editPart, final int type) + { + final DawnElementStylizer stylizer = DawnElementStylizerRegistry.instance.getStylizer(editPart); + if (stylizer != null) + { + DawnEditorHelper.getDisplay().syncExec(new Runnable() + { + public void run() + { + stylizer.setLocked(editPart, type); + } + }); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/DawnEditPartStylizer.java b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/DawnEditPartStylizer.java index fae55d139c..e614c3b0e4 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/DawnEditPartStylizer.java +++ b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/DawnEditPartStylizer.java @@ -1,60 +1,60 @@ -/*
- * 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.gmf.appearance;
-
-import org.eclipse.emf.cdo.dawn.ui.stylizer.DawnDefaultElementStylizer;
-
-import org.eclipse.gef.EditPart;
-
-/**
- * An EditPartStylizer can influence the visual representation of the models state. Dawn knows three states - default,
- * conflicted and locked. By implementing an own DawnStylizer you can influence the appearance of the three states for
- * your EditPart and it's related models. New stylizer can be registered to Dawn using the
- * <b>org.eclipse.emf.cdo.dawn.editpartstylizers</b> extension point.
- *
- * @author Martin Fluegge
- * @since 2.0
- */
-public abstract class DawnEditPartStylizer extends DawnDefaultElementStylizer
-{
- /**
- * @since 2.0
- */
- public abstract void setDefault(EditPart editPart);
-
- /**
- * @since 2.0
- */
- public abstract void setConflicted(EditPart editPart, int type);
-
- /**
- * @since 2.0
- */
- public abstract void setLocked(EditPart editPart, int type);
-
- @Override
- public void setDefault(Object element)
- {
- setDefault((EditPart)element);
- }
-
- @Override
- public void setConflicted(Object element, int type)
- {
- setConflicted((EditPart)element, type);
- }
-
- @Override
- public void setLocked(Object element, int type)
- {
- setLocked((EditPart)element, type);
- }
-}
+/* + * 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.gmf.appearance; + +import org.eclipse.emf.cdo.dawn.ui.stylizer.DawnDefaultElementStylizer; + +import org.eclipse.gef.EditPart; + +/** + * An EditPartStylizer can influence the visual representation of the models state. Dawn knows three states - default, + * conflicted and locked. By implementing an own DawnStylizer you can influence the appearance of the three states for + * your EditPart and it's related models. New stylizer can be registered to Dawn using the + * <b>org.eclipse.emf.cdo.dawn.editpartstylizers</b> extension point. + * + * @author Martin Fluegge + * @since 2.0 + */ +public abstract class DawnEditPartStylizer extends DawnDefaultElementStylizer +{ + /** + * @since 2.0 + */ + public abstract void setDefault(EditPart editPart); + + /** + * @since 2.0 + */ + public abstract void setConflicted(EditPart editPart, int type); + + /** + * @since 2.0 + */ + public abstract void setLocked(EditPart editPart, int type); + + @Override + public void setDefault(Object element) + { + setDefault((EditPart)element); + } + + @Override + public void setConflicted(Object element, int type) + { + setConflicted((EditPart)element, type); + } + + @Override + public void setLocked(Object element, int type) + { + setLocked((EditPart)element, type); + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/DawnEditPartStylizerRegistry.java b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/DawnEditPartStylizerRegistry.java index 07aa4295d0..508fcbfcfa 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/DawnEditPartStylizerRegistry.java +++ b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/DawnEditPartStylizerRegistry.java @@ -1,130 +1,130 @@ -/*
- * 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.gmf.appearance;
-
-import org.eclipse.emf.cdo.dawn.gmf.appearance.impl.DawnBasicConnectionEditPartStylizerImpl;
-import org.eclipse.emf.cdo.dawn.gmf.appearance.impl.DawnBasicGraphicalEditPartStylizerImpl;
-import org.eclipse.emf.cdo.dawn.gmf.appearance.impl.DawnBasicNodeEditPartStylizerImpl;
-import org.eclipse.emf.cdo.dawn.gmf.appearance.impl.DawnBasicTextAwareEditPartStylizerImpl;
-import org.eclipse.emf.cdo.internal.dawn.bundle.OM;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.InvalidRegistryObjectException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.gef.ConnectionEditPart;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.NodeEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Martin Fluegge
- * @since 2.0
- * @deprecated
- */
-@Deprecated
-public class DawnEditPartStylizerRegistry
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DawnEditPartStylizerRegistry.class);
-
- private static final String DAWN_STYLIZER_EXTENSION_POINT_ID = "org.eclipse.emf.cdo.dawn.editpartstylizers";
-
- public static DawnEditPartStylizerRegistry instance = new DawnEditPartStylizerRegistry();
-
- private Map<String, DawnEditPartStylizer> registeredStylizers = new HashMap<String, DawnEditPartStylizer>();
-
- /**
- * @since 2.0
- */
- public DawnEditPartStylizer getStylizer(EditPart editPart)
- {
- DawnEditPartStylizer stylizer = registeredStylizers.get(editPart.getClass().getCanonicalName());
-
- if (stylizer == null)
- {
- stylizer = getStylizerFromExtensionPoint(editPart);
- }
-
- if (stylizer == null)
- {
- stylizer = getDefaultStylizer(editPart);
- }
-
- return stylizer;
- }
-
- private DawnEditPartStylizer getDefaultStylizer(EditPart editPart)
- {
- DawnEditPartStylizer stylizer = null;
- if (editPart instanceof ConnectionEditPart)
- {
- stylizer = new DawnBasicConnectionEditPartStylizerImpl();
- }
- else if (editPart instanceof NodeEditPart)
- {
- stylizer = new DawnBasicNodeEditPartStylizerImpl();
- }
- else if (editPart instanceof DiagramEditPart)
- {
- stylizer = new DawnBasicNodeEditPartStylizerImpl();
- }
- else if (editPart instanceof ITextAwareEditPart)
- {
- stylizer = new DawnBasicTextAwareEditPartStylizerImpl();
- }
- else
- {
- // In the case that there is no match we use a simple border styled stylizer.
- stylizer = new DawnBasicGraphicalEditPartStylizerImpl();
- }
-
- return stylizer;
- }
-
- private DawnEditPartStylizer getStylizerFromExtensionPoint(EditPart editPart)
- {
- try
- {
- IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(
- DAWN_STYLIZER_EXTENSION_POINT_ID);
- for (IConfigurationElement e : config)
- {
- if (editPart.getClass().getCanonicalName().equals(e.getAttribute("editpart")))
- {
- DawnEditPartStylizer stylizer = (DawnEditPartStylizer)e.createExecutableExtension("stylizer");
- registeredStylizers.put(editPart.getClass().getCanonicalName(), stylizer);
- if (TRACER.isEnabled())
- {
- TRACER.format("Registered DawnEditPartStylizer {0} ", stylizer); //$NON-NLS-1$
- }
-
- return stylizer;
- }
- }
- }
- catch (InvalidRegistryObjectException e1)
- {
- e1.printStackTrace();
- }
- catch (CoreException e)
- {
- e.printStackTrace();
- }
-
- 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.gmf.appearance; + +import org.eclipse.emf.cdo.dawn.gmf.appearance.impl.DawnBasicConnectionEditPartStylizerImpl; +import org.eclipse.emf.cdo.dawn.gmf.appearance.impl.DawnBasicGraphicalEditPartStylizerImpl; +import org.eclipse.emf.cdo.dawn.gmf.appearance.impl.DawnBasicNodeEditPartStylizerImpl; +import org.eclipse.emf.cdo.dawn.gmf.appearance.impl.DawnBasicTextAwareEditPartStylizerImpl; +import org.eclipse.emf.cdo.internal.dawn.bundle.OM; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.InvalidRegistryObjectException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.gef.ConnectionEditPart; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.NodeEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Martin Fluegge + * @since 2.0 + * @deprecated + */ +@Deprecated +public class DawnEditPartStylizerRegistry +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DawnEditPartStylizerRegistry.class); + + private static final String DAWN_STYLIZER_EXTENSION_POINT_ID = "org.eclipse.emf.cdo.dawn.editpartstylizers"; + + public static DawnEditPartStylizerRegistry instance = new DawnEditPartStylizerRegistry(); + + private Map<String, DawnEditPartStylizer> registeredStylizers = new HashMap<String, DawnEditPartStylizer>(); + + /** + * @since 2.0 + */ + public DawnEditPartStylizer getStylizer(EditPart editPart) + { + DawnEditPartStylizer stylizer = registeredStylizers.get(editPart.getClass().getCanonicalName()); + + if (stylizer == null) + { + stylizer = getStylizerFromExtensionPoint(editPart); + } + + if (stylizer == null) + { + stylizer = getDefaultStylizer(editPart); + } + + return stylizer; + } + + private DawnEditPartStylizer getDefaultStylizer(EditPart editPart) + { + DawnEditPartStylizer stylizer = null; + if (editPart instanceof ConnectionEditPart) + { + stylizer = new DawnBasicConnectionEditPartStylizerImpl(); + } + else if (editPart instanceof NodeEditPart) + { + stylizer = new DawnBasicNodeEditPartStylizerImpl(); + } + else if (editPart instanceof DiagramEditPart) + { + stylizer = new DawnBasicNodeEditPartStylizerImpl(); + } + else if (editPart instanceof ITextAwareEditPart) + { + stylizer = new DawnBasicTextAwareEditPartStylizerImpl(); + } + else + { + // In the case that there is no match we use a simple border styled stylizer. + stylizer = new DawnBasicGraphicalEditPartStylizerImpl(); + } + + return stylizer; + } + + private DawnEditPartStylizer getStylizerFromExtensionPoint(EditPart editPart) + { + try + { + IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor( + DAWN_STYLIZER_EXTENSION_POINT_ID); + for (IConfigurationElement e : config) + { + if (editPart.getClass().getCanonicalName().equals(e.getAttribute("editpart"))) + { + DawnEditPartStylizer stylizer = (DawnEditPartStylizer)e.createExecutableExtension("stylizer"); + registeredStylizers.put(editPart.getClass().getCanonicalName(), stylizer); + if (TRACER.isEnabled()) + { + TRACER.format("Registered DawnEditPartStylizer {0} ", stylizer); //$NON-NLS-1$ + } + + return stylizer; + } + } + } + catch (InvalidRegistryObjectException e1) + { + e1.printStackTrace(); + } + catch (CoreException e) + { + e.printStackTrace(); + } + + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicConnectionEditPartStylizerImpl.java b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicConnectionEditPartStylizerImpl.java index 9a230fd0be..d2c2bf71e4 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicConnectionEditPartStylizerImpl.java +++ b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicConnectionEditPartStylizerImpl.java @@ -1,123 +1,123 @@ -/*
- * 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.gmf.appearance.impl;
-
-import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
-import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnEditPartStylizer;
-import org.eclipse.emf.cdo.dawn.spi.DawnState;
-import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants;
-
-import org.eclipse.emf.workspace.AbstractEMFOperation;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gmf.runtime.common.core.util.StringStatics;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.requests.ChangePropertyValueRequest;
-import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
-import org.eclipse.gmf.runtime.emf.core.util.PackageUtil;
-import org.eclipse.gmf.runtime.notation.NotationPackage;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @author Martin Fluegge
- * @since 2.0
- */
-public class DawnBasicConnectionEditPartStylizerImpl extends DawnEditPartStylizer
-{
-
- /**
- * @since 2.0
- */
- @Override
- public void setDefault(EditPart editPart)
- {
- setEdge(editPart, DawnColorConstants.COLOR_NO_CONFLICT);
- }
-
- /**
- * @since 2.0
- */
- @Override
- public void setConflicted(EditPart editPart, int type)
- {
- // Color color = DawnColorConstants.COLOR_DELETE_CONFLICT;
- Color color = getForegroundColor(editPart, DawnState.CONFLICT);
- setEdge(editPart, color);
- }
-
- /**
- * @since 2.0
- */
- private void setEdge(EditPart editPart, Color color)
- {
- ChangePropertyValueRequest request = new ChangePropertyValueRequest(StringStatics.BLANK,
- PackageUtil.getID(NotationPackage.eINSTANCE.getLineStyle_LineColor()), FigureUtilities.colorToInteger(color));
- final Command command = editPart.getCommand(request);
-
- AbstractEMFOperation operation = new AbstractEMFOperation(((IGraphicalEditPart)editPart).getEditingDomain(),
- StringStatics.BLANK, null)
- {
- @Override
- protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
- {
- command.execute();
- return Status.OK_STATUS;
- }
- };
-
- try
- {
- operation.execute(new NullProgressMonitor(), null);
- }
- catch (ExecutionException e)
- {
- }
-
- editPart.refresh();
- editPart.getRoot().refresh();
- }
-
- /**
- * @since 2.0
- */
- @Override
- public void setLocked(EditPart editPart, int type)
- {
- Color color = null;
- switch (type)
- {
- case DawnAppearancer.TYPE_LOCKED_LOCALLY:
- {
- color = getBackgroundColor(editPart, DawnState.LOCKED_LOCALLY);
- break;
- }
- case DawnAppearancer.TYPE_LOCKED_GLOBALLY:
- {
- color = getBackgroundColor(editPart, DawnState.LOCKED_REMOTELY);
- break;
- }
-
- default:
- break;
- }
- if (color != null)
- {
- setEdge(editPart, color);
- }
- }
-}
+/* + * 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.gmf.appearance.impl; + +import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer; +import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnEditPartStylizer; +import org.eclipse.emf.cdo.dawn.spi.DawnState; +import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants; + +import org.eclipse.emf.workspace.AbstractEMFOperation; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Status; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.commands.Command; +import org.eclipse.gmf.runtime.common.core.util.StringStatics; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.requests.ChangePropertyValueRequest; +import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities; +import org.eclipse.gmf.runtime.emf.core.util.PackageUtil; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.swt.graphics.Color; + +/** + * @author Martin Fluegge + * @since 2.0 + */ +public class DawnBasicConnectionEditPartStylizerImpl extends DawnEditPartStylizer +{ + + /** + * @since 2.0 + */ + @Override + public void setDefault(EditPart editPart) + { + setEdge(editPart, DawnColorConstants.COLOR_NO_CONFLICT); + } + + /** + * @since 2.0 + */ + @Override + public void setConflicted(EditPart editPart, int type) + { + // Color color = DawnColorConstants.COLOR_DELETE_CONFLICT; + Color color = getForegroundColor(editPart, DawnState.CONFLICT); + setEdge(editPart, color); + } + + /** + * @since 2.0 + */ + private void setEdge(EditPart editPart, Color color) + { + ChangePropertyValueRequest request = new ChangePropertyValueRequest(StringStatics.BLANK, + PackageUtil.getID(NotationPackage.eINSTANCE.getLineStyle_LineColor()), FigureUtilities.colorToInteger(color)); + final Command command = editPart.getCommand(request); + + AbstractEMFOperation operation = new AbstractEMFOperation(((IGraphicalEditPart)editPart).getEditingDomain(), + StringStatics.BLANK, null) + { + @Override + protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException + { + command.execute(); + return Status.OK_STATUS; + } + }; + + try + { + operation.execute(new NullProgressMonitor(), null); + } + catch (ExecutionException e) + { + } + + editPart.refresh(); + editPart.getRoot().refresh(); + } + + /** + * @since 2.0 + */ + @Override + public void setLocked(EditPart editPart, int type) + { + Color color = null; + switch (type) + { + case DawnAppearancer.TYPE_LOCKED_LOCALLY: + { + color = getBackgroundColor(editPart, DawnState.LOCKED_LOCALLY); + break; + } + case DawnAppearancer.TYPE_LOCKED_GLOBALLY: + { + color = getBackgroundColor(editPart, DawnState.LOCKED_REMOTELY); + break; + } + + default: + break; + } + if (color != null) + { + setEdge(editPart, color); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicDiagramStylizerImpl.java b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicDiagramStylizerImpl.java index 0661e9fb80..c24bbc5b3e 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicDiagramStylizerImpl.java +++ b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicDiagramStylizerImpl.java @@ -1,46 +1,46 @@ -/*
- * 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.gmf.appearance.impl;
-
-import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnEditPartStylizer;
-
-import org.eclipse.gef.EditPart;
-
-/**
- * @author Martin Fluegge
- * @since 2.0
- */
-public class DawnBasicDiagramStylizerImpl extends DawnEditPartStylizer
-{
- /**
- * @since 2.0
- */
- @Override
- public void setDefault(EditPart editpart)
- {
- }
-
- /**
- * @since 2.0
- */
- @Override
- public void setConflicted(EditPart editpart, int type)
- {
- }
-
- /**
- * @since 2.0
- */
- @Override
- public void setLocked(EditPart editpart, int type)
- {
- }
-}
+/* + * 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.gmf.appearance.impl; + +import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnEditPartStylizer; + +import org.eclipse.gef.EditPart; + +/** + * @author Martin Fluegge + * @since 2.0 + */ +public class DawnBasicDiagramStylizerImpl extends DawnEditPartStylizer +{ + /** + * @since 2.0 + */ + @Override + public void setDefault(EditPart editpart) + { + } + + /** + * @since 2.0 + */ + @Override + public void setConflicted(EditPart editpart, int type) + { + } + + /** + * @since 2.0 + */ + @Override + public void setLocked(EditPart editpart, int type) + { + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicGraphicalEditPartStylizerImpl.java b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicGraphicalEditPartStylizerImpl.java index c64f62c1d6..aee8c949f0 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicGraphicalEditPartStylizerImpl.java +++ b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicGraphicalEditPartStylizerImpl.java @@ -1,79 +1,79 @@ -/*
- * 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.gmf.appearance.impl;
-
-import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
-import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnEditPartStylizer;
-import org.eclipse.emf.cdo.dawn.spi.DawnState;
-
-import org.eclipse.draw2d.Border;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.LineBorder;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.GraphicalEditPart;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * @author Martin Fluegge
- * @since 2.0
- */
-
-public class DawnBasicGraphicalEditPartStylizerImpl extends DawnEditPartStylizer
-{
- /**
- * @since 2.0
- */
- @Override
- public void setDefault(EditPart editPart)
- {
- setBorder(editPart, null);
- }
-
- /**
- * @since 2.0
- */
- @Override
- public void setConflicted(EditPart editPart, int type)
- {
- setBorder(editPart, getForegroundColor(editPart, DawnState.CONFLICT), DawnAppearancer.DEFAULT_BORDER_THICKNESS);
- }
-
- /**
- * @since 2.0
- */
- @Override
- public void setLocked(EditPart editPart, int type)
- {
- setBorder(editPart, getBackgroundColor(editPart, DawnState.LOCKED_REMOTELY),
- DawnAppearancer.DEFAULT_BORDER_THICKNESS);
- }
-
- /**
- * @since 2.0
- */
- protected void setBorder(EditPart editPart, Color color, int thickness)
- {
- Border thickBorder = new LineBorder(color, thickness);
- setBorder(editPart, thickBorder);
- }
-
- /**
- * @since 2.0
- */
- protected void setBorder(EditPart editPart, Border border)
- {
- GraphicalEditPart e = (GraphicalEditPart)editPart;
-
- IFigure figure = e.getFigure();
- figure.setBorder(border);
- editPart.refresh();
- }
-}
+/* + * 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.gmf.appearance.impl; + +import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer; +import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnEditPartStylizer; +import org.eclipse.emf.cdo.dawn.spi.DawnState; + +import org.eclipse.draw2d.Border; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.LineBorder; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.swt.graphics.Color; + +/** + * @author Martin Fluegge + * @since 2.0 + */ + +public class DawnBasicGraphicalEditPartStylizerImpl extends DawnEditPartStylizer +{ + /** + * @since 2.0 + */ + @Override + public void setDefault(EditPart editPart) + { + setBorder(editPart, null); + } + + /** + * @since 2.0 + */ + @Override + public void setConflicted(EditPart editPart, int type) + { + setBorder(editPart, getForegroundColor(editPart, DawnState.CONFLICT), DawnAppearancer.DEFAULT_BORDER_THICKNESS); + } + + /** + * @since 2.0 + */ + @Override + public void setLocked(EditPart editPart, int type) + { + setBorder(editPart, getBackgroundColor(editPart, DawnState.LOCKED_REMOTELY), + DawnAppearancer.DEFAULT_BORDER_THICKNESS); + } + + /** + * @since 2.0 + */ + protected void setBorder(EditPart editPart, Color color, int thickness) + { + Border thickBorder = new LineBorder(color, thickness); + setBorder(editPart, thickBorder); + } + + /** + * @since 2.0 + */ + protected void setBorder(EditPart editPart, Border border) + { + GraphicalEditPart e = (GraphicalEditPart)editPart; + + IFigure figure = e.getFigure(); + figure.setBorder(border); + editPart.refresh(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicNodeEditPartStylizerImpl.java b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicNodeEditPartStylizerImpl.java index e317cd13fd..a6481d0177 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicNodeEditPartStylizerImpl.java +++ b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicNodeEditPartStylizerImpl.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.gmf.appearance.impl;
-
-import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
-import org.eclipse.emf.cdo.dawn.spi.DawnState;
-import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants;
-
-import org.eclipse.gef.EditPart;
-
-/**
- * @author Martin Fluegge
- */
-public class DawnBasicNodeEditPartStylizerImpl extends DawnBasicGraphicalEditPartStylizerImpl
-{
-
- @Override
- public void setDefault(EditPart editPart)
- {
- setBorder(editPart, DawnColorConstants.COLOR_NO_CONFLICT, 0);
- }
-
- // @Override
- // public void setConflicted(EditPart editPart, int type)
- // {
- // setBorder(editPart, DawnColorConstants.COLOR_DELETE_CONFLICT, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
- // }
-
- @Override
- public void setLocked(EditPart editPart, int type)
- {
- switch (type)
- {
- case DawnAppearancer.TYPE_LOCKED_GLOBALLY:
- {
- setBorder(editPart, getBackgroundColor(editPart, DawnState.LOCKED_REMOTELY),
- DawnAppearancer.DEFAULT_BORDER_THICKNESS);
- break;
- }
- case DawnAppearancer.TYPE_LOCKED_LOCALLY:
- {
- setBorder(editPart, getBackgroundColor(editPart, DawnState.LOCKED_LOCALLY),
- DawnAppearancer.DEFAULT_BORDER_THICKNESS);
- break;
- }
- }
- }
-}
+/* + * 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.gmf.appearance.impl; + +import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer; +import org.eclipse.emf.cdo.dawn.spi.DawnState; +import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants; + +import org.eclipse.gef.EditPart; + +/** + * @author Martin Fluegge + */ +public class DawnBasicNodeEditPartStylizerImpl extends DawnBasicGraphicalEditPartStylizerImpl +{ + + @Override + public void setDefault(EditPart editPart) + { + setBorder(editPart, DawnColorConstants.COLOR_NO_CONFLICT, 0); + } + + // @Override + // public void setConflicted(EditPart editPart, int type) + // { + // setBorder(editPart, DawnColorConstants.COLOR_DELETE_CONFLICT, DawnAppearancer.DEFAULT_BORDER_THICKNESS); + // } + + @Override + public void setLocked(EditPart editPart, int type) + { + switch (type) + { + case DawnAppearancer.TYPE_LOCKED_GLOBALLY: + { + setBorder(editPart, getBackgroundColor(editPart, DawnState.LOCKED_REMOTELY), + DawnAppearancer.DEFAULT_BORDER_THICKNESS); + break; + } + case DawnAppearancer.TYPE_LOCKED_LOCALLY: + { + setBorder(editPart, getBackgroundColor(editPart, DawnState.LOCKED_LOCALLY), + DawnAppearancer.DEFAULT_BORDER_THICKNESS); + break; + } + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicTextAwareEditPartStylizerImpl.java b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicTextAwareEditPartStylizerImpl.java index 6a807a6ff8..0469273056 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicTextAwareEditPartStylizerImpl.java +++ b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicTextAwareEditPartStylizerImpl.java @@ -1,65 +1,65 @@ -/*
- * 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.gmf.appearance.impl;
-
-import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
-import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants;
-
-import org.eclipse.draw2d.Border;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Martin Fluegge
- */
-public class DawnBasicTextAwareEditPartStylizerImpl extends DawnBasicGraphicalEditPartStylizerImpl
-{
-
- Map<EditPart, Border> oldValues = new HashMap<EditPart, Border>();
-
- @Override
- public void setDefault(EditPart editPart)
- {
- setBorder(editPart, oldValues.get(editPart));
- }
-
- @Override
- public void setConflicted(EditPart editPart, int type)
- {
- final IGraphicalEditPart e = (IGraphicalEditPart)editPart;
-
- // TODO Setting the foreground color just works until the EditPart is refreshed and the default color is used again.
- // Find a better way to handle this.
- // e.getFigure().setForegroundColor(DawnAppearancer.COLOR_DELETE_CONFLICT);
- oldValues.put(e, e.getFigure().getBorder());
-
- setBorder(editPart, DawnColorConstants.COLOR_DELETE_CONFLICT, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
- // View view = (View)e.getModel();
- // FontStyle style = (FontStyle)view.getStyle(NotationPackage.eINSTANCE.getFontStyle());
- // if (style == null)
- // {
- // style = NotationFactory.eINSTANCE.createFontStyle();
- // style.setFontColor(FigureUtilities.colorToInteger(DiagramColorConstants.red));
- // style.setBold(true);
- //
- // view.getStyles().add(style);
- // }
- }
-
- @Override
- public void setLocked(EditPart editPart, int type)
- {
- setBorder(editPart, DawnColorConstants.COLOR_LOCKED_REMOTELY, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
- }
-}
+/* + * 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.gmf.appearance.impl; + +import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer; +import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants; + +import org.eclipse.draw2d.Border; +import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Martin Fluegge + */ +public class DawnBasicTextAwareEditPartStylizerImpl extends DawnBasicGraphicalEditPartStylizerImpl +{ + + Map<EditPart, Border> oldValues = new HashMap<EditPart, Border>(); + + @Override + public void setDefault(EditPart editPart) + { + setBorder(editPart, oldValues.get(editPart)); + } + + @Override + public void setConflicted(EditPart editPart, int type) + { + final IGraphicalEditPart e = (IGraphicalEditPart)editPart; + + // TODO Setting the foreground color just works until the EditPart is refreshed and the default color is used again. + // Find a better way to handle this. + // e.getFigure().setForegroundColor(DawnAppearancer.COLOR_DELETE_CONFLICT); + oldValues.put(e, e.getFigure().getBorder()); + + setBorder(editPart, DawnColorConstants.COLOR_DELETE_CONFLICT, DawnAppearancer.DEFAULT_BORDER_THICKNESS); + // View view = (View)e.getModel(); + // FontStyle style = (FontStyle)view.getStyle(NotationPackage.eINSTANCE.getFontStyle()); + // if (style == null) + // { + // style = NotationFactory.eINSTANCE.createFontStyle(); + // style.setFontColor(FigureUtilities.colorToInteger(DiagramColorConstants.red)); + // style.setBold(true); + // + // view.getStyles().add(style); + // } + } + + @Override + public void setLocked(EditPart editPart, int type) + { + setBorder(editPart, DawnColorConstants.COLOR_LOCKED_REMOTELY, DawnAppearancer.DEFAULT_BORDER_THICKNESS); + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBlinkingNodeEditPartStylizerImpl.java b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBlinkingNodeEditPartStylizerImpl.java index 40152b9548..d79bd57249 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBlinkingNodeEditPartStylizerImpl.java +++ b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBlinkingNodeEditPartStylizerImpl.java @@ -1,105 +1,105 @@ -/*
- * 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.gmf.appearance.impl;
-
-import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
-import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants;
-
-import org.eclipse.gef.EditPart;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Martin Fluegge
- * @since 2.0
- */
-public class DawnBlinkingNodeEditPartStylizerImpl extends DawnBasicGraphicalEditPartStylizerImpl
-{
- BlinkingThread blinkingThread;
-
- public DawnBlinkingNodeEditPartStylizerImpl()
- {
- blinkingThread = new BlinkingThread();
- blinkingThread.start();
- }
-
- @Override
- public void setDefault(EditPart editPart)
- {
- blinkingThread.stop(editPart);
- setBorder(editPart, DawnColorConstants.COLOR_NO_CONFLICT, 0);
- }
-
- @Override
- public void setConflicted(EditPart editPart, int type)
- {
- blinkingThread.start(editPart);
- }
-
- @Override
- public void setLocked(EditPart editPart, int type)
- {
- setBorder(editPart, DawnColorConstants.COLOR_LOCKED_REMOTELY, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
- }
-
- /**
- * @author Martin Fluegge
- * @since 2.0
- */
- protected class BlinkingThread extends Thread
- {
-
- Map<EditPart, Boolean> editParts = new HashMap<EditPart, Boolean>();
-
- @Override
- public void run()
- {
- while (true)
- {
- for (EditPart e : editParts.keySet())
- {
- if (editParts.get(e))
- {
- setBorder(e, DawnColorConstants.COLOR_NO_CONFLICT, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
- }
- else
- {
- setBorder(e, DawnColorConstants.COLOR_DELETE_CONFLICT, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
- }
-
- editParts.put(e, !editParts.get(e));
- }
- try
- {
- Thread.sleep(500);
- }
- catch (InterruptedException e1)
- {
- e1.printStackTrace();
- }
- }
- }
-
- /**
- * @since 2.0
- */
- public void start(EditPart editPart)
- {
- editParts.put(editPart, true);
- }
-
- public void stop(EditPart editPart)
- {
- editParts.remove(editPart);
- }
- }
-}
+/* + * 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.gmf.appearance.impl; + +import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer; +import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants; + +import org.eclipse.gef.EditPart; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Martin Fluegge + * @since 2.0 + */ +public class DawnBlinkingNodeEditPartStylizerImpl extends DawnBasicGraphicalEditPartStylizerImpl +{ + BlinkingThread blinkingThread; + + public DawnBlinkingNodeEditPartStylizerImpl() + { + blinkingThread = new BlinkingThread(); + blinkingThread.start(); + } + + @Override + public void setDefault(EditPart editPart) + { + blinkingThread.stop(editPart); + setBorder(editPart, DawnColorConstants.COLOR_NO_CONFLICT, 0); + } + + @Override + public void setConflicted(EditPart editPart, int type) + { + blinkingThread.start(editPart); + } + + @Override + public void setLocked(EditPart editPart, int type) + { + setBorder(editPart, DawnColorConstants.COLOR_LOCKED_REMOTELY, DawnAppearancer.DEFAULT_BORDER_THICKNESS); + } + + /** + * @author Martin Fluegge + * @since 2.0 + */ + protected class BlinkingThread extends Thread + { + + Map<EditPart, Boolean> editParts = new HashMap<EditPart, Boolean>(); + + @Override + public void run() + { + while (true) + { + for (EditPart e : editParts.keySet()) + { + if (editParts.get(e)) + { + setBorder(e, DawnColorConstants.COLOR_NO_CONFLICT, DawnAppearancer.DEFAULT_BORDER_THICKNESS); + } + else + { + setBorder(e, DawnColorConstants.COLOR_DELETE_CONFLICT, DawnAppearancer.DEFAULT_BORDER_THICKNESS); + } + + editParts.put(e, !editParts.get(e)); + } + try + { + Thread.sleep(500); + } + catch (InterruptedException e1) + { + e1.printStackTrace(); + } + } + } + + /** + * @since 2.0 + */ + public void start(EditPart editPart) + { + editParts.put(editPart, true); + } + + public void stop(EditPart editPart) + { + editParts.remove(editPart); + } + } +} |