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 75095 Details for
Bug 198310
PDE NLS wizard could use a Preview page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch
patch198310.txt (text/plain), 27.00 KB, created by
Adam Archer
on 2007-08-01 02:04:06 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Adam Archer
Created:
2007-08-01 02:04:06 EDT
Size:
27.00 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.ui >Index: src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifest.java,v >retrieving revision 1.14 >diff -u -r1.14 OrganizeManifest.java >--- src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifest.java 27 Jul 2007 19:24:29 -0000 1.14 >+++ src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifest.java 1 Aug 2007 06:00:33 -0000 >@@ -298,7 +298,7 @@ > HostSpecification hostSpec = bundleDesc.getHost(); > if (hostSpec != null) { > BundleDescription[] hosts = hostSpec.getHosts(); >- for (int i = 0; i < hosts.length; i++) { >+ for (int i = 0; hosts != null && i < hosts.length; i++) { > IPluginModelBase hostModel = PluginRegistry.findModel(hosts[i]); > if (hostModel != null) { > findTranslatedXMLStrings(getTextModel(hostModel, false), list); >Index: src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsWizard.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsWizard.java,v >retrieving revision 1.6 >diff -u -r1.6 OrganizeManifestsWizard.java >--- src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsWizard.java 27 Jul 2007 19:24:29 -0000 1.6 >+++ src/org/eclipse/pde/internal/ui/wizards/tools/OrganizeManifestsWizard.java 1 Aug 2007 06:00:34 -0000 >@@ -21,7 +21,7 @@ > private OrganizeManifestsWizardPage fMainPage; > > public OrganizeManifestsWizard(PDERefactor refactoring) { >- super(refactoring, RefactoringWizard.DIALOG_BASED_USER_INTERFACE); >+ super(refactoring, WIZARD_BASED_USER_INTERFACE); > setNeedsProgressMonitor(true); > setWindowTitle(PDEUIMessages.OrganizeManifestsWizard_title); > setDialogSettings(PDEPlugin.getDefault().getDialogSettings()); >Index: src/org/eclipse/pde/internal/ui/PDEUIMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java,v >retrieving revision 1.306 >diff -u -r1.306 PDEUIMessages.java >--- src/org/eclipse/pde/internal/ui/PDEUIMessages.java 31 Jul 2007 18:22:34 -0000 1.306 >+++ src/org/eclipse/pde/internal/ui/PDEUIMessages.java 1 Aug 2007 06:00:29 -0000 >@@ -71,6 +71,10 @@ > > public static String EclipsePluginValidationOperation_pluginMissing; > >+ public static String ExternalizeStringsOperation_pluginChangeName; >+ >+ public static String ExternalizeStringsProcessor_errorMessage; >+ > public static String JavaArgumentsTab_appendLauncherIni; > > public static String OrganizeManifestsProcessor_invalidParam; >Index: src/org/eclipse/pde/internal/ui/pderesources.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties,v >retrieving revision 1.900 >diff -u -r1.900 pderesources.properties >--- src/org/eclipse/pde/internal/ui/pderesources.properties 31 Jul 2007 18:22:35 -0000 1.900 >+++ src/org/eclipse/pde/internal/ui/pderesources.properties 1 Aug 2007 06:00:32 -0000 >@@ -584,8 +584,10 @@ > ExternalizeStringsWizardPage_localizationLabel=&Localization: > ExternalizeStringsWizardPage_propertiesLabel=Strings to externalize: > ExternalizeStringsWizardPage_sourceLabel=Source: >+ExternalizeStringsProcessor_errorMessage=The files to change have not been set on the ExternalizeStringsProcessor > ExternalizeStringsWizardPage_keyEmptyError=New key may not be empty > ExternalizeStringsWizardPage_keyCommentError=New key may not begin with #, ! or % characters >+ExternalizeStringsOperation_pluginChangeName=Externalize Strings for {0} > ExternalizeStringsWizardPage_keyError=New key may not contain : or = " " (space) characters > ExternalizeStringsWizardPage_value=Value > ExternalizeStringsWizardPage_subKey=Substitution Key >Index: src/org/eclipse/pde/internal/ui/nls/ExternalizeStringsWizard.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/nls/ExternalizeStringsWizard.java,v >retrieving revision 1.5 >diff -u -r1.5 ExternalizeStringsWizard.java >--- src/org/eclipse/pde/internal/ui/nls/ExternalizeStringsWizard.java 3 May 2006 13:31:05 -0000 1.5 >+++ src/org/eclipse/pde/internal/ui/nls/ExternalizeStringsWizard.java 1 Aug 2007 06:00:32 -0000 >@@ -10,36 +10,24 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.ui.nls; > >-import java.lang.reflect.InvocationTargetException; >- >-import org.eclipse.jface.wizard.Wizard; >+import org.eclipse.ltk.ui.refactoring.RefactoringWizard; > import org.eclipse.pde.internal.ui.PDEPluginImages; > import org.eclipse.pde.internal.ui.PDEUIMessages; >+import org.eclipse.pde.internal.ui.refactoring.PDERefactor; > >-public class ExternalizeStringsWizard extends Wizard { >+public class ExternalizeStringsWizard extends RefactoringWizard { > private ExternalizeStringsWizardPage page1; > private ModelChangeTable fModelChangeTable; > >- public ExternalizeStringsWizard(ModelChangeTable changeTable) { >+ public ExternalizeStringsWizard(ModelChangeTable changeTable, PDERefactor refactoring) { >+ super(refactoring, WIZARD_BASED_USER_INTERFACE); > setWindowTitle(PDEUIMessages.ExternalizeStringsWizard_title); > setDefaultPageImageDescriptor(PDEPluginImages.DESC_EXTSTR_WIZ); > setNeedsProgressMonitor(true); > fModelChangeTable = changeTable; > } >- >- public boolean performFinish() { >- try { >- getContainer().run(false, false, >- new ExternalizeStringsOperation(page1.getChangeFiles())); >- } catch (InvocationTargetException e) { >- return false; >- } catch (InterruptedException e) { >- return false; >- } >- return true; >- } >- >- public void addPages() { >+ protected void addUserInputPages() { >+ setDefaultPageTitle( getRefactoring().getName() ); > page1 = new ExternalizeStringsWizardPage(fModelChangeTable); > addPage(page1); > } >Index: src/org/eclipse/pde/internal/ui/nls/ExternalizeStringsWizardPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/nls/ExternalizeStringsWizardPage.java,v >retrieving revision 1.22 >diff -u -r1.22 ExternalizeStringsWizardPage.java >--- src/org/eclipse/pde/internal/ui/nls/ExternalizeStringsWizardPage.java 28 Dec 2006 18:59:32 -0000 1.22 >+++ src/org/eclipse/pde/internal/ui/nls/ExternalizeStringsWizardPage.java 1 Aug 2007 06:00:33 -0000 >@@ -37,7 +37,7 @@ > import org.eclipse.jface.viewers.TextCellEditor; > import org.eclipse.jface.viewers.Viewer; > import org.eclipse.jface.viewers.ViewerFilter; >-import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.ltk.ui.refactoring.UserInputWizardPage; > import org.eclipse.pde.core.plugin.IPluginModelBase; > import org.eclipse.pde.internal.ui.IHelpContextIds; > import org.eclipse.pde.internal.ui.PDEPlugin; >@@ -48,6 +48,7 @@ > import org.eclipse.pde.internal.ui.editor.text.IColorManager; > import org.eclipse.pde.internal.ui.editor.text.ManifestConfiguration; > import org.eclipse.pde.internal.ui.editor.text.XMLConfiguration; >+import org.eclipse.pde.internal.ui.refactoring.PDERefactor; > import org.eclipse.pde.internal.ui.wizards.ListUtil; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.SashForm; >@@ -70,7 +71,7 @@ > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer; > >-public class ExternalizeStringsWizardPage extends WizardPage { >+public class ExternalizeStringsWizardPage extends UserInputWizardPage { > > public static final String PAGE_NAME = "ExternalizeStringsWizardPage"; //$NON-NLS-1$ > >@@ -573,4 +574,13 @@ > if (!exception.equals(fDeselectAll)) > fDeselectAll.setEnabled(enabled); > } >+ >+ public void setPageComplete(boolean complete) { >+ super.setPageComplete(complete); >+ // if the page is ready to be completed set the selection on the processor so it knows >+ // what work needs to be done >+ if (complete) >+ ((ExternalizeStringsProcessor)((PDERefactor)getRefactoring()).getProcessor()). >+ setChangeFiles(fInputViewer.getCheckedElements()); >+ } > } >Index: src/org/eclipse/pde/internal/ui/nls/ExternalizeStringsOperation.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/nls/ExternalizeStringsOperation.java,v >retrieving revision 1.12 >diff -u -r1.12 ExternalizeStringsOperation.java >--- src/org/eclipse/pde/internal/ui/nls/ExternalizeStringsOperation.java 8 Jun 2007 16:45:07 -0000 1.12 >+++ src/org/eclipse/pde/internal/ui/nls/ExternalizeStringsOperation.java 1 Aug 2007 06:00:32 -0000 >@@ -10,29 +10,27 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.ui.nls; > >-import java.io.ByteArrayInputStream; >-import java.io.IOException; > import java.lang.reflect.InvocationTargetException; >+import java.util.HashMap; > import java.util.Iterator; > > import org.eclipse.core.filebuffers.FileBuffers; > import org.eclipse.core.filebuffers.ITextFileBuffer; > import org.eclipse.core.filebuffers.ITextFileBufferManager; >-import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.filebuffers.LocationKind; > import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IFolder; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.NullProgressMonitor; >-import org.eclipse.jface.text.BadLocationException; > import org.eclipse.jface.text.IDocument; > import org.eclipse.jface.text.TextUtilities; >+import org.eclipse.ltk.core.refactoring.CompositeChange; >+import org.eclipse.ltk.core.refactoring.TextFileChange; > import org.eclipse.osgi.util.NLS; > import org.eclipse.pde.core.IBaseModel; > import org.eclipse.pde.core.plugin.IPluginModelBase; > import org.eclipse.pde.internal.core.ibundle.IBundle; > import org.eclipse.pde.internal.core.ibundle.IBundlePluginModel; >-import org.eclipse.pde.internal.core.util.CoreUtility; >+import org.eclipse.pde.internal.ui.PDEUIMessages; > import org.eclipse.pde.internal.ui.util.ModelModification; > import org.eclipse.pde.internal.ui.util.PDEModelUtility; > import org.eclipse.text.edits.InsertEdit; >@@ -44,48 +42,74 @@ > public class ExternalizeStringsOperation extends WorkspaceModifyOperation { > > private Object[] fChangeFiles; >+ private CompositeChange fParentChange; >+ private HashMap fCompositeChanges; >+ private HashMap fFileEdits; > >- public ExternalizeStringsOperation(Object[] changeFiles) { >+ public ExternalizeStringsOperation(Object[] changeFiles, CompositeChange parentChange) { > fChangeFiles = changeFiles; >+ fParentChange = parentChange; >+ fCompositeChanges = new HashMap(); >+ fFileEdits = new HashMap(); > } > protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { > for (int i = 0; i < fChangeFiles.length; i++) { > if (fChangeFiles[i] instanceof ModelChangeFile) { > ModelChangeFile changeFile = (ModelChangeFile)fChangeFiles[i]; >+ CompositeChange pluginChange = getChangeForPlugin(changeFile.getModel().getParentModel().getPluginBase().getId()); > ModelChange change = changeFile.getModel(); > IFile pFile = change.getPropertiesFile(); >- checkPropertiesFile(pFile); >+ // if the properties file does not exist and we have not already made a TextFileChange >+ // for it create the Change and insert a comment >+ if (!pFile.exists() && !fFileEdits.containsKey(pFile)) >+ getEditForFile(pFile, pluginChange).addChild(new InsertEdit(0, getPropertiesFileComment(pFile))); > if (!change.localizationSet()) >- addBundleLocalization(change, monitor); >+ addBundleLocalization(change, monitor, pluginChange); > > ITextFileBufferManager pManager = FileBuffers.getTextFileBufferManager(); > try { >- pManager.connect(pFile.getFullPath(), monitor); >- ITextFileBuffer pBuffer = pManager.getTextFileBuffer(pFile.getFullPath()); >+ pManager.connect(pFile.getFullPath(), LocationKind.IFILE, monitor); >+ ITextFileBuffer pBuffer = pManager.getTextFileBuffer(pFile.getFullPath(), LocationKind.IFILE); > IDocument pDoc = pBuffer.getDocument(); >- MultiTextEdit pEdit = new MultiTextEdit(); >+ MultiTextEdit pEdit = getEditForFile(pFile, pluginChange); > >- doReplace(changeFile, pDoc, pEdit, monitor); >- >- pEdit.apply(pDoc); >- pBuffer.commit(monitor, true); >+ doReplace(changeFile, pDoc, pEdit, monitor, pluginChange); > > } catch (MalformedTreeException e) { >- } catch (BadLocationException e) { > } finally { >- pManager.disconnect(pFile.getFullPath(), monitor); >+ pManager.disconnect(pFile.getFullPath(), LocationKind.IFILE, monitor); > } > } > } > } >- private void doReplace(ModelChangeFile changeFile, IDocument pDoc, MultiTextEdit pEdit, IProgressMonitor monitor) throws CoreException { >+ private CompositeChange getChangeForPlugin(String pluginName) { >+ if (fCompositeChanges.containsKey(pluginName)) >+ return (CompositeChange) fCompositeChanges.get(pluginName); >+ CompositeChange result = new CompositeChange(NLS.bind(PDEUIMessages.ExternalizeStringsOperation_pluginChangeName, pluginName)); >+ fCompositeChanges.put(pluginName, result); >+ fParentChange.add(result); >+ return result; >+ } >+ private MultiTextEdit getEditForFile(IFile file, CompositeChange parentChange) { >+ if (fFileEdits.containsKey(file)) >+ return (MultiTextEdit) fFileEdits.get(file); >+ MultiTextEdit edit = new MultiTextEdit(); >+ TextFileChange change = new TextFileChange(file.getName(), file); >+ change.setEdit(edit); >+ // mark a plugin.xml or a fragment.xml as PLUGIN2 type so they will be compared >+ // with the PluginContentMergeViewer >+ String textType = file.getName().equals("plugin.xml") || //$NON-NLS-1$ >+ file.getName().equals("fragment.xml") ? //$NON-NLS-1$ >+ "PLUGIN2" : file.getFileExtension(); //$NON-NLS-1$ >+ change.setTextType(textType); >+ parentChange.add(change); >+ fFileEdits.put(file, edit); >+ return edit; >+ } >+ private void doReplace(ModelChangeFile changeFile, IDocument pDoc, MultiTextEdit pEdit, IProgressMonitor monitor, CompositeChange parentChange) throws CoreException { > IFile uFile = changeFile.getFile(); >- ITextFileBufferManager uManager = FileBuffers.getTextFileBufferManager(); > try { >- uManager.connect(uFile.getFullPath(), monitor); >- ITextFileBuffer uBuffer = uManager.getTextFileBuffer(uFile.getFullPath()); >- IDocument uDoc = uBuffer.getDocument(); >- MultiTextEdit uEdit = new MultiTextEdit(); >+ MultiTextEdit uEdit = getEditForFile(uFile, parentChange); > > Iterator iter = changeFile.getChanges().iterator(); > >@@ -98,21 +122,20 @@ > pEdit.addChild(getPropertiesInsertEdit(pDoc, changeElement)); > } > } >- uEdit.apply(uDoc); >- uBuffer.commit(monitor, true); >- > } catch (MalformedTreeException e) { >- } catch (BadLocationException e) { >- } finally { >- uManager.disconnect(uFile.getFullPath(), monitor); > } > } > >- private void addBundleLocalization(ModelChange change, IProgressMonitor mon) { >+ private void addBundleLocalization(ModelChange change, IProgressMonitor mon, CompositeChange parent) { > IPluginModelBase base = change.getParentModel(); > IFile manifest = base.getUnderlyingResource().getProject().getFile(PDEModelUtility.F_MANIFEST_FP); >+ // if the edit for this manifest file is in the HashMap, then we must have added >+ // the localization already since it is checked first (this must be the second or subsequent >+ // change to the manifest for this plug-in) >+ if (fFileEdits.containsKey(manifest)) >+ return; > final String localiz = change.getBundleLocalization(); >- PDEModelUtility.modifyModel(new ModelModification(manifest) { >+ TextFileChange[] result = PDEModelUtility.changesForModelModication(new ModelModification(manifest) { > protected void modifyModel(IBaseModel model, IProgressMonitor monitor) throws CoreException { > if (model instanceof IBundlePluginModel) { > IBundlePluginModel bundleModel = (IBundlePluginModel) model; >@@ -121,6 +144,10 @@ > } > } > }, mon); >+ // this model change just adds localization to the manifest, so we will only have one change >+ // with one edit >+ if (result.length > 0 && result[0] != null) >+ getEditForFile(manifest, parent).addChild(result[0].getEdit()); > } > > public static InsertEdit getPropertiesInsertEdit(IDocument doc, ModelChangeElement element) { >@@ -132,20 +159,7 @@ > return new InsertEdit(doc.getLength(), sb.toString()); > } > >- public static void checkPropertiesFile(IFile file) { >- if (!file.exists()) { >- String propertiesFileComment = NLS.bind("#Properties file for {0}", file.getProject().getName()); //$NON-NLS-1$ >- ByteArrayInputStream pStream = new ByteArrayInputStream(propertiesFileComment.getBytes()); >- try { >- IContainer container = file.getParent(); >- if (!container.exists()) >- // project will exists, therefore we can assume if !IContainer.exist(), the object is an IFolder >- CoreUtility.createFolder((IFolder)container); >- file.create(pStream, true, new NullProgressMonitor()); >- pStream.close(); >- } catch (CoreException e1) { >- } catch (IOException e) { >- } >- } >+ public static String getPropertiesFileComment(IFile file) { >+ return NLS.bind("#Properties file for {0}", file.getProject().getName()); //$NON-NLS-1$ > } > } >Index: src/org/eclipse/pde/internal/ui/nls/GetNonExternalizedStringsAction.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/nls/GetNonExternalizedStringsAction.java,v >retrieving revision 1.6 >diff -u -r1.6 GetNonExternalizedStringsAction.java >--- src/org/eclipse/pde/internal/ui/nls/GetNonExternalizedStringsAction.java 3 Apr 2006 19:47:23 -0000 1.6 >+++ src/org/eclipse/pde/internal/ui/nls/GetNonExternalizedStringsAction.java 1 Aug 2007 06:00:33 -0000 >@@ -15,10 +15,10 @@ > import org.eclipse.jface.action.IAction; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.viewers.ISelection; >-import org.eclipse.jface.wizard.WizardDialog; >+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation; > import org.eclipse.pde.internal.ui.PDEPlugin; > import org.eclipse.pde.internal.ui.PDEUIMessages; >-import org.eclipse.swt.custom.BusyIndicator; >+import org.eclipse.pde.internal.ui.refactoring.PDERefactor; > import org.eclipse.ui.IWorkbenchWindow; > import org.eclipse.ui.IWorkbenchWindowActionDelegate; > import org.eclipse.ui.PlatformUI; >@@ -41,13 +41,15 @@ > return; > ModelChangeTable changeTable = runnable.getChangeTable(); > if (!changeTable.isEmpty()) { >- ExternalizeStringsWizard wizard = new ExternalizeStringsWizard(changeTable); >- final WizardDialog dialog = new WizardDialog(PDEPlugin.getActiveWorkbenchShell(), wizard); >- BusyIndicator.showWhile(PDEPlugin.getActiveWorkbenchShell().getDisplay(), new Runnable() { >- public void run() { >- dialog.open(); >- } >- }); >+ ExternalizeStringsProcessor processor = new ExternalizeStringsProcessor(); >+ PDERefactor refactor = new PDERefactor(processor); >+ ExternalizeStringsWizard wizard = new ExternalizeStringsWizard(changeTable, refactor); >+ RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation( wizard ); >+ >+ try { >+ op.run( PDEPlugin.getActiveWorkbenchShell(), "" ); //$NON-NLS-1$ >+ } catch( final InterruptedException irex ) { >+ } > } else > MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), > PDEUIMessages.GetNonExternalizedStringsAction_allExternalizedTitle, >Index: src/org/eclipse/pde/internal/ui/correction/ExternalizeResolution.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/ExternalizeResolution.java,v >retrieving revision 1.5 >diff -u -r1.5 ExternalizeResolution.java >--- src/org/eclipse/pde/internal/ui/correction/ExternalizeResolution.java 30 Jan 2007 22:48:19 -0000 1.5 >+++ src/org/eclipse/pde/internal/ui/correction/ExternalizeResolution.java 1 Aug 2007 06:00:32 -0000 >@@ -10,14 +10,21 @@ > *******************************************************************************/ > package org.eclipse.pde.internal.ui.correction; > >+import java.io.ByteArrayInputStream; >+import java.io.IOException; >+ > import org.eclipse.core.filebuffers.FileBuffers; > import org.eclipse.core.filebuffers.ITextFileBuffer; > import org.eclipse.core.filebuffers.ITextFileBufferManager; >+import org.eclipse.core.filebuffers.LocationKind; >+import org.eclipse.core.resources.IContainer; > import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IFolder; > import org.eclipse.core.resources.IMarker; > import org.eclipse.core.resources.IProject; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.NullProgressMonitor; > import org.eclipse.jface.text.BadLocationException; > import org.eclipse.jface.text.IDocument; > import org.eclipse.osgi.util.NLS; >@@ -26,6 +33,7 @@ > import org.eclipse.pde.internal.core.PDEManager; > import org.eclipse.pde.internal.core.ibundle.IBundle; > import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase; >+import org.eclipse.pde.internal.core.util.CoreUtility; > import org.eclipse.pde.internal.ui.PDEPlugin; > import org.eclipse.pde.internal.ui.PDEUIMessages; > import org.eclipse.pde.internal.ui.nls.ExternalizeStringsOperation; >@@ -53,11 +61,11 @@ > localization += ModelChange.LOCALIZATION_FILE_SUFFIX; > IProject project = model.getUnderlyingResource().getProject(); > IFile file = project.getFile(localization); >- ExternalizeStringsOperation.checkPropertiesFile(file); >+ checkPropertiesFile(file); > try { > ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager(); >- manager.connect(file.getFullPath(), null); >- ITextFileBuffer buffer = manager.getTextFileBuffer(file.getFullPath()); >+ manager.connect(file.getFullPath(), LocationKind.IFILE, null); >+ ITextFileBuffer buffer = manager.getTextFileBuffer(file.getFullPath(), LocationKind.IFILE); > if (buffer.isDirty()) > buffer.commit(null, true); > >@@ -72,7 +80,7 @@ > PDEPlugin.log(e); > } finally { > try { >- FileBuffers.getTextFileBufferManager().disconnect(file.getFullPath(), null); >+ FileBuffers.getTextFileBufferManager().disconnect(file.getFullPath(), LocationKind.IFILE, null); > } catch (CoreException e) { > PDEPlugin.log(e); > } >@@ -123,4 +131,20 @@ > PDEModelUtility.modifyModel(modification, null); > } > >+ private void checkPropertiesFile(IFile file) { >+ if (!file.exists()) { >+ String propertiesFileComment = ExternalizeStringsOperation.getPropertiesFileComment(file); >+ ByteArrayInputStream pStream = new ByteArrayInputStream(propertiesFileComment.getBytes()); >+ try { >+ IContainer container = file.getParent(); >+ if (!container.exists()) >+ // project will exists, therefore we can assume if !IContainer.exist(), the object is an IFolder >+ CoreUtility.createFolder((IFolder)container); >+ file.create(pStream, true, new NullProgressMonitor()); >+ pStream.close(); >+ } catch (CoreException e1) { >+ } catch (IOException e) { >+ } >+ } >+ } > } >Index: src/org/eclipse/pde/internal/ui/nls/ExternalizeStringsProcessor.java >=================================================================== >RCS file: src/org/eclipse/pde/internal/ui/nls/ExternalizeStringsProcessor.java >diff -N src/org/eclipse/pde/internal/ui/nls/ExternalizeStringsProcessor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/pde/internal/ui/nls/ExternalizeStringsProcessor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,83 @@ >+/******************************************************************************* >+ * Copyright (c) 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.pde.internal.ui.nls; >+ >+import java.lang.reflect.InvocationTargetException; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.ltk.core.refactoring.Change; >+import org.eclipse.ltk.core.refactoring.CompositeChange; >+import org.eclipse.ltk.core.refactoring.RefactoringStatus; >+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; >+import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant; >+import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor; >+import org.eclipse.ltk.core.refactoring.participants.SharableParticipants; >+import org.eclipse.pde.internal.ui.PDEUIMessages; >+ >+public class ExternalizeStringsProcessor extends RefactoringProcessor { >+ >+ Object[] fChangeFiles = null; >+ >+ public RefactoringStatus checkFinalConditions(IProgressMonitor pm, >+ CheckConditionsContext context) throws CoreException, >+ OperationCanceledException { >+ RefactoringStatus status = new RefactoringStatus(); >+ if (fChangeFiles == null) >+ status.addFatalError(PDEUIMessages.ExternalizeStringsProcessor_errorMessage); >+ return status; >+ } >+ >+ public RefactoringStatus checkInitialConditions(IProgressMonitor pm) >+ throws CoreException, OperationCanceledException { >+ return null; >+ } >+ >+ public Change createChange(IProgressMonitor pm) throws CoreException, >+ OperationCanceledException { >+ CompositeChange change = new CompositeChange(""); //$NON-NLS-1$ >+ change.markAsSynthetic(); >+ ExternalizeStringsOperation op = new ExternalizeStringsOperation(fChangeFiles, change); >+ try { >+ op.run(pm); >+ } catch (InvocationTargetException e) { >+ } catch (InterruptedException e) { >+ } >+ return change; >+ } >+ >+ public Object[] getElements() { >+ return fChangeFiles; >+ } >+ >+ public String getIdentifier() { >+ return getClass().getName(); >+ } >+ >+ public String getProcessorName() { >+ return PDEUIMessages.ExternalizeStringsWizard_title; >+ } >+ >+ public boolean isApplicable() throws CoreException { >+ return true; >+ } >+ >+ public RefactoringParticipant[] loadParticipants(RefactoringStatus status, >+ SharableParticipants sharedParticipants) throws CoreException { >+ return new RefactoringParticipant[0]; >+ } >+ >+ public void setChangeFiles(Object[] changeFiles) { >+ fChangeFiles = changeFiles; >+ } >+ >+}
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 198310
:
75079
| 75095