mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
patch from Tanya Wolff, fix for 69768
This commit is contained in:
parent
9ffd548ae7
commit
59d90063a3
2 changed files with 46 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2004-07-29 Tanya Wolff
|
||||||
|
|
||||||
|
Part Fix for 69768: CDT wasn't displaying non-English templates.
|
||||||
|
*org.eclipse.cdt.internal.corext.template/Templates.java
|
||||||
|
|
||||||
2004-07-27 Tanya Wolff
|
2004-07-27 Tanya Wolff
|
||||||
|
|
||||||
Fix for 70124 -- allow buttons to be expandable for translation
|
Fix for 70124 -- allow buttons to be expandable for translation
|
||||||
|
|
|
@ -5,15 +5,19 @@ package org.eclipse.cdt.internal.corext.template;
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.jface.dialogs.ErrorDialog;
|
import org.eclipse.jface.dialogs.ErrorDialog;
|
||||||
|
import org.eclipse.ui.internal.util.BundleUtility;
|
||||||
|
import org.osgi.framework.Bundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>Templates</code> gives access to the available templates.
|
* <code>Templates</code> gives access to the available templates.
|
||||||
|
@ -21,6 +25,8 @@ import org.eclipse.jface.dialogs.ErrorDialog;
|
||||||
public class Templates extends TemplateSet {
|
public class Templates extends TemplateSet {
|
||||||
|
|
||||||
private static final String DEFAULT_FILE= "default-templates.xml"; //$NON-NLS-1$
|
private static final String DEFAULT_FILE= "default-templates.xml"; //$NON-NLS-1$
|
||||||
|
private static final String NL_DEFAULT_FILE= "$nl$/org/eclipse/cdt/internal/corext/template/default-templates.xml"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static final String TEMPLATE_FILE= "templates.xml"; //$NON-NLS-1$
|
private static final String TEMPLATE_FILE= "templates.xml"; //$NON-NLS-1$
|
||||||
|
|
||||||
/** Singleton. */
|
/** Singleton. */
|
||||||
|
@ -84,8 +90,39 @@ public class Templates extends TemplateSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static InputStream getDefaultsAsStream() {
|
private static InputStream getDefaultsAsStream() {
|
||||||
return Templates.class.getResourceAsStream(DEFAULT_FILE);
|
URL defFile = getDefaultTemplateFile();
|
||||||
|
if (defFile == null) return Templates.class.getResourceAsStream(DEFAULT_FILE);
|
||||||
|
try {
|
||||||
|
return defFile.openStream();
|
||||||
|
} catch (IOException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//return Templates.class.getResourceAsStream(getDefaultTemplateFile());
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Gets the resolved $nl$ path to the NL_DEFAULT_TEMPLATE file as a URL.
|
||||||
|
* If it doesn't exist, then null is returned. Calling procedures use
|
||||||
|
* DEFAULT_TEMPLATES if null is returned from this.
|
||||||
|
*/
|
||||||
|
public static URL getDefaultTemplateFile() {
|
||||||
|
|
||||||
|
Bundle bundle = Platform.getBundle("org.eclipse.cdt.ui"); //$NON-NLS-1$
|
||||||
|
if (!BundleUtility.isReady(bundle))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
URL fullPathString = BundleUtility.find(bundle, NL_DEFAULT_FILE);
|
||||||
|
if (fullPathString == null) {
|
||||||
|
try {
|
||||||
|
fullPathString = new URL(NL_DEFAULT_FILE);
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fullPathString;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private static File getTemplateFile() {
|
private static File getTemplateFile() {
|
||||||
IPath path= CUIPlugin.getDefault().getStateLocation();
|
IPath path= CUIPlugin.getDefault().getStateLocation();
|
||||||
|
|
Loading…
Add table
Reference in a new issue