Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: c070e0b270dc17f28042b9aa8fb0a5795288b3de (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*******************************************************************************
 * Copyright (c) 2007, 2008, 2009 THALES GLOBAL SERVICES.
 * 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:
 *    Obeo - initial API and implementation
 *******************************************************************************/
package org.eclipse.sirius.diagram.ui.edit.api.part;

import org.eclipse.sirius.diagram.ui.internal.edit.parts.BundledImageEditPart;
import org.eclipse.sirius.diagram.ui.internal.edit.parts.CustomStyleEditPart;
import org.eclipse.sirius.diagram.ui.internal.edit.parts.DotEditPart;
import org.eclipse.sirius.diagram.ui.internal.edit.parts.GaugeCompositeEditPart;
import org.eclipse.sirius.diagram.ui.internal.edit.parts.NoteEditPart;
import org.eclipse.sirius.diagram.ui.internal.edit.parts.SquareEditPart;
import org.eclipse.sirius.diagram.ui.internal.edit.parts.WorkspaceImageEditPart;

/**
 * Useful operations for edit part.
 * 
 * @author ymortier
 */
public final class DesignerEditPartHelper {

    /**
     * Avoid instantiation
     */
    private DesignerEditPartHelper() {

    }

    /**
     * Returns <code>true</code> if the <code>visualId</code> is the type of
     * <code>BundledImage</code>.
     * 
     * @param visualId
     *            the visual id.
     * @return <code>true</code> if the <code>visualId</code> is the type of
     *         <code>BundledImage</code>.
     */
    public static boolean isBundledImaged(final int visualId) {
        return BundledImageEditPart.VISUAL_ID == visualId;
    }

    /**
     * Returns <code>true</code> if the <code>visualId</code> is the type of
     * <code>CustomStyle</code>.
     * 
     * @param visualId
     *            the visual id.
     * @return <code>true</code> if the <code>visualId</code> is the type of
     *         <code>CustomStyle</code>.
     */
    public static boolean isCustomStyle(final int visualId) {
        return CustomStyleEditPart.VISUAL_ID == visualId;
    }

    /**
     * Returns <code>true</code> if the <code>visualId</code> is the type of
     * <code>Dot</code>.
     * 
     * @param visualId
     *            the visual id.
     * @return <code>true</code> if the <code>visualId</code> is the type of
     *         <code>Dot</code>.
     */
    public static boolean isDot(final int visualId) {
        return DotEditPart.VISUAL_ID == visualId;
    }

    /**
     * Returns <code>true</code> if the <code>visualId</code> is the type of
     * <code>GaugeCompositeStyle</code>.
     * 
     * @param visualId
     *            the visual id.
     * @return <code>true</code> if the <code>visualId</code> is the type of
     *         <code>GaugeCompositeStyle</code>.
     */
    public static boolean isGaugeCompositeStyle(final int visualId) {
        return GaugeCompositeEditPart.VISUAL_ID == visualId;
    }

    /**
     * Returns <code>true</code> if the <code>visualId</code> is the type of
     * <code>Note</code>.
     * 
     * @param visualId
     *            the visual id.
     * @return <code>true</code> if the <code>visualId</code> is the type of
     *         <code>Note</code>.
     */
    public static boolean isNote(final int visualId) {
        return NoteEditPart.VISUAL_ID == visualId;
    }

    /**
     * Returns <code>true</code> if the <code>visualId</code> is the type of
     * <code>Square</code>.
     * 
     * @param visualId
     *            the visual id.
     * @return <code>true</code> if the <code>visualId</code> is the type of
     *         <code>Square</code>.
     */
    public static boolean isSquare(final int visualId) {
        return SquareEditPart.VISUAL_ID == visualId;
    }

    /**
     * Returns <code>true</code> if the <code>visualId</code> is the type of
     * <code>WorkspaceImage</code>.
     * 
     * @param visualId
     *            the visual id.
     * @return <code>true</code> if the <code>visualId</code> is the type of
     *         <code>WorkspaceImage</code>.
     */
    public static boolean isWorkspaceImage(final int visualId) {
        return WorkspaceImageEditPart.VISUAL_ID == visualId;
    }

    /**
     * Returns <code>true</code> if the <code>visualId</code> is the type of a
     * Node Style.
     * 
     * @param visualId
     *            the visual id.
     * @return <code>true</code> if the <code>visualId</code> is the type of a
     *         Node Style.
     */
    public static boolean isNodeStyle(final int visualId) {

        final boolean isImage = DesignerEditPartHelper.isBundledImaged(visualId) || DesignerEditPartHelper.isWorkspaceImage(visualId);
        final boolean isStyle = DesignerEditPartHelper.isGaugeCompositeStyle(visualId) || DesignerEditPartHelper.isCustomStyle(visualId);
        final boolean isPredefinedFigure = DesignerEditPartHelper.isDot(visualId) || DesignerEditPartHelper.isNote(visualId) || DesignerEditPartHelper.isSquare(visualId);

        return isImage || isStyle || isPredefinedFigure;
    }

}

Back to the top