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 22638 Details for
Bug 98707
[Patch] Apply Patch should have public API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Creates public access for ApplyPatch functionality with dialog settings control.
create-public-ApplyPatch-with-dialogSettings-control.patch (text/plain), 19.98 KB, created by
Jeff Pound
on 2005-06-08 16:32:54 EDT
(
hide
)
Description:
Creates public access for ApplyPatch functionality with dialog settings control.
Filename:
MIME Type:
Creator:
Jeff Pound
Created:
2005-06-08 16:32:54 EDT
Size:
19.98 KB
patch
obsolete
>Index: plugin.xml >=================================================================== >RCS file: /home/eclipse/org.eclipse.compare/plugin.xml,v >retrieving revision 1.57 >diff -u -r1.57 plugin.xml >--- plugin.xml 9 May 2005 16:20:33 -0000 1.57 >+++ plugin.xml 8 Jun 2005 20:26:59 -0000 >@@ -195,7 +195,7 @@ > <action > label="%CompareWithPatchAction.label" > tooltip="%CompareWithPatchAction.tooltip" >- class="org.eclipse.compare.internal.patch.CompareWithPatchAction" >+ class="org.eclipse.compare.CompareWithPatchAction" > menubarPath="team.main/group1" > enablesFor="1" > id="compareWithPatch"> >Index: compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java >=================================================================== >RCS file: compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java >diff -N compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java >--- compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java 14 Apr 2005 13:53:03 -0000 1.17 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,154 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2004 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 >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.compare.internal.patch; >- >-import java.lang.reflect.InvocationTargetException; >-import java.util.Arrays; >- >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.events.SelectionAdapter; >-import org.eclipse.swt.events.SelectionEvent; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.swt.widgets.Button; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Control; >-import org.eclipse.swt.widgets.Shell; >- >-import org.eclipse.jface.dialogs.ProgressMonitorDialog; >-import org.eclipse.jface.operation.IRunnableWithProgress; >-import org.eclipse.jface.util.Assert; >-import org.eclipse.jface.viewers.*; >-import org.eclipse.jface.window.Window; >-import org.eclipse.jface.wizard.IWizard; >-import org.eclipse.jface.wizard.WizardDialog; >- >-import org.eclipse.core.resources.*; >-import org.eclipse.core.runtime.*; >- >-import org.eclipse.ui.IEditorPart; >- >-import org.eclipse.compare.internal.*; >- >- >-public class CompareWithPatchAction extends BaseCompareAction { >- >- static class PatchWizardDialog extends WizardDialog { >- >- PatchWizardDialog(Shell parent, IWizard wizard) { >- super(parent, wizard); >- >- setShellStyle(getShellStyle() | SWT.RESIZE); >- setMinimumPageSize(700, 500); >- } >- } >- >- protected boolean isEnabled(ISelection selection) { >- return Utilities.getResources(selection).length == 1; >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.compare.internal.BaseCompareAction#run(org.eclipse.jface.viewers.ISelection) >- */ >- protected void run(ISelection selection) { >- PatchWizard wizard= new PatchWizard(selection); >- >- if (areAllEditorsSaved()) { >- PatchWizardDialog dialog= new PatchWizardDialog(CompareUIPlugin.getShell(), wizard); >- dialog.open(); >- } >- } >- >- private boolean areAllEditorsSaved(){ >- if (CompareUIPlugin.getDirtyEditors().length == 0) >- return true; >- if (! saveAllDirtyEditors()) >- return false; >- Shell shell= CompareUIPlugin.getShell(); >- try { >- // Save isn't cancelable. >- IWorkspace workspace= ResourcesPlugin.getWorkspace(); >- IWorkspaceDescription description= workspace.getDescription(); >- boolean autoBuild= description.isAutoBuilding(); >- description.setAutoBuilding(false); >- workspace.setDescription(description); >- try { >- new ProgressMonitorDialog(shell).run(false, false, createRunnable()); >- } finally { >- description.setAutoBuilding(autoBuild); >- workspace.setDescription(description); >- } >- return true; >- } catch (InvocationTargetException e) { >- ExceptionHandler.handle(e, shell, PatchMessages.PatchAction_ExceptionTitle, PatchMessages.PatchAction_Exception); >- return false; >- } catch (CoreException e) { >- ExceptionHandler.handle(e, shell, PatchMessages.PatchAction_ExceptionTitle, PatchMessages.PatchAction_Exception); >- return false; >- } catch (InterruptedException e) { >- Assert.isTrue(false); // Can't happen. Operation isn't cancelable. >- return false; >- } >- } >- >- private IRunnableWithProgress createRunnable() { >- return new IRunnableWithProgress() { >- public void run(IProgressMonitor pm) { >- IEditorPart[] editorsToSave= CompareUIPlugin.getDirtyEditors(); >- pm.beginTask(PatchMessages.PatchAction_SavingDirtyEditorsTask, editorsToSave.length); >- for (int i= 0; i < editorsToSave.length; i++) { >- editorsToSave[i].doSave(new SubProgressMonitor(pm, 1)); >- pm.worked(1); >- } >- pm.done(); >- } >- }; >- } >- >- private boolean saveAllDirtyEditors() { >- if (ComparePreferencePage.getSaveAllEditors()) //must save everything >- return true; >- ListDialog dialog= new ListDialog(CompareUIPlugin.getShell()) { >- protected Control createDialogArea(Composite parent) { >- Composite result= (Composite) super.createDialogArea(parent); >- final Button check= new Button(result, SWT.CHECK); >- check.setText(PatchMessages.PatchAction_AlwaysSaveQuestion); >- check.setSelection(ComparePreferencePage.getSaveAllEditors()); >- check.addSelectionListener( >- new SelectionAdapter() { >- public void widgetSelected(SelectionEvent e) { >- ComparePreferencePage.setSaveAllEditors(check.getSelection()); >- } >- } >- ); >- applyDialogFont(result); >- return result; >- } >- }; >- dialog.setTitle(PatchMessages.PatchAction_SaveAllQuestion); >- dialog.setAddCancelButton(true); >- dialog.setLabelProvider(createDialogLabelProvider()); >- dialog.setMessage(PatchMessages.PatchAction_SaveAllDescription); >- dialog.setContentProvider(new ListContentProvider()); >- dialog.setInput(Arrays.asList(CompareUIPlugin.getDirtyEditors())); >- return dialog.open() == Window.OK; >- } >- >- private ILabelProvider createDialogLabelProvider() { >- return new LabelProvider() { >- public Image getImage(Object element) { >- return ((IEditorPart) element).getTitleImage(); >- } >- public String getText(Object element) { >- return ((IEditorPart) element).getTitle(); >- } >- }; >- } >-} >Index: compare/org/eclipse/compare/internal/patch/InputPatchPage.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/InputPatchPage.java,v >retrieving revision 1.26 >diff -u -r1.26 InputPatchPage.java >--- compare/org/eclipse/compare/internal/patch/InputPatchPage.java 6 May 2005 19:03:14 -0000 1.26 >+++ compare/org/eclipse/compare/internal/patch/InputPatchPage.java 8 Jun 2005 20:26:59 -0000 >@@ -10,30 +10,58 @@ > *******************************************************************************/ > package org.eclipse.compare.internal.patch; > >-import java.io.*; >+import java.io.BufferedReader; >+import java.io.File; >+import java.io.FileNotFoundException; >+import java.io.FileReader; >+import java.io.IOException; >+import java.io.Reader; >+import java.io.StringReader; > import java.text.MessageFormat; > >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.dnd.*; >-import org.eclipse.swt.events.*; >-import org.eclipse.swt.layout.*; >-import org.eclipse.swt.widgets.*; >- >-import org.eclipse.jface.dialogs.*; >-import org.eclipse.jface.dialogs.Dialog; >-import org.eclipse.jface.viewers.*; >-import org.eclipse.jface.wizard.*; >- >-import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.model.*; >- > import org.eclipse.compare.internal.ICompareContextIds; > import org.eclipse.compare.internal.Utilities; >-import org.eclipse.core.resources.*; >-import org.eclipse.core.runtime.*; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IWorkspace; >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.jface.dialogs.Dialog; >+import org.eclipse.jface.dialogs.IDialogSettings; >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.jface.viewers.CheckboxTreeViewer; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.ISelectionChangedListener; >+import org.eclipse.jface.viewers.SelectionChangedEvent; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.jface.wizard.IWizardPage; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.dnd.Clipboard; >+import org.eclipse.swt.dnd.TextTransfer; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Combo; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.FileDialog; >+import org.eclipse.swt.widgets.Group; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Text; >+import org.eclipse.swt.widgets.Tree; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.model.WorkbenchContentProvider; >+import org.eclipse.ui.model.WorkbenchLabelProvider; >+import org.eclipse.ui.model.WorkbenchViewerSorter; > > >-/* package */ class InputPatchPage extends WizardPage { >+/* package */public class InputPatchPage extends WizardPage { > > // constants > protected static final int SIZING_TEXT_FIELD_WIDTH= 250; >@@ -41,8 +69,8 @@ > > // dialog store id constants > private final static String PAGE_NAME= "PatchWizardPage1"; //$NON-NLS-1$ >- private final static String STORE_PATCH_FILES_ID= PAGE_NAME + ".PATCH_FILES"; //$NON-NLS-1$ >- private final static String STORE_USE_CLIPBOARD_ID= PAGE_NAME + ".USE_CLIPBOARD"; //$NON-NLS-1$ >+ public final static String STORE_PATCH_FILES_ID= PAGE_NAME + ".PATCH_FILES"; //$NON-NLS-1$ >+ public final static String STORE_USE_CLIPBOARD_ID= PAGE_NAME + ".USE_CLIPBOARD"; //$NON-NLS-1$ > > static final char SEPARATOR = System.getProperty ("file.separator").charAt (0); //$NON-NLS-1$ > >@@ -269,8 +297,11 @@ > > PatchWizard pw= (PatchWizard) getWizard(); > IResource target= pw.getTarget(); >- IWorkspace workspace= target.getWorkspace(); >- IWorkspaceRoot root= workspace.getRoot(); >+ IWorkspaceRoot root = null; >+ if (target != null) { >+ IWorkspace workspace= target.getWorkspace(); >+ root= workspace.getRoot(); >+ } > > Tree tree= new Tree(parent, SWT.BORDER); > GridData gd= new GridData(GridData.FILL_BOTH); >Index: compare/org/eclipse/compare/internal/patch/PatchWizard.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.compare/compare/org/eclipse/compare/internal/patch/PatchWizard.java,v >retrieving revision 1.22 >diff -u -r1.22 PatchWizard.java >--- compare/org/eclipse/compare/internal/patch/PatchWizard.java 14 Apr 2005 13:53:03 -0000 1.22 >+++ compare/org/eclipse/compare/internal/patch/PatchWizard.java 8 Jun 2005 20:26:59 -0000 >@@ -25,10 +25,10 @@ > import org.eclipse.compare.internal.*; > > >-/* package */ class PatchWizard extends Wizard { >+/* package */ public class PatchWizard extends Wizard { > > // dialog store id constants >- private final static String DIALOG_SETTINGS_KEY= "PatchWizard"; //$NON-NLS-1$ >+ public final static String DIALOG_SETTINGS_KEY= "PatchWizard"; //$NON-NLS-1$ > > private boolean fHasNewDialogSettings; > >@@ -41,7 +41,7 @@ > /* > * Creates a wizard for applying a patch file to the workspace. > */ >- /* package */ PatchWizard(ISelection selection) { >+ /* package */ public PatchWizard(ISelection selection) { > > setDefaultPageImageDescriptor(CompareUIPlugin.getImageDescriptor("wizban/applypatch_wizban.gif")); //$NON-NLS-1$ > setWindowTitle(PatchMessages.PatchWizard_title); >Index: compare/org/eclipse/compare/CompareWithPatchAction.java >=================================================================== >RCS file: compare/org/eclipse/compare/CompareWithPatchAction.java >diff -N compare/org/eclipse/compare/CompareWithPatchAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compare/org/eclipse/compare/CompareWithPatchAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,162 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.compare; >+ >+import java.lang.reflect.InvocationTargetException; >+import java.util.Arrays; >+ >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Shell; >+ >+import org.eclipse.jface.dialogs.ProgressMonitorDialog; >+import org.eclipse.jface.operation.IRunnableWithProgress; >+import org.eclipse.jface.util.Assert; >+import org.eclipse.jface.viewers.*; >+import org.eclipse.jface.window.Window; >+import org.eclipse.jface.wizard.IWizard; >+import org.eclipse.jface.wizard.WizardDialog; >+ >+import org.eclipse.core.resources.*; >+import org.eclipse.core.runtime.*; >+ >+import org.eclipse.ui.IEditorPart; >+ >+import org.eclipse.compare.internal.*; >+import org.eclipse.compare.internal.patch.PatchMessages; >+import org.eclipse.compare.internal.patch.PatchWizard; >+ >+ >+public class CompareWithPatchAction extends BaseCompareAction { >+ >+ private PatchDialogSettings dialogSettings; //$NON-NLS-1$ >+ >+ static class PatchWizardDialog extends WizardDialog { >+ >+ PatchWizardDialog(Shell parent, IWizard wizard) { >+ super(parent, wizard); >+ >+ setShellStyle(getShellStyle() | SWT.RESIZE); >+ setMinimumPageSize(700, 500); >+ } >+ } >+ >+ protected boolean isEnabled(ISelection selection) { >+ return Utilities.getResources(selection).length == 1; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.compare.internal.BaseCompareAction#run(org.eclipse.jface.viewers.ISelection) >+ */ >+ protected void run(ISelection selection) { >+ PatchWizard wizard= new PatchWizard(selection); >+ wizard.setDialogSettings(dialogSettings); >+ if (areAllEditorsSaved()) { >+ PatchWizardDialog dialog= new PatchWizardDialog(CompareUIPlugin.getShell(), wizard); >+ dialog.open(); >+ } >+ } >+ >+ private boolean areAllEditorsSaved(){ >+ if (CompareUIPlugin.getDirtyEditors().length == 0) >+ return true; >+ if (! saveAllDirtyEditors()) >+ return false; >+ Shell shell= CompareUIPlugin.getShell(); >+ try { >+ // Save isn't cancelable. >+ IWorkspace workspace= ResourcesPlugin.getWorkspace(); >+ IWorkspaceDescription description= workspace.getDescription(); >+ boolean autoBuild= description.isAutoBuilding(); >+ description.setAutoBuilding(false); >+ workspace.setDescription(description); >+ try { >+ new ProgressMonitorDialog(shell).run(false, false, createRunnable()); >+ } finally { >+ description.setAutoBuilding(autoBuild); >+ workspace.setDescription(description); >+ } >+ return true; >+ } catch (InvocationTargetException e) { >+ ExceptionHandler.handle(e, shell, PatchMessages.PatchAction_ExceptionTitle, PatchMessages.PatchAction_Exception); >+ return false; >+ } catch (CoreException e) { >+ ExceptionHandler.handle(e, shell, PatchMessages.PatchAction_ExceptionTitle, PatchMessages.PatchAction_Exception); >+ return false; >+ } catch (InterruptedException e) { >+ Assert.isTrue(false); // Can't happen. Operation isn't cancelable. >+ return false; >+ } >+ } >+ >+ private IRunnableWithProgress createRunnable() { >+ return new IRunnableWithProgress() { >+ public void run(IProgressMonitor pm) { >+ IEditorPart[] editorsToSave= CompareUIPlugin.getDirtyEditors(); >+ pm.beginTask(PatchMessages.PatchAction_SavingDirtyEditorsTask, editorsToSave.length); >+ for (int i= 0; i < editorsToSave.length; i++) { >+ editorsToSave[i].doSave(new SubProgressMonitor(pm, 1)); >+ pm.worked(1); >+ } >+ pm.done(); >+ } >+ }; >+ } >+ >+ private boolean saveAllDirtyEditors() { >+ if (ComparePreferencePage.getSaveAllEditors()) //must save everything >+ return true; >+ ListDialog dialog= new ListDialog(CompareUIPlugin.getShell()) { >+ protected Control createDialogArea(Composite parent) { >+ Composite result= (Composite) super.createDialogArea(parent); >+ final Button check= new Button(result, SWT.CHECK); >+ check.setText(PatchMessages.PatchAction_AlwaysSaveQuestion); >+ check.setSelection(ComparePreferencePage.getSaveAllEditors()); >+ check.addSelectionListener( >+ new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ ComparePreferencePage.setSaveAllEditors(check.getSelection()); >+ } >+ } >+ ); >+ applyDialogFont(result); >+ return result; >+ } >+ }; >+ dialog.setTitle(PatchMessages.PatchAction_SaveAllQuestion); >+ dialog.setAddCancelButton(true); >+ dialog.setLabelProvider(createDialogLabelProvider()); >+ dialog.setMessage(PatchMessages.PatchAction_SaveAllDescription); >+ dialog.setContentProvider(new ListContentProvider()); >+ dialog.setInput(Arrays.asList(CompareUIPlugin.getDirtyEditors())); >+ return dialog.open() == Window.OK; >+ } >+ >+ private ILabelProvider createDialogLabelProvider() { >+ return new LabelProvider() { >+ public Image getImage(Object element) { >+ return ((IEditorPart) element).getTitleImage(); >+ } >+ public String getText(Object element) { >+ return ((IEditorPart) element).getTitle(); >+ } >+ }; >+ } >+ >+ public void setDialogSettings(PatchDialogSettings config) { >+ this.dialogSettings = config; >+ } >+} >Index: compare/org/eclipse/compare/PatchDialogSettings.java >=================================================================== >RCS file: compare/org/eclipse/compare/PatchDialogSettings.java >diff -N compare/org/eclipse/compare/PatchDialogSettings.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compare/org/eclipse/compare/PatchDialogSettings.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,46 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2004 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.compare; >+ >+import org.eclipse.compare.internal.patch.InputPatchPage; >+import org.eclipse.compare.internal.patch.PatchWizard; >+import org.eclipse.jface.dialogs.DialogSettings; >+ >+/** >+ * <code>CompareWithPatchConfiguration</code> represents a UI configuration >+ * for the <code>CompareWithPatchAction</code> wizard. >+ * >+ * >+ */ >+public class PatchDialogSettings extends DialogSettings { >+ >+ public PatchDialogSettings(String sectionName) { >+ super(sectionName); >+ } >+ >+ public PatchDialogSettings() { >+ super(PatchWizard.DIALOG_SETTINGS_KEY); >+ } >+ >+ public String getPatchPath() { >+ return this.get(InputPatchPage.STORE_PATCH_FILES_ID); >+ } >+ public void setPatchPath(String patchPath) { >+ this.put(InputPatchPage.STORE_PATCH_FILES_ID, patchPath); >+ } >+ >+ public boolean isUseClipboard() { >+ return this.getBoolean(InputPatchPage.STORE_USE_CLIPBOARD_ID); >+ } >+ public void setUseClipboard(boolean useClipboard) { >+ this.put(InputPatchPage.STORE_USE_CLIPBOARD_ID, useClipboard); >+ } >+}
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 98707
:
22533
|
22548
|
22638
|
34624