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 59402 Details for
Bug 113249
[XML Catalog] XML catalog can only import catalogs from the workspace
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]
Patch
patch.txt (text/plain), 14.60 KB, created by
Gabriel Indik
on 2007-02-20 14:21:11 EST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Gabriel Indik
Created:
2007-02-20 14:21:11 EST
Size:
14.60 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.wst.xml.core >Index: src-catalog/org/eclipse/wst/xml/core/internal/catalog/Catalog.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.core/src-catalog/org/eclipse/wst/xml/core/internal/catalog/Catalog.java,v >retrieving revision 1.7 >diff -u -r1.7 Catalog.java >--- src-catalog/org/eclipse/wst/xml/core/internal/catalog/Catalog.java 24 May 2006 14:14:35 -0000 1.7 >+++ src-catalog/org/eclipse/wst/xml/core/internal/catalog/Catalog.java 20 Feb 2007 19:16:39 -0000 >@@ -40,14 +40,15 @@ > { > } > >- public synchronized void save() >+ public synchronized void save() throws IOException > { > try > { > new CatalogWriter().write(Catalog.this, location); >- } catch (Exception e) >+ } catch (IOException e) > { > Logger.logException(e); >+ throw e; > } > } > } >@@ -71,7 +72,10 @@ > * we've created from plug-in extensions to disk. The 'default' > * catalog is only ever written to disk and never read from disk. > */ >- save(); >+ try { >+ save(); >+ } catch (Exception e) { >+ } > } > } > >@@ -202,7 +206,10 @@ > * we've created from plugin extensions to disk. > * The 'system' catalog is only ever written to disk and never read from disk. > */ >- save(); >+ try { >+ save(); >+ } catch (Exception e) { >+ } > } > } > >#P org.eclipse.wst.xml.ui >Index: src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogResources.properties >=================================================================== >RCS file: /cvsroot/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogResources.properties,v >retrieving revision 1.4 >diff -u -r1.4 XMLCatalogResources.properties >--- src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogResources.properties 14 Nov 2006 21:13:54 -0000 1.4 >+++ src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogResources.properties 20 Feb 2007 19:16:40 -0000 >@@ -100,8 +100,8 @@ > UI_LABEL_EXPORT_DIALOG_TITLE = Export XML Catalog Settings > UI_LABEL_EXPORT_DIALOG_HEADING = Specify XML Catalog File > UI_LABEL_EXPORT_DIALOG_MESSAGE = Specify the file that will used to save the XML Catalog Setting >-ERROR_SAVING_FILE = Error saving file %1 >-UI_LABEL_FILE_IS_READ_ONLY = File %1 is read only >+ERROR_SAVING_FILE = Error saving file {0} >+UI_LABEL_FILE_IS_READ_ONLY = File {0} is read only > > EditCatalogEntryDialog_catalogEntryLabel=Catalog Entry > EditCatalogEntryDialog_nextCatalogLabel=Next Catalog >@@ -109,3 +109,5 @@ > UI_BUTTON_MENU_BROWSE_FILE_SYSTEM=File System... > UI_LABEL_SELECT_FILE_FILTER_CONTROL=Files of type: > UI_TEXT_SELECT_FILE_FILTER_CONTROL=All Supported Files >+UI_OVERWRITE_FILE_DIALOG_TITLE=Overwrite >+UI_OVERWRITE_FILE_DIALOG_TEXT=Overwrite existing file? >Index: src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogMessages.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogMessages.java,v >retrieving revision 1.5 >diff -u -r1.5 XMLCatalogMessages.java >--- src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogMessages.java 23 Nov 2006 04:25:49 -0000 1.5 >+++ src-catalog/org/eclipse/wst/xml/ui/internal/catalog/XMLCatalogMessages.java 20 Feb 2007 19:16:40 -0000 >@@ -120,6 +120,8 @@ > public static String UI_BUTTON_MENU_BROWSE_FILE_SYSTEM; > public static String UI_LABEL_SELECT_FILE_FILTER_CONTROL; > public static String UI_TEXT_SELECT_FILE_FILTER_CONTROL; >+ public static String UI_OVERWRITE_FILE_DIALOG_TITLE; >+ public static String UI_OVERWRITE_FILE_DIALOG_TEXT; > > > >Index: src-catalog/org/eclipse/wst/xml/ui/internal/catalog/AdvancedOptionsDialog.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.ui/src-catalog/org/eclipse/wst/xml/ui/internal/catalog/AdvancedOptionsDialog.java,v >retrieving revision 1.4 >diff -u -r1.4 AdvancedOptionsDialog.java >--- src-catalog/org/eclipse/wst/xml/ui/internal/catalog/AdvancedOptionsDialog.java 23 Nov 2006 04:25:49 -0000 1.4 >+++ src-catalog/org/eclipse/wst/xml/ui/internal/catalog/AdvancedOptionsDialog.java 20 Feb 2007 19:16:40 -0000 >@@ -13,6 +13,7 @@ > package org.eclipse.wst.xml.ui.internal.catalog; > > import java.io.ByteArrayInputStream; >+import java.io.File; > > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IProject; >@@ -24,19 +25,25 @@ > import org.eclipse.jface.dialogs.Dialog; > import org.eclipse.jface.dialogs.ErrorDialog; > import org.eclipse.jface.dialogs.IDialogConstants; >+import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.window.Window; > import org.eclipse.osgi.util.NLS; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.SelectionAdapter; > import org.eclipse.swt.events.SelectionEvent; > import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.Button; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.FileDialog; > import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Menu; >+import org.eclipse.swt.widgets.MenuItem; > import org.eclipse.swt.widgets.Shell; > import org.eclipse.ui.dialogs.SaveAsDialog; > import org.eclipse.wst.common.ui.internal.dialogs.SelectSingleFileDialog; >@@ -46,6 +53,21 @@ > > public class AdvancedOptionsDialog extends Dialog { > protected ICatalog workingUserCatalog; >+ >+ private int browseAt; >+ >+ private Button importButton; >+ >+ private Button exportButton; >+ >+ private Menu menu; >+ >+ public static final int NO_OPERATION = 0; >+ >+ public static final int BROWSE_FILE_SYSTEM = 1; >+ >+ public static final int BROWSE_WORKSPACE = 2; >+ > > public AdvancedOptionsDialog(Shell parentShell, ICatalog workingUserCatalog) { > super(parentShell); >@@ -88,10 +110,10 @@ > buttonGroup.setLayout(gridLayout); > buttonGroup.setLayoutData(createGridData()); > >- Button importButton = new Button(buttonGroup, SWT.PUSH | SWT.CENTER); >+ importButton = new Button(buttonGroup, SWT.PUSH | SWT.CENTER); > importButton.setText(" " + XMLCatalogMessages.UI_BUTTON_IMPORT + " "); //$NON-NLS-1$ //$NON-NLS-2$ > >- Button exportButton = new Button(buttonGroup, SWT.PUSH | SWT.CENTER); >+ exportButton = new Button(buttonGroup, SWT.PUSH | SWT.CENTER); > exportButton.setText(" " + XMLCatalogMessages.UI_BUTTON_EXPORT + " "); //$NON-NLS-1$ //$NON-NLS-2$ > > placeHolder = new Composite(buttonComposite, SWT.NONE); >@@ -100,7 +122,20 @@ > // add importButton listener > SelectionListener importButtonSelectionListener = new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { >- invokeImportDialog(); >+ String file = null; >+ Point ptBrowse = importButton.getLocation(); >+ Rectangle rcBrowse = importButton.getBounds(); >+ ptBrowse.y += rcBrowse.height; >+ ptBrowse = importButton.getParent().toDisplay(ptBrowse); >+ browseAt = NO_OPERATION; >+ show_menu(ptBrowse); >+ switch(browseAt) { >+ case BROWSE_FILE_SYSTEM: file = invokeFileSystemImportDialog(); break; >+ case BROWSE_WORKSPACE: file = invokeWorkspaceImportDialog(); >+ } >+ if(file != null) { >+ importCatalog(file); >+ } > } > }; > importButton.addSelectionListener(importButtonSelectionListener); >@@ -108,11 +143,41 @@ > // add exportButton listener > SelectionListener exportButtonSelectionListener = new SelectionAdapter() { > public void widgetSelected(SelectionEvent e) { >- invokeExportDialog(); >+ String file = null; >+ Point ptBrowse = exportButton.getLocation(); >+ Rectangle rcBrowse = exportButton.getBounds(); >+ ptBrowse.y += rcBrowse.height; >+ ptBrowse = exportButton.getParent().toDisplay(ptBrowse); >+ browseAt = NO_OPERATION; >+ show_menu(ptBrowse); >+ switch(browseAt) { >+ case BROWSE_FILE_SYSTEM: file = invokeFileSystemExportDialog(); break; >+ case BROWSE_WORKSPACE: file = invokeWorkspaceExportDialog(); >+ } >+ if(file != null) { >+ exportCatalog(file); >+ } > } > }; > exportButton.addSelectionListener(exportButtonSelectionListener); > >+ menu = new Menu(getShell()); >+ MenuItem menuItem = new MenuItem(menu, SWT.NONE); >+ menuItem.setText(XMLCatalogMessages.UI_BUTTON_MENU_BROWSE_WORKSPACE); >+ browseAt = browseAt +1; >+ browseAt = NO_OPERATION; >+ menuItem.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ browseAt = BROWSE_WORKSPACE; >+ } >+ }); >+ menuItem = new MenuItem(menu, SWT.NONE); >+ menuItem.setText(XMLCatalogMessages.UI_BUTTON_MENU_BROWSE_FILE_SYSTEM); >+ menuItem.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ browseAt = BROWSE_FILE_SYSTEM; >+ } >+ }); > return dialogArea; > } > >@@ -123,8 +188,18 @@ > return gd; > } > >- >- protected void invokeImportDialog() { >+ protected String invokeFileSystemImportDialog() { >+ String fileName = null; >+ FileDialog dialog = new FileDialog(getShell(), SWT.SINGLE | SWT.OPEN); >+ String[] extensions = {"*.xmlcatalog", "*.xml","*.*"}; //$NON-NLS-1$ //$NON-NLS-2$ >+ dialog.setFilterExtensions(extensions); >+ dialog.setText(XMLCatalogMessages.UI_LABEL_IMPORT_DIALOG_TITLE); >+ fileName = dialog.open(); >+ return URIUtils.convertLocationToURI(fileName); >+ } >+ >+ protected String invokeWorkspaceImportDialog() { >+ String fileName = null; > SelectSingleFileDialog dialog = new SelectSingleFileDialog(getShell(), null, true); > String[] extensions = {".xmlcatalog", ".xml"}; //$NON-NLS-1$ //$NON-NLS-2$ > dialog.addFilterExtensions(extensions); >@@ -137,26 +212,44 @@ > if (rc == Window.OK) { > IFile file = dialog.getFile(); > if (file != null) { >- String fileName = file.getLocation().toFile().toURI().toString(); >- try { >- CatalogSet tempResourceSet = new CatalogSet(); >- ICatalog newCatalog = tempResourceSet.lookupOrCreateCatalog("temp", fileName); //$NON-NLS-1$ >- workingUserCatalog.addEntriesFromCatalog(newCatalog); >- } >- catch (Exception e) { >- // TODO... give error message >- } >+ fileName = file.getLocation().toFile().toURI().toString(); > } >- close(); > } >+ return fileName; > } > >+ protected void importCatalog(String fileName) { >+ try { >+ CatalogSet tempResourceSet = new CatalogSet(); >+ ICatalog newCatalog = tempResourceSet.lookupOrCreateCatalog("temp", fileName); //$NON-NLS-1$ >+ workingUserCatalog.addEntriesFromCatalog(newCatalog); >+ } >+ catch (Exception e) { >+ // TODO... give error message >+ } >+ close(); >+ } > >- protected void invokeExportDialog() { >+ protected String invokeFileSystemExportDialog() { >+ String fileName = null; >+ FileDialog dialog = new FileDialog(getShell(), SWT.SINGLE | SWT.SAVE); >+ String[] extensions = {"*.xmlcatalog", "*.xml","*.*"}; //$NON-NLS-1$ //$NON-NLS-2$ >+ dialog.setFilterExtensions(extensions); >+ dialog.setText(XMLCatalogMessages.UI_LABEL_EXPORT_DIALOG_TITLE); >+ fileName = dialog.open(); >+ File file = new File(fileName); >+ if (file != null && file.exists() && !MessageDialog.openConfirm(getShell(), XMLCatalogMessages.UI_OVERWRITE_FILE_DIALOG_TITLE, XMLCatalogMessages.UI_OVERWRITE_FILE_DIALOG_TEXT)) { >+ return null; >+ } >+ return URIUtils.convertLocationToURI(fileName); >+ } >+ >+ protected String invokeWorkspaceExportDialog() { >+ String fileName = null; > IPath originalFilePath = null; > IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); > if (projects.length > 0) { >- originalFilePath = projects[0].getFullPath().append(".xmlcatalog"); //$NON-NLS-1$ >+ originalFilePath = projects[0].getFullPath().append("catalog.xmlcatalog"); //$NON-NLS-1$ > } > > SaveAsDialog dialog = new SaveAsDialog(getShell()); >@@ -176,29 +269,32 @@ > IPath path = dialog.getResult(); > if (path != null) { > IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); >- String fileName = file.getLocation().toFile().toURI().toString(); >- >- // here we save the catalog entries to the selected file >- try { >- createFileIfRequired(file); >- workingUserCatalog.setLocation(fileName); >- workingUserCatalog.save(); >- } >- catch (Exception ex) { >- try { >- String title = XMLCatalogMessages.UI_LABEL_CATALOG_SAVE_ERROR; >- String briefMessage = XMLCatalogMessages.UI_LABEL_CATALOG_COULD_NOT_BE_SAVED; >- String reason = file.isReadOnly() ? NLS.bind(XMLCatalogMessages.UI_LABEL_FILE_IS_READ_ONLY, fileName) : NLS.bind(XMLCatalogMessages.ERROR_SAVING_FILE, fileName); >- String details = NLS.bind(XMLCatalogMessages.ERROR_SAVING_FILE, fileName); >- >- ErrorDialog.openError(Display.getCurrent().getActiveShell(), title, briefMessage, createStatus(reason, details)); >- } >- catch (Exception ex2) { >- } >- } >- close(); >+ fileName = file.getLocation().toFile().toURI().toString(); >+ createFileIfRequired(file); > } > } >+ return URIUtils.convertURIToLocation(fileName); >+ } >+ >+ protected void exportCatalog(String fileName) { >+ workingUserCatalog.setLocation(fileName); >+ try { >+ workingUserCatalog.save(); >+ } catch (Exception e) { >+ try { >+ >+ File file = new File(fileName); >+ fileName = file.getName(); >+ String title = XMLCatalogMessages.UI_LABEL_CATALOG_SAVE_ERROR; >+ String briefMessage = XMLCatalogMessages.UI_LABEL_CATALOG_COULD_NOT_BE_SAVED; >+ String reason = !file.canWrite() ? NLS.bind(XMLCatalogMessages.UI_LABEL_FILE_IS_READ_ONLY, fileName) : NLS.bind(XMLCatalogMessages.ERROR_SAVING_FILE, fileName); >+ String details = NLS.bind(XMLCatalogMessages.ERROR_SAVING_FILE, fileName); >+ ErrorDialog.openError(Display.getCurrent().getActiveShell(), title, briefMessage, createStatus(reason, details)); >+ } >+ catch (Exception ex2) { >+ } >+ } >+ close(); > } > > // TODO... This was copied from WindowUtility. Is there an easier way to >@@ -226,4 +322,14 @@ > catch (Exception e) { > } > } >+ >+ private void show_menu(Point location) { >+ menu.setLocation(location); >+ menu.setVisible(true); >+ while (!menu.isDisposed() && menu.isVisible()) { >+ if (!menu.getDisplay().readAndDispatch()) >+ menu.getDisplay().sleep(); >+ } >+ } >+ > }
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 113249
:
59402