Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 87446 Details for
Bug 129132
[Preferences] preferences for saving-before-build should offer Always, Prompt and Never
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch
129132 (text/plain), 42.20 KB, created by
Tod Creasey
on 2008-01-21 16:21:57 EST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Tod Creasey
Created:
2008-01-21 16:21:57 EST
Size:
42.20 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.ide >Index: src/org/eclipse/ui/internal/ide/dialogs/IDEWorkspacePreferencePage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/IDEWorkspacePreferencePage.java,v >retrieving revision 1.8 >diff -u -r1.8 IDEWorkspacePreferencePage.java >--- src/org/eclipse/ui/internal/ide/dialogs/IDEWorkspacePreferencePage.java 28 Jun 2007 09:07:28 -0000 1.8 >+++ src/org/eclipse/ui/internal/ide/dialogs/IDEWorkspacePreferencePage.java 21 Jan 2008 21:21:35 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * ARM Ltd - ARM Ltd - prompt to save before manual build (bug 129132) > *******************************************************************************/ > package org.eclipse.ui.internal.ide.dialogs; > >@@ -27,6 +28,8 @@ > import org.eclipse.jface.util.PropertyChangeEvent; > import org.eclipse.osgi.util.NLS; > import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.Button; >@@ -58,7 +61,7 @@ > > private Button autoBuildButton; > >- private Button autoSaveAllButton; >+ private RadioGroupFieldEditor saveBeforeBuildEditor; > > private IntegerFieldEditor saveInterval; > >@@ -141,17 +144,35 @@ > } > > protected void createSaveAllBeforeBuildPref(Composite composite) { >- autoSaveAllButton = new Button(composite, SWT.CHECK); >- autoSaveAllButton.setText(IDEWorkbenchMessages.IDEWorkspacePreference_savePriorToBuilding); >- autoSaveAllButton.setToolTipText(IDEWorkbenchMessages.IDEWorkspacePreference_savePriorToBuildingToolTip); >- autoSaveAllButton.setSelection(getIDEPreferenceStore().getBoolean( >- IDEInternalPreferences.SAVE_ALL_BEFORE_BUILD)); >- } >+ String[][] namesAndValues = { >+ { IDEWorkbenchMessages.Always, IDEInternalPreferences.PSPM_ALWAYS }, >+ { IDEWorkbenchMessages.Never, IDEInternalPreferences.PSPM_NEVER }, >+ { IDEWorkbenchMessages.Prompt, IDEInternalPreferences.PSPM_PROMPT } }; >+ saveBeforeBuildEditor = new RadioGroupFieldEditor(IDEInternalPreferences.SAVE_ALL_BEFORE_BUILD, >+ IDEWorkbenchMessages.IDEWorkspacePreference_savePriorToBuilding, >+ 3, namesAndValues, composite, true); >+ saveBeforeBuildEditor.setPreferenceStore(getIDEPreferenceStore()); >+ saveBeforeBuildEditor.setPage(this); >+ composite.setToolTipText(IDEWorkbenchMessages.IDEWorkspacePreference_savePriorToBuildingToolTip); >+ saveBeforeBuildEditor.load(); >+ saveBeforeBuildEditor.setEnabled(!autoBuildButton.getSelection(), composite); >+ } > >- protected void createAutoBuildPref(Composite composite) { >+ protected void createAutoBuildPref(final Composite composite) { > autoBuildButton = new Button(composite, SWT.CHECK); > autoBuildButton.setText(IDEWorkbenchMessages.IDEWorkspacePreference_autobuild); > autoBuildButton.setToolTipText(IDEWorkbenchMessages.IDEWorkspacePreference_autobuildToolTip); >+ autoBuildButton.addSelectionListener(new SelectionListener() { >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ widgetSelected(e); >+ } >+ >+ public void widgetSelected(SelectionEvent e) { >+ saveBeforeBuildEditor.setEnabled(!autoBuildButton.getSelection(), composite); >+ } >+ >+ }); > autoBuildButton.setSelection(ResourcesPlugin.getWorkspace() > .isAutoBuilding()); > } >@@ -326,10 +347,7 @@ > .getDefaultBoolean(ResourcesPlugin.PREF_AUTO_BUILDING); > autoBuildButton.setSelection(autoBuild); > >- IPreferenceStore store = getIDEPreferenceStore(); >- autoSaveAllButton >- .setSelection(store >- .getDefaultBoolean(IDEInternalPreferences.SAVE_ALL_BEFORE_BUILD)); >+ saveBeforeBuildEditor.loadDefault(); > saveInterval.loadDefault(); > > >@@ -370,10 +388,6 @@ > > IPreferenceStore store = getIDEPreferenceStore(); > >- // store the save all prior to build setting >- store.setValue(IDEInternalPreferences.SAVE_ALL_BEFORE_BUILD, >- autoSaveAllButton.getSelection()); >- > // store the workspace save interval > // @issue we should drop our preference constant and let clients use > // core's pref. ours is not up-to-date anyway if someone changes this >@@ -408,6 +422,7 @@ > encodingEditor.store(); > lineSeparatorEditor.store(); > openReferencesEditor.store(); >+ saveBeforeBuildEditor.store(); > return super.performOk(); > } > >Index: src/org/eclipse/ui/internal/ide/dialogs/CleanDialog.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/CleanDialog.java,v >retrieving revision 1.25 >diff -u -r1.25 CleanDialog.java >--- src/org/eclipse/ui/internal/ide/dialogs/CleanDialog.java 11 Oct 2007 12:59:16 -0000 1.25 >+++ src/org/eclipse/ui/internal/ide/dialogs/CleanDialog.java 21 Jan 2008 21:21:35 -0000 >@@ -12,6 +12,8 @@ > *******************************************************************************/ > package org.eclipse.ui.internal.ide.dialogs; > >+import java.util.Arrays; >+ > import org.eclipse.core.resources.IProject; > import org.eclipse.core.resources.IncrementalProjectBuilder; > import org.eclipse.core.resources.ResourcesPlugin; >@@ -56,146 +58,170 @@ > * @since 3.0 > */ > public class CleanDialog extends MessageDialog { >- >- private static final String DIALOG_SETTINGS_SECTION = "CleanDialogSettings"; //$NON-NLS-1$ >- private static final String DIALOG_ORIGIN_X = "DIALOG_X_ORIGIN"; //$NON-NLS-1$ >- private static final String DIALOG_ORIGIN_Y = "DIALOG_Y_ORIGIN"; //$NON-NLS-1$ >- private static final String DIALOG_WIDTH = "DIALOG_WIDTH"; //$NON-NLS-1$ >- private static final String DIALOG_HEIGHT = "DIALOG_HEIGHT"; //$NON-NLS-1$ >- private static final String TOGGLE_SELECTED = "TOGGLE_SELECTED"; //$NON-NLS-1$ >- private static final String BUILD_NOW = "BUILD_NOW"; //$NON-NLS-1$ >- >- private Button allButton, selectedButton, buildNowButton; >- >- private CheckboxTableViewer projectNames; >- >- private Object[] selection; >- >- private IWorkbenchWindow window; >- >- /** >- * Gets the text of the clean dialog, depending on whether the >- * workspace is currently in autobuild mode. >- * @return String the question the user will be asked. >- */ >- private static String getQuestion() { >- boolean autoBuilding = ResourcesPlugin.getWorkspace().isAutoBuilding(); >- if (autoBuilding) { >+ >+ private static final String DIALOG_SETTINGS_SECTION = "CleanDialogSettings"; //$NON-NLS-1$ >+ private static final String DIALOG_ORIGIN_X = "DIALOG_X_ORIGIN"; //$NON-NLS-1$ >+ private static final String DIALOG_ORIGIN_Y = "DIALOG_Y_ORIGIN"; //$NON-NLS-1$ >+ private static final String DIALOG_WIDTH = "DIALOG_WIDTH"; //$NON-NLS-1$ >+ private static final String DIALOG_HEIGHT = "DIALOG_HEIGHT"; //$NON-NLS-1$ >+ private static final String TOGGLE_SELECTED = "TOGGLE_SELECTED"; //$NON-NLS-1$ >+ private static final String BUILD_NOW = "BUILD_NOW"; //$NON-NLS-1$ >+ >+ private Button allButton, selectedButton, buildNowButton; >+ >+ private CheckboxTableViewer projectNames; >+ >+ private Object[] selection; >+ >+ private IWorkbenchWindow window; >+ >+ /** >+ * Gets the text of the clean dialog, depending on whether the workspace is >+ * currently in autobuild mode. >+ * >+ * @return String the question the user will be asked. >+ */ >+ private static String getQuestion() { >+ boolean autoBuilding = ResourcesPlugin.getWorkspace().isAutoBuilding(); >+ if (autoBuilding) { > return IDEWorkbenchMessages.CleanDialog_buildCleanAuto; > } >- return IDEWorkbenchMessages.CleanDialog_buildCleanManual; >- } >+ return IDEWorkbenchMessages.CleanDialog_buildCleanManual; >+ } > >- /** >- * Creates a new clean dialog. >- * >- * @param window the window to create it in >- * @param selection the currently selected projects (may be empty) >- */ >- public CleanDialog(IWorkbenchWindow window, IProject[] selection) { >- super( >- window.getShell(), >- IDEWorkbenchMessages.CleanDialog_title, null, getQuestion(), NONE, new String[] { >- IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0); >- this.window = window; >- this.selection = selection; >- if (this.selection == null) { >+ /** >+ * Creates a new clean dialog. >+ * >+ * @param window >+ * the window to create it in >+ * @param selection >+ * the currently selected projects (may be empty) >+ */ >+ public CleanDialog(IWorkbenchWindow window, IProject[] selection) { >+ super(window.getShell(), IDEWorkbenchMessages.CleanDialog_title, null, >+ getQuestion(), NONE, new String[] { IDialogConstants.OK_LABEL, >+ IDialogConstants.CANCEL_LABEL }, 0); >+ this.window = window; >+ this.selection = selection; >+ if (this.selection == null) { > this.selection = new Object[0]; > } >- } >+ } > >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) >- */ >- protected void buttonPressed(int buttonId) { >- final boolean cleanAll = allButton.getSelection(); >- final boolean buildAll = buildNowButton != null >- && buildNowButton.getSelection(); >- super.buttonPressed(buttonId); >- if (buttonId != IDialogConstants.OK_ID) { >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) >+ */ >+ protected void buttonPressed(int buttonId) { >+ final boolean cleanAll = allButton.getSelection(); >+ final boolean buildAll = buildNowButton != null >+ && buildNowButton.getSelection(); >+ super.buttonPressed(buttonId); >+ if (buttonId != IDialogConstants.OK_ID) { > return; > } >- //save all dirty editors >- BuildUtilities.saveEditors(null); >- //batching changes ensures that autobuild runs after cleaning >- WorkspaceJob cleanJob = new WorkspaceJob(IDEWorkbenchMessages.CleanDialog_taskName) { >- public boolean belongsTo(Object family) { >- return ResourcesPlugin.FAMILY_MANUAL_BUILD.equals(family); >- } >- public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { >- doClean(cleanAll, monitor); >- //see if a build was requested >- if (buildAll) { >- //start an immediate workspace build >- GlobalBuildAction build = new GlobalBuildAction(window, >- IncrementalProjectBuilder.INCREMENTAL_BUILD); >- build.doBuild(); >- } >- return Status.OK_STATUS; >- } >- }; >- cleanJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory() >- .buildRule()); >- cleanJob.setUser(true); >- cleanJob.schedule(); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite) >- */ >- protected Control createCustomArea(Composite parent) { >- Composite area = new Composite(parent, SWT.NONE); >- GridLayout layout = new GridLayout(); >- layout.marginWidth = layout.marginHeight = 0; >- layout.numColumns = 2; >- layout.makeColumnsEqualWidth = true; >- area.setLayout(layout); >- area.setLayoutData(new GridData(GridData.FILL_BOTH)); >- SelectionListener updateEnablement = new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- updateEnablement(); >- } >- }; >- >- IDialogSettings settings = getDialogSettings(DIALOG_SETTINGS_SECTION); >- boolean selectSelectedButton= settings.getBoolean(TOGGLE_SELECTED); >- //first row >- allButton = new Button(area, SWT.RADIO); >- allButton.setText(IDEWorkbenchMessages.CleanDialog_cleanAllButton); >- allButton.setSelection(!selectSelectedButton); >- allButton.addSelectionListener(updateEnablement); >- selectedButton = new Button(area, SWT.RADIO); >- selectedButton.setText(IDEWorkbenchMessages.CleanDialog_cleanSelectedButton); >- selectedButton.setSelection(selectSelectedButton); >- selectedButton.addSelectionListener(updateEnablement); >- >- //second row >- createProjectSelectionTable(area); >- >- //third row >- //only prompt for immediate build if autobuild is off >- if (!ResourcesPlugin.getWorkspace().isAutoBuilding()) { >- buildNowButton = new Button(parent, SWT.CHECK); >- buildNowButton.setText(IDEWorkbenchMessages.CleanDialog_buildNowButton); >- String buildNow = settings.get(BUILD_NOW); >- buildNowButton.setSelection(buildNow == null || Boolean.valueOf(buildNow).booleanValue()); >- buildNowButton.setLayoutData(new GridData( >- GridData.HORIZONTAL_ALIGN_BEGINNING)); >- } >- projectNames.getTable().setEnabled(selectSelectedButton); >- return area; >- } >- >- private void createProjectSelectionTable(Composite radioGroup) { >- projectNames = CheckboxTableViewer.newCheckList(radioGroup, SWT.BORDER); >- projectNames.setContentProvider(new WorkbenchContentProvider()); >- projectNames.setLabelProvider(new WorkbenchLabelProvider()); >- projectNames.setComparator(new ResourceComparator(ResourceComparator.NAME)); >- projectNames.addFilter(new ViewerFilter() { >- private final IProject[] projectHolder = new IProject[1]; >- public boolean select(Viewer viewer, Object parentElement, Object element) { >+ // save all dirty editors >+ // save dirty editors in projects to be cleaned >+ if (cleanAll) { >+ if (!BuildUtilities.saveEditors(null)) { >+ return; >+ } >+ } else { >+ if (!BuildUtilities.saveEditors(Arrays.asList(selection))) { >+ return; >+ } >+ } >+ >+ // batching changes ensures that autobuild runs after cleaning >+ // batching changes ensures that autobuild runs after cleaning >+ WorkspaceJob cleanJob = new WorkspaceJob( >+ IDEWorkbenchMessages.CleanDialog_taskName) { >+ public boolean belongsTo(Object family) { >+ return ResourcesPlugin.FAMILY_MANUAL_BUILD.equals(family); >+ } >+ >+ public IStatus runInWorkspace(IProgressMonitor monitor) >+ throws CoreException { >+ doClean(cleanAll, monitor); >+ // see if a build was requested >+ if (buildAll) { >+ // start an immediate workspace build >+ GlobalBuildAction build = new GlobalBuildAction(window, >+ IncrementalProjectBuilder.INCREMENTAL_BUILD); >+ build.doBuild(); >+ } >+ return Status.OK_STATUS; >+ } >+ }; >+ cleanJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory() >+ .buildRule()); >+ cleanJob.setUser(true); >+ cleanJob.schedule(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite) >+ */ >+ protected Control createCustomArea(Composite parent) { >+ Composite area = new Composite(parent, SWT.NONE); >+ GridLayout layout = new GridLayout(); >+ layout.marginWidth = layout.marginHeight = 0; >+ layout.numColumns = 2; >+ layout.makeColumnsEqualWidth = true; >+ area.setLayout(layout); >+ area.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ SelectionListener updateEnablement = new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ updateEnablement(); >+ } >+ }; >+ >+ IDialogSettings settings = getDialogSettings(DIALOG_SETTINGS_SECTION); >+ boolean selectSelectedButton = settings.getBoolean(TOGGLE_SELECTED); >+ // first row >+ allButton = new Button(area, SWT.RADIO); >+ allButton.setText(IDEWorkbenchMessages.CleanDialog_cleanAllButton); >+ allButton.setSelection(!selectSelectedButton); >+ allButton.addSelectionListener(updateEnablement); >+ selectedButton = new Button(area, SWT.RADIO); >+ selectedButton >+ .setText(IDEWorkbenchMessages.CleanDialog_cleanSelectedButton); >+ selectedButton.setSelection(selectSelectedButton); >+ selectedButton.addSelectionListener(updateEnablement); >+ >+ // second row >+ createProjectSelectionTable(area); >+ >+ // third row >+ // only prompt for immediate build if autobuild is off >+ if (!ResourcesPlugin.getWorkspace().isAutoBuilding()) { >+ buildNowButton = new Button(parent, SWT.CHECK); >+ buildNowButton >+ .setText(IDEWorkbenchMessages.CleanDialog_buildNowButton); >+ String buildNow = settings.get(BUILD_NOW); >+ buildNowButton.setSelection(buildNow == null >+ || Boolean.valueOf(buildNow).booleanValue()); >+ buildNowButton.setLayoutData(new GridData( >+ GridData.HORIZONTAL_ALIGN_BEGINNING)); >+ } >+ projectNames.getTable().setEnabled(selectSelectedButton); >+ return area; >+ } >+ >+ private void createProjectSelectionTable(Composite radioGroup) { >+ projectNames = CheckboxTableViewer.newCheckList(radioGroup, SWT.BORDER); >+ projectNames.setContentProvider(new WorkbenchContentProvider()); >+ projectNames.setLabelProvider(new WorkbenchLabelProvider()); >+ projectNames.setComparator(new ResourceComparator( >+ ResourceComparator.NAME)); >+ projectNames.addFilter(new ViewerFilter() { >+ private final IProject[] projectHolder = new IProject[1]; >+ >+ public boolean select(Viewer viewer, Object parentElement, >+ Object element) { > if (!(element instanceof IProject)) { > return false; > } >@@ -204,19 +230,20 @@ > return false; > } > projectHolder[0] = project; >- return BuildUtilities.isEnabled(projectHolder, IncrementalProjectBuilder.CLEAN_BUILD); >+ return BuildUtilities.isEnabled(projectHolder, >+ IncrementalProjectBuilder.CLEAN_BUILD); > } > }); >- projectNames.setInput(ResourcesPlugin.getWorkspace().getRoot()); >- GridData data = new GridData(GridData.FILL_BOTH); >- data.horizontalSpan = 2; >- data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; >- data.heightHint = IDialogConstants.ENTRY_FIELD_WIDTH; >- projectNames.getTable().setLayoutData(data); >- projectNames.setCheckedElements(selection); >- //table is disabled to start because all button is selected >- projectNames.getTable().setEnabled(selectedButton.getSelection()); >- projectNames.addCheckStateListener(new ICheckStateListener() { >+ projectNames.setInput(ResourcesPlugin.getWorkspace().getRoot()); >+ GridData data = new GridData(GridData.FILL_BOTH); >+ data.horizontalSpan = 2; >+ data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH; >+ data.heightHint = IDialogConstants.ENTRY_FIELD_WIDTH; >+ projectNames.getTable().setLayoutData(data); >+ projectNames.setCheckedElements(selection); >+ // table is disabled to start because all button is selected >+ projectNames.getTable().setEnabled(selectedButton.getSelection()); >+ projectNames.addCheckStateListener(new ICheckStateListener() { > public void checkStateChanged(CheckStateChangedEvent event) { > selection = projectNames.getCheckedElements(); > updateEnablement(); >@@ -226,140 +253,164 @@ > > /** > * Performs the actual clean operation. >- * @param cleanAll if <code>true</true> clean all projects >+ * >+ * @param cleanAll >+ * if <code>true</true> clean all projects > * @param monitor The monitor that the build will report to > * @throws CoreException thrown if there is a problem from the > * core builder. > */ > protected void doClean(boolean cleanAll, IProgressMonitor monitor) >- throws CoreException { >- if (cleanAll) { >+ throws CoreException { >+ if (cleanAll) { > ResourcesPlugin.getWorkspace().build( >- IncrementalProjectBuilder.CLEAN_BUILD, monitor); >+ IncrementalProjectBuilder.CLEAN_BUILD, monitor); > } else { >- try { >- monitor.beginTask(IDEWorkbenchMessages.CleanDialog_taskName, selection.length); >- for (int i = 0; i < selection.length; i++) { >+ try { >+ monitor.beginTask(IDEWorkbenchMessages.CleanDialog_taskName, >+ selection.length); >+ for (int i = 0; i < selection.length; i++) { > ((IProject) selection[i]).build( >- IncrementalProjectBuilder.CLEAN_BUILD, >- new SubProgressMonitor(monitor, 1)); >+ IncrementalProjectBuilder.CLEAN_BUILD, >+ new SubProgressMonitor(monitor, 1)); > } >- } finally { >- monitor.done(); >- } >- } >- } >- >- /** >- * Updates the enablement of the dialog's ok button based >- * on the current choices in the dialog. >- */ >- protected void updateEnablement() { >- projectNames.getTable().setEnabled(selectedButton.getSelection()); >- boolean enabled = allButton.getSelection() || selection.length > 0; >- getButton(OK).setEnabled(enabled); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.window.Window#close() >- */ >- public boolean close() { >- persistDialogSettings(getShell(), DIALOG_SETTINGS_SECTION); >- return super.close(); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.window.Window#getInitialLocation(org.eclipse.swt.graphics.Point) >- */ >- protected Point getInitialLocation(Point initialSize) { >- Point p = getInitialLocation(DIALOG_SETTINGS_SECTION); >- return p != null ? p : super.getInitialLocation(initialSize); >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.jface.window.Window#getInitialSize() >- */ >- protected Point getInitialSize() { >- Point p = super.getInitialSize(); >- return getInitialSize(DIALOG_SETTINGS_SECTION, p); >- } >- >- /** >- * Returns the initial location which is persisted in the Ant UI Plugin dialog settings >- * under the provided dialog setttings section name. >- * If location is not persisted in the settings, the <code>null</code> is returned. >- * >- * @param dialogSettingsSectionName The name of the dialog settings section >- * @return The initial location or <code>null</code> >- */ >- public Point getInitialLocation(String dialogSettingsSectionName) { >- IDialogSettings settings = getDialogSettings(dialogSettingsSectionName); >- try { >- int x= settings.getInt(DIALOG_ORIGIN_X); >- int y= settings.getInt(DIALOG_ORIGIN_Y); >- return new Point(x,y); >- } catch (NumberFormatException e) { >- } >- return null; >- } >- >- private IDialogSettings getDialogSettings(String dialogSettingsSectionName) { >- IDialogSettings settings = IDEWorkbenchPlugin.getDefault().getDialogSettings(); >- IDialogSettings section = settings.getSection(dialogSettingsSectionName); >- if (section == null) { >- section = settings.addNewSection(dialogSettingsSectionName); >- } >- return section; >- } >- >- /** >- * Persists the location and dimensions of the shell and other user settings in the >- * plugin's dialog settings under the provided dialog settings section name >- * >- * @param shell The shell whose geometry is to be stored >- * @param dialogSettingsSectionName The name of the dialog settings section >- */ >- private void persistDialogSettings(Shell shell, String dialogSettingsSectionName) { >- Point shellLocation = shell.getLocation(); >- Point shellSize = shell.getSize(); >- IDialogSettings settings = getDialogSettings(dialogSettingsSectionName); >- settings.put(DIALOG_ORIGIN_X, shellLocation.x); >- settings.put(DIALOG_ORIGIN_Y, shellLocation.y); >- settings.put(DIALOG_WIDTH, shellSize.x); >- settings.put(DIALOG_HEIGHT, shellSize.y); >- >- if (buildNowButton != null) { >- settings.put(BUILD_NOW, buildNowButton.getSelection()); >- } >- settings.put(TOGGLE_SELECTED, selectedButton.getSelection()); >- } >- >- /** >- * Returns the initial size which is the larger of the <code>initialSize</code> or >- * the size persisted in the Ant UI Plugin dialog settings under the provided dialog setttings section name. >- * If no size is persisted in the settings, the <code>initialSize</code> is returned. >- * >- * @param initialSize The initialSize to compare against >- * @param dialogSettingsSectionName The name of the dialog settings section >- * @return the initial size >- */ >- private Point getInitialSize(String dialogSettingsSectionName, Point initialSize) { >- IDialogSettings settings = getDialogSettings(dialogSettingsSectionName); >- try { >- int x, y; >- x = settings.getInt(DIALOG_WIDTH); >- y = settings.getInt(DIALOG_HEIGHT); >- return new Point(Math.max(x, initialSize.x), Math.max(y, initialSize.y)); >- } catch (NumberFormatException e) { >- } >- return initialSize; >- } >- >- /* >- * (non-Javadoc) >- * @see org.eclipse.jface.dialogs.Dialog#isResizable() >- */ >- protected boolean isResizable() { >- return true; >- } >+ } finally { >+ monitor.done(); >+ } >+ } >+ } >+ >+ /** >+ * Updates the enablement of the dialog's ok button based on the current >+ * choices in the dialog. >+ */ >+ protected void updateEnablement() { >+ projectNames.getTable().setEnabled(selectedButton.getSelection()); >+ boolean enabled = allButton.getSelection() || selection.length > 0; >+ getButton(OK).setEnabled(enabled); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.window.Window#close() >+ */ >+ public boolean close() { >+ persistDialogSettings(getShell(), DIALOG_SETTINGS_SECTION); >+ return super.close(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.window.Window#getInitialLocation(org.eclipse.swt.graphics.Point) >+ */ >+ protected Point getInitialLocation(Point initialSize) { >+ Point p = getInitialLocation(DIALOG_SETTINGS_SECTION); >+ return p != null ? p : super.getInitialLocation(initialSize); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.window.Window#getInitialSize() >+ */ >+ protected Point getInitialSize() { >+ Point p = super.getInitialSize(); >+ return getInitialSize(DIALOG_SETTINGS_SECTION, p); >+ } >+ >+ /** >+ * Returns the initial location which is persisted in the Ant UI Plugin >+ * dialog settings under the provided dialog setttings section name. If >+ * location is not persisted in the settings, the <code>null</code> is >+ * returned. >+ * >+ * @param dialogSettingsSectionName >+ * The name of the dialog settings section >+ * @return The initial location or <code>null</code> >+ */ >+ public Point getInitialLocation(String dialogSettingsSectionName) { >+ IDialogSettings settings = getDialogSettings(dialogSettingsSectionName); >+ try { >+ int x = settings.getInt(DIALOG_ORIGIN_X); >+ int y = settings.getInt(DIALOG_ORIGIN_Y); >+ return new Point(x, y); >+ } catch (NumberFormatException e) { >+ } >+ return null; >+ } >+ >+ private IDialogSettings getDialogSettings(String dialogSettingsSectionName) { >+ IDialogSettings settings = IDEWorkbenchPlugin.getDefault() >+ .getDialogSettings(); >+ IDialogSettings section = settings >+ .getSection(dialogSettingsSectionName); >+ if (section == null) { >+ section = settings.addNewSection(dialogSettingsSectionName); >+ } >+ return section; >+ } >+ >+ /** >+ * Persists the location and dimensions of the shell and other user settings >+ * in the plugin's dialog settings under the provided dialog settings >+ * section name >+ * >+ * @param shell >+ * The shell whose geometry is to be stored >+ * @param dialogSettingsSectionName >+ * The name of the dialog settings section >+ */ >+ private void persistDialogSettings(Shell shell, >+ String dialogSettingsSectionName) { >+ Point shellLocation = shell.getLocation(); >+ Point shellSize = shell.getSize(); >+ IDialogSettings settings = getDialogSettings(dialogSettingsSectionName); >+ settings.put(DIALOG_ORIGIN_X, shellLocation.x); >+ settings.put(DIALOG_ORIGIN_Y, shellLocation.y); >+ settings.put(DIALOG_WIDTH, shellSize.x); >+ settings.put(DIALOG_HEIGHT, shellSize.y); >+ >+ if (buildNowButton != null) { >+ settings.put(BUILD_NOW, buildNowButton.getSelection()); >+ } >+ settings.put(TOGGLE_SELECTED, selectedButton.getSelection()); >+ } >+ >+ /** >+ * Returns the initial size which is the larger of the >+ * <code>initialSize</code> or the size persisted in the Ant UI Plugin >+ * dialog settings under the provided dialog setttings section name. If no >+ * size is persisted in the settings, the <code>initialSize</code> is >+ * returned. >+ * >+ * @param initialSize >+ * The initialSize to compare against >+ * @param dialogSettingsSectionName >+ * The name of the dialog settings section >+ * @return the initial size >+ */ >+ private Point getInitialSize(String dialogSettingsSectionName, >+ Point initialSize) { >+ IDialogSettings settings = getDialogSettings(dialogSettingsSectionName); >+ try { >+ int x, y; >+ x = settings.getInt(DIALOG_WIDTH); >+ y = settings.getInt(DIALOG_HEIGHT); >+ return new Point(Math.max(x, initialSize.x), Math.max(y, >+ initialSize.y)); >+ } catch (NumberFormatException e) { >+ } >+ return initialSize; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.dialogs.Dialog#isResizable() >+ */ >+ protected boolean isResizable() { >+ return true; >+ } > } >Index: extensions/org/eclipse/ui/actions/BuildAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/BuildAction.java,v >retrieving revision 1.19 >diff -u -r1.19 BuildAction.java >--- extensions/org/eclipse/ui/actions/BuildAction.java 19 Jul 2006 21:34:36 -0000 1.19 >+++ extensions/org/eclipse/ui/actions/BuildAction.java 21 Jan 2008 21:21:35 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * ARM Ltd - ARM Ltd - prompt to save before manual build (bug 129132) > *******************************************************************************/ > package org.eclipse.ui.actions; > >@@ -25,15 +26,12 @@ > import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.jface.preference.IPreferenceStore; > import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.jface.viewers.StructuredSelection; > import org.eclipse.swt.widgets.Shell; > import org.eclipse.ui.IWorkbenchWindow; > import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.internal.ide.IDEInternalPreferences; > import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; >-import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; > import org.eclipse.ui.internal.ide.IIDEHelpContextIds; > import org.eclipse.ui.internal.ide.actions.BuildUtilities; > >@@ -206,18 +204,6 @@ > return super.isEnabled(); > } > >- /** >- * Returns whether the user's preference is set to automatically save modified >- * resources before a manual build is done. >- * >- * @return <code>true</code> if Save All Before Build is enabled >- */ >- public static boolean isSaveAllSet() { >- IPreferenceStore store = IDEWorkbenchPlugin.getDefault() >- .getPreferenceStore(); >- return store.getBoolean(IDEInternalPreferences.SAVE_ALL_BEFORE_BUILD); >- } >- > /* (non-Javadoc) > * Method declared on WorkspaceAction. > * >@@ -278,7 +264,9 @@ > } > > // Save all resources prior to doing build >- BuildUtilities.saveEditors(projects); >+ if (!BuildUtilities.saveEditors(projects)) { >+ return; >+ } > runInBackground(ResourcesPlugin.getWorkspace().getRuleFactory() > .buildRule(), ResourcesPlugin.FAMILY_MANUAL_BUILD); > } >Index: extensions/org/eclipse/ui/actions/GlobalBuildAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/GlobalBuildAction.java,v >retrieving revision 1.25 >diff -u -r1.25 GlobalBuildAction.java >--- extensions/org/eclipse/ui/actions/GlobalBuildAction.java 8 May 2006 20:54:12 -0000 1.25 >+++ extensions/org/eclipse/ui/actions/GlobalBuildAction.java 21 Jan 2008 21:21:35 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * ARM Ltd - prompt to save before manual build (bug 129132) > *******************************************************************************/ > package org.eclipse.ui.actions; > >@@ -237,7 +238,9 @@ > return; > } > // Save all resources prior to doing build >- BuildUtilities.saveEditors(null); >+ if (!BuildUtilities.saveEditors(null)) { >+ return; >+ } > // Perform the build on all the projects > doBuildOperation(); > } >Index: src/org/eclipse/ui/internal/ide/IDEInternalPreferences.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEInternalPreferences.java,v >retrieving revision 1.19 >diff -u -r1.19 IDEInternalPreferences.java >--- src/org/eclipse/ui/internal/ide/IDEInternalPreferences.java 15 Jan 2008 18:21:22 -0000 1.19 >+++ src/org/eclipse/ui/internal/ide/IDEInternalPreferences.java 21 Jan 2008 21:21:35 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * ARM Ltd - prompt to save before manual build (bug 129132) > *******************************************************************************/ > > package org.eclipse.ui.internal.ide; >@@ -17,7 +18,7 @@ > * The IDEInternalPreferences are the internal constants used by the Workbench. > */ > public interface IDEInternalPreferences { >- // (boolean) Save all dirty editors before running a full or incremental build >+ // (String) Save all dirty editors before running a full or incremental build > public static final String SAVE_ALL_BEFORE_BUILD = "SAVE_ALL_BEFORE_BUILD"; //$NON-NLS-1$ > > // (boolean) Refresh workspace on startup >Index: src/org/eclipse/ui/internal/ide/IDEPreferenceInitializer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEPreferenceInitializer.java,v >retrieving revision 1.14 >diff -u -r1.14 IDEPreferenceInitializer.java >--- src/org/eclipse/ui/internal/ide/IDEPreferenceInitializer.java 15 Jan 2008 18:21:23 -0000 1.14 >+++ src/org/eclipse/ui/internal/ide/IDEPreferenceInitializer.java 21 Jan 2008 21:21:35 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2006 IBM Corporation and others. >+ * Copyright (c) 2004, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * ARM Ltd - prompt to save before manual build (bug 129132) > *******************************************************************************/ > package org.eclipse.ui.internal.ide; > >@@ -45,7 +46,8 @@ > > // Internal preferences > >- node.putBoolean(IDEInternalPreferences.SAVE_ALL_BEFORE_BUILD, false); >+ node.put(IDEInternalPreferences.SAVE_ALL_BEFORE_BUILD, >+ IDEInternalPreferences.PSPM_PROMPT); > node.putInt(IDEInternalPreferences.SAVE_INTERVAL, 5); // 5 minutes > node.putBoolean(IDEInternalPreferences.WELCOME_DIALOG, true); > node.putBoolean(IDEInternalPreferences.REFRESH_WORKSPACE_ON_STARTUP, >Index: src/org/eclipse/ui/internal/ide/actions/BuildUtilities.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/BuildUtilities.java,v >retrieving revision 1.9 >diff -u -r1.9 BuildUtilities.java >--- src/org/eclipse/ui/internal/ide/actions/BuildUtilities.java 24 Feb 2006 17:53:22 -0000 1.9 >+++ src/org/eclipse/ui/internal/ide/actions/BuildUtilities.java 21 Jan 2008 21:21:35 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2006 IBM Corporation and others. >+ * Copyright (c) 2004, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,11 +7,14 @@ > * > * Contributors: > * IBM - Initial API and implementation >+ * ARM Ltd - prompt to save before manual build (bug 129132) > *******************************************************************************/ > package org.eclipse.ui.internal.ide.actions; > >+import java.util.ArrayList; > import java.util.Collection; > import java.util.HashSet; >+import java.util.List; > > import org.eclipse.core.resources.ICommand; > import org.eclipse.core.resources.IFile; >@@ -22,15 +25,21 @@ > import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.resources.mapping.ResourceMapping; > import org.eclipse.core.runtime.CoreException; >+import org.eclipse.jface.dialogs.ProgressMonitorDialog; >+import org.eclipse.jface.operation.IRunnableContext; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.window.IShellProvider; >+import org.eclipse.swt.widgets.Shell; > import org.eclipse.ui.IEditorPart; > import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.IWorkbenchPart; > import org.eclipse.ui.IWorkbenchWindow; > import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.actions.BuildAction; > import org.eclipse.ui.ide.ResourceUtil; >+import org.eclipse.ui.internal.EditorManager; >+import org.eclipse.ui.internal.ide.IDEInternalPreferences; >+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; > > /** > * This class contains convenience methods used by the various build commands >@@ -150,32 +159,58 @@ > * of projects depending on the user's preference. > * @param projects The projects in which to save editors, or <code>null</code> > * to save editors in all projects. >+ * @return <code>true</code> if it is OK to continue with the build, or <code>false</code> >+ * otherwise (i.e. if the user has canceled). > */ >- public static void saveEditors(Collection projects) { >- if (!BuildAction.isSaveAllSet()) { >- return; >+ public static boolean saveEditors(Collection projects) { >+ String saveBeforeBuildSetting = IDEWorkbenchPlugin.getDefault().getPreferenceStore().getString(IDEInternalPreferences.SAVE_ALL_BEFORE_BUILD); >+ if (saveBeforeBuildSetting.equals(IDEInternalPreferences.PSPM_NEVER)) { >+ return true; > } >+ final boolean confirmRequired = saveBeforeBuildSetting.equals(IDEInternalPreferences.PSPM_PROMPT); >+ List dirtyEditors = new ArrayList(); >+ > IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); > for (int i = 0; i < windows.length; i++) { > IWorkbenchPage[] pages = windows[i].getPages(); > for (int j = 0; j < pages.length; j++) { > IWorkbenchPage page = pages[j]; >- if (projects == null) { >- page.saveAllEditors(false); >- } else { >- IEditorPart[] editors = page.getDirtyEditors(); >- for (int k = 0; k < editors.length; k++) { >- IEditorPart editor = editors[k]; >+ IEditorPart[] editors = page.getDirtyEditors(); >+ for (int k = 0; k < editors.length; k++) { >+ IEditorPart editor = editors[k]; >+ if (projects == null) { >+ dirtyEditors.add(editor); >+ } >+ else { > IFile inputFile = ResourceUtil.getFile(editor.getEditorInput()); >- if (inputFile != null) { >- if (projects.contains(inputFile.getProject())) { >- page.saveEditor(editor, false); >- } >+ if (inputFile != null && projects.contains(inputFile.getProject())) { >+ dirtyEditors.add(editor); > } > } > } > } > } >+ >+ /* Taken from org.eclipse.ui.internal.Workbench.saveAllEditors */ >+ IShellProvider shellProvider; >+ IRunnableContext runnableContext; >+ IWorkbenchWindow w = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); >+ if (w == null && windows.length > 0) { >+ w = windows[0]; >+ } >+ if (w != null) { >+ shellProvider = w; >+ runnableContext = w; >+ } else { >+ shellProvider = new IShellProvider() { >+ public Shell getShell() { >+ return null; >+ } >+ }; >+ runnableContext = new ProgressMonitorDialog(null); >+ } >+ >+ return EditorManager.saveAll(dirtyEditors, confirmRequired, false, true, runnableContext, shellProvider); > } > > /**
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 129132
:
76051
| 87446