Skip to main content
summaryrefslogtreecommitdiffstats
blob: e0bb80736ee1b66e14c36d18f5b8d67664b36bbf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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);
        }
      });
    }
  }
}

Back to the top