Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Rennie2006-03-02 17:57:33 -0500
committerMichael Rennie2006-03-02 17:57:33 -0500
commit5a00f8b7dc2ecad7c5d651bafe2d964e40da24d3 (patch)
tree719929fd67d9e6b6533f3cf4c599c081683ea399
parentb2aa9498850fb7030ec03e88feba947b035ec35b (diff)
downloadeclipse.platform.debug-5a00f8b7dc2ecad7c5d651bafe2d964e40da24d3.tar.gz
eclipse.platform.debug-5a00f8b7dc2ecad7c5d651bafe2d964e40da24d3.tar.xz
eclipse.platform.debug-5a00f8b7dc2ecad7c5d651bafe2d964e40da24d3.zip
bug 79912 improvements
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java432
1 files changed, 123 insertions, 309 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java
index c0bd73d02..84c52430e 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java
@@ -29,7 +29,6 @@ import org.eclipse.debug.core.IStatusHandler;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
-import org.eclipse.debug.internal.ui.PixelConverter;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.IDebugView;
@@ -84,6 +83,7 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
@@ -101,12 +101,6 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
private static ILaunchConfigurationDialog fgCurrentlyVisibleLaunchConfigurationDialog;
/**
- * Default weights for the SashForm that specify how wide the selection and
- * edit areas are relative to each other.
- */
- private static final int[] DEFAULT_SASH_WEIGHTS = new int[] {11, 30};
-
- /**
* Id for 'Launch' button.
*/
protected static final int ID_LAUNCH_BUTTON = IDialogConstants.CLIENT_ID + 1;
@@ -130,18 +124,25 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
* Constant specifying how wide this dialog is allowed to get (as a percentage of
* total available screen width) as a result of tab labels in the edit area.
*/
- protected static final float MAX_DIALOG_WIDTH_PERCENT = 0.50f;
+ protected static final float MAX_DIALOG_WIDTH_PERCENT = 0.75f;
/**
* Constant specifying how tall this dialog is allowed to get (as a percentage of
* total available screen height) as a result of preferred tab size.
*/
- protected static final float MAX_DIALOG_HEIGHT_PERCENT = 0.50f;
+ protected static final float MAX_DIALOG_HEIGHT_PERCENT = 0.65f;
/**
* Size of this dialog if there is no preference specifying a size.
*/
- protected static final Point DEFAULT_INITIAL_DIALOG_SIZE = new Point(620, 560);
+ protected static final Point DEFAULT_INITIAL_DIALOG_SIZE = new Point(680, 560);
+
+ /**
+ * defines some default sashweights when we have a new workspace
+ * @since 3.2
+ */
+ protected static final int[] DEFAULT_SASH_WEIGHTS = new int[] {190, 490};
+
/**
* Constant specifying that this dialog should be opened with the last configuration launched
* in the workspace selected.
@@ -262,6 +263,13 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
private Label fFilteringLabel;
/**
+ * the current launch manager
+ *
+ * @since 3.2
+ */
+ private ILaunchManager fLaunchManager = DebugPlugin.getDefault().getLaunchManager();
+
+ /**
* Filters for the LCD
* @since 3.2
*/
@@ -282,7 +290,7 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
*/
private static final String DIALOG_SASH_WEIGHTS_1 = IDebugUIConstants.PLUGIN_ID + ".DIALOG_SASH_WEIGHTS_1"; //$NON-NLS-1$
private static final String DIALOG_SASH_WEIGHTS_2 = IDebugUIConstants.PLUGIN_ID + ".DIALOG_SASH_WEIGHTS_2"; //$NON-NLS-1$
- private static final String DIALOG_WIDTH = IDebugUIConstants.PLUGIN_ID + ".DIALOG_WIDTH"; //$NON-NLS-1$
+ private static final String DIALOG_PERSISTED_SIZE = IDebugUIConstants.PLUGIN_ID + ".DIALOG_SIZED"; //$NON-NLS-1$
/**
* Constructs a new launch configuration dialog on the given
@@ -296,46 +304,6 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
setShellStyle(getShellStyle() | SWT.RESIZE);
setLaunchGroup(group);
}
-
- /**
- * About to start a long running operation triggered through
- * the dialog. Shows the progress monitor and disables the dialog's
- * buttons and controls.
- *
- * @return the saved UI state
- */
- private Object aboutToStart() {
- Map savedState = null;
- if (getShell() != null) {
- // Save focus control
- Control focusControl = getShell().getDisplay().getFocusControl();
- if (focusControl != null && focusControl.getShell() != getShell()) {
- focusControl = null;
- }
-
- // Set the busy cursor to all shells.
- Display d = getShell().getDisplay();
- waitCursor = new Cursor(d, SWT.CURSOR_WAIT);
- setDisplayCursor(waitCursor);
-
- // Set the arrow cursor to the cancel component.
- arrowCursor= new Cursor(d, SWT.CURSOR_ARROW);
- getProgressMonitorCancelButton().setCursor(arrowCursor);
-
- // Deactivate shell
- savedState = saveUIState();
- if (focusControl != null) {
- savedState.put(FOCUS_CONTROL, focusControl);
- }
-
- // Attach the progress monitor part to the cancel button
- getProgressMonitorCancelButton().setEnabled(true);
- getProgressMonitorPart().attachToCancelComponent(getProgressMonitorCancelButton());
- getProgressMonitorPart().getParent().setVisible(true);
- getProgressMonitorCancelButton().setFocus();
- }
- return savedState;
- }
/**
* Adds content to the dialog area
@@ -366,15 +334,15 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
sash.setLayoutData(gd);
sash.setFont(dialogComp.getFont());
sash.setVisible(true);
- setSashForm(sash);
+ fSashForm = sash;
// Build the launch configuration selection area and put it into the composite.
- Control launchConfigSelectionArea = createLaunchConfigurationSelectionArea(getSashForm());
+ Control launchConfigSelectionArea = createLaunchConfigurationSelectionArea(fSashForm);
gd = new GridData(GridData.FILL_VERTICAL);
launchConfigSelectionArea.setLayoutData(gd);
// Build the launch configuration edit area and put it into the composite.
- Composite editAreaComp = createLaunchConfigurationEditArea(getSashForm());
+ Composite editAreaComp = createLaunchConfigurationEditArea(fSashForm);
setEditArea(editAreaComp);
gd = new GridData(GridData.FILL_BOTH);
editAreaComp.setLayoutData(gd);
@@ -408,26 +376,6 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
}
/**
- * Calculate & return a 2 element integer array that specifies the relative
- * weights of the selection area and the edit area, based on the specified
- * increase in width of the owning shell. The point of this method is calculate
- * sash weights such that when the shell gets wider, all of the increase in width
- * is given to the edit area (tab folder), and the selection area (tree) stays
- * the same width.
- *
- * @return an array of the new sash weights
- */
- private int[] calculateNewSashWeights(int widthIncrease) {
- int[] newWeights = new int[2];
- newWeights[0] = getSelectionArea().getBounds().width;
- if(newWeights[0] < 180) {
- newWeights[0] = 180;
- }
- newWeights[1] = getEditArea().getBounds().width + widthIncrease;
- return newWeights;
- }
-
- /**
* Return whether the current configuration can be discarded. This involves determining
* if it is dirty, and if it is, asking the user what to do.
*
@@ -447,7 +395,7 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
if (!isSafeToClose()) {
return false;
}
- persistSashWeights();
+ persistSashWeights();
setCurrentlyVisibleLaunchConfigurationDialog(null);
getBannerImage().dispose();
getTabViewer().dispose();
@@ -484,10 +432,9 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
*/
protected Control createButtonBar(Composite parent) {
Font font = parent.getFont();
- Composite composite= new Composite(parent, SWT.NULL);
-
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
+ Composite composite = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
layout.marginHeight= 0;
layout.marginWidth= 0;
layout.marginLeft = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
@@ -509,16 +456,16 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
monitorComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
GridLayout pmLayout = new GridLayout();
- setProgressMonitorPart(new ProgressMonitorPart(monitorComposite, pmLayout));
- Button cancelButton = createButton(monitorComposite, ID_CANCEL_BUTTON, LaunchConfigurationsMessages.LaunchConfigurationDialog_Cancel_3, true);
- setProgressMonitorCancelButton(cancelButton);
- getProgressMonitorCancelButton().setFont(font);
- getProgressMonitorPart().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- getProgressMonitorPart().setFont(font);
+ fProgressMonitorPart = new ProgressMonitorPart(monitorComposite, pmLayout);
+ fProgressMonitorPart.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ fProgressMonitorPart.setFont(font);
+
+ fProgressMonitorCancelButton = createButton(monitorComposite, ID_CANCEL_BUTTON, LaunchConfigurationsMessages.LaunchConfigurationDialog_Cancel_3, true);
+ fProgressMonitorCancelButton.setFont(font);
monitorComposite.setVisible(false);
- /*
- * This code is duplicated from Dialog#createButtonBar. We do not want
+
+ /* * This code is duplicated from Dialog#createButtonBar. We do not want
* to call the TrayDialog implementation because it adds a help control.
* Since this is a custom button bar, we explicitly added the help control
* in an appropriate place above, and we use the Dialog implementation of
@@ -535,8 +482,7 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
buttonComposite.setLayout(layout);
- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END
- | GridData.VERTICAL_ALIGN_CENTER);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_CENTER);
buttonComposite.setLayoutData(data);
buttonComposite.setFont(composite.getFont());
@@ -633,7 +579,7 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
viewForm.setTopLeft(toolBar);
ToolBarManager toolBarManager= new ToolBarManager(toolBar);
- setSelectionArea(viewForm);
+ fSelectionArea = viewForm;
viewForm.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite viewFormContents = new Composite(viewForm, SWT.FLAT);
@@ -739,13 +685,13 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
public void refreshFilteringLabel() {
try {
int total = 0;
- ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations();
+ ILaunchConfiguration[] configs = fLaunchManager.getLaunchConfigurations();
for(int i = 0; i < configs.length; i++) {
if(configs[i].supportsMode(getMode()) & !configs[i].getAttribute(IDebugUIConstants.ATTR_PRIVATE, false) & equalCategories(configs[i].getCategory(), getLaunchGroup().getCategory())) {
total++;
}
}
- ILaunchConfigurationType[] types = getLaunchManager().getLaunchConfigurationTypes();
+ ILaunchConfigurationType[] types = fLaunchManager.getLaunchConfigurationTypes();
for(int i = 0; i < types.length; i++) {
if(types[i].supportsMode(getMode()) & types[i].isPublic() & equalCategories(types[i].getCategory(), getLaunchGroup().getCategory())) {
total++;
@@ -767,7 +713,7 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
* Set the initial selection in the tree.
*/
public void doInitialTreeSelection() {
- fLaunchConfigurationView.getViewer().setSelection(getInitialSelection());
+ fLaunchConfigurationView.getViewer().setSelection(fInitialSelection);
}
/**
@@ -798,7 +744,7 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
if (name == null) {
name = ""; //$NON-NLS-1$
}
- return getLaunchManager().generateUniqueLaunchConfigurationNameFrom(name);
+ return fLaunchManager.generateUniqueLaunchConfigurationNameFrom(name);
}
/* (non-Javadoc)
@@ -910,30 +856,7 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
protected String getHelpContextId() {
return IDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG;
}
-
- /**
- * Returns the initial selection shown in this dialog when opened in
- * <code>LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_SELECTION</code> mode.
- *
- * @return the initial selection of the dialog
- */
- private IStructuredSelection getInitialSelection() {
- return fInitialSelection;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.window.Window#getInitialSize()
- */
- protected Point getInitialSize() {
- IDialogSettings settings = getDialogSettings();
- try {
- settings.getInt(DIALOG_WIDTH); //we have a persisted setting
- return super.getInitialSize();
- } catch (NumberFormatException e) {
- }
- return DEFAULT_INITIAL_DIALOG_SIZE;
- }
-
+
/**
* Returns the status the dialog was opened on or <code>null</code> if none.
*
@@ -970,15 +893,6 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
return fGroup;
}
- /**
- * Returns the launch manager.
- *
- * @return the launch manager
- */
- private ILaunchManager getLaunchManager() {
- return DebugPlugin.getDefault().getLaunchManager();
- }
-
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationDialog#getMode()
*/
@@ -1004,32 +918,6 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
return fOpenMode;
}
- /**
- * returns the progress monitor for the cancel button
- *
- * @return the progress monitor for the cancel button
- */
- private Button getProgressMonitorCancelButton() {
- return fProgressMonitorCancelButton;
- }
-
- /**
- * returns the local progress monitor part
- *
- * @return the local progress monitor part
- */
- private ProgressMonitorPart getProgressMonitorPart() {
- return fProgressMonitorPart;
- }
-
- /**
- * returns the sash form
- * @return the sash form
- */
- private SashForm getSashForm() {
- return fSashForm;
- }
-
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IPageChangeProvider#getSelectedPage()
*/
@@ -1038,15 +926,6 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
}
/**
- * Returns the launch configuration selection area control.
- *
- * @return control
- */
- private Composite getSelectionArea() {
- return fSelectionArea;
- }
-
- /**
* Returns the title of the shell
* @return the shell title
*/
@@ -1126,8 +1005,7 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
}
}
ILaunchConfiguration original = getTabViewer().getOriginal();
- ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
- if (original != null && newInput == null && launchManager.getMovedTo(original) != null) {
+ if (original != null && newInput == null && fLaunchManager.getMovedTo(original) != null) {
// the current config is about to be deleted ignore this change
return;
}
@@ -1139,7 +1017,7 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
boolean renamed = false;
if (newInput instanceof ILaunchConfiguration) {
ILaunchConfiguration lc = (ILaunchConfiguration)newInput;
- renamed = launchManager.getMovedFrom(lc) != null;
+ renamed = fLaunchManager.getMovedFrom(lc) != null;
}
if (getTabViewer().isDirty() && !deleted && !renamed) {
IStructuredSelection sel;
@@ -1197,9 +1075,8 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
try {
handler.handleStatus(status, this);
return;
- } catch (CoreException e) {
- status = e.getStatus();
}
+ catch (CoreException e) {status = e.getStatus();}
}
// if no handler, or handler failed, display error/warning dialog
String title = null;
@@ -1230,9 +1107,34 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
* @see org.eclipse.jface.window.Window#initializeBounds()
*/
protected void initializeBounds() {
+ IDialogSettings settings = getDialogSettings();
+ if (fSashForm != null) {
+ int w1, w2;
+ try {
+ w1 = settings.getInt(DIALOG_SASH_WEIGHTS_1);
+ w2 = settings.getInt(DIALOG_SASH_WEIGHTS_2);
+ }
+ catch(NumberFormatException nfe) {
+ w1 = DEFAULT_SASH_WEIGHTS[0];
+ w2 = DEFAULT_SASH_WEIGHTS[1];
+ fSashForm.setSize(DEFAULT_INITIAL_DIALOG_SIZE);
+ }
+ fSashForm.setWeights(new int[] {w1, w2});
+ }
+ if(!settings.getBoolean(DIALOG_PERSISTED_SIZE)) {
+ initializeSize();
+ }
super.initializeBounds();
- initializeSashForm();
- resize();
+ }
+
+ /**
+ * sets the default sizes of the dialog if they have not been persisted by the user from
+ * previous invocations
+ * @since 3.2
+ */
+ private void initializeSize() {
+ setShellSize(DEFAULT_INITIAL_DIALOG_SIZE.x, DEFAULT_INITIAL_DIALOG_SIZE.y);
+ fSashForm.setWeights(DEFAULT_SASH_WEIGHTS);
}
/**
@@ -1245,30 +1147,7 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
handleStatus(status);
}
}
-
- /**
- * Initialize the relative weights (widths) of the 2 sides of the sash.
- */
- private void initializeSashForm() {
- if (getSashForm() != null) {
- IDialogSettings settings = getDialogSettings();
- int[] sashWeights;
- try {
- int w1, w2;
- w1 = settings.getInt(DIALOG_SASH_WEIGHTS_1);
- //just to make sure we are always visible for the toolbar
- if(w1 < 270) {
- w1 = 270;
- }
- w2 = settings.getInt(DIALOG_SASH_WEIGHTS_2);
- sashWeights = new int[] {w1, w2};
- } catch (NumberFormatException e) {
- sashWeights = DEFAULT_SASH_WEIGHTS;
- }
- getSashForm().setWeights(sashWeights);
- }
- }
-
+
/**
* Compares two objects to determine their equality
*
@@ -1329,12 +1208,12 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
*/
protected void persistSashWeights() {
IDialogSettings settings = getDialogSettings();
- SashForm sashForm = getSashForm();
- if (sashForm != null) {
- int[] sashWeights = getSashForm().getWeights();
+ if (fSashForm != null) {
+ int[] sashWeights = fSashForm.getWeights();
settings.put(DIALOG_SASH_WEIGHTS_1, sashWeights[0]);
settings.put(DIALOG_SASH_WEIGHTS_2, sashWeights[1]);
}
+ settings.put(DIALOG_PERSISTED_SIZE, true);
}
/**
@@ -1356,82 +1235,15 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
* resize the dialog to show all relevant content
*/
protected void resize() {
- // determine the maximum tab dimensions
- PixelConverter pixelConverter = new PixelConverter(getEditArea());
- int runningTabWidth = 0;
- ILaunchConfigurationTabGroup group = getTabGroup();
- if (group == null) {
- return;
- }
- ILaunchConfigurationTab[] tabs = group.getTabs();
- Point contentSize = new Point(0, 0);
- for (int i = 0; i < tabs.length; i++) {
- String name = tabs[i].getName();
- Image image = tabs[i].getImage();
- runningTabWidth += pixelConverter.convertWidthInCharsToPixels(name.length() + 5);
- if (image != null) {
- runningTabWidth += image.getBounds().width;
- }
- Control control = tabs[i].getControl();
- if (control != null) {
- Point size = control.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- if (size.x > contentSize.x) {
- contentSize.x = size.x;
- }
- if (size.y > contentSize.y) {
- contentSize.y = size.y;
- }
- }
- }
-
- // Determine if more space is needed to show all tab labels across the top of the
- // tab folder. If so, only increase size of dialog to some percent of the available
- // screen real estate.
- if (runningTabWidth > contentSize.x) {
- int maxAllowedWidth = (int) (getDisplay().getBounds().width * MAX_DIALOG_WIDTH_PERCENT);
- int otherWidth = getSashForm().SASH_WIDTH + getSelectionArea().getBounds().width;
- int totalWidth = runningTabWidth + otherWidth;
- if (totalWidth > maxAllowedWidth) {
- contentSize.x = maxAllowedWidth - otherWidth;
- } else {
- contentSize.x = runningTabWidth;
- }
+ if(getTabGroup() != null) {
+ Point shell = getShell().getSize();
+ Point psize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ int maxx = (int)(getDisplay().getBounds().width * MAX_DIALOG_WIDTH_PERCENT),
+ maxy = (int) (getDisplay().getBounds().height * MAX_DIALOG_HEIGHT_PERCENT);
+ if((psize.x > maxx ? maxx : psize.x) > shell.x) {
+ setShellSize(Math.min(psize.x, maxx), Math.min(psize.y, maxy));
+ }
}
-
- int maxAllowedHeight =(int) (getDisplay().getBounds().height * MAX_DIALOG_HEIGHT_PERCENT);
- contentSize.y = Math.min(contentSize.y, maxAllowedHeight);
-
- // Adjust the maximum tab dimensions to account for the extra space required for the tab labels
- Rectangle tabFolderBoundingBox = getEditArea().computeTrim(0, 0, contentSize.x, contentSize.y);
- contentSize.x = tabFolderBoundingBox.width;
- contentSize.y = tabFolderBoundingBox.height;
-
- // Force recalculation of sizes
- getEditArea().layout(true);
-
- // Calculate difference between required space for the tab folder's client area
- // and it's current size, then increase size of this dialog's Shell by that amount
- Rectangle rect = getTabViewer().getTabFolder().getClientArea();
- Point containerSize= new Point(rect.width, rect.height);
- int hdiff= contentSize.x - containerSize.x;
- int vdiff= contentSize.y - containerSize.y;
- // Only increase size of dialog, never shrink it
- if (hdiff > 0 || vdiff > 0) {
- int[] newSashWeights = null;
- if (hdiff > 0) {
- newSashWeights = calculateNewSashWeights(hdiff);
- }
- hdiff= Math.max(0, hdiff);
- vdiff= Math.max(0, vdiff);
- Shell shell= getShell();
- Point shellSize= shell.getSize();
- setShellSize(shellSize.x + hdiff, shellSize.y + vdiff);
- // Adjust the sash weights so that all of the increase in width
- // is given to the tab area
- if (newSashWeights != null) {
- getSashForm().setWeights(newSashWeights);
- }
- }
}
/**
@@ -1446,8 +1258,9 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
private void restoreEnableState(Control w, Map h, String key) {
if (w != null) {
Boolean b = (Boolean) h.get(key);
- if (b != null)
+ if (b != null) {
w.setEnabled(b.booleanValue());
+ }
}
}
@@ -1481,17 +1294,44 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
*/
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
if (isVisible()) {
- // The operation can only be canceled if it is executed in a separate thread.
- // Otherwise the UI is blocked anyway.
- Object state = aboutToStart();
+ Map savedState = null;
+ if (getShell() != null) {
+ // Save focus control
+ Control focusControl = getShell().getDisplay().getFocusControl();
+ if (focusControl != null && focusControl.getShell() != getShell()) {
+ focusControl = null;
+ }
+
+ // Set the busy cursor to all shells.
+ Display d = getShell().getDisplay();
+ waitCursor = new Cursor(d, SWT.CURSOR_WAIT);
+ setDisplayCursor(waitCursor);
+
+ // Set the arrow cursor to the cancel component.
+ arrowCursor= new Cursor(d, SWT.CURSOR_ARROW);
+ fProgressMonitorCancelButton.setCursor(arrowCursor);
+ fProgressMonitorCancelButton.setEnabled(true);
+
+ // Deactivate shell
+ savedState = saveUIState();
+ if (focusControl != null) {
+ savedState.put(FOCUS_CONTROL, focusControl);
+ }
+ // Attach the progress monitor part to the cancel button
+ fProgressMonitorPart.attachToCancelComponent(fProgressMonitorCancelButton);
+ fProgressMonitorPart.getParent().setVisible(true);
+ fProgressMonitorCancelButton.setFocus();
+ }
fActiveRunningOperations++;
try {
ModalContext.run(runnable, fork, fProgressMonitorPart, getShell().getDisplay());
- } finally {
+ }
+ finally {
fActiveRunningOperations--;
- stopped(state);
+ stopped(savedState);
}
- } else {
+ }
+ else {
PlatformUI.getWorkbench().getProgressService().run(fork, cancelable, runnable);
}
}
@@ -1529,8 +1369,8 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
Map savedState= new HashMap(4);
saveEnableStateAndSet(getButton(ID_LAUNCH_BUTTON), savedState, "launch", false);//$NON-NLS-1$
saveEnableStateAndSet(getButton(ID_CLOSE_BUTTON), savedState, "close", false);//$NON-NLS-1$
- if (getSelectionArea() != null) {
- savedState.put("selectionarea", ControlEnableState.disable(getSelectionArea()));//$NON-NLS-1$
+ if (fSelectionArea != null) {
+ savedState.put("selectionarea", ControlEnableState.disable(fSelectionArea));//$NON-NLS-1$
}
savedState.put("editarea", ControlEnableState.disable(getEditArea()));//$NON-NLS-1$
return savedState;
@@ -1619,39 +1459,13 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
public void setOpenMode(int mode) {
fOpenMode = mode;
}
-
- /**
- * Sets the progress monitor on the cancel button
- *
- * @param button
- */
- private void setProgressMonitorCancelButton(Button button) {
- fProgressMonitorCancelButton = button;
- }
-
- private void setProgressMonitorPart(ProgressMonitorPart part) {
- fProgressMonitorPart = part;
- }
-
- private void setSashForm(SashForm sashForm) {
- fSashForm = sashForm;
- }
-
- /**
- * Sets the launch configuration selection area control.
- *
- * @param selectionArea control
- */
- private void setSelectionArea(Composite selectionArea) {
- fSelectionArea = selectionArea;
- }
/**
* Increase the size of this dialog's <code>Shell</code> by the specified amounts.
* Do not increase the size of the Shell beyond the bounds of the Display.
*/
protected void setShellSize(int width, int height) {
- Rectangle bounds = getShell().getDisplay().getBounds();
+ Rectangle bounds = getShell().getMonitor().getBounds();
getShell().setSize(Math.min(width, bounds.width), Math.min(height, bounds.height));
}
@@ -1740,8 +1554,8 @@ public class LaunchConfigurationsDialog extends TitleAreaDialog implements ILaun
*/
private void stopped(Object savedState) {
if (getShell() != null) {
- getProgressMonitorPart().getParent().setVisible(false);
- getProgressMonitorPart().removeFromCancelComponent(getProgressMonitorCancelButton());
+ fProgressMonitorPart.getParent().setVisible(false);
+ fProgressMonitorPart.removeFromCancelComponent(fProgressMonitorCancelButton);
Map state = (Map)savedState;
restoreUIState(state);
setDisplayCursor(null);

Back to the top