Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: fc6e60436293052ba83217a5a76dc5b67be74b2b (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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
/*******************************************************************************
 * Copyright (c) 2015, 2018 Obeo.
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *    Obeo - initial API and implementation
 *******************************************************************************/
package org.eclipse.sirius.diagram.ui.tools.api.editor.tabbar;

import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.ui.tools.internal.editor.tabbar.contributions.TabbarContributionFactory;

/**
 * Abstract implementation of {@link ITabbarContributor}. Inherit from this class allows creating one or several
 * contribution items of the default Sirius tabbar.
 * 
 * @author Florian Barbin
 *
 */
public abstract class AbstractTabbarContributor implements ITabbarContributor {

    private TabbarContributionFactory contributorFactory = new TabbarContributionFactory();

    /**
     * Creates the Automatic Layout contribution item. Organized in a drop-down menu, this item is used to trigger an
     * automatic layout of the elements on the diagram.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem}.
     */
    protected IContributionItem createArrangeMenuManager(IDiagramWorkbenchPart part) {
        return contributorFactory.createArrangeMenuManager(part);
    }

    /**
     * Creates the Select menu manager contribution item. Organized in a drop-down menu, can be used to select groups of
     * diagram elements in a single operation.
     * 
     * @return the {@link IContributionItem}.
     */
    protected IContributionItem createSelectMenuManager() {
        return contributorFactory.createSelectMenuManager();
    }

    /**
     * Creates the Alignment contribution item. This menu contains several operations which can be used to align several
     * graphical elements in various ways.
     * 
     * @return the {@link IContributionItem}.
     */
    protected IContributionItem createAlignMenuManager() {
        return contributorFactory.createAlignMenuManager();
    }

    /**
     * Creates the Layer Selection contribution item.
     * 
     * @param part
     *            the diagram workbench part.
     * @param manager
     *            the toolbar manager.
     * 
     * @return the {@link IContributionItem}.
     */
    protected IContributionItem createLayerContribution(IDiagramWorkbenchPart part, ToolBarManager manager) {
        return contributorFactory.createLayerContribution(part, manager);
    }

    /**
     * Creates the Filter Selection contribution item.
     * 
     * @param part
     *            the diagram workbench part.
     * @param manager
     *            the toolbar manager.
     * @return the {@link IContributionItem}.
     */
    protected IContributionItem createFilterContribution(IDiagramWorkbenchPart part, ToolBarManager manager) {
        return contributorFactory.createFilterContribution(part, manager);
    }

    /**
     * Creates the Concern Selection contribution item, if needed.
     * 
     * @param part
     *            the diagram workbench part.
     * @return the {@link IContributionItem} or null of it is not needed.
     */
    protected IContributionItem createConcernContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createConcernContribution(part);
    }

    /**
     * Creates the Select Hidden Elements contribution item.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     */
    protected IContributionItem createSelectHiddenElementsContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createSelectHiddenElementsContribution(part);
    }

    /**
     * Creates the Hide Element contribution item. This button hides all the selected elements from view.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem}.
     */
    protected IContributionItem createHideElementContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createHideElementContribution(part);
    }

    /**
     * Creates the Hide Element Label contribution item. This button hides the label of the selected elements.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem}.
     */
    protected IContributionItem createHideElementLabelContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createHideElementLabelContribution(part);
    }

    /**
     * Creates the Delete From Diagram contribution item. This action removes the selected graphical element from the
     * diagram, but does not delete the corresponding semantic elements.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem}.
     */
    protected IContributionItem createDeleteFromDiagramContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createDeleteFromDiagramContribution(part);
    }

    /**
     * Creates the Delete From Model contribution item. This action removes both the selected graphical element and the
     * corresponding semantic elements.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     */
    protected IContributionItem createDeleteFromModelContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createDeleteFromModelContribution(part);
    }

    /**
     * Creates the Select Pinned elements contribution item.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     */
    protected IContributionItem createSelectPinnedElementsContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createSelectPinnedElementsContribution(part);
    }

    /**
     * Creates the Pin element contribution item. Mark all the selected elements as pinned.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem}.
     */
    protected IContributionItem createPinElementContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createPinElementContribution(part);
    }

    /**
     * Creates the Unpin element contribution item. Mark all the selected elements as un-pinned.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @param pinElementContributionItem
     *            the opposite pin contribution item. Can be null.
     * @return the {@link IContributionItem}.
     */
    protected IContributionItem createUnPinElementContribution(IDiagramWorkbenchPart part, IContributionItem pinElementContributionItem) {
        return contributorFactory.createUnPinElementContribution(part, pinElementContributionItem);
    }

    /**
     * Creates the Zoom combo contribution item.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     */
    protected IContributionItem createZoomContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createZoomContribution(part);
    }

    /**
     * Creates the Zoom-in contribution item.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     */
    protected IContributionItem createZoomInContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createZoomInContribution(part);
    }

    /**
     * Creates the Zoom-out contribution item.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     */
    protected IContributionItem createZoomOutContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createZoomOutContribution(part);
    }

    /**
     * Creates the Font Color contribution item.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     */
    protected IContributionItem createFontColorContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createFontColorContribution(part);
    }

    /**
     * Creates the Bold font contribution item.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     */
    protected IContributionItem createBoldFontStyleContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createBoldFontStyleContribution(part);
    }

    /**
     * Creates the Italic font contribution item.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     */
    protected IContributionItem createItalicFontStyleContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createItalicFontStyleContribution(part);
    }

    /**
     * Creates the Font dialog contribution item.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     */
    protected IContributionItem createFontDialogContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createFontDialogContribution(part);
    }

    /**
     * Creates the Fill Color contribution item.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     */
    protected IContributionItem createFillColorContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createFillColorContribution(part);
    }

    /**
     * Creates the Line Color contribution item.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     */
    protected IContributionItem createLineColorPropertyContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createLineColorPropertyContribution(part);
    }

    /**
     * Creates the Cancel Custom Style contribution item. The Cancel Custom Style button resets all the style attributes
     * of an element to its default values and un-marks it as customized.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     */
    protected IContributionItem createResetStylePropertyContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createResetStylePropertyContribution(part);
    }

    /**
     * Creates the set style to workspace image contribution item. The Workspace image button can be used to replace the
     * graphical representation of an element by an image that you can select from anywhere in your Eclipse workspace.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem}.
     */
    protected IContributionItem createSetStyleToWorkspaceImageContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createSetStyleToWorkspaceImageContribution(part);
    }

    /**
     * Creates the Distribute menu contribution item. This menu contains several actions which can be used to distribute
     * the selected diagram elements horizontally/vertically with a same space between their centers or their bounds.
     * 
     * @return the {@link IContributionItem}.
     */
    protected IContributionItem createDistributeContribution() {
        return contributorFactory.createDistributeContribution();
    }

    /**
     * Creates the Export As Image contribution item.This button can be used to export the current diagram as an image
     * file stored on disk.
     * 
     * @return the {@link IContributionItem}.
     */
    protected IContributionItem createSaveAsImageContributionItem() {
        return contributorFactory.createSaveAsImageContributionItem();
    }

    /**
     * Creates the Mode Menu Manager contribution item. This drop down menu contains three actions:
     * <ul>
     * <li>Standard mode: Deactivate the layouting and visibility mode if they are activated.</li>
     * <li>Visibility mode: this action shows diagram elements made invisible by user and allows to change the
     * visibility status with double click on diagram elements.</li>
     * <li>Layouting Mode: This button enables a special "layout mode", in which some operations are prevented from
     * having an effect on the semantic model.</li>
     * </ul>
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized or if the diagram
     *         doesn't allow the layouting mode.
     */
    protected IContributionItem createModeMenuManagerContributionItem(IDiagramWorkbenchPart part) {
        return contributorFactory.createModesMenuManager((DDiagram) part.getDiagram().getElement());
    }

    /**
     * Creates the Router contribution item. This action allows changing the line style of edges (Rectilinear, Oblique,
     * Tree)
     * 
     * @return the {@link IContributionItem}.
     */
    protected IContributionItem createRouterContribution() {
        return contributorFactory.createRouterContribution();
    }

    /**
     * Creates the Apply Style contribution item. Use this button to reproduce the visual style of an element onto
     * others.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     */
    protected IContributionItem createCopyAppearancePropertiesContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createCopyAppearancePropertiesContribution(part);
    }

    /**
     * Creates the copy format contribution item. This tool can be used to duplicate the format of some diagram elements
     * from this diagram into another.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     * @deprecated since 4.1.0 Use {@link #createCopyFormatContribution(IDiagramWorkbenchPart)} instead.
     */
    @Deprecated
    protected IContributionItem createCopyLayoutContribution(IDiagramWorkbenchPart part) {
        return createCopyFormatContribution(part);
    }

    /**
     * Creates the copy format contribution item. This tool can be used to duplicate the format of some diagram elements
     * from this diagram into another.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     */
    protected IContributionItem createCopyFormatContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createCopyFormatContribution(part);
    }

    /**
     * Creates the Paste Format contribution item.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     * @deprecated since 4.1.0 Use {@link #createPasteFormatContribution(IDiagramWorkbenchPart)} instead.
     */
    @Deprecated
    protected IContributionItem createPasteLayoutContribution(IDiagramWorkbenchPart part) {
        return createPasteFormatContribution(part);
    }

    /**
     * Creates the Paste Format contribution item.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     */
    protected IContributionItem createPasteFormatContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createPasteFormatContribution(part);
    }

    /**
     * Creates the Refresh action contribution item. This operation, which can also be invoked with the F5 keyboard
     * shortcut, will force an update of the diagram's content according to the latest version of the underlying
     * semantic model.
     * 
     * @return the {@link IContributionItem}.
     */
    protected IContributionItem createRefreshContribution() {
        return contributorFactory.createRefreshContribution();
    }

    /**
     * Creates the Make Same Size contribution item. When multiple elements are selected, clicking on this tool will
     * resize all of them to have the same size (both width and height).
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     */
    protected IContributionItem createSizeBothContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createSizeBothContribution(part);
    }

    /**
     * Creates the Auto-Size contribution item. This button marks the selected elements as auto-sized.
     * 
     * @param part
     *            the current IDiagramWorkbenchPart.
     * @return the {@link IContributionItem} or null if the workbench part is being initialized.
     */
    protected IContributionItem createAutoSizeContribution(IDiagramWorkbenchPart part) {
        return contributorFactory.createAutoSizeContribution(part);
    }

    /**
     * Creates the straighten to contribution item. This menu contains several operations which can be used to
     * straighten to different positions edges.
     * 
     * @return the {@link IContributionItem}.
     */
    protected IContributionItem createStraightenContribution() {
        return contributorFactory.createStraightenContribution();
    }
}

Back to the top