Author: snjeza
Date: 2011-11-07 10:40:28 -0500 (Mon, 07 Nov 2011)
New Revision: 36194
Modified:
trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/plugin.xml
trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/src/org/jboss/tools/common/jdt/debug/ui/RemoteDebugUIActivator.java
trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/src/org/jboss/tools/common/jdt/debug/ui/actions/RemoteLaunchAction.java
trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/src/org/jboss/tools/common/jdt/debug/ui/launching/LaunchRemoteApplicationDialog.java
trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/src/org/jboss/tools/common/jdt/debug/ui/preferences/RemoteDebugPreferencePage.java
Log:
JBIDE-9658 jboss remote launch debug have a badly/noninformative preference on launch
configuration + error in logs
Modified: trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/plugin.xml
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/plugin.xml 2011-11-07
15:14:28 UTC (rev 36193)
+++ trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/plugin.xml 2011-11-07
15:40:28 UTC (rev 36194)
@@ -2,6 +2,7 @@
<?eclipse version="3.4"?>
<plugin>
+ <!--
<extension
point="org.eclipse.debug.ui.launchConfigurationTabGroups">
<launchConfigurationTabGroup
type="org.eclipse.jdt.launching.remoteJavaApplication"
@@ -10,7 +11,7 @@
id="org.jboss.tools.common.jdt.debug.ui.launching.launchConfigurationTabGroup.JBossRemoteJavaApplication2">
</launchConfigurationTabGroup>
</extension>
- <!--
+
<extension
point="org.eclipse.debug.ui.launchConfigurationTabGroups">
<launchConfigurationTabGroup
Modified:
trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/src/org/jboss/tools/common/jdt/debug/ui/RemoteDebugUIActivator.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/src/org/jboss/tools/common/jdt/debug/ui/RemoteDebugUIActivator.java 2011-11-07
15:14:28 UTC (rev 36193)
+++
trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/src/org/jboss/tools/common/jdt/debug/ui/RemoteDebugUIActivator.java 2011-11-07
15:40:28 UTC (rev 36194)
@@ -25,6 +25,7 @@
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.model.IPersistableSourceLocator;
@@ -68,6 +69,7 @@
private static final String KEY_SEQUENCE_PREFIX = "M1+D ";
public static final String DISCOVER_REMOTE_APPLICATION_ACTION_ID =
"org.jboss.tools.common.jdt.debug.ui.discover";
+ public static final String REMOTE_DEBUG_PREFERENCE_PAGE_ID =
"org.jboss.tools.common.jdt.debug.ui.preferences.RemoteDebugPreferencePage";
// The shared instance
private static RemoteDebugUIActivator plugin;
private static VmModel[] vmModels;
@@ -338,4 +340,15 @@
}
return null;
}
+
+ public static ILaunchManager getLaunchManager() {
+ return DebugPlugin.getDefault().getLaunchManager();
+ }
+
+ public static ILaunchConfigurationType getRemoteJavaApplicationConfigurationType() {
+ ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType type = manager
+ .getLaunchConfigurationType(RemoteDebugActivator.REMOTE_JAVA_APPLICATION_ID);
+ return type;
+ }
}
Modified:
trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/src/org/jboss/tools/common/jdt/debug/ui/actions/RemoteLaunchAction.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/src/org/jboss/tools/common/jdt/debug/ui/actions/RemoteLaunchAction.java 2011-11-07
15:14:28 UTC (rev 36193)
+++
trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/src/org/jboss/tools/common/jdt/debug/ui/actions/RemoteLaunchAction.java 2011-11-07
15:40:28 UTC (rev 36194)
@@ -141,7 +141,7 @@
setAttribute(wc);
wc.doSave();
} else {
- ILaunchConfigurationType configType = getConfigurationType();
+ ILaunchConfigurationType configType =
RemoteDebugUIActivator.getRemoteJavaApplicationConfigurationType();
wc = RemoteDebugActivator.createNewLaunchConfiguration(configType);
}
if (javaProject != null && javaProject.isOpen()) {
@@ -179,15 +179,4 @@
attrMap);
}
- private ILaunchManager getLaunchManager() {
- return DebugPlugin.getDefault().getLaunchManager();
- }
-
- private ILaunchConfigurationType getConfigurationType() {
- ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType type = manager
- .getLaunchConfigurationType(RemoteDebugActivator.REMOTE_JAVA_APPLICATION_ID);
- return type;
- }
-
}
Modified:
trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/src/org/jboss/tools/common/jdt/debug/ui/launching/LaunchRemoteApplicationDialog.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/src/org/jboss/tools/common/jdt/debug/ui/launching/LaunchRemoteApplicationDialog.java 2011-11-07
15:14:28 UTC (rev 36193)
+++
trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/src/org/jboss/tools/common/jdt/debug/ui/launching/LaunchRemoteApplicationDialog.java 2011-11-07
15:40:28 UTC (rev 36194)
@@ -8,6 +8,7 @@
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ColumnLayoutData;
import org.eclipse.jface.viewers.ColumnWeightData;
@@ -29,6 +30,8 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.dialogs.WorkbenchPreferenceDialog;
import org.jboss.tools.common.jdt.debug.RemoteDebugActivator;
import org.jboss.tools.common.jdt.debug.VmModel;
import org.jboss.tools.common.jdt.debug.ui.RemoteDebugUIActivator;
@@ -296,7 +299,13 @@
@Override
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.YES_ID) {
- new LaunchDialogAction().run();
+ //new LaunchDialogAction().run();
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getShell();
+ PreferenceDialog dialog = WorkbenchPreferenceDialog.createDialogOn(
+ shell,
+ RemoteDebugUIActivator.REMOTE_DEBUG_PREFERENCE_PAGE_ID);
+ dialog.open();
configureCombo();
} else {
super.buttonPressed(buttonId);
Modified:
trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/src/org/jboss/tools/common/jdt/debug/ui/preferences/RemoteDebugPreferencePage.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/src/org/jboss/tools/common/jdt/debug/ui/preferences/RemoteDebugPreferencePage.java 2011-11-07
15:14:28 UTC (rev 36193)
+++
trunk/common/plugins/org.jboss.tools.common.jdt.debug.ui/src/org/jboss/tools/common/jdt/debug/ui/preferences/RemoteDebugPreferencePage.java 2011-11-07
15:40:28 UTC (rev 36194)
@@ -1,24 +1,49 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2011 Red Hat, Inc. 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:
+ * JBoss by Red Hat - Initial implementation.
+ ************************************************************************************/
package org.jboss.tools.common.jdt.debug.ui.preferences;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationListener;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.internal.ui.DebugPluginImages;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension;
+import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ColumnLayoutData;
-import org.eclipse.jface.viewers.ColumnViewerEditor;
-import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
-import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.TableViewerEditor;
-import org.eclipse.jface.viewers.TableViewerFocusCellManager;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -26,31 +51,97 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.jboss.tools.common.jdt.debug.ui.Messages;
+import org.jboss.tools.common.jdt.debug.RemoteDebugActivator;
import org.jboss.tools.common.jdt.debug.ui.RemoteDebugUIActivator;
+/**
+ *
+ * @author snjeza
+ *
+ */
public class RemoteDebugPreferencePage extends PreferencePage implements
IWorkbenchPreferencePage {
-// private Image checkboxOn;
-// private Image checkboxOff;
-// private Image errorIcon;
-// private RemoteDebug[] remoteDebugs;
-// private TableViewer viewer;
-// private Button discoverButton;
+ private static final String ADD_ALL = " Add All>> ";
+ private static final String ADD = " Add>> ";
+ private static final String REMOVE_ALL = " <<Remove All ";
+ private static final String REMOVE = " <Remove ";
private Button autoConnectButton;
-
+ private Button removeButton;
+ private Button removeAllButton;
+ private Button addButton;
+ private Button addAllButton;
+ private ListViewer eclipseConfigurationsViewer;
+ private ListViewer jbossConfigurationsViewer;
+ private Set<ILaunchConfiguration> jbossConfigurations = new
HashSet<ILaunchConfiguration>();
+ private Set<ILaunchConfiguration> eclipseConfigurations = new
HashSet<ILaunchConfiguration>();
+ private Set<ILaunchConfiguration> selectedEclipseConfigurations = new
HashSet<ILaunchConfiguration>();
+ private Set<ILaunchConfiguration> selectedJBossConfigurations = new
HashSet<ILaunchConfiguration>();
+
+ private ILaunchConfigurationListener launchConfigurationListener = new
ILaunchConfigurationListener() {
+
+ private void updateLaunchConfiguration(ILaunchConfiguration configuration) {
+ try {
+ if (!RemoteDebugActivator.REMOTE_JAVA_APPLICATION_ID
+ .equals(configuration.getType().getIdentifier())) {
+ return;
+ }
+ refreshConfigurations();
+ eclipseConfigurationsViewer.setInput(eclipseConfigurations.toArray(new
ILaunchConfiguration[0]));
+ jbossConfigurationsViewer.setInput(jbossConfigurations.toArray(new
ILaunchConfiguration[0]));
+ } catch (CoreException e) {
+ RemoteDebugUIActivator.log(e);
+ }
+ }
+ @Override
+ public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
+ updateLaunchConfiguration(configuration);
+ }
+
+ @Override
+ public void launchConfigurationChanged(ILaunchConfiguration configuration) {
+ updateLaunchConfiguration(configuration);
+ }
+
+ @Override
+ public void launchConfigurationAdded(ILaunchConfiguration configuration) {
+ updateLaunchConfiguration(configuration);
+ }
+ };
+
@Override
public void init(IWorkbench workbench) {
-// remoteDebugs = RemoteDebugUIActivator.getDefault().getRemoteDebugs();
-// checkboxOn =
RemoteDebugUIActivator.imageDescriptorFromPlugin(RemoteDebugUIActivator.PLUGIN_ID,
"/icons/xpl/complete_tsk.gif").createImage();
-// checkboxOff =
RemoteDebugUIActivator.imageDescriptorFromPlugin(RemoteDebugUIActivator.PLUGIN_ID,
"/icons/xpl/incomplete_tsk.gif").createImage();
-// errorIcon =
RemoteDebugUIActivator.imageDescriptorFromPlugin(RemoteDebugUIActivator.PLUGIN_ID,
"/icons/xpl/error_tsk.gif").createImage();
+ DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(launchConfigurationListener);
}
+ protected void refreshConfigurations() {
+ ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType type =
manager.getLaunchConfigurationType(RemoteDebugActivator.REMOTE_JAVA_APPLICATION_ID);
+ jbossConfigurations.clear();
+ eclipseConfigurations.clear();
+ try {
+ ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
+ for (ILaunchConfiguration config:configs) {
+ if (config.getAttribute(RemoteDebugActivator.JBOSS_REMOTE_JAVA_APPLICATION, false))
{
+ jbossConfigurations.add(config);
+ } else {
+ eclipseConfigurations.add(config);
+ }
+ }
+ } catch (CoreException e) {
+ RemoteDebugUIActivator.log(e);
+ }
+ eclipseConfigurationsViewer.setInput(eclipseConfigurations.toArray(new
ILaunchConfiguration[0]));
+ jbossConfigurationsViewer.setInput(jbossConfigurations.toArray(new
ILaunchConfiguration[0]));
+ selectedJBossConfigurations.clear();
+ selectedEclipseConfigurations.clear();
+ eclipseConfigurationsViewer.setSelection(new
StructuredSelection(selectedEclipseConfigurations));
+ jbossConfigurationsViewer.setSelection(new
StructuredSelection(selectedJBossConfigurations));
+ configureButtons();
+ }
+
@Override
protected Control createContents(Composite parent) {
initializeDialogUnits(parent);
@@ -60,173 +151,242 @@
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
composite.setLayout(layout);
-// Group group = new Group(composite, SWT.NONE);
-// GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
-// group.setLayoutData(gd);
-// layout = new GridLayout(1, false);
-// group.setLayout(layout);
-// group.setText("Key Bindings");
-//
-// viewer = new TableViewer(group, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL
-// | SWT.V_SCROLL | SWT.BORDER);
-// gd = new GridData(GridData.FILL_BOTH);
-// gd.heightHint = 250;
-// viewer.getTable().setLayoutData(gd);
-//
-// Table table = viewer.getTable();
-// table.setHeaderVisible(true);
-// table.setLinesVisible(true);
-// table.setFont(parent.getFont());
-//
-// viewer.setContentProvider(new RemoteDebugContentProvider());
-//
-// String[] columnHeaders = {"Key", "Description", "Port",
"Show"};
-//
-// for (int i = 0; i < columnHeaders.length; i++) {
-// TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
-// column.setLabelProvider(new RemoteDebugLabelProvider(i));
-// column.getColumn().setText(columnHeaders[i]);
-// column.getColumn().setResizable(true);
-// column.getColumn().setMoveable(true);
-// column.setEditingSupport(new RemoteDebugEditingSupport(viewer, i));
-//
-// }
-//
-// ColumnLayoutData[] remoteDebugLayouts= {
-// new ColumnWeightData(150,150),
-// new ColumnWeightData(250,250),
-// new ColumnWeightData(80,80),
-// new ColumnWeightData(60,60),
-// };
-//
-// TableLayout tableLayout = new AutoResizeTableLayout(table);
-// for (int i = 0; i < remoteDebugLayouts.length; i++) {
-// tableLayout.addColumnData(remoteDebugLayouts[i]);
-// }
-//
-// viewer.getTable().setLayout(tableLayout);
-//
-// TableViewerFocusCellManager focusCellManager = new
TableViewerFocusCellManager(viewer, new FocusCellOwnerDrawHighlighter(viewer));
-//
-// ColumnViewerEditorActivationStrategy actSupport = new
ColumnViewerEditorActivationStrategy(viewer) {
-// protected boolean isEditorActivationEvent(
-// ColumnViewerEditorActivationEvent event) {
-// ViewerCell cell = viewer.getColumnViewerEditor().getFocusCell();
-// if (cell != null && cell.getColumnIndex() == 1) {
-// return super.isEditorActivationEvent(event);
-// }
-// return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
-// || event.eventType ==
ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
-// || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED &&
event.keyCode == SWT.CR)
-// || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
-// }
-// };
-//
-// TableViewerEditor.create(viewer, focusCellManager, actSupport,
ColumnViewerEditor.TABBING_HORIZONTAL
-// | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
-// | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);
-//
-// viewer.setInput(remoteDebugs);
-//
-// discoverButton = new Button(composite, SWT.CHECK);
-// discoverButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-// discoverButton.setSelection(RemoteDebugUIActivator.getDefault().isDiscoverRemoteApplication());
-// discoverButton.setText(Messages.Discover_Remote_Applications);
-//
-// createNoteComposite(composite.getFont(), composite, "Note:",
-// "It may take some time to discover remote applications.");
autoConnectButton = new Button(composite, SWT.CHECK);
autoConnectButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
autoConnectButton.setSelection(RemoteDebugUIActivator.getDefault().isAutoConnect());
autoConnectButton.setText("Automatically connect if only one application
found");
+ Group remoteConfigurationsGroup = new Group(composite, SWT.NONE);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ layout = new GridLayout(3, false);
+ remoteConfigurationsGroup.setLayout(layout);
+ remoteConfigurationsGroup.setLayoutData(gd);
+ remoteConfigurationsGroup.setText("Remote Configurations");
+
+ Composite eclipseConfigurationsComposite = new
Composite(remoteConfigurationsGroup, SWT.NONE);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ eclipseConfigurationsComposite.setLayoutData(gd);
+ eclipseConfigurationsComposite.setLayout(new GridLayout(1, false));
+
+ Label eclipseConfigurationLabel = new Label(eclipseConfigurationsComposite,
SWT.NONE);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ eclipseConfigurationLabel.setLayoutData(gd);
+ eclipseConfigurationLabel.setText("Eclipse Remote Java
Configurations:");
+
+ eclipseConfigurationsViewer = new ListViewer(eclipseConfigurationsComposite,
SWT.BORDER | SWT.MULTI);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gd.heightHint = 300;
+
+ eclipseConfigurationsViewer.getList().setLayoutData(gd);
+ eclipseConfigurationsViewer.setContentProvider(new ArrayContentProvider());
+ eclipseConfigurationsViewer.setLabelProvider(new
RemoteConfigurationsLabelProvider());
+
+ Composite buttonsComposite = new Composite(remoteConfigurationsGroup, SWT.NONE);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ buttonsComposite.setLayoutData(gd);
+ buttonsComposite.setLayout(new GridLayout(1, false));
+
+ Label buttonsLabel = new Label(buttonsComposite, SWT.NONE);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ buttonsLabel.setLayoutData(gd);
+
+ Composite buttonsComp = new Composite(buttonsComposite, SWT.NONE);
+ gd = new GridData(SWT.FILL, SWT.FILL, false, true);
+ buttonsComp.setLayoutData(gd);
+ buttonsComp.setLayout(new GridLayout());
+
+ GC gc = new GC(buttonsComp);
+ int maxAddRemoveButtonsWidth = computeMaxAddRemoveButtonsWidth(gc);
+ gc.dispose();
+
+ removeButton = createButton(buttonsComp, maxAddRemoveButtonsWidth, REMOVE);
+ removeAllButton = createButton(buttonsComp, maxAddRemoveButtonsWidth,
REMOVE_ALL);
+ addButton = createButton(buttonsComp, maxAddRemoveButtonsWidth, ADD);
+ addAllButton = createButton(buttonsComp, maxAddRemoveButtonsWidth, ADD_ALL);
+
+ Composite jbossConfigurationsComposite = new Composite(remoteConfigurationsGroup,
SWT.NONE);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ jbossConfigurationsComposite.setLayoutData(gd);
+ jbossConfigurationsComposite.setLayout(new GridLayout());
+
+ Label jbossConfigurationLabel = new Label(jbossConfigurationsComposite,
SWT.NONE);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ jbossConfigurationLabel.setLayoutData(gd);
+ jbossConfigurationLabel.setText("JBoss Remote Java Configurations:");
+
+ jbossConfigurationsViewer = new ListViewer(jbossConfigurationsComposite,
SWT.BORDER | SWT.MULTI);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, false);
+ gd.heightHint = 300;
+ jbossConfigurationsViewer.getList().setLayoutData(gd);
+ jbossConfigurationsViewer.setContentProvider(new ArrayContentProvider());
+ jbossConfigurationsViewer.setLabelProvider(new
RemoteConfigurationsLabelProvider());
+
+ Button remoteConfigurationButton = new Button(composite, SWT.PUSH);
+ remoteConfigurationButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.FILL, true,
false));
+ remoteConfigurationButton.setText("Configure Remote Java Application...");
+ remoteConfigurationButton.setImage(DebugPluginImages
+ .getImage(IDebugUIConstants.IMG_ACT_DEBUG));
+ remoteConfigurationButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ DebugPlugin.getDefault().getLaunchManager().removeLaunchConfigurationListener(launchConfigurationListener);
+ LaunchConfigurationManager lcManager =
DebugUIPlugin.getDefault().getLaunchConfigurationManager();
+ LaunchGroupExtension group =
lcManager.getLaunchGroup(RemoteDebugActivator.LAUNCH_CATEGORY);
+ LaunchConfigurationsDialog dialog = new LaunchConfigurationsDialog(getShell(),
group);
+ //ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfiguration config = null;
+ if (selectedJBossConfigurations.size() > 0) {
+ config = selectedJBossConfigurations.iterator().next();
+ } else if (selectedEclipseConfigurations.size() > 0) {
+ config = selectedEclipseConfigurations.iterator().next();
+ } else if (jbossConfigurations.size() > 0) {
+ config = jbossConfigurations.iterator().next();
+ } else if (eclipseConfigurations.size() > 0) {
+ config = eclipseConfigurations.iterator().next();
+ }
+ if (config != null) {
+ IStructuredSelection selection = new StructuredSelection(config);
+ dialog.setInitialSelection(selection);
+ dialog.setOpenMode(LaunchConfigurationsDialog.LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_SELECTION);
+ } else {
+ dialog.setOpenMode(LaunchConfigurationsDialog.LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_LAST_LAUNCHED);
+ }
+ dialog.open();
+ DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(launchConfigurationListener);
+ refreshConfigurations();
+ }
+
+ });
+
+ eclipseConfigurationsViewer.addSelectionChangedListener(new
ISelectionChangedListener() {
+
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection sel = event.getSelection();
+ selectedEclipseConfigurations.clear();
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) sel;
+ Iterator iterator = selection.iterator();
+ while (iterator.hasNext()) {
+ Object object = iterator.next();
+ if (object instanceof ILaunchConfiguration) {
+ selectedEclipseConfigurations.add((ILaunchConfiguration) object);
+ }
+ }
+ }
+ configureButtons();
+ }
+ });
+ jbossConfigurationsViewer.addSelectionChangedListener(new
ISelectionChangedListener() {
+
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection sel = event.getSelection();
+ selectedJBossConfigurations.clear();
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) sel;
+ Iterator iterator = selection.iterator();
+ while (iterator.hasNext()) {
+ Object object = iterator.next();
+ if (object instanceof ILaunchConfiguration) {
+ selectedJBossConfigurations.add((ILaunchConfiguration) object);
+ }
+ }
+ }
+ configureButtons();
+ }
+ });
+
+ removeButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ changeConfigurations(selectedJBossConfigurations, false);
+ }
+
+ });
+ removeAllButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ changeConfigurations(jbossConfigurations, false);
+ }
+
+ });
+ addButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ changeConfigurations(selectedEclipseConfigurations, true);
+ }
+
+ });
+ addAllButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ changeConfigurations(eclipseConfigurations, true);
+ }
+
+ });
+ refreshConfigurations();
+
return composite;
}
- class RemoteDebugContentProvider implements IStructuredContentProvider {
+ private void configureButtons() {
+ removeButton.setEnabled(selectedJBossConfigurations.size() > 0);
+ removeAllButton.setEnabled(jbossConfigurations.size() > 0);
+ addButton.setEnabled(selectedEclipseConfigurations.size() > 0);
+ addAllButton.setEnabled(eclipseConfigurations.size() > 0);
+ }
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-
- }
+ protected Button createButton(Composite buttonsComp,
+ int maxAddRemoveButtonsWidth, String text) {
+ GridData gd;
+ Button button = new Button(buttonsComp, SWT.NONE | SWT.LEFT);
+ gd = new GridData();
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
+ gd.widthHint = maxAddRemoveButtonsWidth;
+ button.setLayoutData(gd);
+ button.setText(text);
+ return button;
+ }
- @Override
- public Object[] getElements(Object inputElement) {
- //return remoteDebugs;
- return new Object[0];
- }
+ private int computeMaxAddRemoveButtonsWidth(GC gc) {
+ int maxWidth = 0;
+
+ maxWidth = getGreaterWidth(gc,REMOVE, maxWidth);
+ maxWidth = getGreaterWidth(gc,REMOVE_ALL, maxWidth);
+ maxWidth = getGreaterWidth(gc,ADD, maxWidth);
+ maxWidth = getGreaterWidth(gc,ADD_ALL, maxWidth);
- @Override
- public void dispose() {
-
- }
-
+ return maxWidth;
}
- class RemoteDebugLabelProvider extends ColumnLabelProvider {
+ private int getGreaterWidth(GC gc, String str, int compareWidth) {
+ int greaterWidth = compareWidth;
- private int columnIndex;
-
- public RemoteDebugLabelProvider(int i) {
- this.columnIndex = i;
+ Point strExtentPoint = gc.stringExtent(str);
+ int strWidth = strExtentPoint.x;
+ if (strWidth > compareWidth) {
+ greaterWidth = strWidth;
}
- public String getText(Object element) {
- if (element instanceof RemoteDebug) {
- RemoteDebug remoteDebug = (RemoteDebug) element;
- switch (columnIndex) {
- case 0:
- return remoteDebug.getKey(true);
- case 1:
- return remoteDebug.getDescription();
- case 2:
- return remoteDebug.getPort();
- }
- }
- return null;
- }
-
- @Override
- public Image getImage(Object element) {
- if (element == null) {
- return null;
- }
- RemoteDebug remoteDebug = (RemoteDebug) element;
-// if (columnIndex == 0) {
-// return remoteDebug.isValid() ? null : errorIcon;
-// }
-// if (columnIndex == 3) {
-// return remoteDebug.isShow() ? checkboxOn : checkboxOff;
-// }
- return null;
- }
+ return greaterWidth + 5;
}
@Override
public void dispose() {
-// if (checkboxOff != null) {
-// checkboxOff.dispose();
-// }
-// if (checkboxOn != null) {
-// checkboxOn.dispose();
-// }
-// if (errorIcon != null) {
-// errorIcon.dispose();
-// }
+ DebugPlugin.getDefault().getLaunchManager().removeLaunchConfigurationListener(launchConfigurationListener);
super.dispose();
}
@Override
protected void performApply() {
IEclipsePreferences preferences =
RemoteDebugUIActivator.getDefault().getPreferences();
-// int keys = RemoteDebugUIActivator.KEYS;
-// for (int i = 0; i < keys; i++) {
-// preferences.put(RemoteDebugUIActivator.getDescriptionPreferenceName(i),
remoteDebugs[i].getDescription());
-// preferences.put(RemoteDebugUIActivator.getPortPreferenceName(i),
remoteDebugs[i].getPort());
-// preferences.putBoolean(RemoteDebugUIActivator.getShowPreferenceName(i),
remoteDebugs[i].isShow());
-// }
-// preferences.putBoolean(RemoteDebugUIActivator.DISCOVER_REMOTE_APPLICATION,
discoverButton.getSelection());
preferences.putBoolean(RemoteDebugUIActivator.AUTO_CONNECT,
autoConnectButton.getSelection());
RemoteDebugUIActivator.getDefault().savePreferences();
}
@@ -234,21 +394,7 @@
@Override
protected void performDefaults() {
IEclipsePreferences preferences =
RemoteDebugUIActivator.getDefault().getPreferences();
-
-// int keys = RemoteDebugUIActivator.KEYS;
-// for (int i = 0; i < keys; i++) {
-// preferences.put(RemoteDebugUIActivator.getDescriptionPreferenceName(i),
RemoteDebugUIActivator.DEFAULT_DESCRIPTION);
-// preferences.put(RemoteDebugUIActivator.getPortPreferenceName(i),
RemoteDebugUIActivator.DEFAULT_PORT);
-// preferences.putBoolean(RemoteDebugUIActivator.getShowPreferenceName(i),
RemoteDebugUIActivator.DEFAULT_SHOW);
-//
-// }
-// preferences.putBoolean(RemoteDebugUIActivator.DISCOVER_REMOTE_APPLICATION,
RemoteDebugUIActivator.DEFAULT_DISCOVER_REMOTE_APPLICATION);
-// RemoteDebugUIActivator.getDefault().savePreferences();
-// remoteDebugs = RemoteDebugUIActivator.getDefault().getRemoteDebugs();
-// viewer.setInput(remoteDebugs);
-// discoverButton.setSelection(RemoteDebugUIActivator.DEFAULT_DISCOVER_REMOTE_APPLICATION);
-// preferences.putBoolean(RemoteDebugUIActivator.DISCOVER_REMOTE_APPLICATION,
RemoteDebugUIActivator.DEFAULT_DISCOVER_REMOTE_APPLICATION);
-
+
autoConnectButton.setSelection(RemoteDebugUIActivator.AUTO_CONNECT_DEFAULT);
preferences.putBoolean(RemoteDebugUIActivator.AUTO_CONNECT,
RemoteDebugUIActivator.AUTO_CONNECT_DEFAULT);
RemoteDebugUIActivator.getDefault().savePreferences();
@@ -260,5 +406,34 @@
performApply();
return super.performOk();
}
+
+ protected void changeConfigurations(Set<ILaunchConfiguration> configurations,
boolean value) {
+ DebugPlugin.getDefault().getLaunchManager().removeLaunchConfigurationListener(launchConfigurationListener);
+ for (ILaunchConfiguration configuration:configurations) {
+ try {
+ ILaunchConfigurationWorkingCopy wc = configuration.getWorkingCopy();
+ wc.setAttribute(RemoteDebugActivator.JBOSS_REMOTE_JAVA_APPLICATION, value);
+ wc.doSave();
+ } catch (CoreException e) {
+ RemoteDebugUIActivator.log(e);
+ }
+ }
+ DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(launchConfigurationListener);
+ refreshConfigurations();
+ }
+ class RemoteConfigurationsLabelProvider extends LabelProvider {
+ public Image getImage(Object element) {
+ return null;
+ }
+
+ public String getText(Object element) {
+ if (element instanceof ILaunchConfiguration) {
+ ILaunchConfiguration configuration = (ILaunchConfiguration) element;
+ return configuration.getName();
+ }
+ return null;
+ }
+ }
+
}