Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1581f628c2a67e5aee6fa70559f9c9bec215ca64 (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
package org.eclipse.debug.internal.ui;

/*
 * Licensed Materials - Property of IBM,
 * WebSphere Studio Workbench
 * (c) Copyright IBM Corp 2000
 */

import org.eclipse.debug.ui.IDebugModelPresentation;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.StructuredViewer;

/**
 * An action that toggles the state of its viewer to
 * show/hide qualified names.
 */
public class ShowQualifiedAction extends Action {

	private static final String PREFIX= "show_qualified_action.";
	private static final String SHOW= PREFIX + TOOL_TIP_TEXT + ".show";
	private static final String HIDE= PREFIX + TOOL_TIP_TEXT + ".hide";

	protected StructuredViewer fViewer;

	public ShowQualifiedAction(StructuredViewer viewer) {
		super(DebugUIUtils.getResourceString(SHOW));
		fViewer= viewer;
		setToolTipText(DebugUIUtils.getResourceString(SHOW));
	}

	/**
	 * @see Action
	 */
	public void run() {
		valueChanged(isChecked());
	}

	private void valueChanged(boolean on) {
		ILabelProvider labelProvider= (ILabelProvider)fViewer.getLabelProvider();
		if (labelProvider instanceof IDebugModelPresentation) {
			IDebugModelPresentation debugLabelProvider= (IDebugModelPresentation)labelProvider;
			debugLabelProvider.setAttribute(IDebugModelPresentation.DISPLAY_QUALIFIED_NAMES, (on ? Boolean.TRUE : Boolean.FALSE));
			fViewer.refresh();
		}
		setToolTipText(on ? DebugUIUtils.getResourceString(HIDE) : DebugUIUtils.getResourceString(SHOW));

	}

	/**
	 * @see Action
	 */
	public void setChecked(boolean value) {
		super.setChecked(value);
		valueChanged(value);
	}
}

Back to the top