Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
blob: c0117ce8cbff055019f51d05b9a43747100152d7 (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
/*******************************************************************************
 * Copyright (c) 2001, 2006 IBM Corporation 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:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.wst.xsd.ui.internal.design.figures;

import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.xsd.ui.internal.design.layouts.ModelGroupLayout;

public class GenericGroupFigure extends Figure
{
  protected CenteredIconFigure centeredIconFigure;
  protected Figure contentFigure;
  protected String text;
  protected boolean hasText = false;
  protected Label textFigure;
  
  public GenericGroupFigure()
  {
    super();
    setLayoutManager(new ModelGroupLayout(true));
   
    centeredIconFigure = new CenteredIconFigure();
    centeredIconFigure.setPreferredSize(new Dimension(15, 15));

    add(centeredIconFigure);
    contentFigure = new Figure();
    contentFigure.setLayoutManager(new ModelGroupLayout(false, 0));
    add(contentFigure);
  }
  
  public void setText(String text)
  {
    this.text = text;
    hasText = false;
    if (text != null && text.length() > 0)
    {
      hasText = true;
    }
  }
  
  public boolean hasText()
  {
    return hasText;
  }
  
  public String getText()
  {
    return text;
  }
  
  public Point getTextCoordinates()
  {
    Rectangle rect = centeredIconFigure.getBounds();
    return new Point(rect.x, rect.y + 14);
  }
  
  public void setIconFigure(Image image)
  {
    centeredIconFigure.image = image;
  }

  public CenteredIconFigure getTargetFigure()
  {
    return centeredIconFigure;
  }
  
  public CenteredIconFigure getIconFigure()
  {
    return centeredIconFigure;
  }
  
  public Figure getContentFigure()
  {
    return contentFigure;
  }
  
  public void setToolTipText(String text)
  {
    centeredIconFigure.setToolTipText(text);
  }
}

Back to the top