blob: 3be6c88c432cc6963e1ac0099093be8d2c1c000b (
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
|
/*******************************************************************************
* Copyright (c) 2010, 2011 THALES GLOBAL SERVICES.
* 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.internal.outline;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.sirius.diagram.ui.part.SiriusDiagramEditor;
import org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramEditorImpl;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PlatformUI;
/**
* This action will display a quick outline view within a text popup menu.
*
* @author nlepine
*
*/
public class QuickOutlineAction extends Action implements IWorkbenchWindowActionDelegate, IObjectActionDelegate {
/**
* {@inheritDoc}
*
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
*/
@Override
public void dispose() {
// No disposal needed here
}
/**
* {@inheritDoc}
*
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
*/
@Override
public void init(IWorkbenchWindow window) {
// no initialization required
}
/**
* {@inheritDoc}
*
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
super.run();
DDiagramEditorImpl currentEditor = getCurrentEditor();
if (currentEditor != null) {
SiriusInformationPresenter presenter = currentEditor.getQuickOutlinePresenter();
presenter.showInformation();
}
}
/**
* {@inheritDoc}
*
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
* org.eclipse.jface.viewers.ISelection)
*/
@Override
public void selectionChanged(IAction action, ISelection selection) {
// We don't need to react to selection changes
}
/**
* Returns the currently active editor if it's an SiriusDiagramEditor.
*
* @return The currently active editor if it's an SiriusDiagramEditor,
* <code>null</code> otherwise.
*/
protected DDiagramEditorImpl getCurrentEditor() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null && window.getActivePage() != null && window.getActivePage().getActiveEditor() instanceof SiriusDiagramEditor) {
return (DDiagramEditorImpl) window.getActivePage().getActiveEditor();
}
return null;
}
/**
* Empty. {@inheritDoc}
*
* @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction,
* org.eclipse.ui.IWorkbenchPart)
*/
@Override
public void setActivePart(final IAction action, final IWorkbenchPart targetPart) {
// empty.
}
}
|