Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectFavoritesDialog.java')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectFavoritesDialog.java156
1 files changed, 156 insertions, 0 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectFavoritesDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectFavoritesDialog.java
new file mode 100644
index 000000000..d812bbe4b
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectFavoritesDialog.java
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.launchConfigurations;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
+import org.eclipse.debug.internal.ui.SWTFactory;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.model.WorkbenchViewerComparator;
+
+import com.ibm.icu.text.MessageFormat;
+
+/**
+ * This dialog is used to select one or more launch configurations to add to your favorites
+ *
+ * @since 3.3.0
+ */
+public class SelectFavoritesDialog extends AbstractDebugCheckboxSelectionDialog {
+
+ /**
+ * Content provider for table
+ */
+ protected class LaunchConfigurationContentProvider implements IStructuredContentProvider {
+ public Object[] getElements(Object inputElement) {
+ ILaunchConfiguration[] all = null;
+ try {
+ all = LaunchConfigurationManager.filterConfigs(DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations());
+ } catch (CoreException e) {
+ DebugUIPlugin.log(e);
+ return new ILaunchConfiguration[0];
+ }
+ List list = new ArrayList(all.length);
+ ViewerFilter filter = new LaunchGroupFilter(fHistory.getLaunchGroup());
+ for (int i = 0; i < all.length; i++) {
+ if (filter.select(null, null, all[i])) {
+ list.add(all[i]);
+ }
+ }
+ list.removeAll(fCurrentFavoriteSet);
+ Object[] objs = list.toArray();
+ new WorkbenchViewerComparator().sort(getCheckBoxTableViewer(), objs);
+ return objs;
+ }
+
+ public void dispose() {}
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+ }
+
+ private LaunchHistory fHistory;
+ private List fCurrentFavoriteSet;
+
+ /**
+ * Constructor
+ * @param parentShell
+ * @param history
+ * @param favorites
+ */
+ public SelectFavoritesDialog(Shell parentShell, LaunchHistory history, List favorites) {
+ super(parentShell);
+ fHistory = history;
+ fCurrentFavoriteSet = favorites;
+ setTitle(MessageFormat.format(LaunchConfigurationsMessages.FavoritesDialog_0, new String[]{getModeLabel()}));
+ }
+
+ /**
+ * Returns a label to use for launch mode with accelerators removed.
+ *
+ * @return label to use for launch mode with accelerators removed
+ */
+ private String getModeLabel() {
+ return DebugUIPlugin.removeAccelerators(fHistory.getLaunchGroup().getLabel());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getDialogSettingsId()
+ */
+ protected String getDialogSettingsId() {
+ return IDebugUIConstants.PLUGIN_ID + ".SELECT_FAVORITESS_DIALOG"; //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getViewerInput()
+ */
+ protected Object getViewerInput() {
+ return fHistory.getLaunchGroup().getMode();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getContentProvider()
+ */
+ protected IContentProvider getContentProvider() {
+ return new LaunchConfigurationContentProvider();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getHelpContextId()
+ */
+ protected String getHelpContextId() {
+ return IDebugHelpContextIds.SELECT_FAVORITES_DIALOG;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getViewerLabel()
+ */
+ protected String getViewerLabel() {
+ return LaunchConfigurationsMessages.FavoritesDialog_7;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#addCustomFooterControls(org.eclipse.swt.widgets.Composite)
+ */
+ protected void addCustomFooterControls(Composite parent) {
+ Composite comp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL);
+ GridData gd = (GridData) comp.getLayoutData();
+ gd.horizontalAlignment = SWT.END;
+ Button button = SWTFactory.createPushButton(comp, LaunchConfigurationsMessages.SelectFavoritesDialog_0, null);
+ button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ getCheckBoxTableViewer().setAllChecked(true);
+ getOkButton().setEnabled(true);
+ }
+ });
+ button = SWTFactory.createPushButton(comp, LaunchConfigurationsMessages.SelectFavoritesDialog_1, null);
+ button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ getCheckBoxTableViewer().setAllChecked(false);
+ getOkButton().setEnabled(false);
+ }
+ });
+ }
+}

Back to the top