Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 8985cfbd2ee58ed09683951fd10d8fba21d25297 (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
/*******************************************************************************
 * Copyright (c) 2000, 2012 IBM Corporation and others.
 *
 * 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:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.debug.internal.ui.views.launch;

import org.eclipse.debug.internal.core.IInternalDebugCoreConstants;
import org.eclipse.debug.internal.ui.DebugPluginImages;
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.action.Action;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.PlatformUI;

/**
 * Action that controls the view mode for Debug view (auto vs. breadcrumb, vs.
 * tree view).
 *
 * @since 3.5
 */
class DebugViewModeAction extends Action {

	private final LaunchView fLaunchView;
	private final Composite fParent;
	private final String fMode;

	/**
	 * Creates a new action to set the debug view mode.
	 *
	 * @param view Reference to the debug view.
	 * @param mode The mode to be set by this action.
	 * @param parent The view's parent control used to calculate view size
     * in auto mode.
	 */
	public DebugViewModeAction(LaunchView view, String mode, Composite parent) {
		super(IInternalDebugCoreConstants.EMPTY_STRING, AS_RADIO_BUTTON);
		fLaunchView = view;
		fParent = parent;
		fMode = mode;

		if (mode == IDebugPreferenceConstants.DEBUG_VIEW_MODE_AUTO) {
			setText(LaunchViewMessages.DebugViewModeAction_Auto_label);
			setToolTipText(LaunchViewMessages.DebugViewModeAction_Auto_tooltip);
			setImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_DETAIL_PANE_AUTO));
			setHoverImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_DETAIL_PANE_AUTO));
			setDescription(LaunchViewMessages.DebugViewModeAction_Auto_description);
			PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.DEBUG_VIEW_MODE_AUTO_ACTION);
		} else if (mode == IDebugPreferenceConstants.DEBUG_VIEW_MODE_FULL) {
			setText(LaunchViewMessages.DebugViewModeAction_Full_label);
			setToolTipText(LaunchViewMessages.DebugViewModeAction_Full_tooltip);
			setImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_DETAIL_PANE_HIDE));
			setHoverImageDescriptor(DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_DETAIL_PANE_HIDE));
			setDescription(LaunchViewMessages.DebugViewModeAction_Full_description);
			PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.DEBUG_VIEW_MODE_FULL_ACTION);
		} else {
			setText(LaunchViewMessages.DebugViewModeAction_Compact_label);
			setToolTipText(LaunchViewMessages.DebugViewModeAction_Compact_tooltip);
			setDescription(LaunchViewMessages.DebugViewModeAction_Compact_description);
			setImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_DEBUG_VIEW_COMPACT_LAYOUT));
			setHoverImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_DEBUG_VIEW_COMPACT_LAYOUT));
			PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.DEBUG_VIEW_MODE_COMPACT_ACTION);
		}
	}

	/* (non-Javadoc)
	 * @see org.eclipse.jface.action.IAction#run()
	 */
	@Override
	public void run() {
		fLaunchView.setViewMode(fMode, fParent);
	}

	/**
	 * Returns the view mode set by this action.
	 * @return the mode of the action
	 */
	public String getMode() {
	    return fMode;
	}
}

Back to the top