Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: c857d3fc94d2663c6d9da1b9e2c5d40190903b89 (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
/*******************************************************************************
 * Copyright (c) 2006, 2013 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 API and implementation
 *******************************************************************************/
package org.eclipse.debug.internal.ui.actions.breakpointGroups;

import java.util.ArrayList;

import org.eclipse.debug.internal.ui.AbstractDebugCheckboxSelectionDialog;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.PlatformUI;

/**
 * Dialog to allow the selection of working sets without all of the overhead of the
 * platform UI working set dialog
 *
 * @since 3.3
 */
public class SelectBreakpointWorkingsetDialog extends AbstractDebugCheckboxSelectionDialog {

	private static final String SETTINGS_ID = DebugUIPlugin.getUniqueIdentifier() + ".DELETE_ASSOCIATED_CONFIGS_DIALOG"; //$NON-NLS-1$
	private IWorkingSet[] fWorkingSetList = null;

	/**
	 * Constructor
	 * @param parentShell the parent to open this dialog on
	 */
	protected SelectBreakpointWorkingsetDialog(Shell parentShell) {
		super(parentShell);
		fWorkingSetList = getBreakpointWorkingSets();
	}

	/* (non-Javadoc)
	 * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugCheckboxSelectionDialog#addViewerListeners(org.eclipse.jface.viewers.StructuredViewer)
	 */
	@Override
	protected void addViewerListeners(StructuredViewer viewer) {
		CheckboxTableViewer checkViewer = getCheckBoxTableViewer();
		if (checkViewer != null){
			checkViewer.addCheckStateListener(new ICheckStateListener(){
				@Override
				public void checkStateChanged(CheckStateChangedEvent event) {
					getCheckBoxTableViewer().setCheckedElements(new Object[] {event.getElement()});
					getButton(IDialogConstants.OK_ID).setEnabled(true);
				}
			});
		}
	}

	/**
	 * Returns the current listing of breakpoint <code>IWorkingSet</code>s
	 * @return an array of the current breakpoint <code>IWorkingSet</code>s
	 */
	private IWorkingSet[] getBreakpointWorkingSets() {
		IWorkingSet[] ws = PlatformUI.getWorkbench().getWorkingSetManager().getAllWorkingSets();
		ArrayList<IWorkingSet> list = new ArrayList<>();
		for(int i = 0; i < ws.length; i++) {
			if(IDebugUIConstants.BREAKPOINT_WORKINGSET_ID.equals(ws[i].getId())) {
				list.add(ws[i]);
			}
		}
		return list.toArray(new IWorkingSet[list.size()]);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getViewerInput()
	 */
	@Override
	protected Object getViewerInput() {
		return fWorkingSetList;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getDialogSettingsId()
	 */
	@Override
	protected String getDialogSettingsId() {
		return SETTINGS_ID;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getHelpContextId()
	 */
	@Override
	protected String getHelpContextId() {
		return IDebugHelpContextIds.SELECT_DEFAULT_WORKINGSET_DIALOG;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getViewerLabel()
	 */
	@Override
	protected String getViewerLabel() {
		return BreakpointGroupMessages.SelectBreakpointWorkingsetDialog_0;
	}

}

Back to the top