Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1320f3291642b096dde9bc451e20e7f9e37c3393 (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
/*******************************************************************************
 * Copyright (c) 2016 IBM Corporation and others.
 * 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:
 *     IBM Corporation - initial implementation
 *******************************************************************************/
package org.eclipse.debug.internal.ui.actions.breakpointSortBy;

import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
import org.eclipse.debug.internal.ui.breakpoints.provisional.IBreakpointUIConstants;
import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsView;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;

/**
 * An action which sets the breakpoint sorting order on a breakpoint view,
 * effectively telling the view to sort breakpoints according to some sorting
 * order
 */
public class SortBreakpointsAction extends Action {

	private BreakpointsView fView;
	int actionSort;

	/**
	 * Creates a new action which will sort breakpoints in the given breakpoint
	 * view using the given breakpoint container factory
	 * 
	 * @param factory the factory that will be applied to the given view when
	 *            this action is run
	 * @param view the breakpoints view
	 */
	public SortBreakpointsAction(BreakpointsView view, String name, int sortingBy) {
		super(name, IAction.AS_RADIO_BUTTON);
		if (sortingBy == DebugUIPlugin.getDefault().getPreferenceStore().getInt(IInternalDebugUIConstants.PREF_BREAKPOINT_SORTING_ORDER)) {
			this.setChecked(true);
		}
		actionSort = sortingBy;
		fView = view;
	}

	/*
	 * (non-Javadoc)
	 * @see org.eclipse.jface.action.IAction#run()
	 */
	@Override
	public void run() {
		if (isChecked()) {
			DebugUIPlugin.getDefault().getPreferenceStore().setValue(IInternalDebugUIConstants.PREF_BREAKPOINT_SORTING_ORDER, actionSort);
		} else {
			DebugUIPlugin.getDefault().getPreferenceStore().setValue(IInternalDebugUIConstants.PREF_BREAKPOINT_SORTING_ORDER, actionSort);
		}
		// update the presentation context element comparator sorting order
		fView.getTreeModelViewer().getPresentationContext().setProperty(IBreakpointUIConstants.PROP_BREAKPOINTS_ELEMENT_COMPARATOR_SORT, new Integer(actionSort));
	}

}

Back to the top