Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 298363 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java (+1 lines)
Lines 320-325 Link Here
320
	public static String Use_XInclude;
320
	public static String Use_XInclude;
321
    public static String Honour_all_schema_locations;   
321
    public static String Honour_all_schema_locations;   
322
	public static String Open;
322
	public static String Open;
323
	public static String Open_With;
323
	public static String _UI_BUTTON_SORT;
324
	public static String _UI_BUTTON_SORT;
324
	public static String MarkupValidation_files_label;
325
	public static String MarkupValidation_files_label;
325
	public static String MarkupValidation_files;
326
	public static String MarkupValidation_files;
(-)src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties (+1 lines)
Lines 348-353 Link Here
348
gotoMatchingTag_start=Start tag of element <{0}>
348
gotoMatchingTag_start=Start tag of element <{0}>
349
gotoMatchingTag_end=End tag of element <{0}>
349
gotoMatchingTag_end=End tag of element <{0}>
350
Open=Open ''{0}''
350
Open=Open ''{0}''
351
Open_With=Open ''{0}'' with {1}
351
_UI_BUTTON_SORT=Sort
352
_UI_BUTTON_SORT=Sort
352
Validating_files=Validating files
353
Validating_files=Validating files
353
Indicate_no_grammar_specified=Indicate when no &grammar is specified:
354
Indicate_no_grammar_specified=Indicate when no &grammar is specified:
(-)src/org/eclipse/wst/xml/ui/internal/hyperlink/CatalogEntryHyperlink.java (-1 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
2
 * Copyright (c) 2008, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 59-64 Link Here
59
				if (fEntry.getURI().startsWith("jar:file:"))
59
				if (fEntry.getURI().startsWith("jar:file:"))
60
					return new URLStorageHyperlink(fHyperlinkRegion, new URL(fEntry.getURI())) {
60
					return new URLStorageHyperlink(fHyperlinkRegion, new URL(fEntry.getURI())) {
61
						public String getHyperlinkText() {
61
						public String getHyperlinkText() {
62
							final String editorLabel = getEditorLabel();
63
							if (editorLabel != null)
64
								return NLS.bind(XMLUIMessages.Open_With, fEntry.getKey(), editorLabel);
62
							return NLS.bind(XMLUIMessages.Open, fEntry.getKey());
65
							return NLS.bind(XMLUIMessages.Open, fEntry.getKey());
63
						}
66
						}
64
					};
67
					};
(-)src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileHyperlink.java (-1 / +39 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
2
 * Copyright (c) 2005, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-22 Link Here
11
package org.eclipse.wst.xml.ui.internal.hyperlink;
11
package org.eclipse.wst.xml.ui.internal.hyperlink;
12
12
13
import java.io.File;
13
import java.io.File;
14
import java.io.IOException;
15
import java.io.InputStream;
14
16
15
import org.eclipse.core.filesystem.EFS;
17
import org.eclipse.core.filesystem.EFS;
16
import org.eclipse.core.filesystem.IFileStore;
18
import org.eclipse.core.filesystem.IFileStore;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.Platform;
21
import org.eclipse.core.runtime.content.IContentType;
17
import org.eclipse.jface.text.IRegion;
22
import org.eclipse.jface.text.IRegion;
18
import org.eclipse.jface.text.hyperlink.IHyperlink;
23
import org.eclipse.jface.text.hyperlink.IHyperlink;
19
import org.eclipse.osgi.util.NLS;
24
import org.eclipse.osgi.util.NLS;
25
import org.eclipse.ui.IEditorDescriptor;
20
import org.eclipse.ui.IWorkbenchPage;
26
import org.eclipse.ui.IWorkbenchPage;
21
import org.eclipse.ui.PartInitException;
27
import org.eclipse.ui.PartInitException;
22
import org.eclipse.ui.PlatformUI;
28
import org.eclipse.ui.PlatformUI;
Lines 54-62 Link Here
54
		if (path.length() > 60) {
60
		if (path.length() > 60) {
55
			path = path.substring(0, 25) + "..." + path.substring(path.length() - 25, path.length());
61
			path = path.substring(0, 25) + "..." + path.substring(path.length() - 25, path.length());
56
		}
62
		}
63
		final String editorLabel = getEditorLabel();
64
		if (editorLabel != null)
65
			return NLS.bind(XMLUIMessages.Open_With, path, editorLabel);
57
		return NLS.bind(XMLUIMessages.Open, path);
66
		return NLS.bind(XMLUIMessages.Open, path);
58
	}
67
	}
59
68
69
	private String getEditorLabel() {
70
		final IFileStore store = EFS.getLocalFileSystem().getStore(fHyperlinkFile.toURI());
71
		final String name = store.fetchInfo().getName();
72
73
		if (name == null) {
74
			return null;
75
		}
76
77
		IContentType contentType= null;
78
		try {
79
			InputStream is = null;
80
			try {
81
				is = store.openInputStream(EFS.NONE, null);
82
				contentType= Platform.getContentTypeManager().findContentTypeFor(is, name);
83
			} finally {
84
				if (is != null) {
85
					is.close();
86
				}
87
			}
88
		} catch (CoreException ex) {
89
			// continue without content type
90
		} catch (IOException ex) {
91
			// continue without content type
92
		}
93
94
		final IEditorDescriptor descriptor = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(name, contentType);
95
		return descriptor != null ? descriptor.getLabel() : null;
96
	}
97
60
	public void open() {
98
	public void open() {
61
		if (fHyperlinkFile != null) {
99
		if (fHyperlinkFile != null) {
62
			try {
100
			try {
(-)src/org/eclipse/wst/xml/ui/internal/hyperlink/URLStorageHyperlink.java (-3 / +54 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
1
package org.eclipse.wst.xml.ui.internal.hyperlink;
11
package org.eclipse.wst.xml.ui.internal.hyperlink;
2
12
13
import java.io.IOException;
3
import java.io.InputStream;
14
import java.io.InputStream;
4
import java.net.URL;
15
import java.net.URL;
5
16
Lines 8-14 Link Here
8
import org.eclipse.core.runtime.IPath;
19
import org.eclipse.core.runtime.IPath;
9
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.core.runtime.IStatus;
10
import org.eclipse.core.runtime.Path;
21
import org.eclipse.core.runtime.Path;
22
import org.eclipse.core.runtime.Platform;
11
import org.eclipse.core.runtime.Status;
23
import org.eclipse.core.runtime.Status;
24
import org.eclipse.core.runtime.content.IContentType;
12
import org.eclipse.jface.resource.ImageDescriptor;
25
import org.eclipse.jface.resource.ImageDescriptor;
13
import org.eclipse.jface.text.IRegion;
26
import org.eclipse.jface.text.IRegion;
14
import org.eclipse.jface.text.hyperlink.IHyperlink;
27
import org.eclipse.jface.text.hyperlink.IHyperlink;
Lines 152-158 Link Here
152
	 * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText()
165
	 * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText()
153
	 */
166
	 */
154
	public String getHyperlinkText() {
167
	public String getHyperlinkText() {
155
		return NLS.bind(XMLUIMessages.Open, fURL.toString());
168
		String path = fURL.toString();
169
		if (path.length() > 60) {
170
			path = path.substring(0, 25) + "..." + path.substring(path.length() - 25, path.length());
171
		}
172
		final String editorLabel = getEditorLabel();
173
		if (editorLabel != null)
174
			return NLS.bind(XMLUIMessages.Open_With, path, editorLabel);
175
		return NLS.bind(XMLUIMessages.Open, path);
176
	}
177
178
	protected String getEditorLabel() {
179
		IEditorDescriptor descriptor = getEditorDescriptor();
180
		return descriptor != null ? descriptor.getLabel() : null;
181
	}
182
183
	private IEditorDescriptor getEditorDescriptor() {
184
		final URLStorage storage = new URLStorage(fURL);
185
		final String path = fURL.getPath();
186
		String name = null;
187
		if (path != null)
188
			name = new Path(fURL.getPath()).lastSegment();
189
190
		IContentType contentType= null;
191
		try {
192
			InputStream is = null;
193
			try {
194
				is = storage.getContents();
195
				contentType= Platform.getContentTypeManager().findContentTypeFor(is, name);
196
			} finally {
197
				if (is != null) {
198
					is.close();
199
				}
200
			}
201
		} catch (CoreException ex) {
202
			// continue without content type
203
		} catch (IOException ex) {
204
			// continue without content type
205
		}
206
207
		return PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(name, contentType);
156
	}
208
	}
157
209
158
	/*
210
	/*
Lines 163-171 Link Here
163
	public void open() {
215
	public void open() {
164
		if (fURL != null) {
216
		if (fURL != null) {
165
			IEditorInput input = new StorageEditorInput(new URLStorage(fURL));
217
			IEditorInput input = new StorageEditorInput(new URLStorage(fURL));
166
			IEditorDescriptor descriptor;
167
			try {
218
			try {
168
				descriptor = IDE.getEditorDescriptor(input.getName());
219
				final IEditorDescriptor descriptor = getEditorDescriptor();
169
				if (descriptor != null) {
220
				if (descriptor != null) {
170
					IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
221
					IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
171
					IDE.openEditor(page, input, descriptor.getId(), true);
222
					IDE.openEditor(page, input, descriptor.getId(), true);
(-)src/org/eclipse/wst/xml/ui/internal/hyperlink/WorkspaceFileHyperlink.java (-1 / +18 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2006 IBM Corporation and others.
2
 * Copyright (c) 2005, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-19 Link Here
11
package org.eclipse.wst.xml.ui.internal.hyperlink;
11
package org.eclipse.wst.xml.ui.internal.hyperlink;
12
12
13
import org.eclipse.core.resources.IFile;
13
import org.eclipse.core.resources.IFile;
14
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.jface.text.IRegion;
15
import org.eclipse.jface.text.IRegion;
15
import org.eclipse.jface.text.hyperlink.IHyperlink;
16
import org.eclipse.jface.text.hyperlink.IHyperlink;
16
import org.eclipse.osgi.util.NLS;
17
import org.eclipse.osgi.util.NLS;
18
import org.eclipse.ui.IEditorDescriptor;
17
import org.eclipse.ui.IEditorPart;
19
import org.eclipse.ui.IEditorPart;
18
import org.eclipse.ui.IWorkbenchPage;
20
import org.eclipse.ui.IWorkbenchPage;
19
import org.eclipse.ui.PartInitException;
21
import org.eclipse.ui.PartInitException;
Lines 71-79 Link Here
71
		if (path.length() > 60) {
73
		if (path.length() > 60) {
72
			path = path.substring(0, 25) + "..." + path.substring(path.length() - 25, path.length());
74
			path = path.substring(0, 25) + "..." + path.substring(path.length() - 25, path.length());
73
		}
75
		}
76
		String editorLabel = null;
77
		try {
78
			editorLabel = getEditorLabel();
79
		}
80
		catch (CoreException e) {
81
			Logger.logException(e);
82
		}
83
		if (editorLabel != null) {
84
			return NLS.bind(XMLUIMessages.Open_With, path, editorLabel);
85
		}
74
		return NLS.bind(XMLUIMessages.Open, path);
86
		return NLS.bind(XMLUIMessages.Open, path);
75
	}
87
	}
76
88
89
	private String getEditorLabel() throws CoreException {
90
		final IEditorDescriptor defaultEditor = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(fFile.getName(), fFile.getContentDescription().getContentType());
91
		return defaultEditor != null ? defaultEditor.getLabel() : null;
92
	}
93
77
	public void open() {
94
	public void open() {
78
		if ((fFile != null) && fFile.exists()) {
95
		if ((fFile != null) && fFile.exists()) {
79
			try {
96
			try {

Return to bug 298363