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 76051 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]
Proposed patch
patch (text/plain), 19.01 KB, created by
Bernie
on 2007-08-14 11:32:47 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Bernie
Created:
2007-08-14 11:32:47 EDT
Size:
19.01 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.ide >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 14 Aug 2007 15:13:37 -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); > } > > /** >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.17 >diff -u -r1.17 IDEInternalPreferences.java >--- src/org/eclipse/ui/internal/ide/IDEInternalPreferences.java 1 Mar 2006 17:30:20 -0000 1.17 >+++ src/org/eclipse/ui/internal/ide/IDEInternalPreferences.java 14 Aug 2007 15:13:37 -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.10 >diff -u -r1.10 IDEPreferenceInitializer.java >--- src/org/eclipse/ui/internal/ide/IDEPreferenceInitializer.java 1 Mar 2006 17:30:20 -0000 1.10 >+++ src/org/eclipse/ui/internal/ide/IDEPreferenceInitializer.java 14 Aug 2007 15:13:37 -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; > >@@ -44,7 +45,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/dialogs/CleanDialog.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/CleanDialog.java,v >retrieving revision 1.24 >diff -u -r1.24 CleanDialog.java >--- src/org/eclipse/ui/internal/ide/dialogs/CleanDialog.java 2 Jul 2007 22:56:08 -0000 1.24 >+++ src/org/eclipse/ui/internal/ide/dialogs/CleanDialog.java 14 Aug 2007 15:13:37 -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,9 +7,12 @@ > * > * Contributors: > * IBM - Initial API and implementation >+ * ARM Ltd - prompt to save before manual build (bug 129132) > *******************************************************************************/ > 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; >@@ -115,8 +118,18 @@ > if (buttonId != IDialogConstants.OK_ID) { > return; > } >- //save all dirty editors >- BuildUtilities.saveEditors(null); >+ //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 > WorkspaceJob cleanJob = new WorkspaceJob(IDEWorkbenchMessages.CleanDialog_taskName) { > public boolean belongsTo(Object family) { >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 14 Aug 2007 15:13:37 -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: 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 14 Aug 2007 15:13:37 -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 14 Aug 2007 15:13:37 -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(); > }
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