diff --git a/com.wudsn.ide.lng.asm.test/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesTestCompilersPage.java b/com.wudsn.ide.lng.asm.test/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesTestCompilersPage.java index 454a8fa2..d3af512e 100644 --- a/com.wudsn.ide.lng.asm.test/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesTestCompilersPage.java +++ b/com.wudsn.ide.lng.asm.test/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesTestCompilersPage.java @@ -20,7 +20,7 @@ package com.wudsn.ide.lng.asm.preferences; import com.wudsn.ide.base.hardware.Hardware; import com.wudsn.ide.lng.Language; -import com.wudsn.ide.lng.preferences.LanguagePreferencesCompilersPage; +import com.wudsn.ide.lng.preferences.LanguageHardwarePreferencesPage; /** * Visual editor page for the assembler preferences regarding arbitrary @@ -29,7 +29,7 @@ import com.wudsn.ide.lng.preferences.LanguagePreferencesCompilersPage; * @author Peter Dell * */ -public final class AssemblerPreferencesTestCompilersPage extends LanguagePreferencesCompilersPage { +public final class AssemblerPreferencesTestCompilersPage extends LanguageHardwarePreferencesPage { /** * Create is public. Used by extension point "org.eclipse.ui.preferencePages". diff --git a/com.wudsn.ide.lng.asm/OSGI-INF/l10n/bundle.properties b/com.wudsn.ide.lng.asm/OSGI-INF/l10n/bundle.properties index e84ca5d6..5e3fe81a 100644 --- a/com.wudsn.ide.lng.asm/OSGI-INF/l10n/bundle.properties +++ b/com.wudsn.ide.lng.asm/OSGI-INF/l10n/bundle.properties @@ -1,12 +1,12 @@ com.wudsn.ide.lng.asm.preferences.AssemblerPreferences.name=Assembler Preferences com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesPage.name=Assembler -com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesApple2CompilersPage.name=Apple II Assemblers -com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesAtari2600CompilersPage.name=Atari 2600 Assemblers -com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesAtari7800CompilersPage.name=Atari 7800 Assemblers -com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesAtari8CompilersPage.name=Atari 8-bit Assemblers -com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesC64CompilersPage.name=C64 Assemblers -com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesNESCompilersPage.name=NES Assemblers +com.wudsn.ide.lng.asm.preferences.AssemblerApple2PreferencesPage.name=Apple II Assemblers +com.wudsn.ide.lng.asm.preferences.AssemblerAtari2600PreferencesPage.name=Atari 2600 Assemblers +com.wudsn.ide.lng.asm.preferences.AssemblerAtari7800PreferencesPage.name=Atari 7800 Assemblers +com.wudsn.ide.lng.asm.preferences.AssemblerAtari8PreferencesPage.name=Atari 8-bit Assemblers +com.wudsn.ide.lng.asm.preferences.AssemblerC64PreferencesPage.name=C64 Assemblers +com.wudsn.ide.lng.asm.preferences.AssemblerNESPreferencesPage.name=NES Assemblers com.wudsn.ide.lng.asm.compiler.acme.AcmeCompiler.name=ACME com.wudsn.ide.lng.asm.compiler.acme.AcmeEditor.name=ACME Editor diff --git a/com.wudsn.ide.lng.asm/OSGI-INF/l10n/bundle_de.properties b/com.wudsn.ide.lng.asm/OSGI-INF/l10n/bundle_de.properties index e91a5689..36adefe8 100644 --- a/com.wudsn.ide.lng.asm/OSGI-INF/l10n/bundle_de.properties +++ b/com.wudsn.ide.lng.asm/OSGI-INF/l10n/bundle_de.properties @@ -1,12 +1,12 @@ com.wudsn.ide.lng.asm.preferences.AssemblerPreferences.name=Assembler Einstellungen com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesPage.name=Assembler -com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesApple2CompilersPage.name=Apple II Assembler -com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesAtari2600CompilersPage.name=Atari 2600 Assembler -com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesAtari7800CompilersPage.name=Atari 7800 Assembler -com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesAtari8CompilersPage.name=Atari 8-bit Assembler -com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesC64CompilersPage.name=C64 Assembler -com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesNESCompilersPage.name=NES Assembler +com.wudsn.ide.lng.asm.preferences.AssemblerApple2PreferencesPage.name=Apple II Assembler +com.wudsn.ide.lng.asm.preferences.AssemblerAtari2600PreferencesPage.name=Atari 2600 Assembler +com.wudsn.ide.lng.asm.preferences.AssemblerAtari7800PreferencesPage.name=Atari 7800 Assembler +com.wudsn.ide.lng.asm.preferences.AssemblerAtari8PreferencesPage.name=Atari 8-bit Assembler +com.wudsn.ide.lng.asm.preferences.AssemblerC64PreferencesPage.name=C64 Assembler +com.wudsn.ide.lng.asm.preferences.AssemblerNESPreferencesPage.name=NES Assembler com.wudsn.ide.lng.asm.compiler.acme.AcmeCompiler.name=ACME com.wudsn.ide.lng.asm.compiler.acme.AcmeEditor.name=ACME Editor diff --git a/com.wudsn.ide.lng.asm/plugin.xml b/com.wudsn.ide.lng.asm/plugin.xml index 1dd5ad60..606358c9 100644 --- a/com.wudsn.ide.lng.asm/plugin.xml +++ b/com.wudsn.ide.lng.asm/plugin.xml @@ -15,39 +15,39 @@ point="org.eclipse.ui.preferencePages"> + class="com.wudsn.ide.lng.asm.preferences.AssemblerApple2PreferencesPage" + id="com.wudsn.ide.lng.asm.preferences.AssemblerApple2PreferencesPage" + name="%com.wudsn.ide.lng.asm.preferences.AssemblerApple2PreferencesPage.name"> + class="com.wudsn.ide.lng.asm.preferences.AssemblerAtari8PreferencesPage" + id="com.wudsn.ide.lng.asm.preferences.AssemblerAtari8PreferencesPage" + name="%com.wudsn.ide.lng.asm.preferences.AssemblerAtari8PreferencesPage.name"> + class="com.wudsn.ide.lng.asm.preferences.AssemblerAtari2600PreferencesPage" + id="com.wudsn.ide.lng.asm.preferences.AssemblerAtari2600PreferencesPage" + name="%com.wudsn.ide.lng.asm.preferences.AssemblerAtari2600PreferencesPage.name"> + class="com.wudsn.ide.lng.asm.preferences.AssemblerAtari7800PreferencesPage" + id="com.wudsn.ide.lng.asm.preferences.AssemblerAtari7800PreferencesPage" + name="%com.wudsn.ide.lng.asm.preferences.AssemblerAtari7800PreferencesPage.name"> + class="com.wudsn.ide.lng.asm.preferences.AssemblerC64PreferencesPage" + id="com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesPage" + name="%com.wudsn.ide.lng.asm.preferences.AssemblerPreferencesPage.name"> + class="com.wudsn.ide.lng.asm.preferences.AssemblerNESPreferencesPage" + id="com.wudsn.ide.lng.asm.preferences.AssemblerNESPreferencesPage" + name="%com.wudsn.ide.lng.asm.preferences.AssemblerNESPreferencesPage.name"> diff --git a/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesApple2CompilersPage.java b/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerApple2PreferencesPage.java similarity index 81% rename from com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesApple2CompilersPage.java rename to com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerApple2PreferencesPage.java index 9f3626a7..eb0cdf69 100644 --- a/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesApple2CompilersPage.java +++ b/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerApple2PreferencesPage.java @@ -1,41 +1,41 @@ -/** - * Copyright (C) 2009 - 2021 Peter Dell - * - * 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 . - */ -package com.wudsn.ide.lng.asm.preferences; - -import com.wudsn.ide.base.hardware.Hardware; -import com.wudsn.ide.lng.Language; -import com.wudsn.ide.lng.preferences.LanguagePreferencesCompilersPage; - -/** - * Visual editor page for the assembler preferences regarding Apple 2 compilers. - * - * @author Peter Dell - * - */ -public final class AssemblerPreferencesApple2CompilersPage extends LanguagePreferencesCompilersPage { - - /** - * Create is public. Used by extension point "org.eclipse.ui.preferencePages". - */ - public AssemblerPreferencesApple2CompilersPage() { - super(Language.ASM, Hardware.APPLE2); - - } - +/** + * Copyright (C) 2009 - 2021 Peter Dell + * + * 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 . + */ +package com.wudsn.ide.lng.asm.preferences; + +import com.wudsn.ide.base.hardware.Hardware; +import com.wudsn.ide.lng.Language; +import com.wudsn.ide.lng.preferences.LanguageHardwarePreferencesPage; + +/** + * Visual editor page for the assembler preferences regarding Apple 2 compilers. + * + * @author Peter Dell + * + */ +public final class AssemblerApple2PreferencesPage extends LanguageHardwarePreferencesPage { + + /** + * Create is public. Used by extension point "org.eclipse.ui.preferencePages". + */ + public AssemblerApple2PreferencesPage() { + super(Language.ASM, Hardware.APPLE2); + + } + } \ No newline at end of file diff --git a/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesAtari2600CompilersPage.java b/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerAtari2600PreferencesPage.java similarity index 81% rename from com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesAtari2600CompilersPage.java rename to com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerAtari2600PreferencesPage.java index c7595ab3..e6ed1501 100644 --- a/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesAtari2600CompilersPage.java +++ b/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerAtari2600PreferencesPage.java @@ -1,41 +1,41 @@ -/** - * Copyright (C) 2009 - 2021 Peter Dell - * - * 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 . - */ -package com.wudsn.ide.lng.asm.preferences; - -import com.wudsn.ide.base.hardware.Hardware; -import com.wudsn.ide.lng.Language; -import com.wudsn.ide.lng.preferences.LanguagePreferencesCompilersPage; - -/** - * Visual editor page for the assembler preferences regarding Apple 2 compilers. - * - * @author Peter Dell - * - */ -public final class AssemblerPreferencesAtari2600CompilersPage extends LanguagePreferencesCompilersPage { - - /** - * Create is public. Used by extension point "org.eclipse.ui.preferencePages". - */ - public AssemblerPreferencesAtari2600CompilersPage() { - super(Language.ASM,Hardware.ATARI2600); - - } - +/** + * Copyright (C) 2009 - 2021 Peter Dell + * + * 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 . + */ +package com.wudsn.ide.lng.asm.preferences; + +import com.wudsn.ide.base.hardware.Hardware; +import com.wudsn.ide.lng.Language; +import com.wudsn.ide.lng.preferences.LanguageHardwarePreferencesPage; + +/** + * Visual editor page for the assembler preferences regarding Apple 2 compilers. + * + * @author Peter Dell + * + */ +public final class AssemblerAtari2600PreferencesPage extends LanguageHardwarePreferencesPage { + + /** + * Create is public. Used by extension point "org.eclipse.ui.preferencePages". + */ + public AssemblerAtari2600PreferencesPage() { + super(Language.ASM,Hardware.ATARI2600); + + } + } \ No newline at end of file diff --git a/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesAtari7800CompilersPage.java b/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerAtari7800PreferencesPage.java similarity index 81% rename from com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesAtari7800CompilersPage.java rename to com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerAtari7800PreferencesPage.java index 47d42153..dd942b91 100644 --- a/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesAtari7800CompilersPage.java +++ b/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerAtari7800PreferencesPage.java @@ -1,41 +1,41 @@ -/** - * Copyright (C) 2009 - 2021 Peter Dell - * - * 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 . - */ -package com.wudsn.ide.lng.asm.preferences; - -import com.wudsn.ide.base.hardware.Hardware; -import com.wudsn.ide.lng.Language; -import com.wudsn.ide.lng.preferences.LanguagePreferencesCompilersPage; - -/** - * Visual editor page for the assembler preferences regarding Apple 2 compilers. - * - * @author Peter Dell - * - */ -public final class AssemblerPreferencesAtari7800CompilersPage extends LanguagePreferencesCompilersPage { - - /** - * Create is public. Used by extension point "org.eclipse.ui.preferencePages". - */ - public AssemblerPreferencesAtari7800CompilersPage() { - super(Language.ASM, Hardware.ATARI7800); - - } - +/** + * Copyright (C) 2009 - 2021 Peter Dell + * + * 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 . + */ +package com.wudsn.ide.lng.asm.preferences; + +import com.wudsn.ide.base.hardware.Hardware; +import com.wudsn.ide.lng.Language; +import com.wudsn.ide.lng.preferences.LanguageHardwarePreferencesPage; + +/** + * Visual editor page for the assembler preferences regarding Apple 2 compilers. + * + * @author Peter Dell + * + */ +public final class AssemblerAtari7800PreferencesPage extends LanguageHardwarePreferencesPage { + + /** + * Create is public. Used by extension point "org.eclipse.ui.preferencePages". + */ + public AssemblerAtari7800PreferencesPage() { + super(Language.ASM, Hardware.ATARI7800); + + } + } \ No newline at end of file diff --git a/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesAtari8CompilersPage.java b/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerAtari8PreferencesPage.java similarity index 81% rename from com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesAtari8CompilersPage.java rename to com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerAtari8PreferencesPage.java index 7324bccd..490fa7a3 100644 --- a/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesAtari8CompilersPage.java +++ b/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerAtari8PreferencesPage.java @@ -1,42 +1,42 @@ -/** - * Copyright (C) 2009 - 2021 Peter Dell - * - * 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 . - */ -package com.wudsn.ide.lng.asm.preferences; - -import com.wudsn.ide.base.hardware.Hardware; -import com.wudsn.ide.lng.Language; -import com.wudsn.ide.lng.preferences.LanguagePreferencesCompilersPage; - -/** - * Visual editor page for the assembler preferences regarding Atari 8-bit - * compilers. - * - * @author Peter Dell - * - */ -public final class AssemblerPreferencesAtari8CompilersPage extends LanguagePreferencesCompilersPage { - - /** - * Create is public. Used by extension point "org.eclipse.ui.preferencePages". - */ - public AssemblerPreferencesAtari8CompilersPage() { - super(Language.ASM,Hardware.ATARI8BIT); - - } - +/** + * Copyright (C) 2009 - 2021 Peter Dell + * + * 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 . + */ +package com.wudsn.ide.lng.asm.preferences; + +import com.wudsn.ide.base.hardware.Hardware; +import com.wudsn.ide.lng.Language; +import com.wudsn.ide.lng.preferences.LanguageHardwarePreferencesPage; + +/** + * Visual editor page for the assembler preferences regarding Atari 8-bit + * compilers. + * + * @author Peter Dell + * + */ +public final class AssemblerAtari8PreferencesPage extends LanguageHardwarePreferencesPage { + + /** + * Create is public. Used by extension point "org.eclipse.ui.preferencePages". + */ + public AssemblerAtari8PreferencesPage() { + super(Language.ASM,Hardware.ATARI8BIT); + + } + } \ No newline at end of file diff --git a/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesC64CompilersPage.java b/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerC64PreferencesPage.java similarity index 81% rename from com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesC64CompilersPage.java rename to com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerC64PreferencesPage.java index a304ea31..d386727c 100644 --- a/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesC64CompilersPage.java +++ b/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerC64PreferencesPage.java @@ -1,41 +1,41 @@ -/** - * Copyright (C) 2009 - 2021 Peter Dell - * - * 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 . - */ -package com.wudsn.ide.lng.asm.preferences; - -import com.wudsn.ide.base.hardware.Hardware; -import com.wudsn.ide.lng.Language; -import com.wudsn.ide.lng.preferences.LanguagePreferencesCompilersPage; - -/** - * Visual editor page for the assembler preferences regarding C64 compilers. - * - * @author Peter Dell - * - */ -public final class AssemblerPreferencesC64CompilersPage extends LanguagePreferencesCompilersPage { - - /** - * Create is public. Used by extension point "org.eclipse.ui.preferencePages". - */ - public AssemblerPreferencesC64CompilersPage() { - super(Language.ASM, Hardware.C64); - - } - +/** + * Copyright (C) 2009 - 2021 Peter Dell + * + * 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 . + */ +package com.wudsn.ide.lng.asm.preferences; + +import com.wudsn.ide.base.hardware.Hardware; +import com.wudsn.ide.lng.Language; +import com.wudsn.ide.lng.preferences.LanguageHardwarePreferencesPage; + +/** + * Visual editor page for the assembler preferences regarding C64 compilers. + * + * @author Peter Dell + * + */ +public final class AssemblerC64PreferencesPage extends LanguageHardwarePreferencesPage { + + /** + * Create is public. Used by extension point "org.eclipse.ui.preferencePages". + */ + public AssemblerC64PreferencesPage() { + super(Language.ASM, Hardware.C64); + + } + } \ No newline at end of file diff --git a/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesNESCompilersPage.java b/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerNESPreferencesPage.java similarity index 81% rename from com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesNESCompilersPage.java rename to com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerNESPreferencesPage.java index 5f7a7cb7..cc83482d 100644 --- a/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerPreferencesNESCompilersPage.java +++ b/com.wudsn.ide.lng.asm/src/com/wudsn/ide/lng/asm/preferences/AssemblerNESPreferencesPage.java @@ -1,41 +1,41 @@ -/** - * Copyright (C) 2009 - 2021 Peter Dell - * - * 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 . - */ -package com.wudsn.ide.lng.asm.preferences; - -import com.wudsn.ide.base.hardware.Hardware; -import com.wudsn.ide.lng.Language; -import com.wudsn.ide.lng.preferences.LanguagePreferencesCompilersPage; - -/** - * Visual editor page for the assembler preferences regarding NES compilers. - * - * @author Peter Dell - * - */ -public final class AssemblerPreferencesNESCompilersPage extends LanguagePreferencesCompilersPage { - - /** - * Create is public. Used by extension point "org.eclipse.ui.preferencePages". - */ - public AssemblerPreferencesNESCompilersPage() { - super(Language.ASM, Hardware.NES); - - } - +/** + * Copyright (C) 2009 - 2021 Peter Dell + * + * 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 . + */ +package com.wudsn.ide.lng.asm.preferences; + +import com.wudsn.ide.base.hardware.Hardware; +import com.wudsn.ide.lng.Language; +import com.wudsn.ide.lng.preferences.LanguageHardwarePreferencesPage; + +/** + * Visual editor page for the assembler preferences regarding NES compilers. + * + * @author Peter Dell + * + */ +public final class AssemblerNESPreferencesPage extends LanguageHardwarePreferencesPage { + + /** + * Create is public. Used by extension point "org.eclipse.ui.preferencePages". + */ + public AssemblerNESPreferencesPage() { + super(Language.ASM, Hardware.NES); + + } + } \ No newline at end of file diff --git a/com.wudsn.ide.lng.pas/OSGI-INF/l10n/bundle.properties b/com.wudsn.ide.lng.pas/OSGI-INF/l10n/bundle.properties index 69eca6fa..569ae957 100644 --- a/com.wudsn.ide.lng.pas/OSGI-INF/l10n/bundle.properties +++ b/com.wudsn.ide.lng.pas/OSGI-INF/l10n/bundle.properties @@ -1,12 +1,12 @@ com.wudsn.ide.lng.pas.preferences.PascalPreferences.name=Pascal Preferences com.wudsn.ide.lng.pas.preferences.PascalPreferencesPage.name=Pascal -com.wudsn.ide.lng.pas.preferences.PascalPreferencesApple2CompilersPage.name=Apple II Compilers -com.wudsn.ide.lng.pas.preferences.PascalPreferencesAtari2600CompilersPage.name=Atari 2600 Compilers -com.wudsn.ide.lng.pas.preferences.PascalPreferencesAtari7800CompilersPage.name=Atari 7800 Compilers -com.wudsn.ide.lng.pas.preferences.PascalPreferencesAtari8CompilersPage.name=Atari 8-bit Compilers -com.wudsn.ide.lng.pas.preferences.PascalPreferencesC64CompilersPage.name=C64 Compilers -com.wudsn.ide.lng.pas.preferences.PascalPreferencesNESCompilersPage.name=NES Compilers +com.wudsn.ide.lng.pas.preferences.PascalApple2PreferencesPage.name=Apple II Compilers +com.wudsn.ide.lng.pas.preferences.PascalAtari2600PreferencesPage.name=Atari 2600 Compilers +com.wudsn.ide.lng.pas.preferences.PascalAtari7800PreferencesPage.name=Atari 7800 Compilers +com.wudsn.ide.lng.pas.preferences.PascalAtari8PreferencesPage.name=Atari 8-bit Compilers +com.wudsn.ide.lng.pas.preferences.PascalC64PreferencesPage.name=C64 Compilers +com.wudsn.ide.lng.pas.preferences.PascalNESPreferencesPage.name=NES Compilers com.wudsn.ide.lng.pas.compiler.PascalSourceFile.name=Pascal Source File diff --git a/com.wudsn.ide.lng.pas/OSGI-INF/l10n/bundle_de.properties b/com.wudsn.ide.lng.pas/OSGI-INF/l10n/bundle_de.properties index f59331a6..29b4992d 100644 --- a/com.wudsn.ide.lng.pas/OSGI-INF/l10n/bundle_de.properties +++ b/com.wudsn.ide.lng.pas/OSGI-INF/l10n/bundle_de.properties @@ -1,12 +1,12 @@ com.wudsn.ide.lng.pas.preferences.PascalPreferences.name=Ustawienia Pascala com.wudsn.ide.lng.pas.preferences.PascalPreferencesPage.name=Pascal -com.wudsn.ide.lng.pas.preferences.PascalPreferencesApple2CompilersPage.name=Kompilator Apple II -com.wudsn.ide.lng.pas.preferences.PascalPreferencesAtari2600CompilersPage.name=Kompilator Atari 2600 -com.wudsn.ide.lng.pas.preferences.PascalPreferencesAtari7800CompilersPage.name=Kompilator Atari 7800 -com.wudsn.ide.lng.pas.preferences.PascalPreferencesAtari8CompilersPage.name=Kompilator Atari 8-bit -com.wudsn.ide.lng.pas.preferences.PascalPreferencesC64CompilersPage.name=Kompilator C64 -com.wudsn.ide.lng.pas.preferences.PascalPreferencesNESCompilersPage.name=Kompilator NES +com.wudsn.ide.lng.pas.preferences.PascalApple2PreferencesPage.name=Kompilator Apple II +com.wudsn.ide.lng.pas.preferences.PascalAtari2600PreferencesPage.name=Kompilator Atari 2600 +com.wudsn.ide.lng.pas.preferences.PascalAtari7800PreferencesPage.name=Kompilator Atari 7800 +com.wudsn.ide.lng.pas.preferences.PascalAtari8PreferencesPage.name=Kompilator Atari 8-bit +com.wudsn.ide.lng.pas.preferences.PascalC64PreferencesPage.name=Kompilator C64 +com.wudsn.ide.lng.pas.preferences.PascalNESPreferencesPage.name=Kompilator NES com.wudsn.ide.lng.pas.compiler.PascalSourceFile.name=Plik \u017Aród\u0142owy Pascala diff --git a/com.wudsn.ide.lng.pas/OSGI-INF/l10n/bundle_pl.properties b/com.wudsn.ide.lng.pas/OSGI-INF/l10n/bundle_pl.properties index 785498a9..8bb38a55 100644 --- a/com.wudsn.ide.lng.pas/OSGI-INF/l10n/bundle_pl.properties +++ b/com.wudsn.ide.lng.pas/OSGI-INF/l10n/bundle_pl.properties @@ -1,12 +1,12 @@ com.wudsn.ide.lng.pas.preferences.PascalPreferences.name=Pascal Einstellungen com.wudsn.ide.lng.pas.preferences.PascalPreferencesPage.name=Pascal -com.wudsn.ide.lng.pas.preferences.PascalPreferencesApple2CompilersPage.name=Apple II Kompiler -com.wudsn.ide.lng.pas.preferences.PascalPreferencesAtari2600CompilersPage.name=Atari 2600 Kompiler -com.wudsn.ide.lng.pas.preferences.PascalPreferencesAtari7800CompilersPage.name=Atari 7800 Kompiler -com.wudsn.ide.lng.pas.preferences.PascalPreferencesAtari8CompilersPage.name=Atari 8-bit Kompiler -com.wudsn.ide.lng.pas.preferences.PascalPreferencesC64CompilersPage.name=C64 Kompiler -com.wudsn.ide.lng.pas.preferences.PascalPreferencesNESCompilersPage.name=NES Kompiler +com.wudsn.ide.lng.pas.preferences.PascalApple2PreferencesPage.name=Apple II Kompiler +com.wudsn.ide.lng.pas.preferences.PascalAtari2600PreferencesPage.name=Atari 2600 Kompiler +com.wudsn.ide.lng.pas.preferences.PascalAtari7800PreferencesPage.name=Atari 7800 Kompiler +com.wudsn.ide.lng.pas.preferences.PascalAtari8PreferencesPage.name=Atari 8-bit Kompiler +com.wudsn.ide.lng.pas.preferences.PascalC64PreferencesPage.name=C64 Kompiler +com.wudsn.ide.lng.pas.preferences.PascalNESPreferencesPage.name=NES Kompiler com.wudsn.ide.lng.pas.compiler.PascalSourceFile.name=Pascal Quell-Datei diff --git a/com.wudsn.ide.lng.pas/plugin.xml b/com.wudsn.ide.lng.pas/plugin.xml index 8a5331ce..65ecf9ae 100644 --- a/com.wudsn.ide.lng.pas/plugin.xml +++ b/com.wudsn.ide.lng.pas/plugin.xml @@ -14,39 +14,39 @@ point="org.eclipse.ui.preferencePages"> + class="com.wudsn.ide.lng.pas.preferences.PascalApple2PreferencesPage" + id="com.wudsn.ide.lng.pas.preferences.PascalApple2PreferencesPage" + name="%com.wudsn.ide.lng.pas.preferences.PascalApple2PreferencesPage.name"> + class="com.wudsn.ide.lng.pas.preferences.PascalAtari8PreferencesPage" + id="com.wudsn.ide.lng.pas.preferences.PascalAtari8PreferencesPage" + name="%com.wudsn.ide.lng.pas.preferences.PascalAtari8PreferencesPage.name"> + class="com.wudsn.ide.lng.pas.preferences.PascalAtari2600PreferencesPage" + id="com.wudsn.ide.lng.pas.preferences.PascalAtari2600PreferencesPage" + name="%com.wudsn.ide.lng.pas.preferences.PascalAtari2600PreferencesPage.name"> + class="com.wudsn.ide.lng.pas.preferences.PascalAtari7800PreferencesPage" + id="com.wudsn.ide.lng.pas.preferences.PascalAtari7800PreferencesPage" + name="%com.wudsn.ide.lng.pas.preferences.PascalAtari7800PreferencesPage.name"> + class="com.wudsn.ide.lng.pas.preferences.PascalC64PreferencesPage" + id="com.wudsn.ide.lng.pas.preferences.PascalC64PreferencesPag" + name="%com.wudsn.ide.lng.pas.preferences.PascalC64PreferencesPage.name"> + class="com.wudsn.ide.lng.pas.preferences.PascalNESPreferencesPage" + id="com.wudsn.ide.lng.pas.preferences.PascalNESPreferencesPage" + name="%com.wudsn.ide.lng.pas.preferences.PascalNESPreferencesPage.name"> diff --git a/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalPreferencesApple2CompilersPage.java b/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalApple2PreferencesPage.java similarity index 81% rename from com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalPreferencesApple2CompilersPage.java rename to com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalApple2PreferencesPage.java index e4f8e9ec..e396b8f9 100644 --- a/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalPreferencesApple2CompilersPage.java +++ b/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalApple2PreferencesPage.java @@ -1,41 +1,41 @@ -/** - * Copyright (C) 2009 - 2021 Peter Dell - * - * 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 . - */ -package com.wudsn.ide.lng.pas.preferences; - -import com.wudsn.ide.base.hardware.Hardware; -import com.wudsn.ide.lng.Language; -import com.wudsn.ide.lng.preferences.LanguagePreferencesCompilersPage; - -/** - * Visual editor page for the Pascal preferences regarding Apple 2 compilers. - * - * @author Peter Dell - * - */ -public final class PascalPreferencesApple2CompilersPage extends LanguagePreferencesCompilersPage { - - /** - * Create is public. Used by extension point "org.eclipse.ui.preferencePages". - */ - public PascalPreferencesApple2CompilersPage() { - super(Language.PAS, Hardware.APPLE2); - - } - +/** + * Copyright (C) 2009 - 2021 Peter Dell + * + * 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 . + */ +package com.wudsn.ide.lng.pas.preferences; + +import com.wudsn.ide.base.hardware.Hardware; +import com.wudsn.ide.lng.Language; +import com.wudsn.ide.lng.preferences.LanguageHardwarePreferencesPage; + +/** + * Visual editor page for the Pascal preferences regarding Apple 2 compilers. + * + * @author Peter Dell + * + */ +public final class PascalApple2PreferencesPage extends LanguageHardwarePreferencesPage { + + /** + * Create is public. Used by extension point "org.eclipse.ui.preferencePages". + */ + public PascalApple2PreferencesPage() { + super(Language.PAS, Hardware.APPLE2); + + } + } \ No newline at end of file diff --git a/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalPreferencesAtari2600CompilersPage.java b/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalAtari2600PreferencesPage.java similarity index 81% rename from com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalPreferencesAtari2600CompilersPage.java rename to com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalAtari2600PreferencesPage.java index c02ab3fb..ad219373 100644 --- a/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalPreferencesAtari2600CompilersPage.java +++ b/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalAtari2600PreferencesPage.java @@ -1,41 +1,41 @@ -/** - * Copyright (C) 2009 - 2021 Peter Dell - * - * 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 . - */ -package com.wudsn.ide.lng.pas.preferences; - -import com.wudsn.ide.base.hardware.Hardware; -import com.wudsn.ide.lng.Language; -import com.wudsn.ide.lng.preferences.LanguagePreferencesCompilersPage; - -/** - * Visual editor page for the Pascal preferences regarding Apple 2 compilers. - * - * @author Peter Dell - * - */ -public final class PascalPreferencesAtari2600CompilersPage extends LanguagePreferencesCompilersPage { - - /** - * Create is public. Used by extension point "org.eclipse.ui.preferencePages". - */ - public PascalPreferencesAtari2600CompilersPage() { - super(Language.PAS,Hardware.ATARI2600); - - } - +/** + * Copyright (C) 2009 - 2021 Peter Dell + * + * 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 . + */ +package com.wudsn.ide.lng.pas.preferences; + +import com.wudsn.ide.base.hardware.Hardware; +import com.wudsn.ide.lng.Language; +import com.wudsn.ide.lng.preferences.LanguageHardwarePreferencesPage; + +/** + * Visual editor page for the Pascal preferences regarding Apple 2 compilers. + * + * @author Peter Dell + * + */ +public final class PascalAtari2600PreferencesPage extends LanguageHardwarePreferencesPage { + + /** + * Create is public. Used by extension point "org.eclipse.ui.preferencePages". + */ + public PascalAtari2600PreferencesPage() { + super(Language.PAS,Hardware.ATARI2600); + + } + } \ No newline at end of file diff --git a/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalPreferencesAtari7800CompilersPage.java b/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalAtari7800PreferencesPage.java similarity index 81% rename from com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalPreferencesAtari7800CompilersPage.java rename to com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalAtari7800PreferencesPage.java index 8a3b3bb7..5d7a0fe0 100644 --- a/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalPreferencesAtari7800CompilersPage.java +++ b/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalAtari7800PreferencesPage.java @@ -1,41 +1,41 @@ -/** - * Copyright (C) 2009 - 2021 Peter Dell - * - * 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 . - */ -package com.wudsn.ide.lng.pas.preferences; - -import com.wudsn.ide.base.hardware.Hardware; -import com.wudsn.ide.lng.Language; -import com.wudsn.ide.lng.preferences.LanguagePreferencesCompilersPage; - -/** - * Visual editor page for the Pascal preferences regarding Apple 2 compilers. - * - * @author Peter Dell - * - */ -public final class PascalPreferencesAtari7800CompilersPage extends LanguagePreferencesCompilersPage { - - /** - * Create is public. Used by extension point "org.eclipse.ui.preferencePages". - */ - public PascalPreferencesAtari7800CompilersPage() { - super(Language.PAS, Hardware.ATARI7800); - - } - +/** + * Copyright (C) 2009 - 2021 Peter Dell + * + * 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 . + */ +package com.wudsn.ide.lng.pas.preferences; + +import com.wudsn.ide.base.hardware.Hardware; +import com.wudsn.ide.lng.Language; +import com.wudsn.ide.lng.preferences.LanguageHardwarePreferencesPage; + +/** + * Visual editor page for the Pascal preferences regarding Apple 2 compilers. + * + * @author Peter Dell + * + */ +public final class PascalAtari7800PreferencesPage extends LanguageHardwarePreferencesPage { + + /** + * Create is public. Used by extension point "org.eclipse.ui.preferencePages". + */ + public PascalAtari7800PreferencesPage() { + super(Language.PAS, Hardware.ATARI7800); + + } + } \ No newline at end of file diff --git a/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalPreferencesAtari8CompilersPage.java b/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalAtari8PreferencesPage.java similarity index 81% rename from com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalPreferencesAtari8CompilersPage.java rename to com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalAtari8PreferencesPage.java index bf534632..85e87365 100644 --- a/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalPreferencesAtari8CompilersPage.java +++ b/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalAtari8PreferencesPage.java @@ -1,42 +1,42 @@ -/** - * Copyright (C) 2009 - 2021 Peter Dell - * - * 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 . - */ -package com.wudsn.ide.lng.pas.preferences; - -import com.wudsn.ide.base.hardware.Hardware; -import com.wudsn.ide.lng.Language; -import com.wudsn.ide.lng.preferences.LanguagePreferencesCompilersPage; - -/** - * Visual editor page for the Pascal preferences regarding Atari 8-bit - * compilers. - * - * @author Peter Dell - * - */ -public final class PascalPreferencesAtari8CompilersPage extends LanguagePreferencesCompilersPage { - - /** - * Create is public. Used by extension point "org.eclipse.ui.preferencePages". - */ - public PascalPreferencesAtari8CompilersPage() { - super(Language.PAS,Hardware.ATARI8BIT); - - } - +/** + * Copyright (C) 2009 - 2021 Peter Dell + * + * 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 . + */ +package com.wudsn.ide.lng.pas.preferences; + +import com.wudsn.ide.base.hardware.Hardware; +import com.wudsn.ide.lng.Language; +import com.wudsn.ide.lng.preferences.LanguageHardwarePreferencesPage; + +/** + * Visual editor page for the Pascal preferences regarding Atari 8-bit + * compilers. + * + * @author Peter Dell + * + */ +public final class PascalAtari8PreferencesPage extends LanguageHardwarePreferencesPage { + + /** + * Create is public. Used by extension point "org.eclipse.ui.preferencePages". + */ + public PascalAtari8PreferencesPage() { + super(Language.PAS,Hardware.ATARI8BIT); + + } + } \ No newline at end of file diff --git a/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalPreferencesC64CompilersPage.java b/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalC64PreferencesPage.java similarity index 81% rename from com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalPreferencesC64CompilersPage.java rename to com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalC64PreferencesPage.java index 59b45ce2..8e99d2c8 100644 --- a/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalPreferencesC64CompilersPage.java +++ b/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalC64PreferencesPage.java @@ -1,41 +1,41 @@ -/** - * Copyright (C) 2009 - 2021 Peter Dell - * - * 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 . - */ -package com.wudsn.ide.lng.pas.preferences; - -import com.wudsn.ide.base.hardware.Hardware; -import com.wudsn.ide.lng.Language; -import com.wudsn.ide.lng.preferences.LanguagePreferencesCompilersPage; - -/** - * Visual editor page for the Pascal preferences regarding C64 compilers. - * - * @author Peter Dell - * - */ -public final class PascalPreferencesC64CompilersPage extends LanguagePreferencesCompilersPage { - - /** - * Create is public. Used by extension point "org.eclipse.ui.preferencePages". - */ - public PascalPreferencesC64CompilersPage() { - super(Language.PAS, Hardware.C64); - - } - +/** + * Copyright (C) 2009 - 2021 Peter Dell + * + * 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 . + */ +package com.wudsn.ide.lng.pas.preferences; + +import com.wudsn.ide.base.hardware.Hardware; +import com.wudsn.ide.lng.Language; +import com.wudsn.ide.lng.preferences.LanguageHardwarePreferencesPage; + +/** + * Visual editor page for the Pascal preferences regarding C64 compilers. + * + * @author Peter Dell + * + */ +public final class PascalC64PreferencesPage extends LanguageHardwarePreferencesPage { + + /** + * Create is public. Used by extension point "org.eclipse.ui.preferencePages". + */ + public PascalC64PreferencesPage() { + super(Language.PAS, Hardware.C64); + + } + } \ No newline at end of file diff --git a/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalPreferencesNESCompilersPage.java b/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalNESPreferencesPage.java similarity index 81% rename from com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalPreferencesNESCompilersPage.java rename to com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalNESPreferencesPage.java index fb0611d8..d76178dd 100644 --- a/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalPreferencesNESCompilersPage.java +++ b/com.wudsn.ide.lng.pas/src/com/wudsn/ide/lng/pas/preferences/PascalNESPreferencesPage.java @@ -1,41 +1,41 @@ -/** - * Copyright (C) 2009 - 2021 Peter Dell - * - * 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 . - */ -package com.wudsn.ide.lng.pas.preferences; - -import com.wudsn.ide.base.hardware.Hardware; -import com.wudsn.ide.lng.Language; -import com.wudsn.ide.lng.preferences.LanguagePreferencesCompilersPage; - -/** - * Visual editor page for the Pascal preferences regarding NES compilers. - * - * @author Peter Dell - * - */ -public final class PascalPreferencesNESCompilersPage extends LanguagePreferencesCompilersPage { - - /** - * Create is public. Used by extension point "org.eclipse.ui.preferencePages". - */ - public PascalPreferencesNESCompilersPage() { - super(Language.PAS,Hardware.NES); - - } - +/** + * Copyright (C) 2009 - 2021 Peter Dell + * + * 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 . + */ +package com.wudsn.ide.lng.pas.preferences; + +import com.wudsn.ide.base.hardware.Hardware; +import com.wudsn.ide.lng.Language; +import com.wudsn.ide.lng.preferences.LanguageHardwarePreferencesPage; + +/** + * Visual editor page for the Pascal preferences regarding NES compilers. + * + * @author Peter Dell + * + */ +public final class PascalNESPreferencesPage extends LanguageHardwarePreferencesPage { + + /** + * Create is public. Used by extension point "org.eclipse.ui.preferencePages". + */ + public PascalNESPreferencesPage() { + super(Language.PAS,Hardware.NES); + + } + } \ No newline at end of file diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/LanguagePlugin.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/LanguagePlugin.java index 84eed441..8ab70cfc 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/LanguagePlugin.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/LanguagePlugin.java @@ -48,13 +48,12 @@ import com.wudsn.ide.lng.compiler.CompilerPathsTest; import com.wudsn.ide.lng.compiler.CompilerRegistry; import com.wudsn.ide.lng.preferences.LanguagePreferences; import com.wudsn.ide.lng.preferences.LanguagePreferencesChangeListener; -import com.wudsn.ide.lng.preferences.LanguagePreferencesConstants; import com.wudsn.ide.lng.preferences.LanguagesPreferences; import com.wudsn.ide.lng.preferences.TextAttributeDefinition; import com.wudsn.ide.lng.runner.RunnerPaths; import com.wudsn.ide.lng.runner.RunnerPathsTest; import com.wudsn.ide.lng.runner.RunnerRegistry; - +import com.wudsn.ide.lng.preferences.LanguagePreferencesConstants.EditorConstants; /** * The main plugin class to be used in the desktop. * @@ -150,6 +149,7 @@ public final class LanguagePlugin extends AbstractIDEPlugin { logError("Cannot initialize compiler registry", null, ex); throw ex; } + compilerPaths.init(); compilerConsole = new CompilerConsole(); try { runnerRegistry.init(); @@ -167,7 +167,7 @@ public final class LanguagePlugin extends AbstractIDEPlugin { if (event.getProperty().equals(JFaceResources.TEXT_FONT) || event.getProperty().equals(BLOCK_SELECTION_MODE_FONT)) { for (Language language : languages) { - List textAttributeDefinitions = LanguagePreferencesConstants + List textAttributeDefinitions = EditorConstants .getTextAttributeDefinitions(language); Set changedPropertyNames = new TreeSet(); for (TextAttributeDefinition textAttributeDefinition : textAttributeDefinitions) { diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/compiler/CompilerFiles.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/compiler/CompilerFiles.java index f014326d..c6ab49f8 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/compiler/CompilerFiles.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/compiler/CompilerFiles.java @@ -27,7 +27,7 @@ import com.wudsn.ide.base.common.FileUtility; import com.wudsn.ide.base.common.StringUtility; import com.wudsn.ide.lng.LanguageProperties; import com.wudsn.ide.lng.LanguageProperties.LanguageProperty; -import com.wudsn.ide.lng.preferences.CompilerPreferences; +import com.wudsn.ide.lng.preferences.LanguageHardwareCompilerDefinitionPreferences; /** * Container class for the folder, file names and paths of the source file, the @@ -116,7 +116,7 @@ public final class CompilerFiles { public CompilerFiles(IFile mainSourceIFile, LanguageProperties mainSourceFileLanguageProperties, IFile sourceIFile, LanguageProperties sourceFileLanguageProperties, - CompilerPreferences compilerPreferences) { + LanguageHardwareCompilerDefinitionPreferences languageHardwareCompilerDefinitionPreferences) { if (mainSourceIFile == null) { throw new IllegalArgumentException("Parameter 'mainSourceIFile' must not be null."); @@ -124,7 +124,7 @@ public final class CompilerFiles { if (sourceIFile == null) { throw new IllegalArgumentException("Parameter 'sourceIFile' must not be null."); } - if (compilerPreferences == null) { + if (languageHardwareCompilerDefinitionPreferences == null) { throw new IllegalArgumentException("Parameter 'compilerPreferences' must not be null."); } this.mainSourceFile = new SourceFile(mainSourceIFile, mainSourceFileLanguageProperties); @@ -132,9 +132,9 @@ public final class CompilerFiles { // Output folder mode // Can be overridden via annotation property in main source file - String localOutputFolderPath = compilerPreferences.getOutputFolderPath(); - String localOutputFolderMode = compilerPreferences.getOutputFolderMode(); - String localOutputFileExtension = compilerPreferences.getOutputFileExtension(); + String localOutputFolderPath = languageHardwareCompilerDefinitionPreferences.getOutputFolderPath(); + String localOutputFolderMode = languageHardwareCompilerDefinitionPreferences.getOutputFolderMode(); + String localOutputFileExtension = languageHardwareCompilerDefinitionPreferences.getOutputFileExtension(); // Properties which override the preferences outputFolderModeProperty = mainSourceFileLanguageProperties.get(LanguageProperties.OUTPUT_FOLDER_MODE); diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/compiler/CompilerPaths.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/compiler/CompilerPaths.java index 59ed33fd..8969ac76 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/compiler/CompilerPaths.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/compiler/CompilerPaths.java @@ -43,30 +43,32 @@ public final class CompilerPaths { public static final class CompilerPath { public final Language language; - public final String compilerId; + public final CompilerDefinition compilerDefinition; public final String os; public final String osArch; public final String executablePath; - private CompilerPath(Language language, String compilerId, String os, String osArch, String executablePath) { + private CompilerPath(Language language, CompilerDefinition compilerDefinition, String os, String osArch, + String executablePath) { this.language = language; - this.compilerId = compilerId; + this.compilerDefinition = compilerDefinition; this.os = os; this.osArch = osArch; this.executablePath = executablePath; } - public static String getKey(Language language, String compilerId, String os, String osArch) { - return language.name() + "/" + compilerId + "/" + os + "/" + osArch; + public static String getKey(Language language, CompilerDefinition compilerDefinition, String os, + String osArch) { + return language.name() + "/" + compilerDefinition.getId() + "/" + os + "/" + osArch; } public String getKey() { - return getKey(language, compilerId, os, osArch); + return getKey(language, compilerDefinition, os, osArch); } public String getRelativePath() { - return language.name() + "/" + compilerId.toUpperCase() + "/" + executablePath; + return language.name() + "/" + compilerDefinition.getId().toUpperCase() + "/" + executablePath; } public File getAbsoluteFile() { @@ -81,6 +83,12 @@ public final class CompilerPaths { * Created by the {@linkplain LanguagePlugin}. */ public CompilerPaths() { + } + + /** + * Initialize the default paths. + */ + public void init() { compilerPaths = new TreeMap(); // See https://github.com/peterdell/wudsn-ide-tools // TODO: Add MERLIN32 @@ -116,20 +124,27 @@ public final class CompilerPaths { if (!compilerId.equals(compilerId.toLowerCase())) { throw new IllegalArgumentException("Parameter 'compilerId' value " + compilerId + " must be lower case."); } - CompilerPath compilerPath = new CompilerPath(language, compilerId, os, osArch, executablePath); + var compilerDefinition = LanguagePlugin.getInstance().getCompilerRegistry().getCompilerDefinitionById(language, compilerId); + CompilerPath compilerPath = new CompilerPath(language, compilerDefinition, os, osArch, executablePath); compilerPaths.put(compilerPath.getKey(), compilerPath); } - public CompilerPath getDefaultCompilerPath(Language language, String compilerId) { + public CompilerPath getDefaultCompilerPath(Language language, CompilerDefinition compilerDefinition) { + if (language == null) { + throw new IllegalArgumentException("Parameter 'language' must not be null."); + } + if (compilerDefinition == null) { + throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null."); + } String os = Platform.getOS(); String osArch = Platform.getOSArch(); - String key = CompilerPath.getKey(language, compilerId, os, osArch); + String key = CompilerPath.getKey(language, compilerDefinition, os, osArch); CompilerPath compilerPath = compilerPaths.get(key); // Default to 32-bit version if 64-bit version not defined? if (compilerPath == null) { if (osArch.equals(Platform.ARCH_X86_64)) { osArch = Platform.ARCH_X86; - key = CompilerPath.getKey(language, compilerId, os, osArch); + key = CompilerPath.getKey(language, compilerDefinition, os, osArch); compilerPath = compilerPaths.get(key); } } @@ -140,16 +155,16 @@ public final class CompilerPaths { return Collections.unmodifiableList(new ArrayList(compilerPaths.values())); } - public List getCompilerPaths(Language language, String id) { + public List getCompilerPaths(Language language, String compilerId) { if (language == null) { throw new IllegalArgumentException("Parameter 'language' must not be null."); } - if (id == null) { - throw new IllegalArgumentException("Parameter 'id' must not be null."); + if (compilerId == null) { + throw new IllegalArgumentException("Parameter 'compilerId' must not be null."); } List result = new ArrayList<>(); for (CompilerPath compilerPath : compilerPaths.values()) { - if (compilerPath.language.equals(language) && compilerPath.compilerId.equals(id)) { + if (compilerPath.language.equals(language) && compilerPath.compilerDefinition.getId().equals(compilerId)) { result.add(compilerPath); } } diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/compiler/CompilerPathsTest.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/compiler/CompilerPathsTest.java index 0264f46e..5daa35c5 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/compiler/CompilerPathsTest.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/compiler/CompilerPathsTest.java @@ -49,7 +49,7 @@ public final class CompilerPathsTest { filePath = file.getAbsolutePath(); result = file.exists() ? "found" : "NOT found"; } - Test.log("Language " + compilerPath.language + ", compiler " + compilerPath.compilerId + ", OS " + Test.log("Language " + compilerPath.language.name() + ", compiler " + compilerPath.compilerDefinition.getId() + ", OS " + compilerPath.os + ", OS architecture " + compilerPath.osArch + ": File " + filePath + " " + result); } diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/compiler/CompilerRegistry.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/compiler/CompilerRegistry.java index d329328b..656d44be 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/compiler/CompilerRegistry.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/compiler/CompilerRegistry.java @@ -244,7 +244,7 @@ public final class CompilerRegistry { * * @return The compiler, not null. */ - public Compiler getCompilerByKey(String key) { + private Compiler getCompilerByKey(String key) { if (key == null) { throw new IllegalArgumentException("Parameter 'key' must not be null."); } @@ -260,4 +260,17 @@ public final class CompilerRegistry { return result; } + /** + * Gets the compiler for a given language and compiler Id + * + * @param language The language, not null. + * @param compilerId The compiler Id, not empty and not null. + * + * @return The compiler definition, not null. + */ + public CompilerDefinition getCompilerDefinitionById(Language language, String compilerId) { + var key = CompilerDefinition.getKey(language, compilerId); + return getCompilerByKey(key).getDefinition(); + } + } diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditor.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditor.java index 59f41c8d..ea18d07d 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditor.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditor.java @@ -66,7 +66,7 @@ import com.wudsn.ide.lng.compiler.parser.CompilerSourceParser; import com.wudsn.ide.lng.compiler.parser.CompilerSourceParserTreeObject; import com.wudsn.ide.lng.compiler.parser.CompilerSourcePartitionScanner; import com.wudsn.ide.lng.outline.LanguageOutlinePage; -import com.wudsn.ide.lng.preferences.CompilerPreferences; +import com.wudsn.ide.lng.preferences.LanguageHardwareCompilerDefinitionPreferences; import com.wudsn.ide.lng.preferences.LanguagePreferences; /** @@ -154,7 +154,7 @@ public abstract class LanguageEditor extends TextEditor { } return plugin; } - + /** * Gets the language. * @@ -178,8 +178,8 @@ public abstract class LanguageEditor extends TextEditor { * * @return The compiler preferences, not null. */ - public final CompilerPreferences getCompilerPreferences() { - return getLanguagePreferences().getCompilerPreferences(getCompilerDefinition(), getHardware()); + public final LanguageHardwareCompilerDefinitionPreferences getLanguageHardwareCompilerPreferences() { + return getLanguagePreferences().getLanguageHardwareCompilerDefinitionPreferences(getHardware(), getCompilerDefinition()); } /** @@ -220,7 +220,7 @@ public abstract class LanguageEditor extends TextEditor { if (compiler == null) { throw new IllegalStateException("Field 'compiler' must not be null."); } - target = getCompilerPreferences().getTarget(); + target = getLanguageHardwareCompilerPreferences().getTarget(); result = compiler.createSourceParser(); result.init(compiler.getDefinition().getSyntax().getInstructionSet(target)); return result; @@ -429,13 +429,12 @@ public abstract class LanguageEditor extends TextEditor { } else { newIdentifiers = compilerSourceFile.getIdentifiers(); } - + LanguageSourceViewerConfiguration asvc; LanguageSourceScanner ais; asvc = (LanguageSourceViewerConfiguration) getSourceViewerConfiguration(); ais = asvc.getInstructionScanner(); - ais.setIdentifiers(newIdentifiers); profiler.begin("refreshSourceViewer"); // refreshSourceViewer(); TODO Required? diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditorCompileCommand.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditorCompileCommand.java index 4e3fc570..43fdaa46 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditorCompileCommand.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditorCompileCommand.java @@ -218,7 +218,7 @@ final class LanguageEditorCompileCommand { // Create wrapper for run properties. CompilerDefinition compilerDefinition = languageEditor.getCompilerDefinition(); CompilerRunPreferences compilerRunPreferences = new CompilerRunPreferences( - languageEditor.getCompilerPreferences(), files.mainSourceFile.languageProperties); + languageEditor.getLanguageHardwareCompilerPreferences(), files.mainSourceFile.languageProperties); // Check if output file is modifiable in case it already exists. long outputFileLastModified = -1; @@ -248,21 +248,20 @@ final class LanguageEditorCompileCommand { // Get and check path to compiler executable. String compilerPreferencesText = LanguageUtility.getCompilerPreferencesText(compilerDefinition.getLanguage()); - - String compilerExecutablePath = languageEditor.getCompilerPreferences().getCompilerExecutablePathOrDefault(); + String compilerExecutablePath = languageEditor.getLanguagePreferences() + .getCompilerExecutablePathOrDefault(compilerDefinition); if (StringUtility.isEmpty(compilerExecutablePath)) { // ERROR: Path to {0} '{1}' executable is not set in the '{2}' preferences. - createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E100, - compilerDefinition.getText(), compilerDefinition.getName(), compilerPreferencesText); + createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E100, compilerDefinition.getText(), + compilerDefinition.getName(), compilerPreferencesText); return false; } File compilerExecutableFile = new File(compilerExecutablePath); if (!compilerExecutableFile.exists()) { // ERROR: Path to {0} '{1}' executable in the '{2}' preferences points to // non-existing file '{3}'. - createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E103, - compilerDefinition.getText(), compilerDefinition.getName(), compilerPreferencesText, - compilerExecutablePath); + createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E103, compilerDefinition.getText(), + compilerDefinition.getName(), compilerPreferencesText, compilerExecutablePath); return false; } @@ -282,8 +281,8 @@ final class LanguageEditorCompileCommand { String compilerParameterArray[] = compilerParameters.split(" "); if (compilerParameterArray.length == 0) { // ERROR: The {0} '{1}' does not specify default parameters. - createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E101, - compilerDefinition.getText(), compilerDefinition.getName()); + createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E101, compilerDefinition.getText(), + compilerDefinition.getName()); return false; } @@ -323,9 +322,9 @@ final class LanguageEditorCompileCommand { } catch (IOException ex) { // ERROR: Cannot execute {0} process '{1}' in working directory '{2}'. System // error: {3} - createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E105, - compilerDefinition.getText(), compilerProcess.getCommandArrayString(), - compilerProcess.getWorkingDirectory().getPath(), ex.getMessage()); + createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E105, compilerDefinition.getText(), + compilerProcess.getCommandArrayString(), compilerProcess.getWorkingDirectory().getPath(), + ex.getMessage()); } // Refresh the output and the symbols file resource. @@ -403,8 +402,7 @@ final class LanguageEditorCompileCommand { if (!compilerSuccess && !errorFound) { // ERROR: {0} process ended with return code {1}. Check the error messages and // the console log. - createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E127, - compilerDefinition.getText(), + createMainSourceFileMessage(files, IMarker.SEVERITY_ERROR, Texts.MESSAGE_E127, compilerDefinition.getText(), NumberUtility.getLongValueDecimalString(compilerProcess.getExitValue())); } diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditorCompileCommandDelegate.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditorCompileCommandDelegate.java index ec88fdf1..7e8dbc02 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditorCompileCommandDelegate.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditorCompileCommandDelegate.java @@ -40,7 +40,7 @@ import com.wudsn.ide.base.hardware.Hardware; import com.wudsn.ide.base.hardware.HardwareUtility; import com.wudsn.ide.lng.LanguagePlugin; import com.wudsn.ide.lng.Texts; -import com.wudsn.ide.lng.preferences.CompilerPreferences; +import com.wudsn.ide.lng.preferences.LanguageHardwareCompilerDefinitionPreferences; import com.wudsn.ide.lng.runner.RunnerDefinition; import com.wudsn.ide.lng.runner.RunnerId; import com.wudsn.ide.lng.runner.RunnerRegistry; @@ -110,7 +110,7 @@ public final class LanguageEditorCompileCommandDelegate RunnerRegistry runnerRegistry = languagePlugin.getRunnerRegistry(); Hardware hardware = languageEditor.getHardware(); List runnerDefinitions = runnerRegistry.getDefinitions(hardware); - CompilerPreferences compilerPreferences = languageEditor.getCompilerPreferences(); + LanguageHardwareCompilerDefinitionPreferences languageHardwareCompilerDefinitionPreferences = languageEditor.getLanguageHardwareCompilerPreferences(); Menu menu = new Menu(parent); setMenu(menu); @@ -123,7 +123,7 @@ public final class LanguageEditorCompileCommandDelegate String runnerName = runnerDefinition.getName(); // The system default application does not need an executable path. if (!runnerId.equals(RunnerId.DEFAULT_APPLICATION)) { - if (StringUtility.isEmpty(compilerPreferences.getRunnerExecutablePath(runnerId))) { + if (StringUtility.isEmpty(languageHardwareCompilerDefinitionPreferences.getRunnerExecutablePath(runnerId))) { continue; } } @@ -131,7 +131,7 @@ public final class LanguageEditorCompileCommandDelegate Action action = new CompileAndRunAction(runnerId); action.setActionDefinitionId(LanguageEditorCompileCommand.COMPILE_AND_RUN_WITH); action.setImageDescriptor(imageDescriptor); - if (runnerId.equals(compilerPreferences.getRunnerId())) { + if (runnerId.equals(languageHardwareCompilerDefinitionPreferences.getRunnerId())) { runnerName = runnerName + " " + Texts.COMPILER_TOOLBAR_RUN_WITH_DEFAULT_LABEL; } action.setText(runnerName); diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditorCompilerHelpCommandHandler.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditorCompilerHelpCommandHandler.java index 14f5ae39..5f703a79 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditorCompilerHelpCommandHandler.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditorCompilerHelpCommandHandler.java @@ -45,8 +45,8 @@ public final class LanguageEditorCompilerHelpCommandHandler extends AbstractHand var languageEditor = (LanguageEditor) editor; var compilerDefinition = languageEditor.getCompilerDefinition(); - var compilerPreferences = languageEditor.getCompilerPreferences(); - var compilerExecutablePath = compilerPreferences.getCompilerExecutablePathOrDefault(); + var languagePreferences = languageEditor.getLanguagePreferences(); + var compilerExecutablePath = languagePreferences.getCompilerExecutablePathOrDefault(compilerDefinition); try { var helpDocument = compilerDefinition.getInstalledHelpForCurrentLocale(compilerExecutablePath); diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditorFilesLogic.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditorFilesLogic.java index edbfc251..2f15eedf 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditorFilesLogic.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageEditorFilesLogic.java @@ -120,7 +120,7 @@ public final class LanguageEditorFilesLogic { } } result = new CompilerFiles(mainSourceIFile, mainSourceFileProperties, sourceIFile, sourceFileProperties, - languageEditor.getCompilerPreferences()); + languageEditor.getLanguageHardwareCompilerPreferences()); } else { result = null; } diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageRuleBasedScanner.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageRuleBasedScanner.java index 9c910bc5..2e320089 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageRuleBasedScanner.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageRuleBasedScanner.java @@ -47,22 +47,21 @@ final class LanguageRuleBasedScanner extends RuleBasedScanner { * Creates a new instance. Called by {@link LanguageSourceViewerConfiguration}. * * @param languagePreferences The language preferences, not null. - * @param textAttributeName The text attribute name to listen to for text + * @param preferencesKey The preferences key to listen to for text * attribute changes, not null. See * {@link LanguagePreferencesConstants} */ - LanguageRuleBasedScanner(LanguagePreferences languagePreferences, String textAttributeName) { + LanguageRuleBasedScanner(LanguagePreferences languagePreferences, String preferencesKey) { if (languagePreferences == null) { throw new IllegalArgumentException("Parameter 'language' must not be null."); } - if (textAttributeName == null) { - throw new IllegalArgumentException("Parameter 'textAttributeName' must not be null."); + if (preferencesKey == null) { + throw new IllegalArgumentException("Parameter 'preferencesKey' must not be null."); } - this.preferencesKey = LanguagePreferencesConstants.getPreferencesKey(languagePreferences.getLanguage(), - textAttributeName); + this.preferencesKey = preferencesKey; - defaultToken = new Token(languagePreferences.getEditorTextAttribute(textAttributeName)); + defaultToken = new Token(languagePreferences.getTextAttribute(preferencesKey)); super.setDefaultReturnToken(defaultToken); } @@ -94,7 +93,7 @@ final class LanguageRuleBasedScanner extends RuleBasedScanner { boolean refresh = false; if (changedPropertyNames.contains(preferencesKey)) { TextAttributeConverter.dispose((TextAttribute) defaultToken.getData()); - defaultToken.setData(preferences.getLanguagesPreferences().getEditorTextAttribute(preferencesKey)); + defaultToken.setData(preferences.getTextAttribute(preferencesKey)); refresh = true; } return refresh; diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageSourceScanner.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageSourceScanner.java index bfa6d9b7..f1fb7320 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageSourceScanner.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageSourceScanner.java @@ -41,8 +41,10 @@ import com.wudsn.ide.lng.compiler.syntax.Instruction; import com.wudsn.ide.lng.compiler.syntax.InstructionSet; import com.wudsn.ide.lng.compiler.syntax.InstructionType; import com.wudsn.ide.lng.compiler.syntax.Opcode; +import com.wudsn.ide.lng.preferences.LanguageHardwareCompilerDefinitionPreferencesConstants; import com.wudsn.ide.lng.preferences.LanguagePreferences; import com.wudsn.ide.lng.preferences.LanguagePreferencesConstants; +import com.wudsn.ide.lng.preferences.LanguagePreferencesConstants.EditorConstants; import com.wudsn.ide.lng.preferences.TextAttributeConverter; /** @@ -397,27 +399,27 @@ final class LanguageSourceScanner extends RuleBasedScanner { private void createTokens() { // Numbers - numberToken = createToken(LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_NUMBER); + numberToken = createLanguageToken(EditorConstants.EDITOR_TEXT_ATTRIBUTE_NUMBER); // Instructions - directiveToken = createToken(LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_DIRECTVE); - legalOpcodeToken = createToken(LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_OPCODE_LEGAL); - illegalOpcodeToken = createToken(LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_OPCODE_ILLEGAL); - pseudoOpcodeToken = createToken(LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_OPCODE_PSEUDO); + directiveToken = createLanguageToken(EditorConstants.EDITOR_TEXT_ATTRIBUTE_DIRECTVE); + legalOpcodeToken = createLanguageToken(EditorConstants.EDITOR_TEXT_ATTRIBUTE_OPCODE_LEGAL); + illegalOpcodeToken = createLanguageToken(EditorConstants.EDITOR_TEXT_ATTRIBUTE_OPCODE_ILLEGAL); + pseudoOpcodeToken = createLanguageToken(EditorConstants.EDITOR_TEXT_ATTRIBUTE_OPCODE_PSEUDO); // Identifiers - equateIdentifierToken = createToken(LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_EQUATE); - labelIdentifierToken = createToken(LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_LABEL); - enumDefinitionSectionIdentifierToken = createToken( - LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_ENUM_DEFINITION_SECTION); - structureDefinitionSectionIdentifierToken = createToken( - LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_STRUCTURE_DEFINITION_SECTION); - localSectionIdentifierToken = createToken( - LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_LOCAL_SECTION); - macroDefinitionSectionIdentifierToken = createToken( - LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_MACRO_DEFINITION_SECTION); - procedureDefinitionSectionIdentifierToken = createToken( - LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_PROCEDURE_DEFINITION_SECTION); + equateIdentifierToken = createLanguageToken(EditorConstants.EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_EQUATE); + labelIdentifierToken = createLanguageToken(EditorConstants.EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_LABEL); + enumDefinitionSectionIdentifierToken = createLanguageToken( + EditorConstants.EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_ENUM_DEFINITION_SECTION); + structureDefinitionSectionIdentifierToken = createLanguageToken( + EditorConstants.EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_STRUCTURE_DEFINITION_SECTION); + localSectionIdentifierToken = createLanguageToken( + EditorConstants.EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_LOCAL_SECTION); + macroDefinitionSectionIdentifierToken = createLanguageToken( + EditorConstants.EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_MACRO_DEFINITION_SECTION); + procedureDefinitionSectionIdentifierToken = createLanguageToken( + EditorConstants.EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_PROCEDURE_DEFINITION_SECTION); } @@ -428,14 +430,13 @@ final class LanguageSourceScanner extends RuleBasedScanner { * null. * @return The new token, not null. */ - private IToken createToken(String textAttributeName) { + private IToken createLanguageToken(String textAttributeName) { if (textAttributeName == null) { throw new IllegalArgumentException("Parameter 'textAttributeName' must not be null."); } - LanguagePreferences preferences = editor.getLanguagePreferences(); - String preferencesKey = LanguagePreferencesConstants.getPreferencesKey(preferences.getLanguage(), - textAttributeName); - Token token = new Token(preferences.getEditorTextAttribute(textAttributeName)); + var preferences = editor.getLanguagePreferences(); + var preferencesKey = EditorConstants.getEditorAttributeKey(preferences.getLanguage(), textAttributeName); + var token = new Token(preferences.getTextAttribute(preferencesKey)); tokens.put(preferencesKey, token); return token; } @@ -482,27 +483,29 @@ final class LanguageSourceScanner extends RuleBasedScanner { * {@link LanguageSourceViewerConfiguration}. * * @param preferences The preferences, not null. - * @param changedPropertyNames The set of changed property names, not + * @param changedPreferencesKeys The set of changed property names, not * null. * * @return true If the editor has to be refreshed. */ - final boolean preferencesChanged(LanguagePreferences preferences, Set changedPropertyNames) { + final boolean preferencesChanged(LanguagePreferences preferences, Set changedPreferencesKeys) { if (preferences == null) { throw new IllegalArgumentException("Parameter 'preferences' must not be null."); } - if (changedPropertyNames == null) { + if (changedPreferencesKeys == null) { throw new IllegalArgumentException("Parameter 'changedPropertyNames' must not be null."); } boolean refresh = false; - for (String propertyName : changedPropertyNames) { - Token token = tokens.get(propertyName); + var compilerTargetPreferencesKey = LanguageHardwareCompilerDefinitionPreferencesConstants + .getCompilerTargetName(editor.getLanguage(), editor.getHardware(), editor.getCompilerDefinition()); + for (String preferencesKey : changedPreferencesKeys) { + Token token = tokens.get(preferencesKey); if (token != null) { TextAttributeConverter.dispose((TextAttribute) token.getData()); - token.setData(preferences.getLanguagesPreferences().getEditorTextAttribute(propertyName)); + token.setData(preferences.getTextAttribute(preferencesKey)); refresh = true; - } else if (LanguagePreferencesConstants.isCompilerTargetName(propertyName)) { + } else if (compilerTargetPreferencesKey.equals(preferencesKey)) { CompilerSourceParser compilerSourceParser = editor.createCompilerSourceParser(); wordRule.setCompilerSourceParser(compilerSourceParser); wordRule.setInstructions(); diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageSourceViewerConfiguration.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageSourceViewerConfiguration.java index db7309bd..7b94647d 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageSourceViewerConfiguration.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/editor/LanguageSourceViewerConfiguration.java @@ -40,7 +40,7 @@ import org.eclipse.ui.editors.text.TextSourceViewerConfiguration; import com.wudsn.ide.lng.compiler.parser.CompilerSourcePartitionScanner; import com.wudsn.ide.lng.preferences.LanguagePreferences; import com.wudsn.ide.lng.preferences.LanguagePreferencesChangeListener; -import com.wudsn.ide.lng.preferences.LanguagePreferencesConstants; +import com.wudsn.ide.lng.preferences.LanguagePreferencesConstants.EditorConstants; /** * Source configuration for the language editor. Provides syntax highlighting. @@ -140,7 +140,7 @@ final class LanguageSourceViewerConfiguration extends TextSourceViewerConfigurat if (changedPropertyNames == null) { throw new IllegalArgumentException("Parameter 'changedPropertyNames' must not be null."); } - boolean refresh = false; + var refresh = false; refresh |= commentSingleScanner.preferencesChanged(preferences, changedPropertyNames); refresh |= commentMultipleScanner.preferencesChanged(preferences, changedPropertyNames); refresh |= stringScanner.preferencesChanged(preferences, changedPropertyNames); @@ -168,25 +168,26 @@ final class LanguageSourceViewerConfiguration extends TextSourceViewerConfigurat if (sourceViewer == null) { throw new IllegalArgumentException("Parameter 'sourceViewer' must not be null."); } - PresentationReconciler reconciler = new PresentationReconciler(); - DefaultDamagerRepairer dr; + var reconciler = new PresentationReconciler(); - LanguagePreferences languagePreferences = editor.getLanguagePreferences(); + var languagePreferences = editor.getLanguagePreferences(); + var language = languagePreferences.getLanguage(); - commentSingleScanner = new LanguageRuleBasedScanner(languagePreferences, - LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_COMMENT); - dr = new DefaultDamagerRepairer(commentSingleScanner); + var preferencesKey = EditorConstants.getEditorAttributeKey(language, + EditorConstants.EDITOR_TEXT_ATTRIBUTE_COMMENT); + commentSingleScanner = new LanguageRuleBasedScanner(languagePreferences, preferencesKey); + var dr = new DefaultDamagerRepairer(commentSingleScanner); reconciler.setDamager(dr, CompilerSourcePartitionScanner.PARTITION_COMMENT_SINGLE); reconciler.setRepairer(dr, CompilerSourcePartitionScanner.PARTITION_COMMENT_SINGLE); - commentMultipleScanner = new LanguageRuleBasedScanner(languagePreferences, - LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_COMMENT); + preferencesKey = EditorConstants.getEditorAttributeKey(language, EditorConstants.EDITOR_TEXT_ATTRIBUTE_COMMENT); + commentMultipleScanner = new LanguageRuleBasedScanner(languagePreferences, preferencesKey); dr = new DefaultDamagerRepairer(commentMultipleScanner); reconciler.setDamager(dr, CompilerSourcePartitionScanner.PARTITION_COMMENT_MULTIPLE); reconciler.setRepairer(dr, CompilerSourcePartitionScanner.PARTITION_COMMENT_MULTIPLE); - stringScanner = new LanguageRuleBasedScanner(languagePreferences, - LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_STRING); + preferencesKey = EditorConstants.getEditorAttributeKey(language, EditorConstants.EDITOR_TEXT_ATTRIBUTE_STRING); + stringScanner = new LanguageRuleBasedScanner(languagePreferences, preferencesKey); dr = new DefaultDamagerRepairer(stringScanner); reconciler.setDamager(dr, CompilerSourcePartitionScanner.PARTITION_STRING); reconciler.setRepairer(dr, CompilerSourcePartitionScanner.PARTITION_STRING); @@ -206,16 +207,18 @@ final class LanguageSourceViewerConfiguration extends TextSourceViewerConfigurat } IReconcilingStrategy reconcilingStrategy = new LanguageReconcilingStategy(editor); - MonoReconciler reconciler = new MonoReconciler(reconcilingStrategy, false); + var reconciler = new MonoReconciler(reconcilingStrategy, false); reconciler.setProgressMonitor(new NullProgressMonitor()); - reconciler.setDelay(500); // TODO Compute delay based on size of content on the source viewer (sourceViewer.getDocument().getLength()) or the fact that the parser is still parsing + reconciler.setDelay(500); // TODO Compute delay based on size of content on the source viewer + // (sourceViewer.getDocument().getLength()) or the fact that the parser is still + // parsing return reconciler; } @Override protected Map getHyperlinkDetectorTargets(ISourceViewer sourceViewer) { - Map targets = super.getHyperlinkDetectorTargets(sourceViewer); + var targets = super.getHyperlinkDetectorTargets(sourceViewer); targets.put(LanguageHyperlinkDetector.TARGET, editor); return targets; } diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/help/LanguageHelpContentProducer.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/help/LanguageHelpContentProducer.java index 1fcea647..db8183cd 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/help/LanguageHelpContentProducer.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/help/LanguageHelpContentProducer.java @@ -64,7 +64,6 @@ import com.wudsn.ide.lng.compiler.syntax.InstructionSet; import com.wudsn.ide.lng.compiler.syntax.InstructionType; import com.wudsn.ide.lng.compiler.syntax.Opcode; import com.wudsn.ide.lng.compiler.syntax.Opcode.OpcodeAddressingMode; -import com.wudsn.ide.lng.preferences.CompilerPreferences; import com.wudsn.ide.lng.preferences.LanguagePreferences; import com.wudsn.ide.lng.runner.RunnerDefinition; import com.wudsn.ide.lng.runner.RunnerId; @@ -301,20 +300,16 @@ public final class LanguageHelpContentProducer implements IHelpContentProducer { CompilerRegistry compilerRegistry = languagePlugin.getCompilerRegistry(); // Find non-empty compiler executable path. - Language language = Language.valueOf(languageString); - String compilerKey = CompilerDefinition.getKey(language, compilerId); - CompilerDefinition compilerDefinition = compilerRegistry.getCompilerByKey(compilerKey).getDefinition(); - + var language = Language.valueOf(languageString); + var compilerDefinition = compilerRegistry.getCompilerDefinitionById(language, compilerId); if (section.startsWith(SECTION_GENERAL)) { return getInputStream(getCompilerGeneralSection(compilerDefinition)); } else if (section.startsWith(SECTION_MANUAL)) { LanguagePreferences languagePreferences = languagePlugin.getLanguagePreferences(language); - CompilerPreferences compilerPreferences = languagePreferences.getCompilerPreferences(compilerDefinition, - Hardware.GENERIC); try { - var helpDocDocument = compilerDefinition - .getInstalledHelpForCurrentLocale(compilerPreferences.getCompilerExecutablePathOrDefault()); + var helpDocDocument = compilerDefinition.getInstalledHelpForCurrentLocale( + languagePreferences.getCompilerExecutablePathOrDefault(compilerDefinition)); File file = helpDocDocument.file; if (file == null) { throw new RuntimeException( diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/help/LanguageTocProvider.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/help/LanguageTocProvider.java index af5d7984..0839c349 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/help/LanguageTocProvider.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/help/LanguageTocProvider.java @@ -262,8 +262,7 @@ public final class LanguageTocProvider extends AbstractTocProvider { var languagePreferences = LanguagePlugin.getInstance() .getLanguagePreferences(compilerDefinition.getLanguage()); - var compilerPreferences = languagePreferences.getCompilerPreferences(compilerDefinition, Hardware.GENERIC); - var compilerExecutablePath = compilerPreferences.getCompilerExecutablePathOrDefault(); + var compilerExecutablePath = languagePreferences.getCompilerExecutablePathOrDefault(compilerDefinition); var icon = ""; var manualTopics = new ArrayList(); diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/CompilerRunPreferences.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/CompilerRunPreferences.java index 4ad3507c..0e29a365 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/CompilerRunPreferences.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/CompilerRunPreferences.java @@ -32,18 +32,18 @@ import com.wudsn.ide.lng.LanguageProperties; */ public final class CompilerRunPreferences { - private CompilerPreferences compilerPreferences; + private LanguageHardwareCompilerDefinitionPreferences languageHardwareCompilerDefinitionPreferences; private LanguageProperties mainSourceFileProperties; - public CompilerRunPreferences(CompilerPreferences compilerPreferences, + public CompilerRunPreferences(LanguageHardwareCompilerDefinitionPreferences languageHardwareCompilerDefinitionPreferences, LanguageProperties mainSourceFileProperties) { - if (compilerPreferences == null) { - throw new IllegalArgumentException("Parameter 'compilerPreferences' must not be null."); + if (languageHardwareCompilerDefinitionPreferences == null) { + throw new IllegalArgumentException("Parameter 'languageHardwareCompilerDefinitionPreferences' must not be null."); } if (mainSourceFileProperties == null) { throw new IllegalArgumentException("Parameter 'properties' must not be null."); } - this.compilerPreferences = compilerPreferences; + this.languageHardwareCompilerDefinitionPreferences = languageHardwareCompilerDefinitionPreferences; this.mainSourceFileProperties = mainSourceFileProperties; } @@ -55,7 +55,7 @@ public final class CompilerRunPreferences { * @since 1.6.1 */ public Hardware getHardware() { - return compilerPreferences.getHardware(); + return languageHardwareCompilerDefinitionPreferences.getHardware(); } /** @@ -68,7 +68,7 @@ public final class CompilerRunPreferences { String result; - result = compilerPreferences.getParameters(); + result = languageHardwareCompilerDefinitionPreferences.getParameters(); return result; } @@ -81,7 +81,7 @@ public final class CompilerRunPreferences { public String getRunnerId() { String result; - result = compilerPreferences.getRunnerId(); + result = languageHardwareCompilerDefinitionPreferences.getRunnerId(); return result; } @@ -103,7 +103,7 @@ public final class CompilerRunPreferences { String result; - result = compilerPreferences.getRunnerExecutablePath(runnerId); + result = languageHardwareCompilerDefinitionPreferences.getRunnerExecutablePath(runnerId); return result; } @@ -122,7 +122,7 @@ public final class CompilerRunPreferences { throw new IllegalArgumentException("Parameter 'runnerId' must not be empty."); } String result; - result = compilerPreferences.getRunnerCommandLine(runnerId); + result = languageHardwareCompilerDefinitionPreferences.getRunnerCommandLine(runnerId); return result; } @@ -144,7 +144,7 @@ public final class CompilerRunPreferences { throw new IllegalArgumentException("Parameter 'runnerId' must not be empty."); } boolean result; - result = compilerPreferences.isRunnerWaitForCompletion(runnerId); + result = languageHardwareCompilerDefinitionPreferences.isRunnerWaitForCompletion(runnerId); return result; } diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/CompilerPreferences.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguageHardwareCompilerDefinitionPreferences.java similarity index 57% rename from com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/CompilerPreferences.java rename to com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguageHardwareCompilerDefinitionPreferences.java index 157d927c..3888a9c3 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/CompilerPreferences.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguageHardwareCompilerDefinitionPreferences.java @@ -1,281 +1,222 @@ -/** - * Copyright (C) 2009 - 2021 Peter Dell - * - * 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 . - */ - -package com.wudsn.ide.lng.preferences; - -import java.io.File; - -import com.wudsn.ide.base.common.StringUtility; -import com.wudsn.ide.base.hardware.Hardware; -import com.wudsn.ide.lng.LanguagePlugin; -import com.wudsn.ide.lng.Target; -import com.wudsn.ide.lng.compiler.CompilerOutputFolderMode; -import com.wudsn.ide.lng.compiler.CompilerPaths; -import com.wudsn.ide.lng.compiler.CompilerPaths.CompilerPath; -import com.wudsn.ide.lng.runner.RunnerId; - -/** - * Facade class for typed access to the global compiler preferences for a given - * hardware. - * - * @author Peter Dell - */ -public final class CompilerPreferences { - - private LanguagePreferences languagePreferences; - private Hardware hardware; - private String compilerId; - - CompilerPreferences(LanguagePreferences languagePreferences, String compilerId, Hardware hardware) { - if (languagePreferences == null) { - throw new IllegalArgumentException("Parameter 'languagePreferences' must not be null."); - } - if (compilerId == null) { - throw new IllegalArgumentException("Parameter 'compilerId' must not be null."); - } - if (StringUtility.isEmpty(compilerId)) { - throw new IllegalArgumentException("Parameter 'compilerId' must not be empty."); - } - if (hardware == null) { - throw new IllegalArgumentException("Parameter 'hardware' must not be null."); - } - this.languagePreferences = languagePreferences; - this.compilerId = compilerId; - this.hardware = hardware; - } - - /** - * Gets the compiler id of the compiler. - * - * @return The compiler id of the compiler, not empty and not null. - */ - public String getCompilerId() { - return compilerId; - } - - /** - * Gets the configured executable path for the compiler. - * - * @return The executable path for the runner, may be empty, not - * null. - */ - public String getCompilerExecutablePath() { - return languagePreferences.getString(LanguagePreferencesConstants.getCompilerExecutablePathName(compilerId)); - } - - /** - * Gets the executable path for the compiler. - * - * @return The executable path for the runner, may be empty, not - * null. - */ - public String getCompilerExecutablePathOrDefault() { - String compilerExecutablePath = getCompilerExecutablePath(); - - CompilerPaths compilerPaths = LanguagePlugin.getInstance().getCompilerPaths(); - if (StringUtility.isEmpty(compilerExecutablePath)) { - CompilerPath compilerPath = compilerPaths.getDefaultCompilerPath(languagePreferences.getLanguage(), - compilerId); - if (compilerPath != null) { - File compilerFile = compilerPath.getAbsoluteFile(); - if (compilerFile != null) { - if (compilerFile.exists() && compilerFile.isFile() && compilerFile.canExecute()) { - compilerExecutablePath = compilerFile.getAbsolutePath(); - } - } - } - - } - return compilerExecutablePath; - } - - /** - * Gets the hardware for which the compiler is invoked. - * - * @return The hardware, not null. - * - * @since 1.6.1 - */ - public Hardware getHardware() { - return hardware; - } - - /** - * Gets the Target for which the instructions shall be active. - * - * @return The Target, not null. - * - * @since 1.6.1 - */ - public Target getTarget() { - Target result; - String targetString = languagePreferences - .getString(LanguagePreferencesConstants.getCompilerTargetName(compilerId, hardware)); - - if (StringUtility.isEmpty(targetString)) { - result = Target.MOS6502; - } else { - result = Target.valueOf(targetString); - } - return result; - } - - /** - * Determines if illegal opcodes shall be highlighted and proposed. - * - * @return true if yet, false otherwise. - */ - @Deprecated - public boolean isIllegalOpcodesVisible() { - return getTarget() == Target.MOS6502_ILLEGAL; - } - - /** - * Determines if W65816 opcodes shall be highlighted and proposed. - * - * @return true if yet, false otherwise. - */ - @Deprecated - public boolean isW65816OpcodesVisible() { - return getTarget() == Target.MOS65816; - } - - /** - * Gets the parameters for the compiler. - * - * @return The parameters path for the compiler, may be empty, not - * null. - */ - public String getParameters() { - return languagePreferences - .getString(LanguagePreferencesConstants.getCompilerParametersName(compilerId, hardware)); - } - - /** - * Gets the output folder mode for the compiler. - * - * @return The output folder mode for the compiler, see - * {@link CompilerOutputFolderMode}, may be empty, not - * null. - */ - public String getOutputFolderMode() { - - return languagePreferences - .getString(LanguagePreferencesConstants.getCompilerOutputFolderModeName(compilerId, hardware)); - } - - /** - * Gets the output folder for the compiler in case the output folder mode is - * {@link CompilerOutputFolderMode#FIXED_FOLDER}. - * - * @return The output folder mode for the compiler, see - * {@link CompilerOutputFolderMode#FIXED_FOLDER}, may be empty, not - * null. - */ - public String getOutputFolderPath() { - - return languagePreferences - .getString(LanguagePreferencesConstants.getCompilerOutputFolderPathName(compilerId, hardware)); - } - - /** - * Gets the output file extension for the compiler. - * - * @return The output file extension may be empty, not null. - */ - public String getOutputFileExtension() { - - return languagePreferences - .getString(LanguagePreferencesConstants.getCompilerOutputFileExtensionName(compilerId, hardware)); - } - - /** - * Gets the id of the default runner to run the output file. - * - * @return The id of the runner to run the output file, not empty and not - * null. - */ - public String getRunnerId() { - String result = languagePreferences - .getString(LanguagePreferencesConstants.getCompilerRunnerIdName(compilerId, hardware)); - if (StringUtility.isEmpty(result)) { - result = RunnerId.DEFAULT_APPLICATION; - } - return result; - } - - /** - * Gets the executable path for the runner. - * - * @param runnerId The runner id, not empty and not null. - * - * @return The executable path for the runner, may be empty, not - * null. - */ - public String getRunnerExecutablePath(String runnerId) { - if (runnerId == null) { - throw new IllegalArgumentException("Parameter 'runnerId' must not be null."); - } - if (StringUtility.isEmpty(runnerId)) { - throw new IllegalArgumentException("Parameter 'runnerId' must not be empty."); - } - return languagePreferences.getString( - LanguagePreferencesConstants.getCompilerRunnerExecutablePathName(compilerId, hardware, runnerId)); - } - - /** - * Gets the parameters for the runner. - * - * @param runnerId The runner id, not empty and not null. - * - * @return The parameters for the runner, may be empty, not null. - */ - public String getRunnerCommandLine(String runnerId) { - if (runnerId == null) { - throw new IllegalArgumentException("Parameter 'runnerId' must not be null."); - } - if (StringUtility.isEmpty(runnerId)) { - throw new IllegalArgumentException("Parameter 'runnerId' must not be empty."); - } - return languagePreferences.getString( - LanguagePreferencesConstants.getCompilerRunnerCommandLineName(compilerId, hardware, runnerId)); - } - - /** - * Gets the wait for completion indicator for the runner. - * - * @param runnerId The runner id, not empty and not null. - * - * @return trueif waiting for completion is requested, - * false otherwise. - * - * @since 1.6.1 - */ - public boolean isRunnerWaitForCompletion(String runnerId) { - if (runnerId == null) { - throw new IllegalArgumentException("Parameter 'runnerId' must not be null."); - } - if (StringUtility.isEmpty(runnerId)) { - throw new IllegalArgumentException("Parameter 'runnerId' must not be empty."); - } - return languagePreferences.getBoolean( - LanguagePreferencesConstants.getCompilerRunnerWaitForCompletionName(compilerId, hardware, runnerId)); - } - -} +/** + * Copyright (C) 2009 - 2021 Peter Dell + * + * 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 . + */ + +package com.wudsn.ide.lng.preferences; + +import com.wudsn.ide.base.common.StringUtility; +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.CompilerDefinition; +import com.wudsn.ide.lng.compiler.CompilerOutputFolderMode; +import com.wudsn.ide.lng.runner.RunnerId; + +/** + * Facade class for typed access to the global compiler preferences for a given + * hardware. + * + * @author Peter Dell + */ +public final class LanguageHardwareCompilerDefinitionPreferences { + + private LanguagePreferences languagePreferences; + private Language language; + private Hardware hardware; + private CompilerDefinition compilerDefinition; + + LanguageHardwareCompilerDefinitionPreferences(LanguagePreferences languagePreferences, Hardware hardware, + CompilerDefinition compilerDefinition) { + if (languagePreferences == null) { + throw new IllegalArgumentException("Parameter 'languagePreferences' must not be null."); + } + if (compilerDefinition == null) { + throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null."); + } + if (hardware == null) { + throw new IllegalArgumentException("Parameter 'hardware' must not be null."); + } + this.languagePreferences = languagePreferences; + this.language = this.languagePreferences.getLanguage(); + this.compilerDefinition = compilerDefinition; + this.hardware = hardware; + } + + /** + * Gets the hardware for which the compiler is invoked. + * + * @return The hardware, not null. + * + * @since 1.6.1 + */ + public Hardware getHardware() { + return hardware; + } + + /** + * Gets the compiler definition. + * + * @return The compiler definition, not null. + */ + public CompilerDefinition getCompilerDefinition() { + return compilerDefinition; + } + + /** + * Gets the Target for which the instructions shall be active. + * + * @return The Target, not null. + * + * @since 1.6.1 + */ + public Target getTarget() { + Target result; + String targetString = languagePreferences + .getString(LanguageHardwareCompilerDefinitionPreferencesConstants.getCompilerTargetName(language, hardware, compilerDefinition)); + + if (StringUtility.isEmpty(targetString)) { + result = Target.MOS6502; + } else { + result = Target.valueOf(targetString); + } + return result; + } + + /** + * Gets the parameters for the compiler. + * + * @return The parameters path for the compiler, may be empty, not + * null. + */ + public String getParameters() { + return languagePreferences.getString( + LanguageHardwareCompilerDefinitionPreferencesConstants.getCompilerParametersName(language, hardware, compilerDefinition)); + } + + /** + * Gets the output folder mode for the compiler. + * + * @return The output folder mode for the compiler, see + * {@link CompilerOutputFolderMode}, may be empty, not + * null. + */ + public String getOutputFolderMode() { + + return languagePreferences.getString( + LanguageHardwareCompilerDefinitionPreferencesConstants.getCompilerOutputFolderModeName(language, hardware, compilerDefinition)); + } + + /** + * Gets the output folder for the compiler in case the output folder mode is + * {@link CompilerOutputFolderMode#FIXED_FOLDER}. + * + * @return The output folder mode for the compiler, see + * {@link CompilerOutputFolderMode#FIXED_FOLDER}, may be empty, not + * null. + */ + public String getOutputFolderPath() { + + return languagePreferences.getString( + LanguageHardwareCompilerDefinitionPreferencesConstants.getCompilerOutputFolderPathName(language, hardware, compilerDefinition)); + } + + /** + * Gets the output file extension for the compiler. + * + * @return The output file extension may be empty, not null. + */ + public String getOutputFileExtension() { + + return languagePreferences.getString(LanguageHardwareCompilerDefinitionPreferencesConstants.getCompilerOutputFileExtensionName(language, + hardware, compilerDefinition)); + } + + /** + * Gets the id of the default runner to run the output file. + * + * @return The id of the runner to run the output file, not empty and not + * null. + */ + public String getRunnerId() { + String result = languagePreferences.getString( + LanguageHardwareCompilerDefinitionPreferencesConstants.getCompilerRunnerIdName(language, hardware, compilerDefinition)); + if (StringUtility.isEmpty(result)) { + result = RunnerId.DEFAULT_APPLICATION; + } + return result; + } + + /** + * Gets the executable path for the runner. + * + * @param runnerId The runner id, not empty and not null. + * + * @return The executable path for the runner, may be empty, not + * null. + */ + public String getRunnerExecutablePath(String runnerId) { + if (runnerId == null) { + throw new IllegalArgumentException("Parameter 'runnerId' must not be null."); + } + if (StringUtility.isEmpty(runnerId)) { + throw new IllegalArgumentException("Parameter 'runnerId' must not be empty."); + } + return languagePreferences.getString(LanguageHardwareCompilerDefinitionPreferencesConstants.getCompilerRunnerExecutablePathName(language, + hardware, compilerDefinition, runnerId)); + } + + /** + * Gets the parameters for the runner. + * + * @param runnerId The runner id, not empty and not null. + * + * @return The parameters for the runner, may be empty, not null. + */ + public String getRunnerCommandLine(String runnerId) { + if (runnerId == null) { + throw new IllegalArgumentException("Parameter 'runnerId' must not be null."); + } + if (StringUtility.isEmpty(runnerId)) { + throw new IllegalArgumentException("Parameter 'runnerId' must not be empty."); + } + return languagePreferences.getString(LanguageHardwareCompilerDefinitionPreferencesConstants.getCompilerRunnerCommandLineName(language, + hardware, compilerDefinition, runnerId)); + } + + /** + * Gets the wait for completion indicator for the runner. + * + * @param runnerId The runner id, not empty and not null. + * + * @return trueif waiting for completion is requested, + * false otherwise. + * + * @since 1.6.1 + */ + public boolean isRunnerWaitForCompletion(String runnerId) { + if (runnerId == null) { + throw new IllegalArgumentException("Parameter 'runnerId' must not be null."); + } + if (StringUtility.isEmpty(runnerId)) { + throw new IllegalArgumentException("Parameter 'runnerId' must not be empty."); + } + return languagePreferences.getBoolean(LanguageHardwareCompilerDefinitionPreferencesConstants + .getCompilerRunnerWaitForCompletionName(language, hardware, compilerDefinition, runnerId)); + } + +} diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguageHardwareCompilerDefinitionPreferencesConstants.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguageHardwareCompilerDefinitionPreferencesConstants.java new file mode 100644 index 00000000..60b0a365 --- /dev/null +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguageHardwareCompilerDefinitionPreferencesConstants.java @@ -0,0 +1,298 @@ +/** +R * Copyright (C) 2009 - 2021 Peter Dell + * + * 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 . + */ + +package com.wudsn.ide.lng.preferences; + +import com.wudsn.ide.base.hardware.Hardware; +import com.wudsn.ide.lng.Language; +import com.wudsn.ide.lng.compiler.CompilerDefinition; + +/** + * Constants for preferences. + * + * @author Peter Dell + */ +public final class LanguageHardwareCompilerDefinitionPreferencesConstants { + + /** + * Gets preference key name prefix for a given hardware and compiler. + * + * @param language The language, not null. + * @param hardware The hardware, not null. + * @param compilerDefinition The compiler id, not null. + * + * + * @return The preference key name prefix without trailing dot, not empty and + * not null. + */ + private static String getLanguageHardwareCompilerDefinitionPrefix(Language language, Hardware hardware, + CompilerDefinition compilerDefinition) { + if (language == null) { + throw new IllegalArgumentException("Parameter 'language' must not be null."); + } + if (hardware == null) { + throw new IllegalArgumentException("Parameter 'hardware' must not be null."); + } + if (compilerDefinition == null) { + throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null."); + } + return LanguagePreferencesConstants.getLanguagePreferencesKey(language, + "hardware." + hardware.name().toLowerCase() + ".compiler." + compilerDefinition.getId()); + } + + /** + * Gets preference key name for the compiler output file extension. + * + * @param language The language, not null. + * @param compilerDefinition The compiler id, not null. + * @param hardware The hardware, not null. + * + * @return The preference key name for the compiler output file extension, not + * empty and not null. + */ + static String getCompilerOutputFileExtensionName(Language language, Hardware hardware, + CompilerDefinition compilerDefinition) { + if (language == null) { + throw new IllegalArgumentException("Parameter 'language' must not be null."); + } + if (hardware == null) { + throw new IllegalArgumentException("Parameter 'hardware' must not be null."); + } + if (compilerDefinition == null) { + throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null."); + } + return getLanguageHardwareCompilerDefinitionPrefix(language, hardware, compilerDefinition) + + ".output.file.extension"; //$NON-NLS-1$ + + } + + /** + * Gets preference key name for the compiler output folder mode. + * + * @param language The language, not null. + * @param compilerDefinition The compiler id, not null. + * @param hardware The hardware, not null. + * + * @return The preference key name for the compiler output folder mode, not + * empty and not null. + */ + static String getCompilerOutputFolderModeName(Language language, Hardware hardware, + CompilerDefinition compilerDefinition) { + if (language == null) { + throw new IllegalArgumentException("Parameter 'language' must not be null."); + } + if (hardware == null) { + throw new IllegalArgumentException("Parameter 'hardware' must not be null."); + } + if (compilerDefinition == null) { + throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null."); + } + return getLanguageHardwareCompilerDefinitionPrefix(language, hardware, compilerDefinition) + + ".output.folder.mode"; //$NON-NLS-1$ + + } + + /** + * Gets preference key name for the compiler output folder path. + * + * @param language The language, not null. + * @param compilerDefinition The compiler id, not null. + * @param hardware The hardware, not null. + * + * @return The preference key name for the compiler output folder path, not + * empty and not null. + */ + static String getCompilerOutputFolderPathName(Language language, Hardware hardware, + CompilerDefinition compilerDefinition) { + if (language == null) { + throw new IllegalArgumentException("Parameter 'language' must not be null."); + } + if (hardware == null) { + throw new IllegalArgumentException("Parameter 'hardware' must not be null."); + } + if (compilerDefinition == null) { + throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null."); + } + return getLanguageHardwareCompilerDefinitionPrefix(language, hardware, compilerDefinition) + + ".output.folder.path"; //$NON-NLS-1$ + + } + + /** + * Gets preference key name for the compiler parameters. + * + * @param language The language, not null. + * @param compilerDefinition The compiler id, not null. + * @param hardware The hardware, not null. + * + * @return The preference key name for the compiler parameters, not empty and + * not null. + */ + static String getCompilerParametersName(Language language, Hardware hardware, + CompilerDefinition compilerDefinition) { + if (language == null) { + throw new IllegalArgumentException("Parameter 'language' must not be null."); + } + if (hardware == null) { + throw new IllegalArgumentException("Parameter 'hardware' must not be null."); + } + if (compilerDefinition == null) { + throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null."); + } + return getLanguageHardwareCompilerDefinitionPrefix(language, hardware, compilerDefinition) + + ".default.parameters"; //$NON-NLS-1$ + } + + /** + * Gets preference key name for the runner command line. + * + * @param compilerDefinition The compiler id, not null. + * @param hardware The hardware, not null. + * @param runnerId The runner id, not null. + * + * @return The preference key name for the runner command line, not empty and + * not null. + */ + static String getCompilerRunnerCommandLineName(Language language, Hardware hardware, + CompilerDefinition compilerDefinition, String runnerId) { + if (language == null) { + throw new IllegalArgumentException("Parameter 'language' must not be null."); + } + if (hardware == null) { + throw new IllegalArgumentException("Parameter 'hardware' must not be null."); + } + if (compilerDefinition == null) { + throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null."); + } + if (runnerId == null) { + throw new IllegalArgumentException("Parameter 'runnerId' must not be null."); + } + return getLanguageHardwareCompilerDefinitionPrefix(language, hardware, compilerDefinition) + ".runner." //$NON-NLS-1$ + + runnerId + ".parameters"; + + } + + /** + * Gets preference key name for the runner executable path. + * + * @param language The language, not null. + * @param compilerDefinition The compiler id, not null. + * @param hardware The hardware, not null. + * @param runnerId The runner id, not null. + * + * @return The preference key name for the runner executable path, not empty and + * not null. + */ + static String getCompilerRunnerExecutablePathName(Language language, Hardware hardware, + CompilerDefinition compilerDefinition, String runnerId) { + if (language == null) { + throw new IllegalArgumentException("Parameter 'language' must not be null."); + } + if (hardware == null) { + throw new IllegalArgumentException("Parameter 'hardware' must not be null."); + } + if (compilerDefinition == null) { + throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null."); + } + if (runnerId == null) { + throw new IllegalArgumentException("Parameter 'runnerId' must not be null."); + } + return getLanguageHardwareCompilerDefinitionPrefix(language, hardware, compilerDefinition) + ".runner." //$NON-NLS-1$ + + runnerId + ".executable.path"; + + } + + /** + * Gets preference key name for the runner to run the output file. + * + * @param language The language, not null. + * @param compilerDefinition The compiler id, not null. + * @param hardware The hardware, not null. + * + * @return The preference key name for the for the runner to run the output + * file, not empty and not null. + */ + static String getCompilerRunnerIdName(Language language, Hardware hardware, CompilerDefinition compilerDefinition) { + if (language == null) { + throw new IllegalArgumentException("Parameter 'language' must not be null."); + } + if (hardware == null) { + throw new IllegalArgumentException("Parameter 'hardware' must not be null."); + } + if (compilerDefinition == null) { + throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null."); + } + return getLanguageHardwareCompilerDefinitionPrefix(language, hardware, compilerDefinition) + ".runner.id"; //$NON-NLS-1$ + + } + + /** + * Gets preference key name for the runner wait for completion flag. + * + * @param compilerDefinition The compiler id, not null. + * @param hardware The hardware, not null. + * @param runnerId The runner id, not null. + * + * @return The preference key name for the runner command line, not empty and + * not null. + * @since 1.6.1 + */ + static String getCompilerRunnerWaitForCompletionName(Language language, Hardware hardware, + CompilerDefinition compilerDefinition, String runnerId) { + if (language == null) { + throw new IllegalArgumentException("Parameter 'language' must not be null."); + } + if (hardware == null) { + throw new IllegalArgumentException("Parameter 'hardware' must not be null."); + } + if (compilerDefinition == null) { + throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null."); + } + if (runnerId == null) { + throw new IllegalArgumentException("Parameter 'runnerId' must not be null."); + } + return getLanguageHardwareCompilerDefinitionPrefix(language, hardware, compilerDefinition) + ".runner." //$NON-NLS-1$ + + runnerId + ".waitForCompletion"; + + } + + /** + * Gets preference key name for the compiler Target visibility. + * + * @param language The language, not null. + * @param compilerDefinition The compiler id, not null. + * @param hardware The hardware, not null. + * + * @return The preference key name for the compiler Target, not empty and not + * null. + */ + public static String getCompilerTargetName(Language language, Hardware hardware, CompilerDefinition compilerDefinition) { + if (language == null) { + throw new IllegalArgumentException("Parameter 'language' must not be null."); + } + if (hardware == null) { + throw new IllegalArgumentException("Parameter 'hardware' must not be null."); + } + if (compilerDefinition == null) { + throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null."); + } + return getLanguageHardwareCompilerDefinitionPrefix(language, hardware, compilerDefinition) + ".target"; //$NON-NLS-1$ + } + +} diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagePreferencesCompilersPage.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguageHardwarePreferencesPage.java similarity index 90% rename from com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagePreferencesCompilersPage.java rename to com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguageHardwarePreferencesPage.java index 2e51f7ad..7c02839a 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagePreferencesCompilersPage.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguageHardwarePreferencesPage.java @@ -1,654 +1,656 @@ -/** - * Copyright (C) 2009 - 2021 Peter Dell - * - * 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 . - */ - -package com.wudsn.ide.lng.preferences; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import org.eclipse.jface.fieldassist.ControlDecoration; -import org.eclipse.jface.preference.BooleanFieldEditor; -import org.eclipse.jface.preference.ComboFieldEditor; -import org.eclipse.jface.preference.FieldEditor; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.RadioGroupFieldEditor; -import org.eclipse.jface.preference.StringFieldEditor; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.TabFolder; -import org.eclipse.swt.widgets.TabItem; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -import com.wudsn.ide.base.common.EnumUtility; -import com.wudsn.ide.base.common.ProcessWithLogs; -import com.wudsn.ide.base.common.StringUtility; -import com.wudsn.ide.base.common.TextUtility; -import com.wudsn.ide.base.gui.SWTFactory; -import com.wudsn.ide.base.hardware.Hardware; -import com.wudsn.ide.lng.Language; -import com.wudsn.ide.lng.LanguagePlugin; -import com.wudsn.ide.lng.LanguageUtility; -import com.wudsn.ide.lng.Texts; -import com.wudsn.ide.lng.compiler.CompilerDefinition; -import com.wudsn.ide.lng.compiler.CompilerOutputFolderMode; -import com.wudsn.ide.lng.editor.LanguageEditor; -import com.wudsn.ide.lng.runner.RunnerId; - -/** - * Visual editor page for the language preferences regarding compilers. There is - * a separate page per {@link Hardware}. Subclasses only implement the - * constructor. - * - * @author Peter Dell - */ -public abstract class LanguagePreferencesCompilersPage extends FieldEditorPreferencePage - implements IWorkbenchPreferencePage { - - private static final class Tab { - - public final CompilerDefinition compilerDefinition; - public final int tabIndex; - public final TabItem tabItem; - public final Control enabledControl; - public final Control disabledControl; - public final List controlDecorations; - public boolean initialized; - public boolean enabled; - - public Tab(CompilerDefinition compilerDefinition, int tabIndex, TabItem tabItem, Control enabledControl, - Control disabledControl, List controlDecorations) { - this.compilerDefinition = compilerDefinition; - this.tabIndex = tabIndex; - this.tabItem = tabItem; - this.enabledControl = enabledControl; - this.disabledControl = disabledControl; - this.controlDecorations = controlDecorations; - initialized = false; - enabled = false; - } - } - - /** - * Local workaround class to react on changes of a radio group field editor. By - * default the selection listener is set to the containing page, so we need a - * second listener mechanism. - */ - private final class RadioGroupFieldEditorWithAction extends RadioGroupFieldEditor { - - private IPropertyChangeListener propertyChangeListener; - - public RadioGroupFieldEditorWithAction(String name, String labelText, int numColumns, String[][] labelAndValues, - Composite parent) { - super(name, labelText, numColumns, labelAndValues, parent); - } - - @Override - protected void fireValueChanged(String property, Object oldValue, Object newValue) { - super.fireValueChanged(property, oldValue, newValue); - if (propertyChangeListener != null) { - propertyChangeListener.propertyChange(new PropertyChangeEvent(this, property, oldValue, newValue)); - } - - } - - public void setAdditionalPropertyChangeListener(IPropertyChangeListener propertyChangeListener) { - this.propertyChangeListener = propertyChangeListener; - - } - } - - /** - * Property change listener to set the enabled state of the output folder path - * field based on the output folder mode field. - */ - private final class OutputFolderModeChangeListener implements IPropertyChangeListener { - - private Composite outputFolderPathFieldEditorParent; - private StringFieldEditor outputFolderPathFieldEditor; - - public OutputFolderModeChangeListener(Composite outputFolderPathFieldEditorParent, - StringFieldEditor outputFolderPathFieldEditor) { - if (outputFolderPathFieldEditorParent == null) { - throw new IllegalArgumentException("Parameter 'outputFolderPathFieldEditorParent' must not be null."); - } - if (outputFolderPathFieldEditor == null) { - throw new IllegalArgumentException("Parameter 'outputFolderPathFieldEditor' must not be null."); - } - this.outputFolderPathFieldEditorParent = outputFolderPathFieldEditorParent; - this.outputFolderPathFieldEditor = outputFolderPathFieldEditor; - } - - @Override - public void propertyChange(PropertyChangeEvent event) { - if (event == null) { - throw new IllegalArgumentException("Parameter 'event' must not be null."); - } - setOutputFolderMode((String) event.getNewValue()); - } - - public void setOutputFolderMode(String newValue) { - var enabled = CompilerOutputFolderMode.FIXED_FOLDER.equals(newValue); - outputFolderPathFieldEditor.setEnabled(enabled, outputFolderPathFieldEditorParent); - } - - } - - /** - * The language. - */ - final Language language; - - /** - * The type of hardware used to filter the compilers and emulators. - */ - final Hardware hardware; - - /** - * The owning plugin. - */ - private final LanguagePlugin plugin; - - /** - * The tab folder and all visible tab items. - */ - private TabFolder tabFolder; - private final Map tabs; - - /** - * The id of the compiler and runner to be used as default. - */ - private String activeCompilerId; - private String activeRunnerId; - - /** - * Creation is protected for sub-classes. - * - * @param hardware The type of hardware used to filter the compilers and - * emulators, not null. - */ - protected LanguagePreferencesCompilersPage(Language language, Hardware hardware) { - super(GRID); - if (language == null) { - throw new IllegalArgumentException("Parameter 'language' must not be null."); - } - if (hardware == null) { - throw new IllegalArgumentException("Parameter 'hardware' must not be null."); - } - this.language = language; - this.hardware = hardware; - plugin = LanguagePlugin.getInstance(); - IPreferenceStore preferencesStore = plugin.getPreferenceStore(); - setPreferenceStore(preferencesStore); - - tabs = new TreeMap(); - } - - @Override - public final void init(IWorkbench workbench) { - if (workbench == null) { - throw new IllegalArgumentException("Parameter 'workbench' must not be null."); - } - var editor = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - if (editor instanceof LanguageEditor) { - LanguageEditor languageEditor; - languageEditor = (LanguageEditor) editor; - activeCompilerId = languageEditor.getCompilerDefinition().getId(); - activeRunnerId = languageEditor.getCompilerPreferences().getRunnerId(); - } else { - activeCompilerId = ""; - activeRunnerId = ""; - } - } - - @Override - public final void createFieldEditors() { - - var parent = getFieldEditorParent(); - var gridData = new GridData(); - gridData.verticalIndent = 0; - gridData.horizontalIndent = 0; - parent.setLayoutData(gridData); - - createCompilerFieldEditors(parent); - setTabsStatus(); - } - - private void createCompilerFieldEditors(Composite parent) { - if (parent == null) { - throw new IllegalArgumentException("Parameter 'parent' must not be null."); - } - - // Create the editors for all compilers of the hardware. - var compilerRegistry = plugin.getCompilerRegistry(); - var compilerDefinitions = compilerRegistry.getCompilerDefinitions(language); - - tabFolder = new TabFolder(parent, SWT.FLAT); - for (var compilerDefinition : compilerDefinitions) { - - createTabItem(tabFolder, compilerDefinition); - } - - // Default to tab item for active compiler or to first. - TabItem selectedTabItem = null; - if (activeCompilerId != null) { - var selectedTab = tabs.get(activeCompilerId); - if (selectedTab != null) { - selectedTabItem = selectedTab.tabItem; - } - } - if (selectedTabItem == null && tabFolder.getItemCount() > 0) { - selectedTabItem = tabFolder.getItem(0); - } - if (selectedTabItem != null) { - tabFolder.setSelection(selectedTabItem); - } - - // Make sure the control decorations are updated as required - tabFolder.addSelectionListener(new SelectionListener() { - - @Override - public void widgetSelected(SelectionEvent e) { - setTabsStatus(); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - } - - private void createTabItem(TabFolder tabFolder, CompilerDefinition compilerDefinition) { - if (tabFolder == null) { - throw new IllegalArgumentException("Parameter 'tabFolder' must not be null."); - } - if (compilerDefinition == null) { - throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null."); - } - - var labelsAndValues = new String[][] { - { Texts.PREFERENCES_COMPILER_OUTPUT_FOLDER_MODE_SOURCE_FOLDER_TEXT, - CompilerOutputFolderMode.SOURCE_FOLDER }, - { Texts.PREFERENCES_COMPILER_OUTPUT_FOLDER_MODE_TEMP_FOLDER_TEXT, - CompilerOutputFolderMode.TEMP_FOLDER }, - { Texts.PREFERENCES_COMPILER_OUTPUT_FOLDER_MODE_FIXED_FOLDER_TEXT, - CompilerOutputFolderMode.FIXED_FOLDER } - - }; - - var compilerId = compilerDefinition.getId(); - var tabItem = new TabItem(tabFolder, SWT.NONE); - tabItem.setText(compilerDefinition.getName()); - - var tabContent = SWTFactory.createComposite(tabFolder, 1, 1, GridData.FILL_BOTH); - - List controlDecorations; - controlDecorations = new ArrayList(); - - // Field: target - var composite = SWTFactory.createComposite(tabContent, 2, 3, GridData.FILL_HORIZONTAL); - - // Filtering of Target based on hardware is currently not implemented - // because expansion boards like a W65816 board might be there/added - // for a hardware. - var targets = compilerDefinition.getSupportedTargets(); - String[][] entryNamesAndValues = new String[targets.size()][]; - int i = 0; - for (var target : targets) { - entryNamesAndValues[i] = new String[2]; - entryNamesAndValues[i][1] = target.name(); - entryNamesAndValues[i][0] = EnumUtility.getText(target); - i++; - } - - var comboFieldEditor = new ComboFieldEditor( - LanguagePreferencesConstants.getCompilerTargetName(compilerId, hardware), - Texts.PREFERENCES_COMPILER_TARGET_LABEL, entryNamesAndValues, composite); - comboFieldEditor.setEnabled(entryNamesAndValues.length > 1, composite); - addField(comboFieldEditor); - - // Field: defaultParameters - composite = SWTFactory.createComposite(tabContent, 2, 2, GridData.FILL_HORIZONTAL); - - var label = new Label(composite, SWT.LEFT); - label.setText(Texts.PREFERENCES_COMPILER_DEFAULT_PARAMETERS_LABEL); - var textField = new Text(composite, SWT.SINGLE | SWT.BORDER); - textField.setEditable(false); - textField.setText(compilerDefinition.getDefaultParameters()); - var gd = new GridData(); - gd.horizontalSpan = 2; - gd.horizontalAlignment = GridData.FILL; - gd.grabExcessHorizontalSpace = true; - textField.setLayoutData(gd); - - // Field: parameters - composite = SWTFactory.createComposite(tabContent, 2, 2, GridData.FILL_HORIZONTAL); - var name = LanguagePreferencesConstants.getCompilerParametersName(compilerId, hardware); - var parametersFieldEditor = new StringFieldEditor(name, Texts.PREFERENCES_COMPILER_PARAMETERS_LABEL, - tabContent); - - var compilerParametersHelp = Texts.PREFERENCES_COMPILER_PARAMETERS_HELP + "\n" - + Texts.PREFERENCES_COMPILER_PARAMETERS_VARIABLES; - controlDecorations.add(createHelpDecoration(parametersFieldEditor, tabContent, compilerParametersHelp)); - - gd = new GridData(); - gd.horizontalSpan = 1; - gd.horizontalAlignment = GridData.FILL; - gd.grabExcessHorizontalSpace = true; - gd.horizontalIndent = 14; - parametersFieldEditor.getTextControl(tabContent).setLayoutData(gd); - - addField(parametersFieldEditor); - - // Field: outputFolderMode - composite = SWTFactory.createComposite(tabContent, 2, 2, GridData.FILL_HORIZONTAL); - var outputFolderModeChoiceEditor = new RadioGroupFieldEditorWithAction( - LanguagePreferencesConstants.getCompilerOutputFolderModeName(compilerId, hardware), - Texts.PREFERENCES_COMPILER_OUTPUT_FOLDER_MODE_LABEL, 3, labelsAndValues, composite); - addField(outputFolderModeChoiceEditor); - - // Field: outputFolderPath - composite = SWTFactory.createComposite(tabContent, 2, 2, GridData.FILL_HORIZONTAL); - var outputFolderPathFieldEditor = new DirectoryFieldDownloadEditor( - LanguagePreferencesConstants.getCompilerOutputFolderPathName(compilerId, hardware), - Texts.PREFERENCES_COMPILER_OUTPUT_FOLDER_PATH_LABEL, composite); - addField(outputFolderPathFieldEditor); - - // Create a connection between the output mode field and the output - // path field. - var outputFolderModeChangeListener = new OutputFolderModeChangeListener(composite, outputFolderPathFieldEditor); - // Set initial status based on current output folder mode. - outputFolderModeChangeListener - .setOutputFolderMode(getPreferenceStore().getString(outputFolderModeChoiceEditor.getPreferenceName())); - // Register for changes. - outputFolderModeChoiceEditor.setAdditionalPropertyChangeListener(outputFolderModeChangeListener); - - // Field: outputFileExtension - composite = SWTFactory.createComposite(tabContent, 2, 2, GridData.FILL_HORIZONTAL); - var outputFileExtensionFieldEditor = new StringFieldEditor( - LanguagePreferencesConstants.getCompilerOutputFileExtensionName(compilerId, hardware), - Texts.PREFERENCES_COMPILER_OUTPUT_FILE_EXTENSION_LABEL, composite); - - gd = new GridData(SWT.BEGINNING, SWT.FILL, true, false); - gd.widthHint = convertWidthInCharsToPixels(5); - outputFileExtensionFieldEditor.getTextControl(composite).setLayoutData(gd); - outputFileExtensionFieldEditor.getTextControl(composite); - addField(outputFileExtensionFieldEditor); - - composite = SWTFactory.createComposite(tabContent, 1, 2, GridData.FILL_HORIZONTAL); - - var runnerRegistry = plugin.getRunnerRegistry(); - var runnerDefinitions = runnerRegistry.getDefinitions(hardware); - entryNamesAndValues = new String[runnerDefinitions.size()][]; - i = 0; - for (var runnerDefinition : runnerDefinitions) { - entryNamesAndValues[i] = new String[2]; - entryNamesAndValues[i][1] = runnerDefinition.getId(); - entryNamesAndValues[i][0] = runnerDefinition.getName(); - i++; - } - comboFieldEditor = new ComboFieldEditor( - LanguagePreferencesConstants.getCompilerRunnerIdName(compilerId, hardware), - Texts.PREFERENCES_COMPILER_RUNNER_ID_LABEL, entryNamesAndValues, composite); - addField(comboFieldEditor); - createRunnerFieldEdiors(compilerId, composite, controlDecorations); - - var disabledControl = SWTFactory.createComposite(tabFolder, 1, 1, GridData.FILL_BOTH); - label = new Label(disabledControl, SWT.NONE); - - // ERROR: Path to {0} '{1}' executable is not set in the '{2}' preferences. - var compilerPreferencesText = LanguageUtility.getCompilerPreferencesText(compilerDefinition.getLanguage()); - label.setText(TextUtility.format(Texts.MESSAGE_E100, compilerDefinition.getText(), compilerDefinition.getName(), - compilerPreferencesText)); - var tab = new Tab(compilerDefinition, tabs.size(), tabItem, tabContent, disabledControl, controlDecorations); - tabs.put(compilerId, tab); - - } - - void setTabsStatus() { - for (Tab tab : tabs.values()) { - setTabStatus(tab); - - } - } - - private void setTabStatus(Tab tab) { - if (tab == null) { - throw new IllegalArgumentException("Parameter 'tab' must not be null."); - } - - var languagePreferences = plugin.getLanguagePreferences(language); - var compilerPreferences = languagePreferences.getCompilerPreferences(tab.compilerDefinition, hardware); - var enabled = StringUtility.isSpecified(compilerPreferences.getCompilerExecutablePathOrDefault()); - - if (!tab.initialized || enabled != tab.enabled) { - tab.initialized = true; - tab.enabled = enabled; - if (enabled) { - tab.tabItem.setControl(tab.enabledControl); - } else { - tab.tabItem.setControl(tab.disabledControl); - } - tab.disabledControl.setVisible(!enabled); - tab.enabledControl.setVisible(enabled); - } - var tabActive = tab.tabIndex == tabFolder.getSelectionIndex(); - for (var controlDecoration : tab.controlDecorations) { - if (enabled && tabActive) { - controlDecoration.show(); - } else { - controlDecoration.hide(); - } - } - - } - - private void createRunnerFieldEdiors(String compilerId, Composite parent, - List controlDecorations) { - if (compilerId == null) { - throw new IllegalArgumentException("Parameter 'compilerId' must not be null."); - } - if (parent == null) { - throw new IllegalArgumentException("Parameter 'parent' must not be null."); - } - if (controlDecorations == null) { - throw new IllegalArgumentException("Parameter 'controlDecorations' must not be null."); - } - - var tabFolder = new TabFolder(parent, SWT.NONE); - TabItem selectedTabItem = null; - - var gd = new GridData(); - gd.horizontalSpan = 1; - gd.horizontalAlignment = GridData.FILL; - gd.grabExcessHorizontalSpace = true; - tabFolder.setLayoutData(gd); - - var runnerRegistry = plugin.getRunnerRegistry(); - var runnerDefinitions = runnerRegistry.getDefinitions(hardware); - var runnerPaths = plugin.getRunnerPaths(); - - var runnerCommandLineHelp = Texts.PREFERENCES_COMPILER_RUNNER_COMMAND_LINE_HELP + "\n" - + Texts.PREFERENCES_COMPILER_RUNNER_COMMAND_LINE_VARIABLES; - - for (var runnerDefinition : runnerDefinitions) { - - var runnerId = runnerDefinition.getId(); - - if (runnerId.equals(RunnerId.DEFAULT_APPLICATION)) { - continue; - } - - var tabItem = new TabItem(tabFolder, SWT.NONE); - tabItem.setText(runnerDefinition.getName()); - - var tabContent = SWTFactory.createComposite(tabFolder, 2, 1, GridData.FILL_BOTH); - - var name = LanguagePreferencesConstants.getCompilerRunnerExecutablePathName(compilerId, hardware, runnerId); - - var composite = SWTFactory.createComposite(tabContent, 4, 2, GridData.FILL_HORIZONTAL); - var fileFieldEditor = new FileFieldDownloadEditor(name, - Texts.PREFERENCES_COMPILER_RUNNER_EXECUTABLE_PATH_LABEL, composite); - var runnerPath = runnerPaths.getDefaultRunnerPath(hardware, runnerId); - if (runnerPath != null) { - var file = runnerPath.getAbsoluteFile(); - if (file != null) { - fileFieldEditor.setFilterPath(file.getParentFile()); - } - } - fileFieldEditor.setFileExtensions(ProcessWithLogs.getExecutableExtensions()); - fileFieldEditor.setEnabled(runnerDefinition.isRunnerExecutablePathPossible(), composite); - addField(fileFieldEditor); - - // Field: defaultEmulatorParameters - composite = SWTFactory.createComposite(tabContent, 2, 2, GridData.FILL_HORIZONTAL); - - var label = new Label(composite, SWT.LEFT); - label.setText(Texts.PREFERENCES_COMPILER_RUNNER_DEFAULT_COMMAND_LINE_LABEL); - var textField = new Text(composite, SWT.SINGLE | SWT.BORDER); - textField.setEditable(false); - textField.setText(runnerDefinition.getDefaultCommandLine()); - gd = new GridData(); - gd.horizontalSpan = 2; - gd.horizontalAlignment = GridData.FILL; - gd.grabExcessHorizontalSpace = true; - textField.setLayoutData(gd); - - // Field: parameters - composite = SWTFactory.createComposite(tabContent, 2, 2, GridData.FILL_HORIZONTAL); - name = LanguagePreferencesConstants.getCompilerRunnerCommandLineName(compilerId, hardware, runnerId); - var commandLineFieldEditor = new StringFieldEditor(name, - Texts.PREFERENCES_COMPILER_RUNNER_COMMAND_LINE_LABEL, tabContent); - - gd = new GridData(); - gd.horizontalSpan = 1; - gd.horizontalAlignment = GridData.FILL; - gd.grabExcessHorizontalSpace = true; - gd.horizontalIndent = 14; - commandLineFieldEditor.getTextControl(tabContent).setLayoutData(gd); - addField(commandLineFieldEditor); - - controlDecorations.add(createHelpDecoration(commandLineFieldEditor, tabContent, runnerCommandLineHelp)); - var url = runnerDefinition.getHomePageURL(); - fileFieldEditor.setLinkURL(url); - - // Field: illegalOpcodesVisible - composite = SWTFactory.createComposite(tabContent, 2, 3, GridData.FILL_HORIZONTAL); - FieldEditor booleanFieldEditor = new BooleanFieldEditor( - LanguagePreferencesConstants.getCompilerRunnerWaitForCompletionName(compilerId, hardware, runnerId), - Texts.PREFERENCES_COMPILER_RUNNER_WAIT_FOR_COMPLETION_LABEL, composite); - - addField(booleanFieldEditor); - - tabItem.setControl(tabContent); - - if (runnerId.equals(activeRunnerId)) { - selectedTabItem = tabItem; - } - - } - - // Default to selected tab item. - if (selectedTabItem != null) { - tabFolder.setSelection(selectedTabItem); - } - } - - private ControlDecoration createHelpDecoration(StringFieldEditor parametersFieldEditor, Composite tabContent, - String text) { - if (parametersFieldEditor == null) { - throw new IllegalArgumentException("Parameter 'parametersFieldEditor' must not be null."); - } - if (tabContent == null) { - throw new IllegalArgumentException("Parameter 'tabContent' must not be null."); - } - if (text == null) { - throw new IllegalArgumentException("Parameter 'text' must not be null."); - } - var textControl = parametersFieldEditor.getTextControl(tabContent); - var controlDecoration = new ControlDecoration(textControl, SWT.LEFT | SWT.CENTER); - controlDecoration.hide(); - controlDecoration.setShowHover(true); - controlDecoration.setDescriptionText(text); - - controlDecoration.setImage(LanguagePlugin.getInstance().getImage("help-16x16.gif")); - - return controlDecoration; - } - - /** - * {@inheritDoc} - */ - @Override - public final boolean performOk() { - if (super.performOk()) { - saveChanges(); - return true; - } - return false; - } - - /** - * The field editor preference page implementation of a - * PreferencePage method loads all the field editors with their - * default values except for the executable paths. - */ - @Override - protected final void performDefaults() { - - super.performDefaults(); - - } - - @Override - public final void dispose() { - super.dispose(); - - } - - @Override - public void setVisible(boolean visible) { - super.setVisible(visible); - - if (visible) { - setTabsStatus(); - } - - } - - /** - * Saves all changes to the {@link IPreferenceStore}. - */ - private void saveChanges() { - - plugin.savePreferences(); - - } -} +/** + * Copyright (C) 2009 - 2021 Peter Dell + * + * 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 . + */ + +package com.wudsn.ide.lng.preferences; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import org.eclipse.jface.fieldassist.ControlDecoration; +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.ComboFieldEditor; +import org.eclipse.jface.preference.FieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.RadioGroupFieldEditor; +import org.eclipse.jface.preference.StringFieldEditor; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.TabItem; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +import com.wudsn.ide.base.common.EnumUtility; +import com.wudsn.ide.base.common.ProcessWithLogs; +import com.wudsn.ide.base.common.StringUtility; +import com.wudsn.ide.base.common.TextUtility; +import com.wudsn.ide.base.gui.SWTFactory; +import com.wudsn.ide.base.hardware.Hardware; +import com.wudsn.ide.lng.Language; +import com.wudsn.ide.lng.LanguagePlugin; +import com.wudsn.ide.lng.LanguageUtility; +import com.wudsn.ide.lng.Texts; +import com.wudsn.ide.lng.compiler.CompilerDefinition; +import com.wudsn.ide.lng.compiler.CompilerOutputFolderMode; +import com.wudsn.ide.lng.editor.LanguageEditor; +import com.wudsn.ide.lng.runner.RunnerId; + +/** + * Visual editor page for the language preferences regarding compilers. There is + * a separate page per {@link Hardware}. Subclasses only implement the + * constructor. + * + * @author Peter Dell + */ +public abstract class LanguageHardwarePreferencesPage extends FieldEditorPreferencePage + implements IWorkbenchPreferencePage { + + private static final class Tab { + + public final CompilerDefinition compilerDefinition; + public final int tabIndex; + public final TabItem tabItem; + public final Control enabledControl; + public final Control disabledControl; + public final List controlDecorations; + public boolean initialized; + public boolean enabled; + + public Tab(CompilerDefinition compilerDefinition, int tabIndex, TabItem tabItem, Control enabledControl, + Control disabledControl, List controlDecorations) { + this.compilerDefinition = compilerDefinition; + this.tabIndex = tabIndex; + this.tabItem = tabItem; + this.enabledControl = enabledControl; + this.disabledControl = disabledControl; + this.controlDecorations = controlDecorations; + initialized = false; + enabled = false; + } + } + + /** + * Local workaround class to react on changes of a radio group field editor. By + * default the selection listener is set to the containing page, so we need a + * second listener mechanism. + */ + private final class RadioGroupFieldEditorWithAction extends RadioGroupFieldEditor { + + private IPropertyChangeListener propertyChangeListener; + + public RadioGroupFieldEditorWithAction(String name, String labelText, int numColumns, String[][] labelAndValues, + Composite parent) { + super(name, labelText, numColumns, labelAndValues, parent); + } + + @Override + protected void fireValueChanged(String property, Object oldValue, Object newValue) { + super.fireValueChanged(property, oldValue, newValue); + if (propertyChangeListener != null) { + propertyChangeListener.propertyChange(new PropertyChangeEvent(this, property, oldValue, newValue)); + } + + } + + public void setAdditionalPropertyChangeListener(IPropertyChangeListener propertyChangeListener) { + this.propertyChangeListener = propertyChangeListener; + + } + } + + /** + * Property change listener to set the enabled state of the output folder path + * field based on the output folder mode field. + */ + private final class OutputFolderModeChangeListener implements IPropertyChangeListener { + + private Composite outputFolderPathFieldEditorParent; + private StringFieldEditor outputFolderPathFieldEditor; + + public OutputFolderModeChangeListener(Composite outputFolderPathFieldEditorParent, + StringFieldEditor outputFolderPathFieldEditor) { + if (outputFolderPathFieldEditorParent == null) { + throw new IllegalArgumentException("Parameter 'outputFolderPathFieldEditorParent' must not be null."); + } + if (outputFolderPathFieldEditor == null) { + throw new IllegalArgumentException("Parameter 'outputFolderPathFieldEditor' must not be null."); + } + this.outputFolderPathFieldEditorParent = outputFolderPathFieldEditorParent; + this.outputFolderPathFieldEditor = outputFolderPathFieldEditor; + } + + @Override + public void propertyChange(PropertyChangeEvent event) { + if (event == null) { + throw new IllegalArgumentException("Parameter 'event' must not be null."); + } + setOutputFolderMode((String) event.getNewValue()); + } + + public void setOutputFolderMode(String newValue) { + var enabled = CompilerOutputFolderMode.FIXED_FOLDER.equals(newValue); + outputFolderPathFieldEditor.setEnabled(enabled, outputFolderPathFieldEditorParent); + } + + } + + /** + * The language. + */ + final Language language; + + /** + * The type of hardware used to filter the compilers and emulators. + */ + final Hardware hardware; + + /** + * The owning plugin. + */ + private final LanguagePlugin plugin; + + /** + * The tab folder and all visible tab items. + */ + private TabFolder tabFolder; + private final Map tabs; + + /** + * The id of the compiler and runner to be used as default. + */ + private String activeCompilerId; + private String activeRunnerId; + + /** + * Creation is protected for sub-classes. + * + * @param hardware The type of hardware used to filter the compilers and + * emulators, not null. + */ + protected LanguageHardwarePreferencesPage(Language language, Hardware hardware) { + super(GRID); + if (language == null) { + throw new IllegalArgumentException("Parameter 'language' must not be null."); + } + if (hardware == null) { + throw new IllegalArgumentException("Parameter 'hardware' must not be null."); + } + this.language = language; + this.hardware = hardware; + plugin = LanguagePlugin.getInstance(); + IPreferenceStore preferencesStore = plugin.getPreferenceStore(); + setPreferenceStore(preferencesStore); + + tabs = new TreeMap(); + } + + @Override + public final void init(IWorkbench workbench) { + if (workbench == null) { + throw new IllegalArgumentException("Parameter 'workbench' must not be null."); + } + var editor = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor(); + if (editor instanceof LanguageEditor) { + LanguageEditor languageEditor; + languageEditor = (LanguageEditor) editor; + activeCompilerId = languageEditor.getCompilerDefinition().getId(); + activeRunnerId = languageEditor.getLanguageHardwareCompilerPreferences().getRunnerId(); + } else { + activeCompilerId = ""; + activeRunnerId = ""; + } + } + + @Override + public final void createFieldEditors() { + + var parent = getFieldEditorParent(); + var gridData = new GridData(); + gridData.verticalIndent = 0; + gridData.horizontalIndent = 0; + parent.setLayoutData(gridData); + + createCompilerFieldEditors(parent); + setTabsStatus(); + } + + private void createCompilerFieldEditors(Composite parent) { + if (parent == null) { + throw new IllegalArgumentException("Parameter 'parent' must not be null."); + } + + // Create the editors for all compilers of the hardware. + var compilerRegistry = plugin.getCompilerRegistry(); + var compilerDefinitions = compilerRegistry.getCompilerDefinitions(language); + + tabFolder = new TabFolder(parent, SWT.FLAT); + for (var compilerDefinition : compilerDefinitions) { + + createTabItem(tabFolder, compilerDefinition); + } + + // Default to tab item for active compiler or to first. + TabItem selectedTabItem = null; + if (activeCompilerId != null) { + var selectedTab = tabs.get(activeCompilerId); + if (selectedTab != null) { + selectedTabItem = selectedTab.tabItem; + } + } + if (selectedTabItem == null && tabFolder.getItemCount() > 0) { + selectedTabItem = tabFolder.getItem(0); + } + if (selectedTabItem != null) { + tabFolder.setSelection(selectedTabItem); + } + + // Make sure the control decorations are updated as required + tabFolder.addSelectionListener(new SelectionListener() { + + @Override + public void widgetSelected(SelectionEvent e) { + setTabsStatus(); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + } + + private void createTabItem(TabFolder tabFolder, CompilerDefinition compilerDefinition) { + if (tabFolder == null) { + throw new IllegalArgumentException("Parameter 'tabFolder' must not be null."); + } + if (compilerDefinition == null) { + throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null."); + } + + var labelsAndValues = new String[][] { + { Texts.PREFERENCES_COMPILER_OUTPUT_FOLDER_MODE_SOURCE_FOLDER_TEXT, + CompilerOutputFolderMode.SOURCE_FOLDER }, + { Texts.PREFERENCES_COMPILER_OUTPUT_FOLDER_MODE_TEMP_FOLDER_TEXT, + CompilerOutputFolderMode.TEMP_FOLDER }, + { Texts.PREFERENCES_COMPILER_OUTPUT_FOLDER_MODE_FIXED_FOLDER_TEXT, + CompilerOutputFolderMode.FIXED_FOLDER } + + }; + + var compilerId = compilerDefinition.getId(); + var tabItem = new TabItem(tabFolder, SWT.NONE); + tabItem.setText(compilerDefinition.getName()); + + var tabContent = SWTFactory.createComposite(tabFolder, 1, 1, GridData.FILL_BOTH); + + List controlDecorations; + controlDecorations = new ArrayList(); + + // Field: target + var composite = SWTFactory.createComposite(tabContent, 2, 3, GridData.FILL_HORIZONTAL); + + // Filtering of Target based on hardware is currently not implemented + // because expansion boards like a W65816 board might be there/added + // for a hardware. + var targets = compilerDefinition.getSupportedTargets(); + String[][] entryNamesAndValues = new String[targets.size()][]; + int i = 0; + for (var target : targets) { + entryNamesAndValues[i] = new String[2]; + entryNamesAndValues[i][1] = target.name(); + entryNamesAndValues[i][0] = EnumUtility.getText(target); + i++; + } + + var comboFieldEditor = new ComboFieldEditor( + LanguageHardwareCompilerDefinitionPreferencesConstants.getCompilerTargetName(language, hardware, compilerDefinition), + Texts.PREFERENCES_COMPILER_TARGET_LABEL, entryNamesAndValues, composite); + comboFieldEditor.setEnabled(entryNamesAndValues.length > 1, composite); + addField(comboFieldEditor); + + // Field: defaultParameters + composite = SWTFactory.createComposite(tabContent, 2, 2, GridData.FILL_HORIZONTAL); + + var label = new Label(composite, SWT.LEFT); + label.setText(Texts.PREFERENCES_COMPILER_DEFAULT_PARAMETERS_LABEL); + var textField = new Text(composite, SWT.SINGLE | SWT.BORDER); + textField.setEditable(false); + textField.setText(compilerDefinition.getDefaultParameters()); + var gd = new GridData(); + gd.horizontalSpan = 2; + gd.horizontalAlignment = GridData.FILL; + gd.grabExcessHorizontalSpace = true; + textField.setLayoutData(gd); + + // Field: parameters + composite = SWTFactory.createComposite(tabContent, 2, 2, GridData.FILL_HORIZONTAL); + var name = LanguageHardwareCompilerDefinitionPreferencesConstants.getCompilerParametersName(language, hardware, compilerDefinition); + var parametersFieldEditor = new StringFieldEditor(name, Texts.PREFERENCES_COMPILER_PARAMETERS_LABEL, + tabContent); + + var compilerParametersHelp = Texts.PREFERENCES_COMPILER_PARAMETERS_HELP + "\n" + + Texts.PREFERENCES_COMPILER_PARAMETERS_VARIABLES; + controlDecorations.add(createHelpDecoration(parametersFieldEditor, tabContent, compilerParametersHelp)); + + gd = new GridData(); + gd.horizontalSpan = 1; + gd.horizontalAlignment = GridData.FILL; + gd.grabExcessHorizontalSpace = true; + gd.horizontalIndent = 14; + parametersFieldEditor.getTextControl(tabContent).setLayoutData(gd); + + addField(parametersFieldEditor); + + // Field: outputFolderMode + composite = SWTFactory.createComposite(tabContent, 2, 2, GridData.FILL_HORIZONTAL); + var outputFolderModeChoiceEditor = new RadioGroupFieldEditorWithAction( + LanguageHardwareCompilerDefinitionPreferencesConstants.getCompilerOutputFolderModeName(language, hardware, compilerDefinition), + Texts.PREFERENCES_COMPILER_OUTPUT_FOLDER_MODE_LABEL, 3, labelsAndValues, composite); + addField(outputFolderModeChoiceEditor); + + // Field: outputFolderPath + composite = SWTFactory.createComposite(tabContent, 2, 2, GridData.FILL_HORIZONTAL); + var outputFolderPathFieldEditor = new DirectoryFieldDownloadEditor( + LanguageHardwareCompilerDefinitionPreferencesConstants.getCompilerOutputFolderPathName(language, hardware, compilerDefinition), + Texts.PREFERENCES_COMPILER_OUTPUT_FOLDER_PATH_LABEL, composite); + addField(outputFolderPathFieldEditor); + + // Create a connection between the output mode field and the output + // path field. + var outputFolderModeChangeListener = new OutputFolderModeChangeListener(composite, outputFolderPathFieldEditor); + // Set initial status based on current output folder mode. + outputFolderModeChangeListener + .setOutputFolderMode(getPreferenceStore().getString(outputFolderModeChoiceEditor.getPreferenceName())); + // Register for changes. + outputFolderModeChoiceEditor.setAdditionalPropertyChangeListener(outputFolderModeChangeListener); + + // Field: outputFileExtension + composite = SWTFactory.createComposite(tabContent, 2, 2, GridData.FILL_HORIZONTAL); + var outputFileExtensionFieldEditor = new StringFieldEditor( + LanguageHardwareCompilerDefinitionPreferencesConstants.getCompilerOutputFileExtensionName(language, hardware, compilerDefinition), + Texts.PREFERENCES_COMPILER_OUTPUT_FILE_EXTENSION_LABEL, composite); + + gd = new GridData(SWT.BEGINNING, SWT.FILL, true, false); + gd.widthHint = convertWidthInCharsToPixels(5); + outputFileExtensionFieldEditor.getTextControl(composite).setLayoutData(gd); + outputFileExtensionFieldEditor.getTextControl(composite); + addField(outputFileExtensionFieldEditor); + + composite = SWTFactory.createComposite(tabContent, 1, 2, GridData.FILL_HORIZONTAL); + + var runnerRegistry = plugin.getRunnerRegistry(); + var runnerDefinitions = runnerRegistry.getDefinitions(hardware); + entryNamesAndValues = new String[runnerDefinitions.size()][]; + i = 0; + for (var runnerDefinition : runnerDefinitions) { + entryNamesAndValues[i] = new String[2]; + entryNamesAndValues[i][1] = runnerDefinition.getId(); + entryNamesAndValues[i][0] = runnerDefinition.getName(); + i++; + } + comboFieldEditor = new ComboFieldEditor( + LanguageHardwareCompilerDefinitionPreferencesConstants.getCompilerRunnerIdName(language, hardware, compilerDefinition), + Texts.PREFERENCES_COMPILER_RUNNER_ID_LABEL, entryNamesAndValues, composite); + addField(comboFieldEditor); + createRunnerFieldEdiors(compilerDefinition, composite, controlDecorations); + + var disabledControl = SWTFactory.createComposite(tabFolder, 1, 1, GridData.FILL_BOTH); + label = new Label(disabledControl, SWT.NONE); + + // ERROR: Path to {0} '{1}' executable is not set in the '{2}' preferences. + var compilerPreferencesText = LanguageUtility.getCompilerPreferencesText(compilerDefinition.getLanguage()); + label.setText(TextUtility.format(Texts.MESSAGE_E100, compilerDefinition.getText(), compilerDefinition.getName(), + compilerPreferencesText)); + var tab = new Tab(compilerDefinition, tabs.size(), tabItem, tabContent, disabledControl, controlDecorations); + tabs.put(compilerId, tab); + + } + + void setTabsStatus() { + for (Tab tab : tabs.values()) { + setTabStatus(tab); + + } + } + + private void setTabStatus(Tab tab) { + if (tab == null) { + throw new IllegalArgumentException("Parameter 'tab' must not be null."); + } + + var languagePreferences = plugin.getLanguagePreferences(language); + var enabled = StringUtility + .isSpecified(languagePreferences.getCompilerExecutablePathOrDefault(tab.compilerDefinition)); + + if (!tab.initialized || enabled != tab.enabled) { + tab.initialized = true; + tab.enabled = enabled; + if (enabled) { + tab.tabItem.setControl(tab.enabledControl); + } else { + tab.tabItem.setControl(tab.disabledControl); + } + tab.disabledControl.setVisible(!enabled); + tab.enabledControl.setVisible(enabled); + } + var tabActive = tab.tabIndex == tabFolder.getSelectionIndex(); + for (var controlDecoration : tab.controlDecorations) { + if (enabled && tabActive) { + controlDecoration.show(); + } else { + controlDecoration.hide(); + } + } + + } + + private void createRunnerFieldEdiors(CompilerDefinition compilerDefinition, Composite parent, + List controlDecorations) { + if (compilerDefinition == null) { + throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null."); + } + if (parent == null) { + throw new IllegalArgumentException("Parameter 'parent' must not be null."); + } + if (controlDecorations == null) { + throw new IllegalArgumentException("Parameter 'controlDecorations' must not be null."); + } + + var tabFolder = new TabFolder(parent, SWT.NONE); + TabItem selectedTabItem = null; + + var gd = new GridData(); + gd.horizontalSpan = 1; + gd.horizontalAlignment = GridData.FILL; + gd.grabExcessHorizontalSpace = true; + tabFolder.setLayoutData(gd); + + var runnerRegistry = plugin.getRunnerRegistry(); + var runnerDefinitions = runnerRegistry.getDefinitions(hardware); + var runnerPaths = plugin.getRunnerPaths(); + + var runnerCommandLineHelp = Texts.PREFERENCES_COMPILER_RUNNER_COMMAND_LINE_HELP + "\n" + + Texts.PREFERENCES_COMPILER_RUNNER_COMMAND_LINE_VARIABLES; + + for (var runnerDefinition : runnerDefinitions) { + + var runnerId = runnerDefinition.getId(); + + if (runnerId.equals(RunnerId.DEFAULT_APPLICATION)) { + continue; + } + + var tabItem = new TabItem(tabFolder, SWT.NONE); + tabItem.setText(runnerDefinition.getName()); + + var tabContent = SWTFactory.createComposite(tabFolder, 2, 1, GridData.FILL_BOTH); + + var name = LanguageHardwareCompilerDefinitionPreferencesConstants.getCompilerRunnerExecutablePathName(language, hardware, compilerDefinition, + runnerId); + + var composite = SWTFactory.createComposite(tabContent, 4, 2, GridData.FILL_HORIZONTAL); + var fileFieldEditor = new FileFieldDownloadEditor(name, + Texts.PREFERENCES_COMPILER_RUNNER_EXECUTABLE_PATH_LABEL, composite); + var runnerPath = runnerPaths.getDefaultRunnerPath(hardware, runnerId); + if (runnerPath != null) { + var file = runnerPath.getAbsoluteFile(); + if (file != null) { + fileFieldEditor.setFilterPath(file.getParentFile()); + } + } + fileFieldEditor.setFileExtensions(ProcessWithLogs.getExecutableExtensions()); + fileFieldEditor.setEnabled(runnerDefinition.isRunnerExecutablePathPossible(), composite); + addField(fileFieldEditor); + + // Field: defaultEmulatorParameters + composite = SWTFactory.createComposite(tabContent, 2, 2, GridData.FILL_HORIZONTAL); + + var label = new Label(composite, SWT.LEFT); + label.setText(Texts.PREFERENCES_COMPILER_RUNNER_DEFAULT_COMMAND_LINE_LABEL); + var textField = new Text(composite, SWT.SINGLE | SWT.BORDER); + textField.setEditable(false); + textField.setText(runnerDefinition.getDefaultCommandLine()); + gd = new GridData(); + gd.horizontalSpan = 2; + gd.horizontalAlignment = GridData.FILL; + gd.grabExcessHorizontalSpace = true; + textField.setLayoutData(gd); + + // Field: parameters + composite = SWTFactory.createComposite(tabContent, 2, 2, GridData.FILL_HORIZONTAL); + name = LanguageHardwareCompilerDefinitionPreferencesConstants.getCompilerRunnerCommandLineName(language, hardware, compilerDefinition, + runnerId); + var commandLineFieldEditor = new StringFieldEditor(name, + Texts.PREFERENCES_COMPILER_RUNNER_COMMAND_LINE_LABEL, tabContent); + + gd = new GridData(); + gd.horizontalSpan = 1; + gd.horizontalAlignment = GridData.FILL; + gd.grabExcessHorizontalSpace = true; + gd.horizontalIndent = 14; + commandLineFieldEditor.getTextControl(tabContent).setLayoutData(gd); + addField(commandLineFieldEditor); + + controlDecorations.add(createHelpDecoration(commandLineFieldEditor, tabContent, runnerCommandLineHelp)); + var url = runnerDefinition.getHomePageURL(); + fileFieldEditor.setLinkURL(url); + + // Field: illegalOpcodesVisible + composite = SWTFactory.createComposite(tabContent, 2, 3, GridData.FILL_HORIZONTAL); + FieldEditor booleanFieldEditor = new BooleanFieldEditor(LanguageHardwareCompilerDefinitionPreferencesConstants + .getCompilerRunnerWaitForCompletionName(language, hardware, compilerDefinition, runnerId), + Texts.PREFERENCES_COMPILER_RUNNER_WAIT_FOR_COMPLETION_LABEL, composite); + + addField(booleanFieldEditor); + + tabItem.setControl(tabContent); + + if (runnerId.equals(activeRunnerId)) { + selectedTabItem = tabItem; + } + + } + + // Default to selected tab item. + if (selectedTabItem != null) { + tabFolder.setSelection(selectedTabItem); + } + } + + private ControlDecoration createHelpDecoration(StringFieldEditor parametersFieldEditor, Composite tabContent, + String text) { + if (parametersFieldEditor == null) { + throw new IllegalArgumentException("Parameter 'parametersFieldEditor' must not be null."); + } + if (tabContent == null) { + throw new IllegalArgumentException("Parameter 'tabContent' must not be null."); + } + if (text == null) { + throw new IllegalArgumentException("Parameter 'text' must not be null."); + } + var textControl = parametersFieldEditor.getTextControl(tabContent); + var controlDecoration = new ControlDecoration(textControl, SWT.LEFT | SWT.CENTER); + controlDecoration.hide(); + controlDecoration.setShowHover(true); + controlDecoration.setDescriptionText(text); + + controlDecoration.setImage(LanguagePlugin.getInstance().getImage("help-16x16.gif")); + + return controlDecoration; + } + + /** + * {@inheritDoc} + */ + @Override + public final boolean performOk() { + if (super.performOk()) { + saveChanges(); + return true; + } + return false; + } + + /** + * The field editor preference page implementation of a + * PreferencePage method loads all the field editors with their + * default values except for the executable paths. + */ + @Override + protected final void performDefaults() { + + super.performDefaults(); + + } + + @Override + public final void dispose() { + super.dispose(); + + } + + @Override + public void setVisible(boolean visible) { + super.setVisible(visible); + + if (visible) { + setTabsStatus(); + } + + } + + /** + * Saves all changes to the {@link IPreferenceStore}. + */ + private void saveChanges() { + + plugin.savePreferences(); + + } +} diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagePreferences.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagePreferences.java index 9e6065b9..634355c3 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagePreferences.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagePreferences.java @@ -19,12 +19,19 @@ package com.wudsn.ide.lng.preferences; +import java.io.File; + import org.eclipse.jface.text.TextAttribute; import com.wudsn.ide.base.common.AbstractIDEPlugin; +import com.wudsn.ide.base.common.StringUtility; import com.wudsn.ide.base.hardware.Hardware; 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.CompilerPaths; +import com.wudsn.ide.lng.compiler.CompilerPaths.CompilerPath; +import com.wudsn.ide.lng.preferences.LanguagePreferencesConstants.EditorConstants; import com.wudsn.ide.lng.editor.LanguageContentAssistProcessorDefaultCase; import com.wudsn.ide.lng.editor.LanguageEditorCompileCommandPositioningMode; @@ -72,7 +79,7 @@ public final class LanguagePreferences { * See {@link LanguageContentAssistProcessorDefaultCase}. */ public String getEditorContentAssistProcessorDefaultCase() { - return getString(LanguagePreferencesConstants.EDITOR_CONTENT_ASSIST_PROCESSOR_DEFAULT_CASE); + return getString(EditorConstants.getEditorContentProcessorDefaultCaseKey(language)); } /** @@ -83,91 +90,134 @@ public final class LanguagePreferences { * @since 1.6.1 */ public String getEditorCompileCommandPositioningMode() { - return getString(LanguagePreferencesConstants.EDITOR_COMPILE_COMMAND_POSITIONING_MODE); + return getString(EditorConstants.getEditorCompileCommandPositioningModeKey(language)); + } + + /** + * Gets the executable path for the compiler. + * + * @param compilerDefinition The compiler definition, not null. + * + * @return The executable path for the runner, may be empty, not + * null. + */ + public String getCompilerExecutablePath(CompilerDefinition compilerDefinition) { + if (compilerDefinition == null) { + throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null."); + } + return getString(LanguagePreferencesConstants.getCompilerExecutablePathKey(language, compilerDefinition)); + } + + /** + * Gets the executable path for the compiler or the default from the + * {@linkplain CompilerPaths}. + * + * @param compilerDefinition The compiler definition, not null. + * + * @return The executable path for the runner, may be empty, not + * null. + */ + public String getCompilerExecutablePathOrDefault(CompilerDefinition compilerDefinition) { + String compilerExecutablePath = getCompilerExecutablePath(compilerDefinition); + + CompilerPaths compilerPaths = LanguagePlugin.getInstance().getCompilerPaths(); + if (StringUtility.isEmpty(compilerExecutablePath)) { + CompilerPath compilerPath = compilerPaths.getDefaultCompilerPath(language, compilerDefinition); + if (compilerPath != null) { + File compilerFile = compilerPath.getAbsoluteFile(); + if (compilerFile != null) { + if (compilerFile.exists() && compilerFile.isFile() && compilerFile.canExecute()) { + compilerExecutablePath = compilerFile.getAbsolutePath(); + } + } + } + + } + return compilerExecutablePath; } /** * Gets the preferences for a compiler. * - * @param compilerDefinition The compiler definition, not empty and not - * null. * @param hardware The preferences or null if the * compiler is not active for that hardware. + * @param compilerDefinition The compiler definition, not empty and not + * null. * * @return The compiler preferences, not null. */ - public CompilerPreferences getCompilerPreferences(CompilerDefinition compilerDefinition, Hardware hardware) { + public LanguageHardwareCompilerDefinitionPreferences getLanguageHardwareCompilerDefinitionPreferences( + Hardware hardware, CompilerDefinition compilerDefinition) { + if (hardware == null) { + throw new IllegalArgumentException("Parameter 'hardware' must not be null."); + } if (compilerDefinition == null) { throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null."); } - if (hardware == null) { - throw new IllegalArgumentException("Parameter 'hardware' must not be null."); - } - return new CompilerPreferences(this, compilerDefinition.getId(), hardware); + return new LanguageHardwareCompilerDefinitionPreferences(this, hardware, compilerDefinition); } /** - * Gets the preferences for the language of these preferences and a suffix. + * Create the preferences key for a property of a given language. * - * @param preferencesKeySuffix The key suffix, not empty and not null. - * @return The language preferences key, not empty and not null. + * @param language The language, not null + * @param preferencesKeySuffix The suffix as defined by the constants of this + * class, not empty, not null + * @return */ - public String getPreferencesKey(String preferencesKeySuffix) { - return LanguagePreferencesConstants.getPreferencesKey(language, preferencesKeySuffix); + public static String getLanguagePreferencesKey(Language language, String preferencesKeySuffix) { + return language.name().toLowerCase() + "." + preferencesKeySuffix; } - + /** * Gets the current value of the boolean preference with the given name. Returns * the default value false if there is no preference with the given * name, or if the current value cannot be treated as a boolean. * - * @param preferencesKeySuffix The he preferences key suffix of the preference, - * not null. + * @param preferencesKey The key of the preference, not empty and not + * null. * @return The preference value. */ - boolean getBoolean(String preferencesKeySuffix) { - if (preferencesKeySuffix == null) { - throw new IllegalArgumentException("Parameter 'preferencesKeySuffix' must not be null."); + boolean getBoolean(String preferencesKey) { + if (preferencesKey == null) { + throw new IllegalArgumentException("Parameter 'preferencesKey' must not be null."); } - return languagesPreferences - .getBoolean(getPreferencesKey(preferencesKeySuffix)); + return languagesPreferences.getBoolean(preferencesKey); } - /** * Gets the current value of the string-valued preference with the given name. * Returns the default-default value (the empty string "" ) if * there is no preference with the given name, or if the current value cannot be * treated as a string. * - * @param preferencesKeySuffix The preferences key suffix of the preference, not - * null. + * @param preferencesKey The key of the preference, not empty and not + * null. + * * @return The preference value, may be empty, not null. */ - String getString(String preferencesKeySuffix) { - if (preferencesKeySuffix == null) { - throw new IllegalArgumentException("Parameter 'preferencesKeySuffix' must not be null."); + String getString(String preferencesKey) { + if (preferencesKey == null) { + throw new IllegalArgumentException("Parameter 'preferencesKey' must not be null."); } - return languagesPreferences - .getString(getPreferencesKey(preferencesKeySuffix)); + return languagesPreferences.getString(preferencesKey); } /** * Gets the text attribute for a token type. * - * @param textAttributeName The suffix of the preferences for the token type, - * see {@link LanguagePreferencesConstants}. + * @param preferencesKey The key of the preference, not empty and not + * null. * * @return The text attribute, not null. */ - public TextAttribute getEditorTextAttribute(String textAttributeName) { - if (textAttributeName == null) { - throw new IllegalArgumentException("Parameter 'textAttributeName' must not be null."); + public TextAttribute getTextAttribute(String preferencesKey) { + if (preferencesKey == null) { + throw new IllegalArgumentException("Parameter 'preferencesKey' must not be null."); } - return languagesPreferences - .getEditorTextAttribute(getPreferencesKey(textAttributeName)); + return languagesPreferences.getEditorTextAttribute(preferencesKey); } diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagePreferencesConstants.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagePreferencesConstants.java index 98cc005d..ce5ec5da 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagePreferencesConstants.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagePreferencesConstants.java @@ -1,464 +1,303 @@ -/** -R * Copyright (C) 2009 - 2021 Peter Dell - * - * 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 . - */ - -package com.wudsn.ide.lng.preferences; - -import java.util.ArrayList; -import java.util.List; - -import com.wudsn.ide.base.hardware.Hardware; -import com.wudsn.ide.lng.Language; -import com.wudsn.ide.lng.Texts; - -/** - * Constants for preferences. The string constants are preferences key suffix - * that are not used directly but prefixes with the language. - * - * @author Peter Dell - */ -public final class LanguagePreferencesConstants { - - /** - * Creation is private. - */ - private LanguagePreferencesConstants() { - } - - /** - * Preference key for comment text style. - */ - public static final String EDITOR_TEXT_ATTRIBUTE_COMMENT = "editor.text.attribute.comment"; //$NON-NLS-1$ - - /** - * Preferences key for string text style. - */ - public static final String EDITOR_TEXT_ATTRIBUTE_STRING = "editor.text.attribute.string"; //$NON-NLS-1$ - - /** - * Preferences key for number text style. - */ - public static final String EDITOR_TEXT_ATTRIBUTE_NUMBER = "editor.text.attribute.number"; //$NON-NLS-1$ - - /** - * Preference key for directive text style. - */ - public static final String EDITOR_TEXT_ATTRIBUTE_DIRECTVE = "editor.text.attribute.directive"; //$NON-NLS-1$ - - /** - * Preference key for legal opcode text style. - */ - public static final String EDITOR_TEXT_ATTRIBUTE_OPCODE_LEGAL = "editor.text.attribute.opcode.legal"; //$NON-NLS-1$ - - /** - * Preference key for illegal opcode text style. - */ - public static final String EDITOR_TEXT_ATTRIBUTE_OPCODE_ILLEGAL = "editor.text.attribute.opcode.illegal"; //$NON-NLS-1$ - - /** - * Preference key for pseudo opcode text style. - */ - public static final String EDITOR_TEXT_ATTRIBUTE_OPCODE_PSEUDO = "editor.text.attribute.opcode.pseudo"; //$NON-NLS-1$ - - /** - * Preference key for equate identifier text style. - */ - public static final String EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_EQUATE = "editor.text.attribute.identifier.equate"; //$NON-NLS-1$ - - /** - * Preference key for label identifier text style. - */ - public static final String EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_LABEL = "editor.text.attribute.identifier.label"; //$NON-NLS-1$ - - /** - * Preference key for enum identifier text style. - */ - public static final String EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_ENUM_DEFINITION_SECTION = "editor.text.attribute.identifier.enum"; //$NON-NLS-1$ - - /** - * Preference key for structure identifier text style. - */ - public static final String EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_STRUCTURE_DEFINITION_SECTION = "editor.text.attribute.identifier.structure"; //$NON-NLS-1$ - - /** - * Preference key for local identifier text style. - */ - public static final String EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_LOCAL_SECTION = "editor.text.attribute.identifier.local"; //$NON-NLS-1$ - - /** - * Preference key for macro identifier text style. - */ - public static final String EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_MACRO_DEFINITION_SECTION = "editor.text.attribute.identifier.macro"; //$NON-NLS-1$ - - /** - * Preference key for procedure identifier text style. - */ - public static final String EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_PROCEDURE_DEFINITION_SECTION = "editor.text.attribute.identifier.procedure"; //$NON-NLS-1$ - - /** - * Preference key for default case for content assist. - */ - static final String EDITOR_CONTENT_ASSIST_PROCESSOR_DEFAULT_CASE = "editor.content.assist.processor.default.case"; //$NON-NLS-1$ - - /** - * Preference key for positioning for for compiling. - * - * @since 1.6.1 - */ - static final String EDITOR_COMPILE_COMMAND_POSITIONING_MODE = "editor.compile.command.positioning.mode"; //$NON-NLS-1$ - - /** - * Create the preferences key for a property of a given language. - * - * @param language The language, not null - * @param preferencesKeySuffix The suffix as defined by the constants of this - * class, not empty, not null - * @return - */ - public static String getPreferencesKey(Language language, String preferencesKeySuffix) { - return language.name().toLowerCase() + "." + preferencesKeySuffix; - } - - /** - * Get list of all preferences keys that depend on the global JFact text font - * setting. - */ - public static List getTextAttributeDefinitions(Language language) { - if (language == null) { - throw new IllegalArgumentException("Parameter 'language' must not be null."); - } - - List result = new ArrayList(); - - // Comments and literals - result.add(new TextAttributeDefinition(getPreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_COMMENT), - Texts.PREFERENCES_TEXT_ATTRIBUTE_COMMENT_NAME)); - result.add(new TextAttributeDefinition(getPreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_NUMBER), - Texts.PREFERENCES_TEXT_ATTRIBUTE_NUMBER_NAME)); - result.add(new TextAttributeDefinition(getPreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_STRING), - Texts.PREFERENCES_TEXT_ATTRIBUTE_STRING_NAME)); - - switch (language) { - case ASM: { - - // Built-in - result.add(new TextAttributeDefinition(getPreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_DIRECTVE), - Texts.PREFERENCES_TEXT_ATTRIBUTE_DIRECTIVE)); - result.add(new TextAttributeDefinition(getPreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_OPCODE_ILLEGAL), - Texts.PREFERENCES_TEXT_ATTRIBUTE_OPCODE_ILLEGAL_NAME)); - result.add(new TextAttributeDefinition(getPreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_OPCODE_LEGAL), - Texts.PREFERENCES_TEXT_ATTRIBUTE_OPCODE_LEGAL_NAME)); - result.add(new TextAttributeDefinition(getPreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_OPCODE_PSEUDO), - Texts.PREFERENCES_TEXT_ATTRIBUTE_OPCODE_PSEUDO_NAME)); - - // Identifiers - result.add(new TextAttributeDefinition( - getPreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_ENUM_DEFINITION_SECTION), - Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_ENUM_DEFINITION_SECTION)); - result.add(new TextAttributeDefinition(getPreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_EQUATE), - Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_EQUATE)); - result.add(new TextAttributeDefinition(getPreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_LABEL), - Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_LABEL)); - result.add(new TextAttributeDefinition( - getPreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_LOCAL_SECTION), - Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_LOCAL_SECTION)); - result.add(new TextAttributeDefinition( - getPreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_MACRO_DEFINITION_SECTION), - Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_MACRO_DEFINITION_SECTION)); - result.add(new TextAttributeDefinition( - getPreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_PROCEDURE_DEFINITION_SECTION), - Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_PROCEDURE_DEFINITION_SECTION)); - result.add(new TextAttributeDefinition( - getPreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_STRUCTURE_DEFINITION_SECTION), - Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_STRUCTURE_DEFINITION_SECTION)); - break; - - } - - case PAS: { - - // Built-in - result.add(new TextAttributeDefinition(getPreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_DIRECTVE), - Texts.PREFERENCES_TEXT_ATTRIBUTE_DIRECTIVE)); - - // Identifiers - result.add(new TextAttributeDefinition( - getPreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_ENUM_DEFINITION_SECTION), - Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_ENUM_DEFINITION_SECTION)); - result.add(new TextAttributeDefinition( - getPreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_PROCEDURE_DEFINITION_SECTION), - Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_PROCEDURE_DEFINITION_SECTION)); - result.add(new TextAttributeDefinition( - getPreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_STRUCTURE_DEFINITION_SECTION), - Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_STRUCTURE_DEFINITION_SECTION)); - break; - - } - default: - throw new IllegalArgumentException("Unsupported language " + language + "."); - } - - return result; - } - - /** - * Determines if preference key name represents a setting for compiler targets - * visibility. - * - * @param name The name of the preferences key, not null. - * @return true if preference key name represents a setting for - * compiler opcodes visibility, false otherwise. - */ - public static boolean isCompilerTargetName(String name) { - if (name == null) { - throw new IllegalArgumentException("Parameter 'name' must not be null."); - } - boolean result = name.startsWith("compiler.") && name.endsWith(".target"); - return result; - } - - /** - * Gets preference key name for the compiler executable path. This is the only - * hardware independent compiler setting. - * - * @param compilerId The compiler id, not null. - * - * @return The preference key name for the compiler executable path, not empty - * and not null. - */ - static String getCompilerExecutablePathName(String compilerId) { - - if (compilerId == null) { - throw new IllegalArgumentException("Parameter 'compilerId' must not be null."); - } - return "compiler." + compilerId + ".executable.path"; //$NON-NLS-1$ - } - - /** - * Gets preference key name for the compiler Target visibility. - * - * @param compilerId The compiler id, not null. - * @param hardware The hardware, not null. - * - * @return The preference key name for the compiler Target, not empty and not - * null. - */ - static String getCompilerTargetName(String compilerId, Hardware hardware) { - if (compilerId == null) { - throw new IllegalArgumentException("Parameter 'compilerId' must not be null."); - } - if (hardware == null) { - throw new IllegalArgumentException("Parameter 'hardware' must not be null."); - } - return getCompilerHardwarePrefix(compilerId, hardware) + ".target"; //$NON-NLS-1$ - } - - /** - * Gets preference key name for the compiler parameters. - * - * @param compilerId The compiler id, not null. - * @param hardware The hardware, not null. - * - * @return The preference key name for the compiler parameters, not empty and - * not null. - */ - static String getCompilerParametersName(String compilerId, Hardware hardware) { - if (compilerId == null) { - throw new IllegalArgumentException("Parameter 'compilerId' must not be null."); - } - if (hardware == null) { - throw new IllegalArgumentException("Parameter 'hardware' must not be null."); - } - return getCompilerHardwarePrefix(compilerId, hardware) + ".default.parameters"; //$NON-NLS-1$ - } - - /** - * Gets preference key name for the compiler output folder mode. - * - * @param compilerId The compiler id, not null. - * @param hardware The hardware, not null. - * - * @return The preference key name for the compiler output folder mode, not - * empty and not null. - */ - static String getCompilerOutputFolderModeName(String compilerId, Hardware hardware) { - if (compilerId == null) { - throw new IllegalArgumentException("Parameter 'compilerId' must not be null."); - } - if (hardware == null) { - throw new IllegalArgumentException("Parameter 'hardware' must not be null."); - } - return getCompilerHardwarePrefix(compilerId, hardware) + ".output.folder.mode"; //$NON-NLS-1$ - - } - - /** - * Gets preference key name for the compiler output folder path. - * - * @param compilerId The compiler id, not null. - * @param hardware The hardware, not null. - * - * @return The preference key name for the compiler output folder path, not - * empty and not null. - */ - static String getCompilerOutputFolderPathName(String compilerId, Hardware hardware) { - if (compilerId == null) { - throw new IllegalArgumentException("Parameter 'compilerId' must not be null."); - } - if (hardware == null) { - throw new IllegalArgumentException("Parameter 'hardware' must not be null."); - } - return getCompilerHardwarePrefix(compilerId, hardware) + ".output.folder.path"; //$NON-NLS-1$ - - } - - /** - * Gets preference key name for the compiler output file extension. - * - * @param compilerId The compiler id, not null. - * @param hardware The hardware, not null. - * - * @return The preference key name for the compiler output file extension, not - * empty and not null. - */ - static String getCompilerOutputFileExtensionName(String compilerId, Hardware hardware) { - if (compilerId == null) { - throw new IllegalArgumentException("Parameter 'compilerId' must not be null."); - } - if (hardware == null) { - throw new IllegalArgumentException("Parameter 'hardware' must not be null."); - } - return getCompilerHardwarePrefix(compilerId, hardware) + ".output.file.extension"; //$NON-NLS-1$ - - } - - /** - * Gets preference key name for the runner to run the output file. - * - * @param compilerId The compiler id, not null. - * @param hardware The hardware, not null. - * - * @return The preference key name for the for the runner to run the output - * file, not empty and not null. - */ - static String getCompilerRunnerIdName(String compilerId, Hardware hardware) { - if (compilerId == null) { - throw new IllegalArgumentException("Parameter 'compilerId' must not be null."); - } - if (hardware == null) { - throw new IllegalArgumentException("Parameter 'hardware' must not be null."); - } - return getCompilerHardwarePrefix(compilerId, hardware) + ".runner.id"; //$NON-NLS-1$ - - } - - /** - * Gets preference key name for the runner executable path. - * - * @param compilerId The compiler id, not null. - * @param hardware The hardware, not null. - * @param runnerId The runner id, not null. - * - * @return The preference key name for the runner executable path, not empty and - * not null. - */ - static String getCompilerRunnerExecutablePathName(String compilerId, Hardware hardware, String runnerId) { - if (compilerId == null) { - throw new IllegalArgumentException("Parameter 'compilerId' must not be null."); - } - if (hardware == null) { - throw new IllegalArgumentException("Parameter 'hardware' must not be null."); - } - if (runnerId == null) { - throw new IllegalArgumentException("Parameter 'runnerId' must not be null."); - } - return getCompilerHardwarePrefix(compilerId, hardware) + ".runner." + runnerId + ".executable.path"; //$NON-NLS-1$ - - } - - /** - * Gets preference key name for the runner command line. - * - * @param compilerId The compiler id, not null. - * @param hardware The hardware, not null. - * @param runnerId The runner id, not null. - * - * @return The preference key name for the runner command line, not empty and - * not null. - */ - static String getCompilerRunnerCommandLineName(String compilerId, Hardware hardware, String runnerId) { - if (compilerId == null) { - throw new IllegalArgumentException("Parameter 'compilerId' must not be null."); - } - if (hardware == null) { - throw new IllegalArgumentException("Parameter 'hardware' must not be null."); - } - if (runnerId == null) { - throw new IllegalArgumentException("Parameter 'runnerId' must not be null."); - } - return getCompilerHardwarePrefix(compilerId, hardware) + ".runner." + runnerId + ".parameters"; //$NON-NLS-1$ - - } - - /** - * Gets preference key name for the runner wait for completion flag. - * - * @param compilerId The compiler id, not null. - * @param hardware The hardware, not null. - * @param runnerId The runner id, not null. - * - * @return The preference key name for the runner command line, not empty and - * not null. - * @since 1.6.1 - */ - static String getCompilerRunnerWaitForCompletionName(String compilerId, Hardware hardware, String runnerId) { - - if (compilerId == null) { - throw new IllegalArgumentException("Parameter 'compilerId' must not be null."); - } - if (hardware == null) { - throw new IllegalArgumentException("Parameter 'hardware' must not be null."); - } - if (runnerId == null) { - throw new IllegalArgumentException("Parameter 'runnerId' must not be null."); - } - return getCompilerHardwarePrefix(compilerId, hardware) + ".runner." + runnerId + ".waitForCompletion"; //$NON-NLS-1$ - - } - - /** - * Gets preference key name prefix for a given hardware and compiler. - * - * @param hardware The hardware, not null. - * @param compilerId The compiler id, not null. - * - * - * @return The preference key name prefix without trailing dot, not empty and - * not null. - */ - private static String getCompilerHardwarePrefix(String compilerId, Hardware hardware) { - - if (compilerId == null) { - throw new IllegalArgumentException("Parameter 'compilerId' must not be null."); - } - if (hardware == null) { - throw new IllegalArgumentException("Parameter 'hardware' must not be null."); - } - return "compiler." + compilerId + "." + hardware.name().toLowerCase(); - } -} +/** +R * Copyright (C) 2009 - 2021 Peter Dell + * + * 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 . + */ + +package com.wudsn.ide.lng.preferences; + +import java.util.ArrayList; +import java.util.List; + +import com.wudsn.ide.lng.Language; +import com.wudsn.ide.lng.Texts; +import com.wudsn.ide.lng.compiler.CompilerDefinition; +import com.wudsn.ide.lng.preferences.LanguagePreferencesConstants.EditorConstants; + +/** + * Constants for preferences. + * + * @author Peter Dell + */ +public final class LanguagePreferencesConstants { + + public static final class EditorConstants { + /** + * Preference key for comment text style. + */ + public static final String EDITOR_TEXT_ATTRIBUTE_COMMENT = "editor.text.attribute.comment"; //$NON-NLS-1$ + + /** + * Preferences key for string text style. + */ + public static final String EDITOR_TEXT_ATTRIBUTE_STRING = "editor.text.attribute.string"; //$NON-NLS-1$ + + /** + * Preferences key for number text style. + */ + public static final String EDITOR_TEXT_ATTRIBUTE_NUMBER = "editor.text.attribute.number"; //$NON-NLS-1$ + + /** + * Preference key for directive text style. + */ + public static final String EDITOR_TEXT_ATTRIBUTE_DIRECTVE = "editor.text.attribute.directive"; //$NON-NLS-1$ + + /** + * Preference key for legal opcode text style. + */ + public static final String EDITOR_TEXT_ATTRIBUTE_OPCODE_LEGAL = "editor.text.attribute.opcode.legal"; //$NON-NLS-1$ + + /** + * Preference key for illegal opcode text style. + */ + public static final String EDITOR_TEXT_ATTRIBUTE_OPCODE_ILLEGAL = "editor.text.attribute.opcode.illegal"; //$NON-NLS-1$ + + /** + * Preference key for pseudo opcode text style. + */ + public static final String EDITOR_TEXT_ATTRIBUTE_OPCODE_PSEUDO = "editor.text.attribute.opcode.pseudo"; //$NON-NLS-1$ + + /** + * Preference key for equate identifier text style. + */ + public static final String EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_EQUATE = "editor.text.attribute.identifier.equate"; //$NON-NLS-1$ + + /** + * Preference key for label identifier text style. + */ + public static final String EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_LABEL = "editor.text.attribute.identifier.label"; //$NON-NLS-1$ + + /** + * Preference key for enum identifier text style. + */ + public static final String EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_ENUM_DEFINITION_SECTION = "editor.text.attribute.identifier.enum"; //$NON-NLS-1$ + + /** + * Preference key for structure identifier text style. + */ + public static final String EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_STRUCTURE_DEFINITION_SECTION = "editor.text.attribute.identifier.structure"; //$NON-NLS-1$ + + /** + * Preference key for local identifier text style. + */ + public static final String EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_LOCAL_SECTION = "editor.text.attribute.identifier.local"; //$NON-NLS-1$ + + /** + * Preference key for macro identifier text style. + */ + public static final String EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_MACRO_DEFINITION_SECTION = "editor.text.attribute.identifier.macro"; //$NON-NLS-1$ + + /** + * Preference key for default case for content assist. + */ + static final String EDITOR_CONTENT_ASSIST_PROCESSOR_DEFAULT_CASE = "editor.content.assist.processor.default.case"; //$NON-NLS-1$ + + /** + * Preference key for procedure identifier text style. + */ + public static final String EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_PROCEDURE_DEFINITION_SECTION = "editor.text.attribute.identifier.procedure"; //$NON-NLS-1$ + + + /** + * Preference key for positioning for for compiling. + * + * @since 1.6.1 + */ + static final String EDITOR_COMPILE_COMMAND_POSITIONING_MODE = "editor.compile.command.positioning.mode"; //$NON-NLS-1$ + + /** + * Gets preference key name for a editor attribute. + * + * @param language The language null. + * + * @return The preference key name for the compiler executable path, not empty + * and not null. + */ + public static String getEditorAttributeKey(Language language, String textAttributeName) { + if (language == null) { + throw new IllegalArgumentException("Parameter 'language' must not be null."); + } + String preferencesKey = getLanguagePreferencesKey(language, textAttributeName); + return preferencesKey; + } + + static String getEditorContentProcessorDefaultCaseKey(Language language) { + if (language == null) { + throw new IllegalArgumentException("Parameter 'language' must not be null."); + } + + return getEditorAttributeKey(language, EditorConstants.EDITOR_CONTENT_ASSIST_PROCESSOR_DEFAULT_CASE); + } + + static String getEditorCompileCommandPositioningModeKey(Language language) { + if (language == null) { + throw new IllegalArgumentException("Parameter 'language' must not be null."); + } + + return getEditorAttributeKey(language, EditorConstants.EDITOR_COMPILE_COMMAND_POSITIONING_MODE); + } + + /** + * Gets the list of all preferences keys that depend on the global JFact text + * font setting. + * + * @param language The language, not null. + */ + public static List getTextAttributeDefinitions(Language language) { + if (language == null) { + throw new IllegalArgumentException("Parameter 'language' must not be null."); + } + + List result = new ArrayList(); + + // Comments and literals + result.add(new TextAttributeDefinition(getEditorAttributeKey(language, EDITOR_TEXT_ATTRIBUTE_COMMENT), + Texts.PREFERENCES_TEXT_ATTRIBUTE_COMMENT_NAME)); + result.add(new TextAttributeDefinition(getEditorAttributeKey(language, EDITOR_TEXT_ATTRIBUTE_NUMBER), + Texts.PREFERENCES_TEXT_ATTRIBUTE_NUMBER_NAME)); + result.add(new TextAttributeDefinition(getEditorAttributeKey(language, EDITOR_TEXT_ATTRIBUTE_STRING), + Texts.PREFERENCES_TEXT_ATTRIBUTE_STRING_NAME)); + + switch (language) { + case ASM: { + + // Built-in + result.add(new TextAttributeDefinition(getEditorAttributeKey(language, EDITOR_TEXT_ATTRIBUTE_DIRECTVE), + Texts.PREFERENCES_TEXT_ATTRIBUTE_DIRECTIVE)); + result.add(new TextAttributeDefinition( + getEditorAttributeKey(language, EDITOR_TEXT_ATTRIBUTE_OPCODE_ILLEGAL), + Texts.PREFERENCES_TEXT_ATTRIBUTE_OPCODE_ILLEGAL_NAME)); + result.add( + new TextAttributeDefinition(getEditorAttributeKey(language, EDITOR_TEXT_ATTRIBUTE_OPCODE_LEGAL), + Texts.PREFERENCES_TEXT_ATTRIBUTE_OPCODE_LEGAL_NAME)); + result.add(new TextAttributeDefinition( + getEditorAttributeKey(language, EDITOR_TEXT_ATTRIBUTE_OPCODE_PSEUDO), + Texts.PREFERENCES_TEXT_ATTRIBUTE_OPCODE_PSEUDO_NAME)); + + // Identifiers + result.add(new TextAttributeDefinition( + getEditorAttributeKey(language, EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_ENUM_DEFINITION_SECTION), + Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_ENUM_DEFINITION_SECTION)); + result.add(new TextAttributeDefinition( + getEditorAttributeKey(language, EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_EQUATE), + Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_EQUATE)); + result.add(new TextAttributeDefinition( + getEditorAttributeKey(language, EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_LABEL), + Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_LABEL)); + result.add(new TextAttributeDefinition( + getEditorAttributeKey(language, EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_LOCAL_SECTION), + Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_LOCAL_SECTION)); + result.add(new TextAttributeDefinition( + getEditorAttributeKey(language, EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_MACRO_DEFINITION_SECTION), + Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_MACRO_DEFINITION_SECTION)); + result.add(new TextAttributeDefinition( + getEditorAttributeKey(language, EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_PROCEDURE_DEFINITION_SECTION), + Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_PROCEDURE_DEFINITION_SECTION)); + result.add(new TextAttributeDefinition( + getEditorAttributeKey(language, EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_STRUCTURE_DEFINITION_SECTION), + Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_STRUCTURE_DEFINITION_SECTION)); + break; + + } + + case PAS: { + + // Built-in + result.add( + new TextAttributeDefinition(getLanguagePreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_DIRECTVE), + Texts.PREFERENCES_TEXT_ATTRIBUTE_DIRECTIVE)); + + // Identifiers + result.add(new TextAttributeDefinition( + getLanguagePreferencesKey(language, EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_ENUM_DEFINITION_SECTION), + Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_ENUM_DEFINITION_SECTION)); + result.add(new TextAttributeDefinition( + getLanguagePreferencesKey(language, + EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_PROCEDURE_DEFINITION_SECTION), + Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_PROCEDURE_DEFINITION_SECTION)); + result.add(new TextAttributeDefinition( + getLanguagePreferencesKey(language, + EDITOR_TEXT_ATTRIBUTE_IDENTIFIER_STRUCTURE_DEFINITION_SECTION), + Texts.PREFERENCES_TEXT_ATTRIBUTE_IDENTIFIER_STRUCTURE_DEFINITION_SECTION)); + break; + + } + default: + throw new IllegalArgumentException("Unsupported language " + language + "."); + } + + return result; + } + } + + /** + * Creation is private. + */ + private LanguagePreferencesConstants() { + } + + /** + * Determines if preference key name represents a setting for compiler targets + * visibility. + * + * @param name The name of the preferences key, not null. + * @return true if preference key name represents a setting for + * compiler opcodes visibility, false otherwise. + */ + public static boolean isCompilerTargetName(Language language, String preferencesKey) { + if (language == null) { + throw new IllegalArgumentException("Parameter 'language' must not be null."); + } + if (preferencesKey == null) { + throw new IllegalArgumentException("Parameter 'preferencesKey' must not be null."); + } + var prefix = getLanguagePreferencesKey(language, "compiler."); + boolean result = preferencesKey.startsWith(prefix) && preferencesKey.endsWith(".target"); + return result; + } + + /** + * Create the preferences key for a property of a given language. + * + * @param language The language, not null + * @param preferencesKeySuffix The suffix as defined by the constants of this + * class, not empty, not null + * @return + */ + static String getLanguagePreferencesKey(Language language, String preferencesKeySuffix) { + return language.name().toLowerCase() + "." + preferencesKeySuffix; + } + + /** + * Gets preference key name for the compiler executable path. This is the only + * hardware independent compiler setting. + * + * @param The language, not null + * @param compilerDefinition The compiler definition, not null. + * + * @return The preference key name for the compiler executable path, not empty + * and not null. + */ + static String getCompilerExecutablePathKey(Language language, CompilerDefinition compilerDefinition) { + if (language == null) { + throw new IllegalArgumentException("Parameter 'language' must not be null."); + } + if (compilerDefinition == null) { + throw new IllegalArgumentException("Parameter 'compilerDefinition' must not be null."); + } + return getLanguagePreferencesKey(language, "compiler." + compilerDefinition.getId() + ".executable.path"); //$NON-NLS-1$ + } +} diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagePreferencesInitializer.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagePreferencesInitializer.java index 75a1c684..a7b574b5 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagePreferencesInitializer.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagePreferencesInitializer.java @@ -19,8 +19,6 @@ package com.wudsn.ide.lng.preferences; -import java.util.List; - import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.TextAttribute; @@ -32,11 +30,10 @@ 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; -import com.wudsn.ide.lng.compiler.CompilerRegistry; import com.wudsn.ide.lng.editor.LanguageContentAssistProcessorDefaultCase; import com.wudsn.ide.lng.editor.LanguageEditorCompileCommandPositioningMode; +import com.wudsn.ide.lng.preferences.LanguagePreferencesConstants.EditorConstants; import com.wudsn.ide.lng.runner.RunnerId; /** @@ -56,15 +53,18 @@ public final class LanguagePreferencesInitializer extends AbstractPreferenceInit } - private void setDefault(Language language, String key, String value) { - store.setDefault(language.name().toLowerCase() + "." + key, value); + private void setDefault(String key, String value) { + store.setDefault(key, value); } - private void setDefault(Language language, String key, int r, int g, int b, int style) { + private void setLanguageTextAttributeDefault(Language language, String textAttributeName, int r, int g, int b, + int style) { // Editor. - Display display = Display.getCurrent(); - TextAttribute textAttribute = new TextAttribute(new Color(display, r, g, b), null, style); - store.setDefault(language.name().toLowerCase() + "." + key, TextAttributeConverter.toString(textAttribute)); + var display = Display.getCurrent(); + var textAttribute = new TextAttribute(new Color(display, r, g, b), null, style); + var preferencesKey = LanguagePreferencesConstants.EditorConstants.getEditorAttributeKey(language, + textAttributeName); + setDefault(preferencesKey, TextAttributeConverter.toString(textAttribute)); } @Override @@ -82,56 +82,62 @@ public final class LanguagePreferencesInitializer extends AbstractPreferenceInit throw new IllegalArgumentException("Parameter 'language' must not be null."); } initializeEditorPreferences(language); - initializeCompilerPreferences(language); + initializeHardwareCompilerDefinitionPreferences(language); } private void initializeEditorPreferences(Language language) { if (language == null) { throw new IllegalArgumentException("Parameter 'language' must not be null."); } - setDefault(language, LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_COMMENT, 0, 128, 0, SWT.ITALIC); - setDefault(language, LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_DIRECTVE, 128, 64, 0, SWT.BOLD); - setDefault(language, LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_NUMBER, 0, 0, 255, SWT.BOLD); - setDefault(language, LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_OPCODE_LEGAL, 0, 0, 128, SWT.BOLD); - setDefault(language, LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_OPCODE_ILLEGAL, 255, 32, 32, SWT.BOLD); - setDefault(language, LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_OPCODE_PSEUDO, 32, 128, 32, SWT.BOLD); - setDefault(language, LanguagePreferencesConstants.EDITOR_TEXT_ATTRIBUTE_STRING, 0, 0, 255, SWT.NORMAL); + setLanguageTextAttributeDefault(language, EditorConstants.EDITOR_TEXT_ATTRIBUTE_COMMENT, 0, 128, 0, SWT.ITALIC); + setLanguageTextAttributeDefault(language, EditorConstants.EDITOR_TEXT_ATTRIBUTE_DIRECTVE, 128, 64, 0, SWT.BOLD); + setLanguageTextAttributeDefault(language, EditorConstants.EDITOR_TEXT_ATTRIBUTE_NUMBER, 0, 0, 255, SWT.BOLD); + setLanguageTextAttributeDefault(language, EditorConstants.EDITOR_TEXT_ATTRIBUTE_OPCODE_LEGAL, 0, 0, 128, + SWT.BOLD); + setLanguageTextAttributeDefault(language, EditorConstants.EDITOR_TEXT_ATTRIBUTE_OPCODE_ILLEGAL, 255, 32, 32, + SWT.BOLD); + setLanguageTextAttributeDefault(language, EditorConstants.EDITOR_TEXT_ATTRIBUTE_OPCODE_PSEUDO, 32, 128, 32, + SWT.BOLD); + setLanguageTextAttributeDefault(language, EditorConstants.EDITOR_TEXT_ATTRIBUTE_STRING, 0, 0, 255, SWT.NORMAL); // Content assist. - setDefault(language, LanguagePreferencesConstants.EDITOR_CONTENT_ASSIST_PROCESSOR_DEFAULT_CASE, - LanguageContentAssistProcessorDefaultCase.LOWER_CASE); + var preferencesKey = EditorConstants.getEditorContentProcessorDefaultCaseKey(language); + setDefault(preferencesKey, LanguageContentAssistProcessorDefaultCase.LOWER_CASE); // Compiling. - setDefault(language, LanguagePreferencesConstants.EDITOR_COMPILE_COMMAND_POSITIONING_MODE, - LanguageEditorCompileCommandPositioningMode.FIRST_ERROR_OR_WARNING); + preferencesKey = EditorConstants.getEditorCompileCommandPositioningModeKey(language); + setDefault(preferencesKey, LanguageEditorCompileCommandPositioningMode.FIRST_ERROR_OR_WARNING); } - private void initializeCompilerPreferences(Language language) { + private void initializeHardwareCompilerDefinitionPreferences(Language language) { if (language == null) { throw new IllegalArgumentException("Parameter 'language' must not be null."); } - LanguagePlugin languagePlugin = LanguagePlugin.getInstance(); - CompilerRegistry compilerRegistry = languagePlugin.getCompilerRegistry(); - List compilerDefinitions = compilerRegistry.getCompilerDefinitions(language); - for (CompilerDefinition compilerDefinition : compilerDefinitions) { - String compilerId = compilerDefinition.getId(); - String name; + var languagePlugin = LanguagePlugin.getInstance(); + var compilerRegistry = languagePlugin.getCompilerRegistry(); + var compilerDefinitions = compilerRegistry.getCompilerDefinitions(language); - for (Hardware hardware : Hardware.values()) { - if (hardware.equals(Hardware.GENERIC)) { - continue; - } - setDefault(language, LanguagePreferencesConstants.getCompilerTargetName(compilerId, hardware), - compilerDefinition.getSupportedTargets().get(0).toString()); + for (Hardware hardware : Hardware.values()) { + if (hardware.equals(Hardware.GENERIC)) { + continue; + } + for (var compilerDefinition : compilerDefinitions) { - name = LanguagePreferencesConstants.getCompilerParametersName(compilerId, hardware); - setDefault(language, name, compilerDefinition.getDefaultParameters()); - name = LanguagePreferencesConstants.getCompilerOutputFolderModeName(compilerId, hardware); - setDefault(language, name, CompilerOutputFolderMode.TEMP_FOLDER); - name = LanguagePreferencesConstants.getCompilerOutputFileExtensionName(compilerId, hardware); - setDefault(language, name, HardwareUtility.getDefaultFileExtension(hardware)); - name = LanguagePreferencesConstants.getCompilerRunnerIdName(compilerId, hardware); - setDefault(language, name, RunnerId.DEFAULT_APPLICATION); + setDefault(LanguageHardwareCompilerDefinitionPreferencesConstants.getCompilerTargetName(language, + hardware, compilerDefinition), compilerDefinition.getSupportedTargets().get(0).toString()); + + var preferencesKey = LanguageHardwareCompilerDefinitionPreferencesConstants + .getCompilerParametersName(language, hardware, compilerDefinition); + setDefault(preferencesKey, compilerDefinition.getDefaultParameters()); + preferencesKey = LanguageHardwareCompilerDefinitionPreferencesConstants + .getCompilerOutputFolderModeName(language, hardware, compilerDefinition); + setDefault(preferencesKey, CompilerOutputFolderMode.TEMP_FOLDER); + preferencesKey = LanguageHardwareCompilerDefinitionPreferencesConstants + .getCompilerOutputFileExtensionName(language, hardware, compilerDefinition); + setDefault(preferencesKey, HardwareUtility.getDefaultFileExtension(hardware)); + preferencesKey = LanguageHardwareCompilerDefinitionPreferencesConstants + .getCompilerRunnerIdName(language, hardware, compilerDefinition); + setDefault(preferencesKey, RunnerId.DEFAULT_APPLICATION); } } diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagePreferencesPage.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagePreferencesPage.java index 5e9c20cf..49706309 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagePreferencesPage.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagePreferencesPage.java @@ -69,6 +69,7 @@ import com.wudsn.ide.lng.compiler.CompilerRegistry; import com.wudsn.ide.lng.editor.LanguageContentAssistProcessorDefaultCase; import com.wudsn.ide.lng.editor.LanguageEditor; import com.wudsn.ide.lng.editor.LanguageEditorCompileCommandPositioningMode; +import com.wudsn.ide.lng.preferences.LanguagePreferencesConstants.EditorConstants; /** * Visual editor page for the language preferences. @@ -358,8 +359,7 @@ public abstract class LanguagePreferencesPage extends FieldEditorPreferencePage if (textAttributeListItems != null) { throw new IllegalStateException("Attribute 'textAttributeListItems' must be null."); } - List textAttributeDefinitions = LanguagePreferencesConstants - .getTextAttributeDefinitions(language); + List textAttributeDefinitions = EditorConstants.getTextAttributeDefinitions(language); textAttributeListItems = new ArrayList(textAttributeDefinitions.size()); for (TextAttributeDefinition textAttributeDefinition : textAttributeDefinitions) { @@ -394,7 +394,7 @@ public abstract class LanguagePreferencesPage extends FieldEditorPreferencePage }; FieldEditor choiceFieldEditor = new RadioGroupFieldEditor( - LanguagePreferencesConstants.EDITOR_CONTENT_ASSIST_PROCESSOR_DEFAULT_CASE, + EditorConstants.getEditorContentProcessorDefaultCaseKey(language), Texts.PREFERENCES_CONTENT_ASSIST_PROCESSOR_DEFAULT_CASE_LABEL, 2, labelsAndValues, space); addField(choiceFieldEditor); @@ -410,7 +410,7 @@ public abstract class LanguagePreferencesPage extends FieldEditorPreferencePage }; choiceFieldEditor = new RadioGroupFieldEditor( - LanguagePreferencesConstants.EDITOR_COMPILE_COMMAND_POSITIONING_MODE, + EditorConstants.getEditorCompileCommandPositioningModeKey(language), Texts.PREFERENCES_COMPILE_COMMAND_POSITIONING_MODE_LABEL, 2, labelsAndValues, space); addField(choiceFieldEditor); @@ -432,21 +432,16 @@ public abstract class LanguagePreferencesPage extends FieldEditorPreferencePage TabItem tabItem = new TabItem(tabFolder, SWT.NONE); tabItem.setText(compilerDefinition.getName()); - Composite tabContent; - tabContent = SWTFactory.createComposite(tabFolder, 1, 1, GridData.FILL_HORIZONTAL); + var tabContent = SWTFactory.createComposite(tabFolder, 1, 1, GridData.FILL_HORIZONTAL); tabItem.setControl(tabContent); - Composite composite; - - String name; - name = LanguagePreferencesConstants.getPreferencesKey(language, - LanguagePreferencesConstants.getCompilerExecutablePathName(compilerId)); + var name = LanguagePreferencesConstants.getCompilerExecutablePathKey(language, compilerDefinition); // Field: executablePath - composite = SWTFactory.createComposite(tabContent, 4, 2, GridData.FILL_HORIZONTAL); + var composite = SWTFactory.createComposite(tabContent, 4, 2, GridData.FILL_HORIZONTAL); FileFieldDownloadEditor fileFieldEditor = new FileFieldDownloadEditor(name, Texts.PREFERENCES_COMPILER_EXECUTABLE_PATH_LABEL, composite); - CompilerPath compilerPath = compilerPaths.getDefaultCompilerPath(language, compilerId); + CompilerPath compilerPath = compilerPaths.getDefaultCompilerPath(language, compilerDefinition); if (compilerPath != null) { File file = compilerPath.getAbsoluteFile(); if (file != null) { diff --git a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagesPreferences.java b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagesPreferences.java index 206b4d87..13ac75df 100644 --- a/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagesPreferences.java +++ b/com.wudsn.ide.lng/src/com/wudsn/ide/lng/preferences/LanguagesPreferences.java @@ -24,6 +24,7 @@ import org.eclipse.jface.text.TextAttribute; import com.wudsn.ide.base.common.AbstractIDEPlugin; import com.wudsn.ide.lng.Language; +import com.wudsn.ide.lng.LanguagePlugin; /** * Facade class for typed access to the plugin preferences. @@ -77,7 +78,9 @@ public final class LanguagesPreferences { if (preferencesKey == null) { throw new IllegalArgumentException("Parameter 'preferencesKey' must not be null."); } - return preferenceStore.getBoolean(preferencesKey); + var result = preferenceStore.getBoolean(preferencesKey); + log(preferencesKey, result ? "true" : "false"); + return result; } /** @@ -100,7 +103,7 @@ public final class LanguagesPreferences { } else { result = result.trim(); } - + log(preferencesKey, result); return result; } @@ -112,12 +115,28 @@ public final class LanguagesPreferences { * @return The text attribute, not null. * */ - public TextAttribute getEditorTextAttribute(String preferencesKey) { + TextAttribute getEditorTextAttribute(String preferencesKey) { if (preferencesKey == null) { throw new IllegalArgumentException("Parameter 'preferencesKey' must not be null."); } - return TextAttributeConverter.fromString(preferenceStore.getString(preferencesKey)); + return TextAttributeConverter.fromString(getString(preferencesKey)); + } + + /** + * Logs the result of a read access for debugging purposes. + * + * @param preferencesKey The preferences key, not null + * @param result The result, not null. + */ + private void log(String preferencesKey, String result) { + if (true) { + if (preferencesKey.startsWith("editor")) { + LanguagePlugin.getInstance().log("Result of language preferences key '{0}' is '{1}'", + new Object[] { preferencesKey, result }); + } + } + } } \ No newline at end of file