Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 44792c44d5af250036e62b98f6431167bda737a4 (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
98
99
100
101
102
103
104
105
/*
 * Copyright (c) 2011, 2012 Eike Stepper (Loehne, 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);
    }
  }
}

Back to the top