diff options
author | David Inglis | 2004-03-31 21:46:52 +0000 |
---|---|---|
committer | David Inglis | 2004-03-31 21:46:52 +0000 |
commit | fd4d49ba3036e74e9348cddf432d5de1fcfab03e (patch) | |
tree | b61da9c11679e3c3435ffd2ab492b8b15a029679 | |
parent | d8a96ca65d097d6d2456c9c1de3141f791626acb (diff) | |
download | org.eclipse.cdt-fd4d49ba3036e74e9348cddf432d5de1fcfab03e.tar.gz org.eclipse.cdt-fd4d49ba3036e74e9348cddf432d5de1fcfab03e.tar.xz org.eclipse.cdt-fd4d49ba3036e74e9348cddf432d5de1fcfab03e.zip |
added background target building
added ui to configure/enable workbecnk clean operation.
11 files changed, 948 insertions, 68 deletions
diff --git a/build/org.eclipse.cdt.make.ui/plugin.properties b/build/org.eclipse.cdt.make.ui/plugin.properties index 3eea17795ca..50331a4ce30 100644 --- a/build/org.eclipse.cdt.make.ui/plugin.properties +++ b/build/org.eclipse.cdt.make.ui/plugin.properties @@ -22,8 +22,11 @@ CommandTargetCreate.name=Create Make Target CommandTargetCreate.description=Create a new make build target for the selected container. PreferenceMakeProject.name=New Make Projects +PreferenceMakeTargets.name=Make Targets +PreferenceScannerConfig.name=Scanner Configuration Discovery PropertyMakeProject.name= C/C++ Make Project +PropertyScannerConfig.name=Scanner Configuration Discovery ViewCatagoryMake.name=Make ViewMake.name=Make Targets @@ -43,5 +46,3 @@ ActionDefinition.uncomment.description= Uncomment the selected # style comment l MakefileEditor.name=Makefile Editor -PropertyScannerConfig.name=Scanner Configuration Discovery -PreferenceScannerConfig.name=Scanner Configuration Discovery diff --git a/build/org.eclipse.cdt.make.ui/plugin.xml b/build/org.eclipse.cdt.make.ui/plugin.xml index 4140b78e3ee..5ec5a348f95 100644 --- a/build/org.eclipse.cdt.make.ui/plugin.xml +++ b/build/org.eclipse.cdt.make.ui/plugin.xml @@ -237,10 +237,7 @@ category="org.eclipse.ui.category.project" id="org.eclipse.cdt.make.ui.targetCreateCommand"> </command> - </extension> <!-- Makefile Editor keybindings --> - <extension - point="org.eclipse.ui.commands"> <category name="%category.source.name" description="%category.source.description" @@ -276,9 +273,21 @@ <page name="%PreferenceMakeProject.name" category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage" - class="org.eclipse.cdt.make.internal.ui.preferences.MakePreferencePage" + class="org.eclipse.cdt.make.internal.ui.preferences.NewMakeProjectPreferencePage" id="org.eclipse.cdt.make.ui.preferences.MakePreferencePage"> </page> + <page + name="%PreferenceScannerConfig.name" + category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage" + class="org.eclipse.cdt.make.internal.ui.preferences.ScannerConfigPreferencePage" + id="org.eclipse.cdt.make.ui.preferences.ScannerConfigPreferencePage"> + </page> + <page + name="%PreferenceMakeTargets.name" + category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage" + class="org.eclipse.cdt.make.internal.ui.preferences.MakeTargetsPreferencePage" + id="org.eclipse.cdt.make.ui.preferences.MakeTargetsPreferencePage"> + </page> </extension> <extension point="org.eclipse.ui.propertyPages"> @@ -293,6 +302,18 @@ value="org.eclipse.cdt.make.core.makeNature"> </filter> </page> + <page + adaptable="true" + objectClass="org.eclipse.core.resources.IProject" + name="%PropertyScannerConfig.name" + class="org.eclipse.cdt.make.internal.ui.properties.ScannerConfigPropertyPage" + id="org.eclipse.cdt.make.ui.properties.ScannerConfigPropertyPage"> + <filter + name="nature" + value="org.eclipse.cdt.make.core.makeNature"> + </filter> + </page> + </extension> <extension point="org.eclipse.ui.views"> @@ -421,28 +442,4 @@ </actionSet> </perspectiveExtension> </extension> - <extension - point="org.eclipse.ui.propertyPages"> - <page - adaptable="true" - objectClass="org.eclipse.core.resources.IProject" - name="%PropertyScannerConfig.name" - class="org.eclipse.cdt.make.internal.ui.properties.ScannerConfigPropertyPage" - id="org.eclipse.cdt.make.ui.properties.ScannerConfigPropertyPage"> - <filter - name="nature" - value="org.eclipse.cdt.make.core.makeNature"> - </filter> - </page> - </extension> - <extension - point="org.eclipse.ui.preferencePages"> - <page - name="%PreferenceScannerConfig.name" - category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage" - class="org.eclipse.cdt.make.internal.ui.preferences.ScannerConfigPreferencePage" - id="org.eclipse.cdt.make.ui.preferences.ScannerConfigPreferencePage"> - </page> - </extension> - </plugin> diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties index 2fed915fa72..ba25cbff428 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties @@ -24,7 +24,6 @@ MakeWizardUpdatePage.projectList=Project list MakeWizardUpdatePage.status.noProjectsToUpdate=No projects to update MakeWizardUpdatePage.status.noProjectsSelected=No projects selected - WizardCheckboxTablePart.WizardCheckboxTablePart.selectAll=Select All WizardCheckboxTablePart.WizardCheckboxTablePart.deselectAll=Deselect All WizardCheckboxTablePart.WizardCheckboxTablePart.counter={0} of {1} Selected @@ -45,6 +44,7 @@ SettingsBlock.makeWorkbench.target=Make build target: SettingsBlock.makeWorkbench.auto=Build on resource save (Auto Build) SettingsBlock.makeWorkbench.incremental=Build (Incremental Build) SettingsBlock.makeWorkbench.full=Rebuild (Full Build) +SettingsBlock.makeWorkbench.clean=Clean TargetBlock.target.group_label=Target TargetBlock.target.label=Target Name: @@ -76,6 +76,8 @@ BuildPropertyCommon.label.message=Value: BuildPropertyCommon.label.browse=Browse... BuildPropertyCommon.label.configs=Defined configurations: +MakeTargetsPreferencePage.buildTargetInBackground.label=Build make targets in background. + MakeDocumentProvider.exception.createElementInfo=Error creating element. AddBuildTargetAction.title=Add To Build Target @@ -85,6 +87,7 @@ AddBuildTargetAction.exception.internal=Internal Error TargetBuild.execption.message=Target Build Error TargetBuild.monitor.beginTask=Building Targets... +TargetBuild.backgroundTask.name=Building Targets. TargetListViewer.button.add=Add... TargetListViewer.button.remove=Remove @@ -150,7 +153,8 @@ MakeUIPlugin.update_project=Update make projects MakeUIPlugin.update_project_message=Older \'make\' projects have been detected in your workspace. \n These projects are no longer supported, would you like to convert these now? # Prefernece Page -MakePreferencePage.description=Make Project Preferences +MakePreferencePage.description=Specify the settings used as defaults by the New Standard Make Project creation wizard. +MakeTargetPreferencePage.buildTargetInBackground.label=Build Make target in the background. #Property Page MakeProjectPropertyPage.closedproject=Project Closed diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeUIPlugin.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeUIPlugin.java index 50909a4c3a6..aba403bbe83 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeUIPlugin.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeUIPlugin.java @@ -7,6 +7,7 @@ import java.util.ResourceBundle; import org.eclipse.cdt.make.internal.ui.editor.IMakefileDocumentProvider; import org.eclipse.cdt.make.internal.ui.editor.MakefileDocumentProvider; import org.eclipse.cdt.make.internal.ui.editor.WorkingCopyManager; +import org.eclipse.cdt.make.internal.ui.preferences.MakeTargetsPreferencePage; import org.eclipse.cdt.make.ui.IWorkingCopyManager; import org.eclipse.cdt.make.ui.actions.UpdateMakeProjectAction; import org.eclipse.core.resources.IProject; @@ -19,6 +20,7 @@ import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IStartup; @@ -266,4 +268,7 @@ public class MakeUIPlugin extends AbstractUIPlugin implements IStartup { } } + protected void initializeDefaultPreferences(IPreferenceStore store) { + MakeTargetsPreferencePage.initDefaults(store); + } } diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/dialogs/GoToBackProgressMonitorDialog.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/dialogs/GoToBackProgressMonitorDialog.java new file mode 100644 index 00000000000..b03724e1e93 --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/dialogs/GoToBackProgressMonitorDialog.java @@ -0,0 +1,772 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.make.internal.ui.dialogs; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IProgressMonitorWithBlocking; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Cursor; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +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.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.IconAndMessageDialog; +import org.eclipse.jface.dialogs.ProgressIndicator; +import org.eclipse.jface.operation.IRunnableContext; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.jface.util.Assert; + +/** + * Progress monitor with a 'Go to background button' + */ +public class GoToBackProgressMonitorDialog extends IconAndMessageDialog implements IRunnableContext { + + private class MyJob extends Job { + + private IRunnableWithProgress runnable; + private volatile boolean continueEventDispatching = true; + private Display display; + + public MyJob(IRunnableWithProgress operation, Display display) { + super(fJobText); + this.runnable = operation; + this.display = display; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) + */ + protected IStatus run(IProgressMonitor monitor) { + progressMonitor.setWrapped(monitor); + + try { + if (runnable != null) + runnable.run(progressMonitor); + } catch (InvocationTargetException e) { + return new Status(IStatus.ERROR, MakeUIPlugin.getPluginId(), -1, "Operation failed.", e); //$NON-NLS-1$ + } catch (InterruptedException e) { + return Status.CANCEL_STATUS; + } catch (OperationCanceledException e) { + return Status.CANCEL_STATUS; + } catch (RuntimeException e) { + return new Status(IStatus.ERROR, MakeUIPlugin.getPluginId(), -1, "Operation failed.", e); //$NON-NLS-1$ + } catch (Error e) { + return new Status(IStatus.ERROR, MakeUIPlugin.getPluginId(), -1, "Operation failed.", e); //$NON-NLS-1$ + } finally { + // Make sure that all events in the asynchronous event queue + // are dispatched. + display.syncExec(new Runnable() { + + public void run() { + // do nothing + } + }); + + // Stop event dispatching + continueEventDispatching = false; + + // Force the event loop to return from sleep () so that + // it stops event dispatching. + display.asyncExec(null); + } + return Status.OK_STATUS; + } + + /** + * Processes events or waits until this modal context thread terminates. + */ + public void block() { + if (display == Display.getCurrent()) { + while (continueEventDispatching && !progressMonitor.isInBackground()) { + if (!display.readAndDispatch()) + display.sleep(); + } + } else { + try { + join(); + } catch (InterruptedException e) { + } + } + } + } + + /** + * Name to use for task when normal task name is empty string. + */ + private static String DEFAULT_TASKNAME = JFaceResources.getString("ProgressMonitorDialog.message"); //$NON-NLS-1$ + + /** + * Constants for label and monitor size + */ + private static int LABEL_DLUS = 21; + private static int BAR_DLUS = 9; + + /** + * The progress indicator control. + */ + protected ProgressIndicator progressIndicator; + + /** + * The label control for the task. Kept for backwards compatibility. + */ + protected Label taskLabel; + + /** + * The label control for the subtask. + */ + protected Label subTaskLabel; + + /** + * The Cancel button control. + */ + protected Button cancel; + + protected Button toBackgroundButton; + + /** + * Indicates whether the Cancel button is to be shown. + */ + protected boolean operationCancelableState = false; + + /** + * Indicates whether the Cancel button is to be enabled. + */ + protected boolean enableCancelButton; + + /** + * The progress monitor. + */ + private ProgressMonitor progressMonitor = new ProgressMonitor(); + + /** + * The name of the current task (used by ProgressMonitor). + */ + private String task; + + /** + * The nesting depth of currently running runnables. + */ + private int nestingDepth; + + /** + * The cursor used in the cancel button; + */ + protected Cursor arrowCursor; + + /** + * The cursor used in the shell; + */ + private Cursor waitCursor; + + /** + * Flag indicating whether to open or merely create the dialog before run. + */ + private boolean openOnRun = true; + + final private String fJobText; + /** + * Internal progress monitor implementation. Wraps the real progress monitor and intercepts all steps to forwrad them to the + * progress monitor dialog. + */ + private class ProgressMonitor implements IProgressMonitorWithBlocking { + + private String fSubTask = "";//$NON-NLS-1$ + private boolean fIsCanceled; + protected boolean locked = false; + + private boolean fInBackground = false; + private IProgressMonitor fWrapped; + + public ProgressMonitor() { + fWrapped = null; + } + + public void setWrapped(IProgressMonitor wrapped) { + fWrapped = wrapped; + } + + public void setInBackground(boolean inBackground) { + fInBackground = inBackground; + } + + public boolean isInBackground() { + return fInBackground; + } + + public void beginTask(final String name, final int totalWork) { + if (fWrapped != null) { + fWrapped.beginTask(name, totalWork); + } + if (fInBackground) { + return; + } + if (progressIndicator.isDisposed()) + return; + + if (name == null) + task = "";//$NON-NLS-1$ + else + task = name; + + getShell().getDisplay().asyncExec(new Runnable() { + + public void run() { + internalBeginTask(name, totalWork); + } + }); + } + + private void internalBeginTask(String name, int totalWork) { + if (progressIndicator.isDisposed()) + return; + + String s = task; + if (s.length() <= 0) + s = DEFAULT_TASKNAME; + setDialogMessage(s); + + if (totalWork == UNKNOWN) { + progressIndicator.beginAnimatedTask(); + } else { + progressIndicator.beginTask(totalWork); + } + } + + public void done() { + if (fWrapped != null) { + fWrapped.done(); + } + if (fInBackground) { + return; + } + getShell().getDisplay().asyncExec(new Runnable() { + + public void run() { + internalDone(); + } + }); + } + + private void internalDone() { + if (!progressIndicator.isDisposed()) { + progressIndicator.sendRemainingWork(); + progressIndicator.done(); + } + } + + public void setTaskName(final String name) { + if (fWrapped != null) { + fWrapped.setTaskName(name); + } + + if (fInBackground) { + return; + } + + if (name == null) + task = "";//$NON-NLS-1$ + else + task = name; + + getShell().getDisplay().asyncExec(new Runnable() { + + public void run() { + internalSetTaskName(name); + } + }); + } + + private void internalSetTaskName(String name) { + String s = task; + if (s.length() <= 0) + s = DEFAULT_TASKNAME; + setDialogMessage(s); + } + + public boolean isCanceled() { + return fIsCanceled || (fWrapped != null && fWrapped.isCanceled()); + } + + public void setCanceled(boolean b) { + if (fWrapped != null) { + fWrapped.setCanceled(b); + } + if (fInBackground) { + return; + } + + fIsCanceled = b; + if (locked) + clearBlocked(); + } + + public void subTask(String name) { + if (fWrapped != null) { + fWrapped.subTask(name); + } + if (fInBackground) { + return; + } + + if (name == null) + fSubTask = "";//$NON-NLS-1$ + else + fSubTask = name; + + if (!subTaskLabel.isDisposed()) { + getShell().getDisplay().asyncExec(new Runnable() { + + public void run() { + if (!subTaskLabel.isDisposed()) { + subTaskLabel.setText(fSubTask); + } + } + }); + } + } + + public void worked(int work) { + if (fWrapped != null) { + fWrapped.worked(work); + } + if (fInBackground) { + return; + } + + internalWorked(work); + } + + public void internalWorked(final double work) { + if (fWrapped != null) { + fWrapped.internalWorked(work); + } + if (fInBackground) { + return; + } + + if (!progressIndicator.isDisposed()) { + getShell().getDisplay().asyncExec(new Runnable() { + + public void run() { + if (!progressIndicator.isDisposed()) { + progressIndicator.worked(work); + } + } + }); + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.IProgressMonitorWithBlocking#clearBlocked() + */ + public void clearBlocked() { + if (fWrapped instanceof IProgressMonitorWithBlocking) { + ((IProgressMonitorWithBlocking) fWrapped).clearBlocked(); + } + if (fInBackground) { + return; + } + + getShell().getDisplay().asyncExec(new Runnable() { + + public void run() { + internalClearBlocked(); + } + }); + } + + private void internalClearBlocked() { + setMessage(task); + locked = false; + setImageLabel(getImage()); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.IProgressMonitorWithBlocking#setBlocked(org.eclipse.core.runtime.IStatus) + */ + public void setBlocked(final IStatus reason) { + if (fWrapped instanceof IProgressMonitorWithBlocking) { + ((IProgressMonitorWithBlocking) fWrapped).setBlocked(reason); + } + if (fInBackground) { + return; + } + getShell().getDisplay().asyncExec(new Runnable() { + + public void run() { + internalSetBlocked(reason); + } + }); + } + + private void internalSetBlocked(IStatus reason) { + setDialogMessage(reason.getMessage()); + locked = true; + setImageLabel(getImage()); + } + + private void setDialogMessage(String message) { + setMessage(message); + } + + private void setImageLabel(Image image) { + imageLabel.setImage(image); + } + + } + /** + * Creates a progress monitor dialog under the given shell. The dialog has a standard title and no image. <code>open</code> is + * non-blocking. + * + * @param parent + * the parent shell, or <code>null</code> to create a top-level shell + */ + public GoToBackProgressMonitorDialog(Shell parent, String jobText) { + super(parent); + setShellStyle(SWT.BORDER | SWT.TITLE | SWT.APPLICATION_MODAL); // no close button + setBlockOnOpen(false); + fJobText = jobText; + } + /** + * Enables the cancel button (asynchronously). + */ + private void asyncSetOperationCancelButtonEnabled(final boolean b) { + if (getShell() != null) { + getShell().getDisplay().asyncExec(new Runnable() { + + public void run() { + setOperationCancelButtonEnabled(b); + } + }); + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) + */ + protected void buttonPressed(int buttonId) { + if (buttonId == IDialogConstants.BACK_ID) { + progressMonitor.setInBackground(true); + toBackgroundButton.setEnabled(false); + cancel.setEnabled(true); + } + super.buttonPressed(buttonId); + } + + /** + * The cancel button has been pressed. + * + * @since 3.0 + */ + protected void cancelPressed() { + //NOTE: this was previously done from a listener installed on the cancel + //button. On GTK, the listener installed by Dialog.createButton is called + //first and this was throwing an exception because the cancel button + //was already disposed + cancel.setEnabled(false); + toBackgroundButton.setEnabled(false); + progressMonitor.setCanceled(true); + super.cancelPressed(); + } + /* + * (non-Javadoc) Method declared on Window. + */ + /** + * The <code>ProgressMonitorDialog</code> implementation of this method only closes the dialog if there are no currently + * running runnables. + */ + public boolean close() { + if (getNestingDepth() <= 0) { + clearCursors(); + return super.close(); + } + return false; + } + + /** + * Clear the cursors in the dialog. + * + * @since 3.0 + */ + protected void clearCursors() { + if (cancel != null && !cancel.isDisposed()) { + cancel.setCursor(null); + } + Shell shell = getShell(); + if (shell != null && !shell.isDisposed()) { + shell.setCursor(null); + } + if (arrowCursor != null) + arrowCursor.dispose(); + if (waitCursor != null) + waitCursor.dispose(); + arrowCursor = null; + waitCursor = null; + } + /* + * (non-Javadoc) Method declared in Window. + */ + protected void configureShell(Shell shell) { + super.configureShell(shell); + shell.setText(JFaceResources.getString("ProgressMonitorDialog.title")); //$NON-NLS-1$ + if (waitCursor == null) + waitCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT); + shell.setCursor(waitCursor); + } + + /* + * (non-Javadoc) Method declared on Dialog. + */ + protected void createButtonsForButtonBar(Composite parent) { + // cancel button + toBackgroundButton = createButton(parent, IDialogConstants.BACK_ID, "Run in Background", true); //$NON-NLS-1$ + cancel = createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true); + + if (arrowCursor == null) + arrowCursor = new Cursor(cancel.getDisplay(), SWT.CURSOR_ARROW); + cancel.setCursor(arrowCursor); + toBackgroundButton.setCursor(arrowCursor); + setOperationCancelButtonEnabled(enableCancelButton); + } + + /* + * (non-Javadoc) Method declared on Dialog. + */ + protected Control createDialogArea(Composite parent) { + + setMessage(DEFAULT_TASKNAME); + createMessageArea(parent); + + //Only set for backwards compatibility + taskLabel = messageLabel; + + // progress indicator + progressIndicator = new ProgressIndicator(parent); + GridData gd = new GridData(); + gd.heightHint = convertVerticalDLUsToPixels(BAR_DLUS); + gd.horizontalAlignment = GridData.FILL; + gd.grabExcessHorizontalSpace = true; + gd.horizontalSpan = 2; + progressIndicator.setLayoutData(gd); + + // label showing current task + subTaskLabel = new Label(parent, SWT.LEFT | SWT.WRAP); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.heightHint = convertVerticalDLUsToPixels(LABEL_DLUS); + gd.horizontalSpan = 2; + subTaskLabel.setLayoutData(gd); + subTaskLabel.setFont(parent.getFont()); + + return parent; + } + + /* + * (non-Javadoc) Method declared in Window. + */ + protected Point getInitialSize() { + + Point calculatedSize = super.getInitialSize(); + if (calculatedSize.x < 450) + calculatedSize.x = 450; + return calculatedSize; + } + /** + * Returns the progress monitor to use for operations run in this progress dialog. + * + * @return the progress monitor + */ + public IProgressMonitor getProgressMonitor() { + return progressMonitor; + } + /* + * (non-Javadoc) Method declared on IRunnableContext. Runs the given <code> IRunnableWithProgress </code> with the progress + * monitor for this progress dialog. The dialog is opened before it is run, and closed after it completes. + */ + public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, + InterruptedException { + Assert.isTrue(fork); + setCancelable(cancelable); + try { + aboutToRun(); + progressMonitor.setInBackground(false); + + MyJob job = new MyJob(runnable, getShell().getDisplay()); + job.schedule(); + job.block(); + if (progressMonitor.isCanceled()) { + throw new InterruptedException(); + } + } finally { + finishedRun(); + } + } + + /** + * Returns whether the dialog should be opened before the operation is run. Defaults to <code>true</code> + * + * @return <code>true</code> to open the dialog before run, <code>false</code> to only create the dialog, but not open it + * @since 3.0 + */ + public boolean getOpenOnRun() { + return openOnRun; + } + + /** + * Sets whether the dialog should be opened before the operation is run. NOTE: Setting this to false and not forking a process + * may starve any asyncExec that tries to open the dialog later. + * + * @param openOnRun + * <code>true</code> to open the dialog before run, <code>false</code> to only create the dialog, but not open it + * @since 3.0 + */ + public void setOpenOnRun(boolean openOnRun) { + this.openOnRun = openOnRun; + } + + /** + * Returns the nesting depth of running operations. + * + * @return the nesting depth of running operations + * @since 3.0 + */ + protected int getNestingDepth() { + return nestingDepth; + } + + /** + * Increments the nesting depth of running operations. + * + * @since 3.0 + */ + protected void incrementNestingDepth() { + nestingDepth++; + } + + /** + * Decrements the nesting depth of running operations. + * + * @since 3.0 + * + */ + protected void decrementNestingDepth() { + nestingDepth--; + } + + /** + * Called just before the operation is run. Default behaviour is to open or create the dialog, based on the setting of + * <code>getOpenOnRun</code>, and increment the nesting depth. + * + * @since 3.0 + */ + protected void aboutToRun() { + if (getOpenOnRun()) { + open(); + } else { + create(); + } + incrementNestingDepth(); + } + + /** + * Called just after the operation is run. Default behaviour is to decrement the nesting depth, and close the dialog. + * + * @since 3.0 + */ + protected void finishedRun() { + decrementNestingDepth(); + close(); + } + + /** + * Sets whether the progress dialog is cancelable or not. + * + * @param cancelable + * <code>true</code> if the end user can cancel this progress dialog, and <code>false</code> if it cannot be + * canceled + */ + public void setCancelable(boolean cancelable) { + if (cancel == null) + enableCancelButton = cancelable; + else + asyncSetOperationCancelButtonEnabled(cancelable); + } + /** + * Helper to enable/disable Cancel button for this dialog. + * + * @param b + * <code>true</code> to enable the cancel button, and <code>false</code> to disable it + * @since 3.0 + */ + protected void setOperationCancelButtonEnabled(boolean b) { + operationCancelableState = b; + cancel.setEnabled(b); + } + + /* + * @see org.eclipse.jface.dialogs.IconAndMessageDialog#getImage() + */ + protected Image getImage() { + if (progressMonitor.locked) + return JFaceResources.getImageRegistry().get(org.eclipse.jface.dialogs.Dialog.DLG_IMG_LOCKED); + else + return JFaceResources.getImageRegistry().get(org.eclipse.jface.dialogs.Dialog.DLG_IMG_INFO); + } + + /** + * Set the message in the message label. + */ + private void setMessage(String messageString) { + //must not set null text in a label + message = messageString == null ? "" : messageString; //$NON-NLS-1$ + if (messageLabel == null || messageLabel.isDisposed()) + return; + messageLabel.setText(message); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.window.Window#open() + */ + public int open() { + //Check to be sure it is not already done. If it is just return OK. + if (!getOpenOnRun()) { + if (getNestingDepth() == 0) + return OK; + } + return super.open(); + } + +}
\ No newline at end of file diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakeTargetsPreferencePage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakeTargetsPreferencePage.java new file mode 100644 index 00000000000..5dcbbb400bb --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakeTargetsPreferencePage.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.make.internal.ui.preferences; + +import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +public class MakeTargetsPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + + private static final String PREF_BUILD_TARGET_IN_BACKGROUND = "MakeTargetPrefs.buildTargetInBackground"; //$NON-NLS-1$ + private static final String TARGET_BUILDS_IN_BACKGROUND = "MakeTargetPreferencePage.buildTargetInBackground.label"; //$NON-NLS-1$ + + public MakeTargetsPreferencePage() { + super(GRID); + setPreferenceStore(MakeUIPlugin.getDefault().getPreferenceStore()); + } + + /** + * @see FieldEditorPreferencePage#createControl(Composite) + */ + protected void createFieldEditors() { + Composite parent = getFieldEditorParent(); + + BooleanFieldEditor tagetBackgroundEditor = new BooleanFieldEditor(PREF_BUILD_TARGET_IN_BACKGROUND, + MakeUIPlugin.getResourceString(TARGET_BUILDS_IN_BACKGROUND), parent); + addField(tagetBackgroundEditor); + } + + public static boolean isBuildTargetInBackground() { + return MakeUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_BUILD_TARGET_IN_BACKGROUND); + } + + public static void setBuildTargetInBackground(boolean enable) { + MakeUIPlugin.getDefault().getPreferenceStore().setValue(PREF_BUILD_TARGET_IN_BACKGROUND, enable); + } + + /** + * Initializes the default values of this page in the preference bundle. + */ + public static void initDefaults(IPreferenceStore prefs) { + prefs.setDefault(PREF_BUILD_TARGET_IN_BACKGROUND, true); + } + + public void init(IWorkbench workbench) { + } +}
\ No newline at end of file diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakePreferencePage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/NewMakeProjectPreferencePage.java index ec629b5400d..629168e8e7a 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakePreferencePage.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/NewMakeProjectPreferencePage.java @@ -22,25 +22,11 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; -/** - * This class represents a preference page that - * is contributed to the Preferences dialog. By - * subclassing <samp>FieldEditorPreferencePage</samp>, we - * can use the field support built into JFace that allows - * us to create a page that is small and knows how to - * save, restore and apply itself. - * <p> - * This page is used to modify preferences only. They - * are stored in the preference store that belongs to - * the main plug-in class. That way, preferences can - * be accessed directly via the preference store. - */ - -public class MakePreferencePage extends PreferencePage implements IWorkbenchPreferencePage, ICOptionContainer { +public class NewMakeProjectPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, ICOptionContainer { private MakeProjectOptionBlock fOptionBlock; - public MakePreferencePage() { + public NewMakeProjectPreferencePage() { setPreferenceStore(MakeUIPlugin.getDefault().getPreferenceStore()); setDescription(MakeUIPlugin.getResourceString("MakePreferencePage.description")); //$NON-NLS-1$ fOptionBlock = new MakeProjectOptionBlock(this); diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/TargetBuild.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/TargetBuild.java index ed562b57d2a..ebff0d85cb8 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/TargetBuild.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/TargetBuild.java @@ -1,8 +1,7 @@ package org.eclipse.cdt.make.ui; /* - * (c) Copyright QNX Software Systems Ltd. 2002. - * All Rights Reserved. + * (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved. */ import java.lang.reflect.InvocationTargetException; @@ -11,13 +10,17 @@ import java.util.List; import org.eclipse.cdt.make.core.IMakeTarget; import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; +import org.eclipse.cdt.make.internal.ui.dialogs.GoToBackProgressMonitorDialog; +import org.eclipse.cdt.make.internal.ui.preferences.MakeTargetsPreferencePage; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.swt.widgets.Shell; @@ -33,8 +36,7 @@ import org.eclipse.ui.actions.BuildAction; public class TargetBuild { /** - * Causes all editors to save any modified resources depending on the user's - * preference. + * Causes all editors to save any modified resources depending on the user's preference. */ static void saveAllResources(IMakeTarget[] targets) { @@ -68,36 +70,74 @@ public class TargetBuild { } } } - + static public void runWithProgressDialog(Shell shell, IMakeTarget[] targets) { - ProgressMonitorDialog pd = new ProgressMonitorDialog(shell); + GoToBackProgressMonitorDialog pd = new GoToBackProgressMonitorDialog(shell, + MakeUIPlugin.getResourceString("TargetBuild.backgroundTask.name")); //$NON-NLS-1$ try { TargetBuild.run(true, pd, targets); } catch (InvocationTargetException e) { - MakeUIPlugin.errorDialog(shell, MakeUIPlugin.getResourceString("TargetBuild.execption.message"), e.getTargetException().toString(), e.getTargetException()); //$NON-NLS-1$ + MakeUIPlugin.errorDialog(shell, MakeUIPlugin.getResourceString("TargetBuild.execption.message"), //$NON-NLS-1$ + e.getTargetException().toString(), e.getTargetException()); + } + } + + static public void buildTargets(Shell shell, final IMakeTarget[] targets) { + if (MakeTargetsPreferencePage.isBuildTargetInBackground()) { + new Job(MakeUIPlugin.getResourceString("TargetBuild.backgroundTask.name")) { //$NON-NLS-1$ + + protected IStatus run(IProgressMonitor monitor) { + monitor.beginTask(MakeUIPlugin.getResourceString("TargetBuild.monitor.beginTask"), targets.length); //$NON-NLS-1$ + try { + for (int i = 0; i < targets.length; i++) { + final IMakeTarget target = targets[i]; + IWorkspaceRunnable runnable = new IWorkspaceRunnable() { + + public void run(IProgressMonitor monitor) throws CoreException { + target.build(new SubProgressMonitor(monitor, 1)); + } + }; + MakeUIPlugin.getWorkspace().run(runnable, monitor); + } + } catch (CoreException e) { + return e.getStatus(); + } catch (OperationCanceledException e) { + } finally { + monitor.done(); + } + return Status.OK_STATUS; + } + }.schedule(); + } else { + runWithProgressDialog(shell, targets); } } - + static public void run(boolean fork, IRunnableContext context, final IMakeTarget[] targets) throws InvocationTargetException { try { saveAllResources(targets); context.run(fork, true, new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + monitor.beginTask(MakeUIPlugin.getResourceString("TargetBuild.monitor.beginTask"), targets.length); //$NON-NLS-1$ try { - IWorkspaceRunnable runnable = new IWorkspaceRunnable() { - public void run(IProgressMonitor monitor) throws CoreException { - monitor.beginTask(MakeUIPlugin.getResourceString("TargetBuild.monitor.beginTask"), targets.length); //$NON-NLS-1$ - for( int i = 0; i < targets.length; i++) { - targets[i].build(new SubProgressMonitor(monitor, 1)); + for (int i = 0; i < targets.length; i++) { + final IMakeTarget target = targets[i]; + IWorkspaceRunnable runnable = new IWorkspaceRunnable() { + + public void run(IProgressMonitor monitor) throws CoreException { + target.build(new SubProgressMonitor(monitor, 1)); } - } - }; - MakeUIPlugin.getWorkspace().run(runnable, monitor); + }; + MakeUIPlugin.getWorkspace().run(runnable, monitor); + } } catch (CoreException e) { throw new InvocationTargetException(e); } catch (OperationCanceledException e) { throw new InterruptedException(e.getMessage()); + } finally { + monitor.done(); } } }); @@ -105,4 +145,4 @@ public class TargetBuild { return; } } -} +}
\ No newline at end of file diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java index a1c76a57d8d..77979af7a4c 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java @@ -80,7 +80,7 @@ public class BuildTargetDialog extends Dialog { IMakeTarget selected = targetPart.getSelectedTarget(); super.okPressed(); if (selected != null) { - TargetBuild.runWithProgressDialog(getParentShell(), new IMakeTarget[] { selected }); + TargetBuild.buildTargets(getParentShell(), new IMakeTarget[] { selected }); } } diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/SettingsBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/SettingsBlock.java index 2596fa03904..51929a2351a 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/SettingsBlock.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/SettingsBlock.java @@ -55,6 +55,7 @@ public class SettingsBlock extends AbstractCOptionPage { private static final String MAKE_WORKBENCH_BUILD_AUTO = PREFIX + ".makeWorkbench.auto"; //$NON-NLS-1$ private static final String MAKE_WORKBENCH_BUILD_INCR = PREFIX + ".makeWorkbench.incremental"; //$NON-NLS-1$ private static final String MAKE_WORKBENCH_BUILD_FULL = PREFIX + ".makeWorkbench.full"; //$NON-NLS-1$ + private static final String MAKE_WORKBENCH_BUILD_CLEAN = PREFIX + ".makeWorkbench.clean"; //$NON-NLS-1$ private static final String MAKE_BUILD_DIR_GROUP = PREFIX + ".makeDir.group_label"; //$NON-NLS-1$ private static final String MAKE_BUILD_DIR_LABEL = PREFIX + ".makeDir.label"; //$NON-NLS-1$ @@ -70,9 +71,11 @@ public class SettingsBlock extends AbstractCOptionPage { Text targetFull; Text targetIncr; Text targetAuto; + Text targetClean; Button fullButton; Button incrButton; Button autoButton; + Button cleanButton; IMakeBuilderInfo fBuildInfo; Preferences fPrefs; @@ -154,6 +157,7 @@ public class SettingsBlock extends AbstractCOptionPage { targetAuto.setEnabled(autoButton.getSelection()); targetFull.setEnabled(fullButton.getSelection()); targetIncr.setEnabled(incrButton.getSelection()); + targetClean.setEnabled(cleanButton.getSelection()); getContainer().updateContainer(); } @@ -189,6 +193,14 @@ public class SettingsBlock extends AbstractCOptionPage { targetFull.setText(fBuildInfo.getFullBuildTarget()); ((GridData) (targetFull.getLayoutData())).horizontalAlignment = GridData.FILL; ((GridData) (targetFull.getLayoutData())).grabExcessHorizontalSpace = true; + + cleanButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_CLEAN)); + cleanButton.addSelectionListener(selectionAdapter); + cleanButton.setSelection(fBuildInfo.isCleanBuildEnabled()); + targetClean = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER); + targetClean.setText(fBuildInfo.getCleanBuildTarget()); + ((GridData) (targetClean.getLayoutData())).horizontalAlignment = GridData.FILL; + ((GridData) (targetClean.getLayoutData())).grabExcessHorizontalSpace = true; selectionAdapter.widgetSelected(null); } @@ -308,6 +320,8 @@ public class SettingsBlock extends AbstractCOptionPage { info.setIncrementalBuildTarget(targetIncr.getText().trim()); info.setFullBuildEnable(fullButton.getSelection()); info.setFullBuildTarget(targetFull.getText().trim()); + info.setCleanBuildEnable(cleanButton.getSelection()); + info.setCleanBuildTarget(targetClean.getText().trim()); if (buildLocation != null) { info.setBuildLocation(new Path(buildLocation.getText().trim())); } @@ -352,6 +366,8 @@ public class SettingsBlock extends AbstractCOptionPage { targetIncr.setText(info.getIncrementalBuildTarget()); fullButton.setSelection(info.isFullBuildEnabled()); targetFull.setText(info.getFullBuildTarget()); + cleanButton.setSelection(info.isCleanBuildEnabled()); + targetClean.setText(info.getCleanBuildTarget()); } boolean isStopOnError() { diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java index 934cf8545ab..106a2ef90cc 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java @@ -33,7 +33,7 @@ public class BuildTargetAction extends SelectionListenerAction { public void run() { if (canBuild()) { IMakeTarget[] targets = (IMakeTarget[]) getSelectedElements().toArray(new IMakeTarget[0]); - TargetBuild.runWithProgressDialog(shell, targets); + TargetBuild.buildTargets(shell, targets); } } |