mirror of
https://github.com/peterdell/wudsn-ide.git
synced 2025-02-25 11:29:02 +00:00
Add Language separation in CompilerDefinition, CompilerRegistry and TOC
This commit is contained in:
parent
2c89002812
commit
04e36c48ba
@ -28,10 +28,11 @@
|
||||
<extension point="com.wudsn.ide.lng.compilers">
|
||||
<compiler
|
||||
class="com.wudsn.ide.lng.asm.compiler.test.TestCompiler"
|
||||
defaultParameters="-o${outputFilePath} ${sourceFilePath}"
|
||||
defaultHardware="TEST"
|
||||
defaultParameters="-o${outputFilePath} ${sourceFilePath}"
|
||||
homePageURL="https://www.wudsn.com"
|
||||
id="test"
|
||||
language="ASM"
|
||||
name="%com.wudsn.ide.lng.asm.compiler.test.TestCompiler.name"
|
||||
version="none">
|
||||
<supportedTarget
|
||||
|
@ -1,11 +1,5 @@
|
||||
com.wudsn.ide.lng.Hardware.GENERIC=Generic
|
||||
com.wudsn.ide.lng.Hardware.APPLE2=Apple 2
|
||||
com.wudsn.ide.lng.Hardware.ATARI2600=Atari 2600
|
||||
com.wudsn.ide.lng.Hardware.ATARI7800=Atari 7800
|
||||
com.wudsn.ide.lng.Hardware.ATARI8BIT=Atari 8-bit
|
||||
com.wudsn.ide.lng.Hardware.C64=C64
|
||||
com.wudsn.ide.lng.Hardware.NES=NES
|
||||
com.wudsn.ide.lng.Hardware.TEST=Test
|
||||
com.wudsn.ide.lng.Language.ASM=Assembler
|
||||
com.wudsn.ide.lng.Language.PAS=Pascal
|
||||
|
||||
com.wudsn.ide.lng.Target.MOS6502=6502
|
||||
com.wudsn.ide.lng.Target.MOS6502_ILLEGAL=6502 with illegal opcodes
|
||||
@ -47,6 +41,9 @@ com.wudsn.ide.lng.editor.LanguageEditorToggleBreakpointCommand.name=Toggle Break
|
||||
com.wudsn.ide.lng.editor.LanguageEditorOpenDeclarationCommand.name=Open Declaration
|
||||
com.wudsn.ide.lng.editor.LanguageEditorEnableDisableBreakpointCommand.name=Enable/Disable Breakpoint
|
||||
|
||||
com.wudsn.ide.lng.editor.LanguageEditorContentAssistProposal_label=Content Assist
|
||||
com.wudsn.ide.lng.editor.LanguageEditorToggleCommentCommand_label=Toggle Comment
|
||||
|
||||
com.wudsn.ide.lng.editor.LanguageHyperlinkDetector.name=Hyperlink Detector
|
||||
com.wudsn.ide.lng.editor.LanguageHyperlinkDetectorEditorTarget.name=Source Code Editor
|
||||
|
||||
|
@ -1,11 +1,5 @@
|
||||
com.wudsn.ide.lng.Hardware.GENERIC=Generisch
|
||||
com.wudsn.ide.lng.Hardware.APPLE2=Apple 2
|
||||
com.wudsn.ide.lng.Hardware.ATARI2600=Atari 2600
|
||||
com.wudsn.ide.lng.Hardware.ATARI7800=Atari 7800
|
||||
com.wudsn.ide.lng.Hardware.ATARI8BIT=Atari 8-bit
|
||||
com.wudsn.ide.lng.Hardware.C64=C64
|
||||
com.wudsn.ide.lng.Hardware.NES=NES
|
||||
com.wudsn.ide.lng.Hardware.TEST=Test
|
||||
com.wudsn.ide.lng.Language.ASM=Assembler
|
||||
com.wudsn.ide.lng.Language.PAS=Pascal
|
||||
|
||||
com.wudsn.ide.lng.Target.MOS6502=6502
|
||||
com.wudsn.ide.lng.Target.MOS6502_ILLEGAL=6502 mit illegalen Opcodes
|
||||
@ -15,9 +9,12 @@ com.wudsn.ide.lng.Target.MOS65816=65816
|
||||
|
||||
com.wudsn.ide.lng.compiler.CompilerSourceFile.name=Quelltext-Datei
|
||||
|
||||
com.wudsn.ide.lng.editor.LanguageEditorAssemblerMenu.label=Assembler
|
||||
com.wudsn.ide.lng.editor.LanguageEditorAssemblerMenu.mnemonic=s
|
||||
com.wudsn.ide.lng.editor.LanguageEditorCompilerMenu.label=Kompiler
|
||||
com.wudsn.ide.lng.editor.LanguageEditorCompilerMenu.mnemonic=K
|
||||
|
||||
com.wudsn.ide.lng.editor.LanguageEditorAssemblerToolbar.label=Assembler
|
||||
com.wudsn.ide.lng.editor.LanguageEditorCompilerToolbar.label=Kompiler
|
||||
|
||||
com.wudsn.ide.lng.editor.LanguageEditorCommands.name=Quelltext Editor Befehle
|
||||
@ -25,6 +22,13 @@ com.wudsn.ide.lng.editor.LanguageEditorOpenSourceFolderCommand.name=Quell-Ordner
|
||||
com.wudsn.ide.lng.editor.LanguageEditorOpenSourceFolderCommand.mnemonic=Q
|
||||
com.wudsn.ide.lng.editor.LanguageEditorOpenOutputFolderCommand.name=Ausgabe-Ordner öffnen
|
||||
com.wudsn.ide.lng.editor.LanguageEditorOpenOutputFolderCommand.mnemonic=A
|
||||
com.wudsn.ide.lng.editor.LanguageEditorAssembleCommand.name=Assemblieren
|
||||
com.wudsn.ide.lng.editor.LanguageEditorAssembleCommand.mnemonic=A
|
||||
com.wudsn.ide.lng.editor.LanguageEditorAssembleAndRunCommand.name=Assemblieren und Ausführen
|
||||
com.wudsn.ide.lng.editor.LanguageEditorAssembleAndRunCommand.mnemonic=f
|
||||
com.wudsn.ide.lng.editor.LanguageEditorAssembleAndRunWithCommand.name=Assemblieren und Ausführen mit...
|
||||
com.wudsn.ide.lng.editor.LanguageEditorAssemblerHelpCommand.name=Assembler Hilfe
|
||||
com.wudsn.ide.lng.editor.LanguageEditorAssemblerHelpCommand.mnemonic=H
|
||||
com.wudsn.ide.lng.editor.LanguageEditorCompileCommand.name=Kompilieren
|
||||
com.wudsn.ide.lng.editor.LanguageEditorCompileCommand.mnemonic=K
|
||||
com.wudsn.ide.lng.editor.LanguageEditorCompileAndRunCommand.name=Kompilieren und Ausführen
|
||||
@ -37,7 +41,7 @@ com.wudsn.ide.lng.editor.LanguageEditorToggleBreakpointCommand.name=Breakpoint u
|
||||
com.wudsn.ide.lng.editor.LanguageEditorOpenDeclarationCommand.name=Deklaration öffnen
|
||||
com.wudsn.ide.lng.editor.LanguageEditorEnableDisableBreakpointCommand.name=Breakpoint ein/ausschalten
|
||||
|
||||
com.wudsn.ide.lng.editor.LanguageHyperlinkDetector.name=Hyperlink Detector
|
||||
com.wudsn.ide.lng.editor.LanguageHyperlinkDetector.name=Hyperlink Detektor
|
||||
com.wudsn.ide.lng.editor.LanguageHyperlinkDetectorEditorTarget.name=Quelltext Editor
|
||||
|
||||
com.wudsn.ide.lng.breakpoint.LanguageBreakpoint.name=Unterbrechungspunkt
|
||||
|
@ -381,7 +381,7 @@
|
||||
id="com.wudsn.ide.lng.editor.LanguageEditorAssemblerToolbar"
|
||||
label="%com.wudsn.ide.lng.editor.LanguageEditorAssemblerToolbar.label">
|
||||
<dynamic
|
||||
class="com.wudsn.ide.lng.editor.LanguageEditorAssembleAndRunCommandMenu"
|
||||
class="com.wudsn.ide.lng.editor.LanguageEditorCompileAndRunCommandMenu"
|
||||
id="com.wudsn.ide.lng.editor.LanguageEditorAssembleAndRunCommandMenu">
|
||||
<visibleWhen
|
||||
checkEnabled="true">
|
||||
@ -478,21 +478,21 @@
|
||||
class="com.wudsn.ide.lng.breakpoint.LanguageBreakpoint"
|
||||
id="languageBreakpoint"
|
||||
markerType="org.eclipse.debug.core.lineBreakpointMarker"
|
||||
name="%com.wudsn.ide.lng.editor.LanguageBreakpoint.name">
|
||||
name="%com.wudsn.ide.lng.breakpoint.LanguageBreakpoint.name">
|
||||
</breakpoint>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.debug.ui.toggleBreakpointsTargetFactories">
|
||||
<toggleTargetFactory
|
||||
class="com.wudsn.ide.lng.breakpoint.LanguageBreakpointAdapterFactory"
|
||||
id="com.wudsn.ide.lng.editor.LanguageBreakpointAdapterFactory">
|
||||
id="com.wudsn.ide.lng.breakpoint.LanguageBreakpointAdapterFactory">
|
||||
</toggleTargetFactory>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.debug.ui.debugModelPresentations">
|
||||
<debugModelPresentation
|
||||
class="com.wudsn.ide.lng.breakpoint.LanguageBreakpoinDebugModelPresentation"
|
||||
id="com.wudsn.ide.asm">
|
||||
id="com.wudsn.ide.lng">
|
||||
</debugModelPresentation>
|
||||
</extension>
|
||||
|
||||
@ -521,8 +521,8 @@
|
||||
point="org.eclipse.ui.preferenceTransfer">
|
||||
<transfer
|
||||
icon="icons/hardware-generic-16x16.gif"
|
||||
id="com.wudsn.ide.lng.preferences.LanguagePreferences"
|
||||
name="%com.wudsn.ide.lng.preferences.LanguagePreferences.name">
|
||||
id="com.wudsn.ide.lng.preferences.LanguagesPreferences"
|
||||
name="%com.wudsn.ide.lng.preferences.LanguagesPreferences.name">
|
||||
<mapping
|
||||
scope="instance">
|
||||
<entry
|
||||
|
@ -2,9 +2,9 @@
|
||||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="com.wudsn.ide.lng" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.schema plugin="com.wudsn.ide.lng" id="compilers" name="Compilers"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
This extension point allows for adding new assemblers and compilers to the WUDSN IDE.
|
||||
</documentation>
|
||||
@ -12,9 +12,9 @@
|
||||
|
||||
<element name="extension">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.element />
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence minOccurs="1" maxOccurs="unbounded">
|
||||
@ -39,9 +39,9 @@
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
@ -51,15 +51,22 @@
|
||||
<complexType>
|
||||
<choice>
|
||||
<sequence>
|
||||
<element ref="supportedCPU" minOccurs="1" maxOccurs="unbounded"/>
|
||||
<element ref="supportedTarget" minOccurs="1" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
<sequence>
|
||||
</sequence>
|
||||
</choice>
|
||||
<attribute name="language" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The technical ID of the language.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="id" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The technical id of the compiler. Must consist of lower case letters or digits.
|
||||
The technical ID of the compiler. Must consist of lower case letters or digits. Must be unique without one language.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
@ -68,9 +75,9 @@
|
||||
<documentation>
|
||||
Translatable name of the compiler. Typically contains only upper case letters.
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="class" type="string" use="required">
|
||||
@ -78,9 +85,9 @@
|
||||
<documentation>
|
||||
The name of the compiler class.
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java" basedOn="com.wudsn.ide.lng.compiler.Compiler:"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="version" type="string" use="required">
|
||||
@ -166,9 +173,9 @@
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.section type="since"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
WUDSN IDE 1.1.0
|
||||
</documentation>
|
||||
@ -176,9 +183,9 @@
|
||||
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.section type="apiinfo"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
To implement this extension point, you have to create a sub-class of com.wudsn.ide.lng.compiler.Compiler, a sub-class of com.wudsn.ide.lng.compiler.parser.CompilerSourceParser and a sub-class of com.wudsn.ide.lng.compiler.CompilerLogParser. In the constructor of the compiler you have to set the source parser instance. In the "createLogParser" method of the compiler you have to create a new instance of the corresponding log parser.
|
||||
</documentation>
|
||||
@ -186,9 +193,9 @@
|
||||
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<appInfo>
|
||||
<meta.section type="copyright"/>
|
||||
</appinfo>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
(c) 2009 Peter Dell
|
||||
</documentation>
|
||||
|
@ -1,3 +0,0 @@
|
||||
# Used by LanguageEditor
|
||||
com.wudsn.ide.lng.editor.ContentAssistProposal_label=Content Assist
|
||||
com.wudsn.ide.lng.editor.LanguageEditorToggleCommentCommand_label=Toggle Comment
|
@ -19,7 +19,10 @@
|
||||
|
||||
package com.wudsn.ide.lng;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@ -56,6 +59,8 @@ public final class LanguagePlugin extends AbstractIDEPlugin {
|
||||
*/
|
||||
private static LanguagePlugin plugin;
|
||||
|
||||
private List<Language> languages;
|
||||
|
||||
/**
|
||||
* The preferences.
|
||||
*/
|
||||
@ -92,6 +97,10 @@ public final class LanguagePlugin extends AbstractIDEPlugin {
|
||||
compilerConsole = null;
|
||||
runnerRegistry = new RunnerRegistry();
|
||||
properties = new HashMap<QualifiedName, String>(10);
|
||||
languages = new ArrayList<Language>(2);
|
||||
languages.add(Language.ASM);
|
||||
languages.add(Language.PAS);
|
||||
languages = Collections.unmodifiableList(languages);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -161,6 +170,16 @@ public final class LanguagePlugin extends AbstractIDEPlugin {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the unmodifiable list of supported languages.
|
||||
*
|
||||
* @return The unmodifiable list of supported languages, may be empty, not
|
||||
* <code>null</code>,
|
||||
*/
|
||||
public List<Language> getLanguages() {
|
||||
return languages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the compiler registry for this plugin.
|
||||
*
|
||||
|
@ -218,6 +218,8 @@ public final class Texts extends NLS {
|
||||
|
||||
public static String TOC_IDE_TOPIC_LABEL;
|
||||
|
||||
public static String TOC_LANGUAGES_TOPIC_LABEL;
|
||||
|
||||
public static String TOC_COMPILERS_TOPIC_LABEL;
|
||||
public static String TOC_COMPILER_GENERAL_TOPIC_LABEL;
|
||||
public static String TOC_COMPILER_NAME_LABEL;
|
||||
|
@ -114,6 +114,8 @@ TOC_WUDSN_IDE_LABEL=WUDSN IDE Guide
|
||||
|
||||
TOC_IDE_TOPIC_LABEL=WUDSN IDE
|
||||
|
||||
TOC_LANGUAGES_TOPIC_LABEL=Languages
|
||||
|
||||
TOC_COMPILERS_TOPIC_LABEL={0}
|
||||
TOC_COMPILER_GENERAL_TOPIC_LABEL=General
|
||||
TOC_COMPILER_NAME_LABEL=Name
|
||||
|
@ -112,6 +112,8 @@ TOC_WUDSN_IDE_LABEL=WUDSN IDE Handbuch
|
||||
|
||||
TOC_IDE_TOPIC_LABEL=WUDSN IDE
|
||||
|
||||
TOC_LANGUAGES_TOPIC_LABEL=Sprachen
|
||||
|
||||
TOC_COMPILERS_TOPIC_LABEL={0}
|
||||
TOC_COMPILER_GENERAL_TOPIC_LABEL=Allgemein
|
||||
TOC_COMPILER_NAME_LABEL=Name
|
||||
|
@ -28,7 +28,6 @@ import com.wudsn.ide.lng.compiler.parser.CompilerSourceParser;
|
||||
*/
|
||||
public abstract class Compiler {
|
||||
|
||||
// See {@link CompilerId} for predefined ids.
|
||||
private CompilerDefinition definition;
|
||||
|
||||
/**
|
||||
|
@ -46,6 +46,9 @@ import com.wudsn.ide.lng.compiler.syntax.CompilerSyntax;
|
||||
*/
|
||||
public final class CompilerDefinition implements Comparable<CompilerDefinition> {
|
||||
|
||||
// Language
|
||||
private String language;
|
||||
|
||||
// Id
|
||||
private String id;
|
||||
private String name;
|
||||
@ -72,6 +75,51 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the key that uniquely identifies the compiler. They key has the format
|
||||
* "<language>/<id>".
|
||||
*
|
||||
* @return The key that uniquely identifies the compiler, not <code>null</code>.
|
||||
*/
|
||||
public String getKey() {
|
||||
if (language == null) {
|
||||
throw new IllegalStateException("Field 'language' must not be null for this or for argument.");
|
||||
}
|
||||
if (id == null) {
|
||||
throw new IllegalStateException("Field 'id' must not be null for this or for argument.");
|
||||
|
||||
}
|
||||
return language + "/" + id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the language of the compiler. Called by {@link CompilerRegistry} only.
|
||||
*
|
||||
* @param language The language of the compiler, not empty and not
|
||||
* <code>null</code>.
|
||||
*/
|
||||
final void setLanguage(String language) {
|
||||
if (language == null) {
|
||||
throw new IllegalArgumentException("Parameter 'language' must not be null.");
|
||||
}
|
||||
if (StringUtility.isEmpty(language)) {
|
||||
throw new IllegalArgumentException("Parameter 'language' must not be empty.");
|
||||
}
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the language of the compiler.
|
||||
*
|
||||
* @return The language of the compiler, not empty and not <code>null</code>.
|
||||
*/
|
||||
public final String getLanguage() {
|
||||
if (language == null) {
|
||||
throw new IllegalStateException("Field 'language' must not be null.");
|
||||
}
|
||||
return language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the id of the compiler. Called by {@link CompilerRegistry} only.
|
||||
*
|
||||
@ -295,8 +343,8 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
|
||||
/**
|
||||
* Sets the list of supported targets. Called by {@link CompilerRegistry} only.
|
||||
*
|
||||
* @param supportedTargets The unmodifiable list of supported CPUs, not empty and
|
||||
* not <code>null</code>.
|
||||
* @param supportedTargets The unmodifiable list of supported CPUs, not empty
|
||||
* and not <code>null</code>.
|
||||
* @since 1.6.1
|
||||
*/
|
||||
final void setSupportedTargets(List<Target> supportedTargets) {
|
||||
@ -408,17 +456,13 @@ public final class CompilerDefinition implements Comparable<CompilerDefinition>
|
||||
if (o == null) {
|
||||
throw new IllegalArgumentException("Parameter 'o' must not be null.");
|
||||
}
|
||||
if (id == null || o.id == null) {
|
||||
if (id == null) {
|
||||
throw new IllegalStateException("Field 'id' must not be null for this or for argument.");
|
||||
}
|
||||
}
|
||||
return id.compareTo(o.id);
|
||||
|
||||
return getKey().compareTo(o.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return id;
|
||||
return getKey();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ import org.eclipse.core.runtime.IExtensionRegistry;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
import com.wudsn.ide.base.hardware.Hardware;
|
||||
import com.wudsn.ide.lng.Language;
|
||||
import com.wudsn.ide.lng.Target;
|
||||
import com.wudsn.ide.lng.compiler.syntax.CompilerSyntax;
|
||||
|
||||
@ -92,6 +93,7 @@ public final class CompilerRegistry {
|
||||
try {
|
||||
CompilerDefinition compilerDefinition;
|
||||
compilerDefinition = new CompilerDefinition();
|
||||
compilerDefinition.setId(configurationElement.getAttribute("language"));
|
||||
compilerDefinition.setId(configurationElement.getAttribute("id"));
|
||||
compilerDefinition.setName(configurationElement.getAttribute("name"));
|
||||
compilerDefinition.setClassName(configurationElement.getAttribute("class"));
|
||||
@ -175,38 +177,40 @@ public final class CompilerRegistry {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the unmodifiable list of compiler definitions, sorted by their id.
|
||||
* Gets the unmodifiable list of compiler definitions for a language, sorted by their key.
|
||||
*
|
||||
*
|
||||
* @return The unmodifiable list of compiler definitions, sorted by their id,
|
||||
* @param language The language or <code>null</code>.
|
||||
* @return The unmodifiable list of compiler definitions, sorted by their key,
|
||||
* may be empty, not <code>null</code>
|
||||
*
|
||||
* @since 1.6.1
|
||||
*/
|
||||
public List<CompilerDefinition> getCompilerDefinitions() {
|
||||
public List<CompilerDefinition> getCompilerDefinitions(Language language) {
|
||||
|
||||
List<CompilerDefinition> result=new ArrayList<CompilerDefinition>();
|
||||
return compilerDefinitionList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the compiler for a given id. Instances of compiler are stateless
|
||||
* Gets the compiler for a given key. Instances of compiler are stateless
|
||||
* singletons within the plugin.
|
||||
*
|
||||
* @param compilerId The compiler id, not <code>null</code>.
|
||||
* @param key The compiler key, not <code>null</code>.
|
||||
*
|
||||
* @return The compiler, not <code>null</code>.
|
||||
*/
|
||||
public Compiler getCompiler(String compilerId) {
|
||||
if (compilerId == null) {
|
||||
throw new IllegalArgumentException("Parameter 'compilerId' must not be null.");
|
||||
public Compiler getCompiler(String key) {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException("Parameter 'key' must not be null.");
|
||||
}
|
||||
Compiler result;
|
||||
synchronized (compilerMap) {
|
||||
|
||||
result = compilerMap.get(compilerId);
|
||||
result = compilerMap.get(key);
|
||||
}
|
||||
if (result == null) {
|
||||
|
||||
throw new IllegalArgumentException("Unknown compiler id '" + compilerId + "'.");
|
||||
throw new IllegalArgumentException("Unknown compiler id '" + key + "'.");
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -25,7 +25,6 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
@ -54,11 +53,12 @@ import org.eclipse.ui.texteditor.TextOperationAction;
|
||||
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
|
||||
|
||||
import com.wudsn.ide.base.common.Profiler;
|
||||
import com.wudsn.ide.base.common.ResourceBundleUtility;
|
||||
import com.wudsn.ide.base.hardware.Hardware;
|
||||
import com.wudsn.ide.lng.LanguagePlugin;
|
||||
import com.wudsn.ide.lng.LanguageProperties;
|
||||
import com.wudsn.ide.lng.Target;
|
||||
import com.wudsn.ide.lng.LanguageProperties.InvalidLanguagePropertyException;
|
||||
import com.wudsn.ide.lng.Target;
|
||||
import com.wudsn.ide.lng.compiler.Compiler;
|
||||
import com.wudsn.ide.lng.compiler.CompilerDefinition;
|
||||
import com.wudsn.ide.lng.compiler.parser.CompilerSourceFile;
|
||||
@ -76,6 +76,13 @@ import com.wudsn.ide.lng.preferences.CompilerPreferences;
|
||||
*/
|
||||
public abstract class LanguageEditor extends TextEditor {
|
||||
|
||||
private static final class Actions {
|
||||
|
||||
public static final String LanguageContentAssistProposal = "com.wudsn.ide.lng.editor.LanguageContentAssistProposal";
|
||||
public static final String LanguageEditorToggleCommentCommand = "com.wudsn.ide.lng.editor.LanguageEditorToggleCommentCommand";
|
||||
public static final String RulerDoubleClick = "RulerDoubleClick";
|
||||
}
|
||||
|
||||
private LanguagePlugin plugin;
|
||||
private LanguageEditorFilesLogic filesLogic;
|
||||
|
||||
@ -240,21 +247,20 @@ public abstract class LanguageEditor extends TextEditor {
|
||||
protected final void createActions() {
|
||||
super.createActions();
|
||||
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("com.wudsn.ide.lng.Actions", Locale.getDefault(),
|
||||
LanguageEditor.class.getClassLoader());
|
||||
ResourceBundle bundle = ResourceBundleUtility.getResourceBundle(Actions.class);
|
||||
|
||||
String actionDefintionId;
|
||||
String actionId;
|
||||
actionDefintionId = ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS;
|
||||
actionId = "com.wudsn.ide.lng.editor.ContentAssistProposal";
|
||||
actionDefintionId = LanguageEditorActionDefinitionIds.LanguageContentAssistProposal;
|
||||
actionId = Actions.LanguageContentAssistProposal;
|
||||
IAction action = new TextOperationAction(bundle, actionId + ".", this, ISourceViewer.CONTENTASSIST_PROPOSALS);
|
||||
action.setActionDefinitionId(actionDefintionId);
|
||||
setAction(actionId, action);
|
||||
markAsStateDependentAction(actionId, true);
|
||||
|
||||
SourceViewer sourceViewer = (SourceViewer) getSourceViewer();
|
||||
actionDefintionId = "com.wudsn.ide.lng.editor.LanguageEditorToggleCommentCommand";
|
||||
actionId = actionDefintionId;
|
||||
actionDefintionId = LanguageEditorActionDefinitionIds.LanguageEditorToggleCommentCommand;
|
||||
actionId = Actions.LanguageEditorToggleCommentCommand;
|
||||
action = new LanguageEditorToggleCommentAction(bundle, actionId + ".", this, sourceViewer);
|
||||
action.setActionDefinitionId(actionId);
|
||||
setAction(actionId, action);
|
||||
@ -262,8 +268,8 @@ public abstract class LanguageEditor extends TextEditor {
|
||||
|
||||
// Register rule double click.
|
||||
ToggleBreakpointAction toggleBreakpointAction;
|
||||
actionDefintionId = "org.eclipse.debug.ui.commands.ToggleBreakpoint";
|
||||
actionId = "RulerDoubleClick";
|
||||
actionDefintionId = LanguageEditorActionDefinitionIds.ToggleBreakpoint;
|
||||
actionId = Actions.RulerDoubleClick;
|
||||
action.setActionDefinitionId(actionId);
|
||||
toggleBreakpointAction = new ToggleBreakpointAction(this, getDocumentProvider().getDocument(getEditorInput()),
|
||||
getVerticalRuler());
|
||||
|
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright (C) 2009 - 2021 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
* WUDSN IDE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WUDSN IDE is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WUDSN IDE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.wudsn.ide.lng.editor;
|
||||
|
||||
/**
|
||||
* Constant definitions for action definition IDs.
|
||||
*
|
||||
* @author Peter Dell
|
||||
*
|
||||
*/
|
||||
public final class LanguageEditorActionDefinitionIds {
|
||||
|
||||
/**
|
||||
* Creation is private.
|
||||
*/
|
||||
private LanguageEditorActionDefinitionIds() {
|
||||
|
||||
}
|
||||
|
||||
public static final String LanguageContentAssistProposal = "com.wudsn.ide.lng.editor.LanguageContentAssistProposal";
|
||||
public static final String LanguageEditorToggleCommentCommand = "com.wudsn.ide.lng.editor.LanguageEditorToggleCommentCommand";
|
||||
public static final String ToggleBreakpoint = "org.eclipse.debug.ui.commands.ToggleBreakpoint";
|
||||
|
||||
}
|
@ -48,6 +48,7 @@ import com.wudsn.ide.base.common.StringUtility;
|
||||
import com.wudsn.ide.base.common.TextUtility;
|
||||
import com.wudsn.ide.base.hardware.Hardware;
|
||||
import com.wudsn.ide.base.hardware.HardwareUtility;
|
||||
import com.wudsn.ide.lng.Language;
|
||||
import com.wudsn.ide.lng.LanguagePlugin;
|
||||
import com.wudsn.ide.lng.Target;
|
||||
import com.wudsn.ide.lng.Texts;
|
||||
@ -115,7 +116,7 @@ public final class LanguageHelpContentProducer implements IHelpContentProducer {
|
||||
} else if (href.startsWith(SCHEMA_HARDWARE)) {
|
||||
return getHardwareInputStream(href);
|
||||
} else if (href.startsWith(SCHEMA_TARGET)) {
|
||||
return getCPUInputStream(href);
|
||||
return getCPUInputStream(Language.ASM, href); // TODO: Language handling
|
||||
} else if (href.endsWith(".html")) { // Web site documents
|
||||
return getHTMLInputStream(href);
|
||||
}
|
||||
@ -593,7 +594,7 @@ public final class LanguageHelpContentProducer implements IHelpContentProducer {
|
||||
return getInputStream(writer);
|
||||
}
|
||||
|
||||
private InputStream getCPUInputStream(String href) {
|
||||
private InputStream getCPUInputStream( Language language, String href) {
|
||||
|
||||
if (href == null) {
|
||||
throw new IllegalArgumentException("Parameter 'href' must not be null.");
|
||||
@ -622,7 +623,7 @@ public final class LanguageHelpContentProducer implements IHelpContentProducer {
|
||||
writer.writeTableHeader(Texts.TOC_TARGET_OPCODE_LABEL);
|
||||
writer.writeTableHeader(Texts.TOC_COMPILER_INSTRUCTION_DESCRIPTION_LABEL);
|
||||
|
||||
List<CompilerDefinition> compilerDefinitions = compilerRegistry.getCompilerDefinitions();
|
||||
List<CompilerDefinition> compilerDefinitions = compilerRegistry.getCompilerDefinitions(language);
|
||||
int compilerDefinitionCount = compilerDefinitions.size();
|
||||
InstructionSet[] instructionSets = new InstructionSet[compilerDefinitions.size()];
|
||||
for (int c = 0; c < compilerDefinitionCount; c++) {
|
||||
|
@ -38,7 +38,9 @@ import org.eclipse.help.ITopic2;
|
||||
import org.eclipse.help.IUAElement;
|
||||
|
||||
import com.wudsn.ide.base.common.EnumUtility;
|
||||
import com.wudsn.ide.base.common.TextUtility;
|
||||
import com.wudsn.ide.base.hardware.Hardware;
|
||||
import com.wudsn.ide.lng.Language;
|
||||
import com.wudsn.ide.lng.LanguagePlugin;
|
||||
import com.wudsn.ide.lng.Target;
|
||||
import com.wudsn.ide.lng.Texts;
|
||||
@ -158,9 +160,10 @@ public final class LanguageTocProvider extends AbstractTocProvider {
|
||||
String label;
|
||||
String key = href;
|
||||
try {
|
||||
Class<LanguageTocProvider> clazz = LanguageTocProvider.class;
|
||||
ResourceBundle resourceBundle;
|
||||
resourceBundle = ResourceBundle.getBundle("com/wudsn/ide/asm/help/LanguageTocProvider",
|
||||
Locale.getDefault(), LanguageTocProvider.class.getClassLoader());
|
||||
resourceBundle = ResourceBundle.getBundle(clazz.getName().replace('.', '/'), Locale.getDefault(),
|
||||
clazz.getClassLoader());
|
||||
label = resourceBundle.getString(key);
|
||||
} catch (MissingResourceException ex) {
|
||||
label = href + " - Text missing";
|
||||
@ -195,25 +198,40 @@ public final class LanguageTocProvider extends AbstractTocProvider {
|
||||
}
|
||||
|
||||
static ITopic[] createTopics() {
|
||||
LanguagePlugin languagePlugin = LanguagePlugin.getInstance();
|
||||
CompilerRegistry compilerRegistry = languagePlugin.getCompilerRegistry();
|
||||
List<CompilerDefinition> compilerDefinitions = compilerRegistry.getCompilerDefinitions();
|
||||
|
||||
List<ITopic> ideTopics = createIDETopics();
|
||||
List<ITopic> compilerTopics = createCompilerTopics(compilerDefinitions);
|
||||
List<ITopic> hardwareTopics = createHardwareTopics();
|
||||
List<ITopic> cpuTopics = createTargetTopics();
|
||||
|
||||
List<ITopic> topics = new ArrayList<ITopic>();
|
||||
|
||||
LanguagePlugin languagePlugin = LanguagePlugin.getInstance();
|
||||
|
||||
List<ITopic> ideTopics = createIDETopics();
|
||||
topics.add(createTopic("", Texts.TOC_IDE_TOPIC_LABEL, "", createTopicsArray(ideTopics)));
|
||||
topics.add(createTopic("", Texts.TOC_COMPILERS_TOPIC_LABEL, "", createTopicsArray(compilerTopics)));
|
||||
|
||||
List<ITopic> languagesTopics = createLanguagesTopics(languagePlugin);
|
||||
topics.add(createTopic("", Texts.TOC_LANGUAGES_TOPIC_LABEL, "", createTopicsArray(languagesTopics)));
|
||||
|
||||
List<ITopic> hardwareTopics = createHardwareTopics();
|
||||
topics.add(createTopic("", Texts.TOC_HARDWARES_TOPIC_LABEL, "", createTopicsArray(hardwareTopics)));
|
||||
|
||||
List<ITopic> cpuTopics = createTargetTopics();
|
||||
topics.add(createTopic("", Texts.TOC_TARGETS_TOPIC_LABEL, "", createTopicsArray(cpuTopics)));
|
||||
|
||||
return createTopicsArray(topics);
|
||||
}
|
||||
|
||||
private static List<ITopic> createLanguagesTopics(LanguagePlugin languagePlugin) {
|
||||
List<ITopic> topics = new ArrayList<ITopic>();
|
||||
for (Language language : languagePlugin.getLanguages()) {
|
||||
CompilerRegistry compilerRegistry = languagePlugin.getCompilerRegistry();
|
||||
|
||||
List<CompilerDefinition> compilerDefinitions = compilerRegistry.getCompilerDefinitions(language);
|
||||
|
||||
List<ITopic> compilerTopics = createCompilersTopics(compilerDefinitions);
|
||||
topics.add(
|
||||
createTopic("", TextUtility.format(Texts.TOC_COMPILERS_TOPIC_LABEL, EnumUtility.getText(language)),
|
||||
"", createTopicsArray(compilerTopics)));
|
||||
}
|
||||
return topics;
|
||||
}
|
||||
|
||||
private static List<ITopic> createIDETopics() {
|
||||
List<ITopic> topics = new ArrayList<ITopic>();
|
||||
|
||||
@ -226,7 +244,8 @@ public final class LanguageTocProvider extends AbstractTocProvider {
|
||||
return topics;
|
||||
}
|
||||
|
||||
private static List<ITopic> createCompilerTopics(List<CompilerDefinition> compilerDefinitions) {
|
||||
private static List<ITopic> createCompilersTopics(List<CompilerDefinition> compilerDefinitions) {
|
||||
|
||||
if (compilerDefinitions == null) {
|
||||
throw new IllegalArgumentException("Parameter 'compilerDefinitions' must not be null.");
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ public abstract class LanguagePreferencesCompilersPage extends FieldEditorPrefer
|
||||
/**
|
||||
* The language.
|
||||
*/
|
||||
final Language langauge;
|
||||
final Language language;
|
||||
|
||||
/**
|
||||
* The type of hardware used to filter the compilers and emulators.
|
||||
@ -207,7 +207,7 @@ public abstract class LanguagePreferencesCompilersPage extends FieldEditorPrefer
|
||||
if (hardware == null) {
|
||||
throw new IllegalArgumentException("Parameter 'hardware' must not be null.");
|
||||
}
|
||||
this.langauge = language;
|
||||
this.language = language;
|
||||
this.hardware = hardware;
|
||||
plugin = LanguagePlugin.getInstance();
|
||||
IPreferenceStore preferencesStore = plugin.getPreferenceStore();
|
||||
@ -253,7 +253,7 @@ public abstract class LanguagePreferencesCompilersPage extends FieldEditorPrefer
|
||||
|
||||
// Create the editors for all compilers of the hardware.
|
||||
CompilerRegistry compilerRegistry = plugin.getCompilerRegistry();
|
||||
List<CompilerDefinition> compilerDefinitions = compilerRegistry.getCompilerDefinitions();
|
||||
List<CompilerDefinition> compilerDefinitions = compilerRegistry.getCompilerDefinitions(language);
|
||||
|
||||
tabFolder = new TabFolder(parent, SWT.FLAT);
|
||||
for (CompilerDefinition compilerDefinition : compilerDefinitions) {
|
||||
|
@ -30,6 +30,7 @@ import org.eclipse.swt.widgets.Display;
|
||||
|
||||
import com.wudsn.ide.base.hardware.Hardware;
|
||||
import com.wudsn.ide.base.hardware.HardwareUtility;
|
||||
import com.wudsn.ide.lng.Language;
|
||||
import com.wudsn.ide.lng.LanguagePlugin;
|
||||
import com.wudsn.ide.lng.compiler.CompilerDefinition;
|
||||
import com.wudsn.ide.lng.compiler.CompilerOutputFolderMode;
|
||||
@ -111,31 +112,34 @@ public final class LanguagePreferencesInitializer extends AbstractPreferenceInit
|
||||
throw new IllegalArgumentException("Parameter 'store' must not be null.");
|
||||
}
|
||||
|
||||
CompilerRegistry compilerRegistry = LanguagePlugin.getInstance().getCompilerRegistry();
|
||||
LanguagePlugin languagePlugin = LanguagePlugin.getInstance();
|
||||
CompilerRegistry compilerRegistry = languagePlugin.getCompilerRegistry();
|
||||
for (Language language : languagePlugin.getLanguages()) {
|
||||
|
||||
List<CompilerDefinition> compilerDefinitions = compilerRegistry.getCompilerDefinitions();
|
||||
for (CompilerDefinition compilerDefinition : compilerDefinitions) {
|
||||
String compilerId;
|
||||
String name;
|
||||
compilerId = compilerDefinition.getId();
|
||||
List<CompilerDefinition> compilerDefinitions = compilerRegistry.getCompilerDefinitions(language);
|
||||
for (CompilerDefinition compilerDefinition : compilerDefinitions) {
|
||||
String compilerId;
|
||||
String name;
|
||||
compilerId = compilerDefinition.getId();
|
||||
|
||||
for (Hardware hardware : Hardware.values()) {
|
||||
if (hardware.equals(Hardware.GENERIC)) {
|
||||
continue;
|
||||
for (Hardware hardware : Hardware.values()) {
|
||||
if (hardware.equals(Hardware.GENERIC)) {
|
||||
continue;
|
||||
}
|
||||
store.setDefault(LanguagePreferencesConstants.getCompilerTargetName(compilerId, hardware),
|
||||
compilerDefinition.getSupportedTargets().get(0).toString());
|
||||
|
||||
name = LanguagePreferencesConstants.getCompilerParametersName(compilerId, hardware);
|
||||
store.setDefault(name, compilerDefinition.getDefaultParameters());
|
||||
name = LanguagePreferencesConstants.getCompilerOutputFolderModeName(compilerId, hardware);
|
||||
store.setDefault(name, CompilerOutputFolderMode.TEMP_FOLDER);
|
||||
name = LanguagePreferencesConstants.getCompilerOutputFileExtensionName(compilerId, hardware);
|
||||
store.setDefault(name, HardwareUtility.getDefaultFileExtension(hardware));
|
||||
name = LanguagePreferencesConstants.getCompilerRunnerIdName(compilerId, hardware);
|
||||
store.setDefault(name, RunnerId.DEFAULT_APPLICATION);
|
||||
}
|
||||
store.setDefault(LanguagePreferencesConstants.getCompilerTargetName(compilerId, hardware),
|
||||
compilerDefinition.getSupportedTargets().get(0).toString());
|
||||
|
||||
name = LanguagePreferencesConstants.getCompilerParametersName(compilerId, hardware);
|
||||
store.setDefault(name, compilerDefinition.getDefaultParameters());
|
||||
name = LanguagePreferencesConstants.getCompilerOutputFolderModeName(compilerId, hardware);
|
||||
store.setDefault(name, CompilerOutputFolderMode.TEMP_FOLDER);
|
||||
name = LanguagePreferencesConstants.getCompilerOutputFileExtensionName(compilerId, hardware);
|
||||
store.setDefault(name, HardwareUtility.getDefaultFileExtension(hardware));
|
||||
name = LanguagePreferencesConstants.getCompilerRunnerIdName(compilerId, hardware);
|
||||
store.setDefault(name, RunnerId.DEFAULT_APPLICATION);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -459,7 +459,7 @@ public abstract class LanguagePreferencesPage extends FieldEditorPreferencePage
|
||||
|
||||
// Create the editors for all compilers of the hardware.
|
||||
CompilerRegistry compilerRegistry = plugin.getCompilerRegistry();
|
||||
List<CompilerDefinition> compilerDefinitions = compilerRegistry.getCompilerDefinitions();
|
||||
List<CompilerDefinition> compilerDefinitions = compilerRegistry.getCompilerDefinitions(language);
|
||||
|
||||
for (CompilerDefinition compilerDefinition : compilerDefinitions) {
|
||||
String compilerId = compilerDefinition.getId();
|
||||
|
@ -28,6 +28,15 @@ com.wudsn.ide.base.editor.text.TextEditorReverseLinesCommand.mnemonic=R
|
||||
|
||||
com.wudsn.ide.base.editor.BinaryFile.name=Binary File
|
||||
|
||||
com.wudsn.ide.base.hardware.Hardware.GENERIC=Generic
|
||||
com.wudsn.ide.base.hardware.Hardware.APPLE2=Apple 2
|
||||
com.wudsn.ide.base.hardware.Hardware.ATARI2600=Atari 2600
|
||||
com.wudsn.ide.base.hardware.Hardware.ATARI7800=Atari 7800
|
||||
com.wudsn.ide.base.hardware.Hardware.ATARI8BIT=Atari 8-bit
|
||||
com.wudsn.ide.base.hardware.Hardware.C64=C64
|
||||
com.wudsn.ide.base.hardware.Hardware.NES=NES
|
||||
com.wudsn.ide.base.hardware.Hardware.TEST=Test
|
||||
|
||||
com.wudsn.ide.base.hardware.HardwareCharacterSet.ASCII=ASCII
|
||||
com.wudsn.ide.base.hardware.HardwareCharacterSet.ATARI_ATASCII=Atari ATASCII
|
||||
com.wudsn.ide.base.hardware.HardwareCharacterSet.ATARI_ATASCII_SCREEN_CODE=Atari ATASCII Screen Code
|
||||
|
@ -28,6 +28,15 @@ com.wudsn.ide.base.editor.text.TextEditorReverseLinesCommand.mnemonic=U
|
||||
|
||||
com.wudsn.ide.base.editor.BinaryFile.name=Binär-Datei
|
||||
|
||||
com.wudsn.ide.base.hardware.Hardware.GENERIC=Generisch
|
||||
com.wudsn.ide.base.hardware.Hardware.APPLE2=Apple 2
|
||||
com.wudsn.ide.base.hardware.Hardware.ATARI2600=Atari 2600
|
||||
com.wudsn.ide.base.hardware.Hardware.ATARI7800=Atari 7800
|
||||
com.wudsn.ide.base.hardware.Hardware.ATARI8BIT=Atari 8-bit
|
||||
com.wudsn.ide.base.hardware.Hardware.C64=C64
|
||||
com.wudsn.ide.base.hardware.Hardware.NES=NES
|
||||
com.wudsn.ide.base.hardware.Hardware.TEST=Test
|
||||
|
||||
com.wudsn.ide.base.hardware.HardwareCharacterSet.ASCII=ASCII
|
||||
com.wudsn.ide.base.hardware.HardwareCharacterSet.ATARI_ATASCII=Atari ATASCII
|
||||
com.wudsn.ide.base.hardware.HardwareCharacterSet.ATARI_ATASCII_SCREEN_CODE=Atari ATASCII Bildschirmcode
|
||||
|
@ -52,7 +52,7 @@ public final class EnumUtility {
|
||||
try {
|
||||
ResourceBundle resourceBundle;
|
||||
|
||||
resourceBundle = ResourceBundle.getBundle("OSGI-INF/l10n/bundle", Locale.getDefault(), enumClass.getClassLoader());
|
||||
resourceBundle = ResourceBundleUtility.getResourceBundle(enumClass);
|
||||
result = resourceBundle.getString(key);
|
||||
} catch (MissingResourceException ex) {
|
||||
result = enumValue.name() + " - Text missing";
|
||||
|
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Copyright (C) 2009 - 2021 <a href="https://www.wudsn.com" target="_top">Peter Dell</a>
|
||||
*
|
||||
* This file is part of WUDSN IDE.
|
||||
*
|
||||
* WUDSN IDE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WUDSN IDE is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WUDSN IDE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.wudsn.ide.base.common;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* Utility class to access localization resource bundles in the default
|
||||
* localization folder of a plugin.
|
||||
*
|
||||
* @author Peter Dell
|
||||
*/
|
||||
public final class ResourceBundleUtility {
|
||||
|
||||
public static ResourceBundle getResourceBundle(Class<?> clazz) {
|
||||
ResourceBundle bundle = ResourceBundle.getBundle("OSGI-INF/l10n/bundle", Locale.getDefault(),
|
||||
clazz.getClassLoader());
|
||||
return bundle;
|
||||
}
|
||||
}
|
@ -31,6 +31,7 @@ import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
|
||||
import com.wudsn.ide.base.BasePlugin;
|
||||
import com.wudsn.ide.base.common.ResourceBundleUtility;
|
||||
|
||||
/**
|
||||
* Combo field offering the elements of an enum class in generic and type safe
|
||||
@ -83,8 +84,7 @@ public final class EnumField<T extends Enum<?>> extends Field {
|
||||
combo = new Combo(parent, SWT.DROP_DOWN);
|
||||
|
||||
ResourceBundle resourceBundle;
|
||||
resourceBundle = ResourceBundle.getBundle("OSGI-INF/l10n/bundle", Locale.getDefault(),
|
||||
enumClass.getClassLoader());
|
||||
resourceBundle = ResourceBundleUtility.getResourceBundle(enumClass);
|
||||
|
||||
T[] constants = enumClass.getEnumConstants();
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
<!--comment-->
|
||||
TODO Have sections in TOC
|
||||
<!-- TODO Have sections in TOC -->
|
Loading…
x
Reference in New Issue
Block a user