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 127978 Details for
Bug 264788
XSL Launcher Should Allow Selection of Open XML Files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Updated to recurse all Sub Content-Types.
Bug264788_update2.patch (text/plain), 16.81 KB, created by
David Carver
on 2009-03-08 22:48:05 EDT
(
hide
)
Description:
Updated to recurse all Sub Content-Types.
Filename:
MIME Type:
Creator:
David Carver
Created:
2009-03-08 22:48:05 EDT
Size:
16.81 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.wst.xsl.debug.ui >Index: src/org/eclipse/wst/xsl/internal/debug/ui/tabs/main/InputFileBlock.java >=================================================================== >RCS file: /cvsroot/webtools/incubator/sourceediting/plugins/org.eclipse.wst.xsl.debug.ui/src/org/eclipse/wst/xsl/internal/debug/ui/tabs/main/InputFileBlock.java,v >retrieving revision 1.10 >diff -u -r1.10 InputFileBlock.java >--- src/org/eclipse/wst/xsl/internal/debug/ui/tabs/main/InputFileBlock.java 23 Feb 2009 22:36:36 -0000 1.10 >+++ src/org/eclipse/wst/xsl/internal/debug/ui/tabs/main/InputFileBlock.java 9 Mar 2009 02:44:34 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * Doug Satchwell (Chase Technology Ltd) - initial API and implementation >+ * Stuart Harper - added "open files" selector > *******************************************************************************/ > package org.eclipse.wst.xsl.internal.debug.ui.tabs.main; > >@@ -24,15 +25,11 @@ > import org.eclipse.wst.xsl.internal.debug.ui.ResourceSelectionBlock; > import org.eclipse.wst.xsl.internal.debug.ui.XSLDebugUIPlugin; > import org.eclipse.wst.xsl.launching.XSLLaunchConfigurationConstants; >-import org.eclipse.core.runtime.content.IContentType; >-import org.eclipse.core.runtime.content.IContentTypeManager; > > > public class InputFileBlock extends ResourceSelectionBlock > { >- private static final String XMLSOURCE_CONTENTTYPE = "org.eclipse.wst.xml.core.xmlsource"; > private final IFile defaultFile; >- IContentTypeManager contentTypeManager = Platform.getContentTypeManager(); > > public InputFileBlock(IFile defaultFile) > { >@@ -40,14 +37,6 @@ > this.defaultFile = defaultFile; > } > >- @Override >- protected String[] getFileExtensions() >- { >- IContentType contentType = contentTypeManager.getContentType(XMLSOURCE_CONTENTTYPE); >- String[] xmlContentTypes = contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC); >- >- return xmlContentTypes; >- } > > public void setDefaults(ILaunchConfigurationWorkingCopy configuration) > { >@@ -135,6 +124,10 @@ > return Messages.InputFileBlock_WORKSPACE_BUTTON; > case WORKSPACE_DIALOG_TITLE: > return Messages.InputFileBlock_WORKSPACE_DIALOG_TITLE; >+ case OPENFILES_BUTTON: >+ return Messages.InputFileBlock_OPENFILES_BUTTON; >+ case OPENFILES_DIALOG_TITLE: >+ return Messages.InputFileBlock_OPENFILES_DIALOG; > } > return "" + type; //$NON-NLS-1$ > } >Index: src/org/eclipse/wst/xsl/internal/debug/ui/actions/AddExternalFileAction.java >=================================================================== >RCS file: /cvsroot/webtools/incubator/sourceediting/plugins/org.eclipse.wst.xsl.debug.ui/src/org/eclipse/wst/xsl/internal/debug/ui/actions/AddExternalFileAction.java,v >retrieving revision 1.8 >diff -u -r1.8 AddExternalFileAction.java >--- src/org/eclipse/wst/xsl/internal/debug/ui/actions/AddExternalFileAction.java 26 Feb 2009 16:24:52 -0000 1.8 >+++ src/org/eclipse/wst/xsl/internal/debug/ui/actions/AddExternalFileAction.java 9 Mar 2009 02:44:34 -0000 >@@ -20,6 +20,7 @@ > import org.eclipse.swt.widgets.FileDialog; > import org.eclipse.wst.xsl.internal.debug.ui.tabs.main.StylesheetViewer; > import org.eclipse.wst.xsl.launching.config.LaunchTransform; >+import org.eclipse.wst.xsl.core.XSLCore; > import org.eclipse.wst.xsl.debug.ui.Messages; > > >@@ -53,7 +54,7 @@ > dialog.setText(Messages.AddExternalFileAction_Selection_3); > dialog.setFilterPath(lastUsedPath); > IContentTypeManager contentTypeManager = Platform.getContentTypeManager(); >- IContentType contentType = contentTypeManager.getContentType("org.eclipse.wst.xml.core.xslsource"); //$NON-NLS-1$ >+ IContentType contentType = contentTypeManager.getContentType(XSLCore.XSL_CONTENT_TYPE); > String[] xslContentTypes = contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC); > > // add *. to front >Index: src/org/eclipse/wst/xsl/debug/ui/Messages.java >=================================================================== >RCS file: /cvsroot/webtools/incubator/sourceediting/plugins/org.eclipse.wst.xsl.debug.ui/src/org/eclipse/wst/xsl/debug/ui/Messages.java,v >retrieving revision 1.3 >diff -u -r1.3 Messages.java >--- src/org/eclipse/wst/xsl/debug/ui/Messages.java 12 Jan 2009 00:50:22 -0000 1.3 >+++ src/org/eclipse/wst/xsl/debug/ui/Messages.java 9 Mar 2009 02:44:34 -0000 >@@ -8,6 +8,7 @@ > * Contributors: > * Doug Satchwell (Chase Technology Ltd) - initial API and implementation > * David Carver (STAR) - updated to meet Galileo requirements >+ * Stuart Harper - added "open files" selector > *******************************************************************************/ > package org.eclipse.wst.xsl.debug.ui; > >@@ -125,6 +126,10 @@ > public static String InputFileBlock_FILE_SYSTEM_BUTTON; > > public static String InputFileBlock_WORKSPACE_BUTTON; >+ >+ public static String InputFileBlock_OPENFILES_BUTTON; >+ >+ public static String InputFileBlock_OPENFILES_DIALOG; > > public static String InputFileBlock_Name; > >Index: src/org/eclipse/wst/xsl/debug/ui/messages.properties >=================================================================== >RCS file: /cvsroot/webtools/incubator/sourceediting/plugins/org.eclipse.wst.xsl.debug.ui/src/org/eclipse/wst/xsl/debug/ui/messages.properties,v >retrieving revision 1.3 >diff -u -r1.3 messages.properties >--- src/org/eclipse/wst/xsl/debug/ui/messages.properties 12 Jan 2009 00:50:22 -0000 1.3 >+++ src/org/eclipse/wst/xsl/debug/ui/messages.properties 9 Mar 2009 02:44:34 -0000 >@@ -41,6 +41,8 @@ > InputFileBlock_VARIABLES_BUTTON=Variables... > InputFileBlock_FILE_SYSTEM_BUTTON=File System... > InputFileBlock_WORKSPACE_BUTTON=Workspace... >+InputFileBlock_OPENFILES_BUTTON=Open Files... >+InputFileBlock_OPENFILES_DIALOG=Select File > InputFileBlock_Name=XML Input File > InputFileBlock_Exception_occurred_reading_configuration=Exception occurred reading configuration > InputFileBlock_WORKSPACE_DIALOG_TITLE=File Selection >Index: src/org/eclipse/wst/xsl/internal/debug/ui/ResourceSelectionBlock.java >=================================================================== >RCS file: /cvsroot/webtools/incubator/sourceediting/plugins/org.eclipse.wst.xsl.debug.ui/src/org/eclipse/wst/xsl/internal/debug/ui/ResourceSelectionBlock.java,v >retrieving revision 1.12 >diff -u -r1.12 ResourceSelectionBlock.java >--- src/org/eclipse/wst/xsl/internal/debug/ui/ResourceSelectionBlock.java 26 Feb 2009 16:24:08 -0000 1.12 >+++ src/org/eclipse/wst/xsl/internal/debug/ui/ResourceSelectionBlock.java 9 Mar 2009 02:44:34 -0000 >@@ -7,10 +7,15 @@ > * > * Contributors: > * Doug Satchwell (Chase Technology Ltd) - initial API and implementation >+ * Stuart Harper - bug 264788 - added "open files" selector >+ * David Carver (STAR) - bug 264788 - pulled up getFileExtensions from InputFileBlock > *******************************************************************************/ > package org.eclipse.wst.xsl.internal.debug.ui; > > import java.io.File; >+import java.lang.reflect.Array; >+import java.util.ArrayList; >+import java.util.Arrays; > > import org.eclipse.core.resources.IContainer; > import org.eclipse.core.resources.IFile; >@@ -20,12 +25,17 @@ > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IPath; > import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.content.IContentType; >+import org.eclipse.core.runtime.content.IContentTypeManager; > import org.eclipse.core.variables.IStringVariableManager; > import org.eclipse.core.variables.VariablesPlugin; > import org.eclipse.debug.core.ILaunchConfiguration; > import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; > import org.eclipse.debug.ui.StringVariableSelectionDialog; >+import org.eclipse.jface.viewers.LabelProvider; > import org.eclipse.jface.viewers.Viewer; > import org.eclipse.jface.viewers.ViewerFilter; > import org.eclipse.jface.window.Window; >@@ -43,11 +53,17 @@ > import org.eclipse.swt.widgets.Group; > import org.eclipse.swt.widgets.Label; > import org.eclipse.swt.widgets.Text; >+import org.eclipse.ui.IEditorInput; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.IEditorReference; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.dialogs.ElementListSelectionDialog; > import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; > import org.eclipse.ui.dialogs.ISelectionStatusValidator; > import org.eclipse.ui.model.WorkbenchContentProvider; > import org.eclipse.ui.model.WorkbenchLabelProvider; > import org.eclipse.ui.views.navigator.ResourceComparator; >+import org.eclipse.wst.xsl.core.internal.util.XMLContentType; > import org.eclipse.wst.xsl.debug.ui.Messages; > > >@@ -71,10 +87,13 @@ > protected static final int FILE_SYSTEM_BUTTON = 9; > protected static final int WORKSPACE_BUTTON = 10; > protected static final int WORKSPACE_DIALOG_TITLE = 11; >+ protected static final int OPENFILES_BUTTON = 12; >+ protected static final int OPENFILES_DIALOG_TITLE = 13; > > protected Button fWorkspaceButton; > protected Button fFileSystemButton; > protected Button fVariablesButton; >+ protected Button fOpenFilesButton; > protected Button useDefaultCheckButton; > protected Text resourceText; > protected WidgetListener widgetListener = new WidgetListener(); >@@ -85,7 +104,13 @@ > protected boolean required; > protected String defaultResource; > protected String resource; >- protected String fileLabel = Messages.ResourceSelectionBlock_0; >+ protected String fileLabel = Messages.ResourceSelectionBlock_0; >+ private static final String XMLSOURCE_CONTENTTYPE = "org.eclipse.wst.xml.core.xmlsource"; >+ private static final String PLATFORM_XMLSOURCE_CONTENTTYPE = "org.eclipse.core.runtime.xml"; >+ >+ >+ IContentTypeManager contentTypeManager = Platform.getContentTypeManager(); >+ > > private final ISelectionStatusValidator validator = new ISelectionStatusValidator() > { >@@ -134,6 +159,10 @@ > { > updateResourceText(useDefaultCheckButton.getSelection()); > } >+ else if (source == fOpenFilesButton) >+ { >+ handleOpenFilesResourceBrowseButtonSelected(); >+ } > } > } > >@@ -267,7 +296,7 @@ > new Label(parent, SWT.NONE); > > Composite buttonComp = new Composite(parent, SWT.NONE); >- GridLayout layout = new GridLayout(3, false); >+ GridLayout layout = new GridLayout(4, false); > layout.marginHeight = 0; > layout.marginWidth = 0; > buttonComp.setLayout(layout); >@@ -284,6 +313,9 @@ > > fVariablesButton = createPushButton(buttonComp, getMessage(VARIABLES_BUTTON), null); > fVariablesButton.addSelectionListener(widgetListener); >+ >+ fOpenFilesButton = createPushButton(buttonComp, getMessage(OPENFILES_BUTTON), null); >+ fOpenFilesButton.addSelectionListener(widgetListener); > } > > protected void updateResourceText(boolean useDefault) >@@ -357,9 +389,67 @@ > > protected String[] getFileExtensions() > { >- return null; >+ return new XMLContentType().getFileExtensions(); > } >+ >+ protected void handleOpenFilesResourceBrowseButtonSelected() >+ { >+ String path = openFileListResourceDialog(); >+ if (path != null) >+ setText("${workspace_loc:" + path + "}"); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ /** >+ * Opens a dialog displaying a list of all XML files in the editor and allows the user to select one of them. >+ * @return The path to the selected XML file or null if none was chosen. >+ */ >+ protected String openFileListResourceDialog(){ >+ IEditorReference[] editors = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences(); >+ >+ WorkbenchContentProvider w = new WorkbenchContentProvider(); >+ String[] paths = filterOpenEditorsByFileExtension(editors); >+ >+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new LabelProvider()); > >+ dialog.setTitle(getMessage(OPENFILES_DIALOG_TITLE)); >+ dialog.setElements(paths); >+ dialog.open(); >+ >+ return (String)dialog.getFirstResult(); >+ >+ } >+ >+ private String[] filterOpenEditorsByFileExtension(IEditorReference[] editors) { >+ String [] paths = new String[editors.length]; >+ String [] fileExts = getFileExtensions(); >+ >+ for(int i =0; i<editors.length; i++){ >+ IEditorReference currentEditor = editors[i]; >+ IEditorPart editorPart = currentEditor.getEditor(true); >+ IPath path = ((IFile) editorPart.getEditorInput().getAdapter(IFile.class)).getFullPath(); >+ >+ if (path != null) { >+ paths[i] = getEditorPath(path, fileExts); >+ } >+ } >+ return paths; >+ } >+ >+ private String getEditorPath(IPath filePath, String[] fileExts) { >+ if (fileExts == null || fileExts.length == 0) { >+ return filePath.toOSString(); >+ } >+ >+ String path = null; >+ for (int cnt = 0; cnt < fileExts.length; cnt++) { >+ if (filePath.getFileExtension().equals(fileExts[cnt])) { >+ path = filePath.toOSString(); >+ break; >+ } >+ } >+ return path; >+ } >+ >+ > protected void handleWorkspaceResourceBrowseButtonSelected() > { > IPath path = openWorkspaceResourceDialog(); >#P org.eclipse.wst.xsl.core >Index: src/org/eclipse/wst/xsl/core/internal/util/XMLContentType.java >=================================================================== >RCS file: src/org/eclipse/wst/xsl/core/internal/util/XMLContentType.java >diff -N src/org/eclipse/wst/xsl/core/internal/util/XMLContentType.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/xsl/core/internal/util/XMLContentType.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,105 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Standards for Technology in Automotive Retail 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: >+ * David Carver (bug 264788) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.wst.xsl.core.internal.util; >+ >+import java.util.*; >+ >+import org.eclipse.core.runtime.*; >+import org.eclipse.core.runtime.content.*; >+ >+/** >+ * XMLContetType handles the gathering of XML content type related information >+ * between the platforms xml content type and WTP's specific version. >+ * >+ * @author David Carver >+ * @since 1.0 >+ * >+ */ >+public class XMLContentType { >+ private static final String XMLSOURCE_CONTENTTYPE = "org.eclipse.wst.xml.core.xmlsource"; //$NON-NLS-1$ >+ private static final String PLATFORM_XMLSOURCE_CONTENTTYPE = "org.eclipse.core.runtime.xml"; //$NON-NLS-1$ >+ >+ private IContentTypeManager contentTypeManager = null; >+ >+ public XMLContentType() { >+ contentTypeManager = Platform.getContentTypeManager(); >+ IContentType contentType; >+ } >+ >+ /** >+ * Returns all the extensions associated with an XML Content Type. >+ * @return The array of file extensions >+ * @since 1.0 >+ */ >+ public String[] getFileExtensions() { >+ IContentType[] contentTypes = getAllXMLContentTypes(); >+ ArrayList<String> xmlFileExtensions = new ArrayList<String>(); >+ if (contentTypes.length > 0) { >+ for (int cnt = 0; cnt < contentTypes.length; cnt++) { >+ String[] exts = getFileSpecs(contentTypes[cnt]); >+ if (exts != null) { >+ for (int sub = 0; sub < exts.length; sub++) { >+ if (!xmlFileExtensions.contains(exts[sub])) { >+ xmlFileExtensions.add(exts[sub]); >+ } >+ } >+ } >+ } >+ } >+ >+ String[] fileExtensions = new String[xmlFileExtensions.size()]; >+ xmlFileExtensions.toArray(fileExtensions); >+ return fileExtensions; >+ } >+ >+ private IContentType[] getAllXMLContentTypes() { >+ ArrayList<IContentType> arrayList = new ArrayList<IContentType>(Arrays.asList(contentTypeManager.getAllContentTypes())); >+ ArrayList<IContentType> copyContents = (ArrayList)arrayList.clone(); >+ >+ for(IContentType contentType : arrayList) { >+ if (!isXMLContentType(contentType)) { >+ copyContents.remove(contentType); >+ } >+ } >+ IContentType[] contentTypes = new IContentType[copyContents.size()]; >+ copyContents.toArray(contentTypes); >+ return contentTypes; >+ } >+ >+ private boolean isXMLContentType(IContentType contentType) { >+ return contentType.getId().equals(PLATFORM_XMLSOURCE_CONTENTTYPE) || >+ contentType.getId().equals(XMLSOURCE_CONTENTTYPE) || >+ isKindOfWTPXML(contentType) || >+ isKindOfXMLSource(contentType); >+ } >+ >+ private boolean isKindOfXMLSource(IContentType contentType) { >+ IContentType platformContentType = contentTypeManager.getContentType(PLATFORM_XMLSOURCE_CONTENTTYPE); >+ boolean returnValue = false; >+ if (platformContentType != null) { >+ returnValue = contentType.isKindOf(platformContentType); >+ } >+ return returnValue; >+ } >+ >+ private boolean isKindOfWTPXML(IContentType contentType) { >+ IContentType wtpContentType = contentTypeManager.getContentType(XMLSOURCE_CONTENTTYPE); >+ boolean returnValue = false; >+ if (wtpContentType != null) { >+ returnValue = contentType.isKindOf(wtpContentType); >+ } >+ return returnValue; >+ } >+ >+ private String[] getFileSpecs(IContentType contentType) { >+ return contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC); >+ } >+}
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
Flags:
d_a_carver
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 264788
:
127571
|
127717
|
127760
|
127960
|
127961
| 127978 |
127979