diff --git a/.gitignore b/.gitignore index 34a1eeb..5dfd7dd 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,7 @@ .mtj.tmp/ # Package Files # -*.jar +#*.jar *.war *.nar *.ear @@ -30,6 +30,7 @@ hs_err_pid* /workspace/ /temp/ /Ocelot-0.6.5-lua52-native.64.dll -/projects/LuaScript1null +/projects/ /Ocelot-0.6.5-lua53-native.64.dll -/dist/ \ No newline at end of file +/dist/ +/.machine/ \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 8be8b47..0000000 --- a/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "OCEmu"] - path = OCEmu - url = https://github.com/zenith391/OCEmu -[submodule "ocelot-brain"] - path = ocelot-brain - url = https://gitlab.com/cc-ru/ocelot/ocelot-brain.git diff --git a/README.md b/README.md index 6b8f7d8..6ea4347 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,27 @@ # OCLIDE -[![Codacy Badge](https://app.codacy.com/project/badge/Grade/d0ace57bc0a349529c699733b8dc3e9e)](https://www.codacy.com/gh/Vladg24YT/Oclide/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Vladg24YT/Oclide&utm_campaign=Badge_Grade)
+ +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/d0ace57bc0a349529c699733b8dc3e9e)](https://www.codacy.com/gh/Vladg24YT/Oclide/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Vladg24YT/Oclide&utm_campaign=Badge_Grade) +[![Java CI](https://github.com/Vladg24YT/OCLIDE/actions/workflows/ant.yml/badge.svg?branch=oclide-rc1)](https://github.com/Vladg24YT/OCLIDE/actions/workflows/ant.yml) ![Program screenshot](https://raw.githubusercontent.com/Vladg24YT/Oclide/gh-pages/images/screenshots/OCLIDE_screenshot.png) Oclide is an INDEV IDE for OpenComputers 1.7.5 written in Java 8 ## Feature list - [x] Editing tools (Undo/Redo, Clipboard) -- [x] Refactoring tools +- [ ] Refactoring tools - [x] Syntax highlighting - [x] OCEmu integration -- [ ] Internationalization -- [ ] Code autocompletion -- [ ] Modularity -- [ ] OCEmu debugging tools -- [ ] Built-in [Ocelot Brain](https://gitlab.com/cc-ru/ocelot/ocelot-brain)-based emulator -- [ ] Minecraft 1.7.10 - 1.12.2 integration - [x] Code autocompletion *(ongoing)* - [ ] Code autoformatting - [ ] Variable navigator - [ ] Static code analyzer -- [x] Minecraft 1.7.10 - 1.12.2 integration *(ongoing)* +- [ ] Minecraft 1.7.10 - 1.12.2 integration *(ongoing)* - [x] [OCEmu](https://github.com/zenith391/OCEmu) integration - [x] [Ocelot Desktop](https://gitlab.com/cc-ru/ocelot/ocelot-desktop/) integration *(done, but blocked in UI)* - [ ] [CODE](https://github.com/Avevad/code) integration - [ ] [AurumEmulator](https://github.com/Zabqer/AurumEmulator) integration -- [x] Built-in [Ocelot Brain](https://gitlab.com/cc-ru/ocelot/ocelot-brain)-based emulator *(ongoing)* -- [x] [OCVM](https://github.com/payonel/ocvm) support *(ongoing)* +- [ ] Built-in [Ocelot Brain](https://gitlab.com/cc-ru/ocelot/ocelot-brain)-based emulator *(ongoing)* +- [ ] [OCVM](https://github.com/payonel/ocvm) support *(ongoing)* - [ ] [OpenComputersVM](https://github.com/FrostyPenguin/OpenComputersVM) support - [x] Internationalization *(ongoing)* - [ ] Modularity @@ -113,3 +109,6 @@ Oclide is an INDEV IDE for OpenComputers 1.7.5 written in Java 8 2. Extract `.rar`/Copy `.jar` and `lib` to any folder you want. It will be OCLIDE's working directory. 3. Run the `OCLIDE.jar` file +## Contributing +Feel free to create push requests with translation files (`io.VladTheMountain.oclide.resources` and `io.VladTheMountain.emulator.resources` packages). +The project is also open to issues about bugs, incorrectly working things or feature requests. diff --git a/build.xml b/build.xml index 9f9329a..b3eeb8d 100644 --- a/build.xml +++ b/build.xml @@ -57,4 +57,29 @@ properties which you can use, check the target you are overriding in the nbproject/build-impl.xml file. --> + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dist/OCLIDE.jar b/dist/OCLIDE.jar index 49afdaa..a8ae9a5 100644 Binary files a/dist/OCLIDE.jar and b/dist/OCLIDE.jar differ diff --git a/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar b/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar new file mode 100644 index 0000000..597c7e2 Binary files /dev/null and b/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar differ diff --git a/lib/autocomplete-3.1.1-javadoc.jar b/lib/autocomplete-3.1.1-javadoc.jar new file mode 100644 index 0000000..e454ae3 Binary files /dev/null and b/lib/autocomplete-3.1.1-javadoc.jar differ diff --git a/lib/autocomplete-3.1.1-sources.jar b/lib/autocomplete-3.1.1-sources.jar new file mode 100644 index 0000000..af5a601 Binary files /dev/null and b/lib/autocomplete-3.1.1-sources.jar differ diff --git a/lib/autocomplete-3.1.1.jar b/lib/autocomplete-3.1.1.jar new file mode 100644 index 0000000..6012a13 Binary files /dev/null and b/lib/autocomplete-3.1.1.jar differ diff --git a/lib/commons-collections4-4.4-javadoc.jar b/lib/commons-collections4-4.4-javadoc.jar new file mode 100644 index 0000000..4472501 Binary files /dev/null and b/lib/commons-collections4-4.4-javadoc.jar differ diff --git a/lib/commons-collections4-4.4-sources.jar b/lib/commons-collections4-4.4-sources.jar new file mode 100644 index 0000000..cb4f2d5 Binary files /dev/null and b/lib/commons-collections4-4.4-sources.jar differ diff --git a/lib/commons-collections4-4.4.jar b/lib/commons-collections4-4.4.jar new file mode 100644 index 0000000..da06c3e Binary files /dev/null and b/lib/commons-collections4-4.4.jar differ diff --git a/lib/nbt-1.5.1-javadoc.jar b/lib/nbt-1.5.1-javadoc.jar new file mode 100644 index 0000000..32e0239 Binary files /dev/null and b/lib/nbt-1.5.1-javadoc.jar differ diff --git a/lib/nbt-1.5.1-sources.jar b/lib/nbt-1.5.1-sources.jar new file mode 100644 index 0000000..fb2facf Binary files /dev/null and b/lib/nbt-1.5.1-sources.jar differ diff --git a/lib/nbt-1.5.1.jar b/lib/nbt-1.5.1.jar new file mode 100644 index 0000000..759447f Binary files /dev/null and b/lib/nbt-1.5.1.jar differ diff --git a/lib/ocelot-brain-0.6.5.jar b/lib/ocelot-brain-0.6.5.jar new file mode 100644 index 0000000..c1fd425 Binary files /dev/null and b/lib/ocelot-brain-0.6.5.jar differ diff --git a/lib/rstaui-3.1.1-javadoc.jar b/lib/rstaui-3.1.1-javadoc.jar new file mode 100644 index 0000000..d04b52d Binary files /dev/null and b/lib/rstaui-3.1.1-javadoc.jar differ diff --git a/lib/rstaui-3.1.1-sources.jar b/lib/rstaui-3.1.1-sources.jar new file mode 100644 index 0000000..e110641 Binary files /dev/null and b/lib/rstaui-3.1.1-sources.jar differ diff --git a/lib/rstaui-3.1.1.jar b/lib/rstaui-3.1.1.jar new file mode 100644 index 0000000..8212374 Binary files /dev/null and b/lib/rstaui-3.1.1.jar differ diff --git a/lib/rsyntaxtextarea-3.1.2-javadoc.jar b/lib/rsyntaxtextarea-3.1.2-javadoc.jar new file mode 100644 index 0000000..162e864 Binary files /dev/null and b/lib/rsyntaxtextarea-3.1.2-javadoc.jar differ diff --git a/lib/rsyntaxtextarea-3.1.2-sources.jar b/lib/rsyntaxtextarea-3.1.2-sources.jar new file mode 100644 index 0000000..4fdb01b Binary files /dev/null and b/lib/rsyntaxtextarea-3.1.2-sources.jar differ diff --git a/lib/rsyntaxtextarea-3.1.2.jar b/lib/rsyntaxtextarea-3.1.2.jar new file mode 100644 index 0000000..cfab966 Binary files /dev/null and b/lib/rsyntaxtextarea-3.1.2.jar differ diff --git a/lib/spellchecker-3.1.1-javadoc.jar b/lib/spellchecker-3.1.1-javadoc.jar new file mode 100644 index 0000000..0dfbb70 Binary files /dev/null and b/lib/spellchecker-3.1.1-javadoc.jar differ diff --git a/lib/spellchecker-3.1.1-sources.jar b/lib/spellchecker-3.1.1-sources.jar new file mode 100644 index 0000000..94cf464 Binary files /dev/null and b/lib/spellchecker-3.1.1-sources.jar differ diff --git a/lib/spellchecker-3.1.1.jar b/lib/spellchecker-3.1.1.jar new file mode 100644 index 0000000..0b3d735 Binary files /dev/null and b/lib/spellchecker-3.1.1.jar differ diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index 36af28b..3cf850e 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -71,8 +71,8 @@ is divided into following sections: - - + + @@ -205,7 +205,7 @@ is divided into following sections: - + @@ -314,7 +314,7 @@ is divided into following sections: Must set src.dir - Must set test.src.dir + Must set test.test.dir Must set build.dir Must set dist.dir Must set build.classes.dir @@ -613,7 +613,7 @@ is divided into following sections: - + @@ -639,7 +639,7 @@ is divided into following sections: - + @@ -1569,14 +1569,14 @@ is divided into following sections: - - + + - + @@ -1617,16 +1617,16 @@ is divided into following sections: - + - + - + @@ -1641,13 +1641,13 @@ is divided into following sections: Must select some files in the IDE or set javac.includes - + - + @@ -1711,6 +1711,7 @@ is divided into following sections: + diff --git a/nbproject/configs/Scala_output.properties b/nbproject/configs/Scala_output.properties deleted file mode 100644 index debcabc..0000000 --- a/nbproject/configs/Scala_output.properties +++ /dev/null @@ -1 +0,0 @@ -$label=Scala output diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index cb71a12..c1783f2 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -1,5 +1,5 @@ # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=5dc6d4d3 -nbproject/build-impl.xml.script.CRC32=d20c0ad3 -nbproject/build-impl.xml.stylesheet.CRC32=f89f7d21@1.93.0.48 +nbproject/build-impl.xml.data.CRC32=22e507ae +nbproject/build-impl.xml.script.CRC32=e2a7c905 +nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.100.0.48 diff --git a/nbproject/project.properties b/nbproject/project.properties index 6ae84b6..57d6f2e 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -38,6 +38,8 @@ dist.jlink.output=${dist.jlink.dir}/OCLIDE endorsed.classpath= excludes= file.reference.autocomplete-3.1.1.jar=lib/autocomplete-3.1.1.jar +file.reference.commons-collections4-4.4.jar=lib/commons-collections4-4.4.jar +file.reference.nbt-1.5.1.jar=lib/nbt-1.5.1.jar file.reference.ocelot-brain-0.6.5.jar=lib/ocelot-brain-0.6.5.jar file.reference.Oclide-src=src file.reference.rstaui-3.1.1.jar=lib/rstaui-3.1.1.jar @@ -52,7 +54,9 @@ javac.classpath=\ ${file.reference.rstaui-3.1.1.jar}:\ ${file.reference.rsyntaxtextarea-3.1.2.jar}:\ ${file.reference.spellchecker-3.1.1.jar}:\ - ${file.reference.ocelot-brain-0.6.5.jar} + ${file.reference.ocelot-brain-0.6.5.jar}:\ + ${file.reference.commons-collections4-4.4.jar}:\ + ${file.reference.nbt-1.5.1.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false @@ -79,6 +83,8 @@ javadoc.nonavbar=false javadoc.notree=false javadoc.private=true javadoc.reference.autocomplete-3.1.1.jar=lib/autocomplete-3.1.1-javadoc.jar +javadoc.reference.commons-collections4-4.4.jar=lib/commons-collections4-4.4-javadoc.jar +javadoc.reference.nbt-1.5.1.jar=lib/nbt-1.5.1-javadoc.jar javadoc.reference.rstaui-3.1.1.jar=lib/rstaui-3.1.1-javadoc.jar javadoc.reference.rsyntaxtextarea-3.1.2.jar=lib/rsyntaxtextarea-3.1.2-javadoc.jar javadoc.reference.spellchecker-3.1.1.jar=lib/spellchecker-3.1.1-javadoc.jar @@ -131,7 +137,10 @@ run.test.modulepath=\ ${javac.test.modulepath} source.encoding=UTF-8 source.reference.autocomplete-3.1.1.jar=lib/autocomplete-3.1.1-sources.jar +source.reference.commons-collections4-4.4.jar=lib/commons-collections4-4.4-sources.jar +source.reference.nbt-1.5.1.jar=lib/nbt-1.5.1-sources.jar source.reference.rstaui-3.1.1.jar=lib/rstaui-3.1.1-sources.jar source.reference.rsyntaxtextarea-3.1.2.jar=lib/rsyntaxtextarea-3.1.2-sources.jar source.reference.spellchecker-3.1.1.jar=lib/spellchecker-3.1.1-sources.jar src.dir=${file.reference.Oclide-src} +test.test.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml index fd4dceb..7ad96b5 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -8,7 +8,7 @@ - + diff --git a/projects/Calculator/main.lua b/projects/Calculator/main.lua deleted file mode 100644 index edc96cd..0000000 --- a/projects/Calculator/main.lua +++ /dev/null @@ -1,19 +0,0 @@ -local term = require("term") - -term.clear() - -local n1 = term.read() -local op = term.read() -local n2 = term.read() - -if op=="+" then - term.write(n1 + n2) -else if op=="-" then - term.write(n1 - n2) -else if op=="*" then - term.write(n1 * n2) -else if op=="/" then - term.write(n1 / n2) -else - term.write("Wrong operator.") -end \ No newline at end of file diff --git a/projects/LuaScript1/main.lua b/projects/LuaScript1/main.lua deleted file mode 100644 index 90fc558..0000000 --- a/projects/LuaScript1/main.lua +++ /dev/null @@ -1,3 +0,0 @@ -local term = require("term") -term.clear() -term.write("Hello, World!") \ No newline at end of file diff --git a/src/ru/VladTheMountain/emulator/Emulator.java b/src/ru/VladTheMountain/emulator/Emulator.java deleted file mode 100644 index 35f78dc..0000000 --- a/src/ru/VladTheMountain/emulator/Emulator.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * The MIT License - * - * Copyright 2021 Vladislav Gorskii. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package ru.VladTheMountain.emulator; - -import java.awt.Color; -import java.awt.Font; -import java.awt.Graphics; -import java.io.File; -import java.util.logging.Level; -import javax.swing.JComponent; -import totoro.ocelot.brain.Ocelot; -import totoro.ocelot.brain.event.BeepEvent; -import totoro.ocelot.brain.event.BeepPatternEvent; -import totoro.ocelot.brain.event.Event; -import totoro.ocelot.brain.event.EventBus; -import totoro.ocelot.brain.event.FileSystemActivityEvent; -import totoro.ocelot.brain.event.MachineCrashEvent; -import totoro.ocelot.brain.event.RelayActivityEvent; -import totoro.ocelot.brain.event.TextBufferCopyEvent; -import totoro.ocelot.brain.event.TextBufferFillEvent; -import totoro.ocelot.brain.event.TextBufferSetBackgroundColorEvent; -import totoro.ocelot.brain.event.TextBufferSetColorDepthEvent; -import totoro.ocelot.brain.event.TextBufferSetEvent; -import totoro.ocelot.brain.event.TextBufferSetForegroundColorEvent; -import totoro.ocelot.brain.event.TextBufferSetPaletteColorEvent; -import totoro.ocelot.brain.event.TextBufferSetResolutionEvent; -import totoro.ocelot.brain.event.TextBufferSetViewportEvent; -import totoro.ocelot.brain.nbt.NBTTagCompound; -import totoro.ocelot.brain.workspace.Workspace; - -/** - * - * @author VladTheMountain - */ -public class Emulator extends JComponent { - - private static final long serialVersionUID = 1L; - - //JComponent - private Color back = Color.BLACK; - private Color fore = Color.WHITE; - private final int CHAR_WIDTH = 9; - private final int CHAR_HEIGHT = 22; - private final Font font = Font.getFont("Monospaced Plain 16"); - //Ocelot - private Workspace world; - private NBTTagCompound emulation; - //Custom - private EmuLogger logger; - - //Emulator-specific - private Color[] colors = { //Data was taken from https://minecraft-ru.gamepedia.com/OpenComputers/Colors_API - new Color(255, 255, 255), //White - new Color(255, 127, 0), //Orange - new Color(255, 0, 255), //Magenta - new Color(0, 127, 127), //Lightblue - new Color(255, 255, 0), //Yellow - new Color(0, 255, 0),//Lime, - new Color(255, 127, 255), //Pink - new Color(85, 85, 85), //Gray - new Color(170, 170, 170), //Silver - new Color(0, 255, 255), //Cyan - new Color(127, 0, 127), //Purple - new Color(0, 0, 127), //Blue - new Color(127, 0, 0), //Brown - new Color(0, 127, 0), //Green - new Color(255, 0, 0), //Red - new Color(0, 0, 0) //Black - }; - - /** - * Launch emulator with a premade workspace - * - * @param workspace Workspace to deploy - */ - public Emulator(Workspace workspace) { - world = workspace; - } - - /** - * Launch emulator with a premade workspace - * - * @param workspaceDir File to get workspace from - */ - public Emulator(File workspaceDir) { - world = new Workspace(workspaceDir.toPath()); - start(); - } - - /** - * What to do when emulation starting - */ - public void start() { - Ocelot.initialize(); - // - - //Event handlers - EventBus.listenTo(BeepEvent.class, (Event v1) -> { - BeepEvent event = (BeepEvent) v1; - logger.log(Level.INFO, "Computer beeped with " + event.frequency() + " Hz for " + event.duration()); - return null; - }); - EventBus.listenTo(BeepPatternEvent.class, (Event v1) -> { - BeepPatternEvent event = (BeepPatternEvent) v1; - logger.log(Level.INFO, "Computer beeped with pattern " + event.pattern()); - return null; - }); - EventBus.listenTo(FileSystemActivityEvent.class, (Event v1) -> { - FileSystemActivityEvent event = (FileSystemActivityEvent) v1; - logger.log(Level.INFO, "Filesystem actvity at " + event.address()); - return null; - }); - EventBus.listenTo(MachineCrashEvent.class, (Event v1) -> { - MachineCrashEvent event = (MachineCrashEvent) v1; - logger.log(Level.WARNING, "Machine crashed. Info:\n" + event.message()); - return null; - }); - EventBus.listenTo(RelayActivityEvent.class, (Event v1) -> { - RelayActivityEvent event = (RelayActivityEvent) v1; - logger.log(Level.INFO, "Relay activity at " + event.relay().toString()); - return null; - }); - // DO NOT MODIFY // - while (true) { - if (loop() != 1) { - break; - } else { - world.update(); - try { - Thread.sleep(50); - } catch (InterruptedException ex) { - System.out.println("[" + Emulator.class.getName() + "]" + ex.getMessage()); - } - } - } - stop(); - } - - /** - * What to perform while working - * - * @return status of performed operation - */ - private int loop() { - - return 1; - } - - /** - * What to do when stopping the emulation - */ - private void stop() { - - // DO NOT MODIFY // - world.save(emulation); - } - - public void exit() { - stop(); - Ocelot.shutdown(); - } - - /** - * GPU-related event handling - * - * @param gr - */ - @Override - public void paintComponent(Graphics gr) { - super.paintComponent(gr); - EventBus.listenTo(TextBufferCopyEvent.class, (Event v1) -> { - TextBufferCopyEvent event = (TextBufferCopyEvent) v1; - logger.log(Level.INFO, "GPU: Copied area " + event.width() + "x" + event.height() + "at" + event.x() + ":" + event.y() + " to " + (event.x() + event.horizontalTranslation()) + ":" + (event.y() + event.verticalTranslation())); - gr.copyArea(event.x(), event.y(), event.width(), event.height(), event.x() + event.horizontalTranslation(), event.y() + event.verticalTranslation()); - return null; - }); - EventBus.listenTo(TextBufferFillEvent.class, (Event v1) -> { - TextBufferFillEvent event = (TextBufferFillEvent) v1; - logger.log(Level.INFO, "GPU: Filled area at " + event.x() + ":" + event.y() + " with size of " + event.width() + "x" + event.height()); - gr.fillRect(event.x(), event.y(), event.width(), event.height()); - return null; - }); - EventBus.listenTo(TextBufferSetBackgroundColorEvent.class, (Event v1) -> { - TextBufferSetBackgroundColorEvent event = (TextBufferSetBackgroundColorEvent) v1; - logger.log(Level.INFO, "GPU: Background set to " + event.color()); - this.setBackground(new Color(event.color())); - return null; - }); - EventBus.listenTo(TextBufferSetColorDepthEvent.class, (Event v1) -> { - TextBufferSetColorDepthEvent event = (TextBufferSetColorDepthEvent) v1; - logger.log(Level.INFO, "GPU: Set color depth to " + event.depth()); - return null; - }); - EventBus.listenTo(TextBufferSetEvent.class, (Event v1) -> { - TextBufferSetEvent event = (TextBufferSetEvent) v1; - logger.log(Level.INFO, "GPU: Printed string " + event.value() + " at " + event.x() + ":" + event.y()); - gr.drawString(event.value(), event.x() * this.CHAR_WIDTH, event.y() * this.CHAR_HEIGHT); - return null; - }); - EventBus.listenTo(TextBufferSetForegroundColorEvent.class, (Event v1) -> { - TextBufferSetForegroundColorEvent event = (TextBufferSetForegroundColorEvent) v1; - logger.log(Level.INFO, "GPU: Foreground set to " + event.color()); - gr.setColor(new Color(event.color())); - return null; - }); - EventBus.listenTo(TextBufferSetPaletteColorEvent.class, (Event v1) -> { - TextBufferSetPaletteColorEvent event = (TextBufferSetPaletteColorEvent) v1; - logger.log(Level.INFO, "GPU: Set palette color " + event.index()); - return null; - }); - EventBus.listenTo(TextBufferSetResolutionEvent.class, (Event v1) -> { - TextBufferSetResolutionEvent event = (TextBufferSetResolutionEvent) v1; - logger.log(Level.INFO, "GPU: Resolution is set to " + event.width() + "x" + event.height()); - this.setSize(event.width() * this.CHAR_WIDTH, event.height() * this.CHAR_HEIGHT); - return null; - }); - EventBus.listenTo(TextBufferSetViewportEvent.class, (Event v1) -> { - TextBufferSetViewportEvent event = (TextBufferSetViewportEvent) v1; - // TODO - return null; - }); - } -} diff --git a/src/ru/VladTheMountain/emulator/resources/Emulator.properties b/src/ru/VladTheMountain/emulator/resources/Emulator.properties deleted file mode 100644 index 4f07669..0000000 --- a/src/ru/VladTheMountain/emulator/resources/Emulator.properties +++ /dev/null @@ -1,2 +0,0 @@ -# Built-in JOcelot-based emulator localization file - diff --git a/src/ru/VladTheMountain/emulator/ui/OcelotEmulatorFrame.form b/src/ru/VladTheMountain/emulator/ui/OcelotEmulatorFrame.form deleted file mode 100644 index 3c278fe..0000000 --- a/src/ru/VladTheMountain/emulator/ui/OcelotEmulatorFrame.form +++ /dev/null @@ -1,86 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/src/ru/VladTheMountain/emulator/ui/OcelotEmulatorFrame.java b/src/ru/VladTheMountain/emulator/ui/OcelotEmulatorFrame.java deleted file mode 100644 index d32e2d3..0000000 --- a/src/ru/VladTheMountain/emulator/ui/OcelotEmulatorFrame.java +++ /dev/null @@ -1,395 +0,0 @@ -/* - * The MIT License - * - * Copyright 2021 Vladislav Gorskii. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package ru.VladTheMountain.emulator.ui; - -import java.awt.Color; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.event.ActionEvent; -import java.io.File; -import java.util.Locale; -import java.util.ResourceBundle; -import java.util.logging.Level; -import javax.swing.GroupLayout; -import javax.swing.JFrame; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JPanel; -import javax.swing.Timer; -import javax.swing.WindowConstants; -import ru.VladTheMountain.emulator.EmuLogger; -import totoro.ocelot.brain.Ocelot; -import totoro.ocelot.brain.entity.CPU; -import totoro.ocelot.brain.entity.Case; -import totoro.ocelot.brain.entity.GraphicsCard; -import totoro.ocelot.brain.entity.HDDManaged; -import totoro.ocelot.brain.entity.Memory; -import totoro.ocelot.brain.entity.Screen; -import totoro.ocelot.brain.event.BeepEvent; -import totoro.ocelot.brain.event.BeepPatternEvent; -import totoro.ocelot.brain.event.Event; -import totoro.ocelot.brain.event.EventBus; -import totoro.ocelot.brain.event.FileSystemActivityEvent; -import totoro.ocelot.brain.event.MachineCrashEvent; -import totoro.ocelot.brain.event.RelayActivityEvent; -import totoro.ocelot.brain.event.TextBufferCopyEvent; -import totoro.ocelot.brain.event.TextBufferFillEvent; -import totoro.ocelot.brain.event.TextBufferSetBackgroundColorEvent; -import totoro.ocelot.brain.event.TextBufferSetColorDepthEvent; -import totoro.ocelot.brain.event.TextBufferSetEvent; -import totoro.ocelot.brain.event.TextBufferSetForegroundColorEvent; -import totoro.ocelot.brain.event.TextBufferSetPaletteColorEvent; -import totoro.ocelot.brain.event.TextBufferSetResolutionEvent; -import totoro.ocelot.brain.event.TextBufferSetViewportEvent; -import totoro.ocelot.brain.loot.Loot; -import totoro.ocelot.brain.nbt.NBTTagCompound; -import totoro.ocelot.brain.nbt.persistence.PersistableString; -import totoro.ocelot.brain.util.Tier; -import totoro.ocelot.brain.workspace.Workspace; - -/** - * - * @author VladTheMountain - */ -public class OcelotEmulatorFrame extends JFrame { - - final ResourceBundle localiztionResource = ResourceBundle.getBundle("ru.VladTheMountain.emulator.resources.Emulator", Locale.getDefault()); - - private static final long serialVersionUID = 1L; - - private static Emulator graphics; - - /** - * Creates new form EmulatorFrame - */ - public OcelotEmulatorFrame() { - Thread thr = new Thread() { - @Override - public void run() { - graphics.start(); - } - }; - graphics = new Emulator(); - initComponents(); - Timer t = new Timer(300, (ActionEvent e) -> { - this.revalidate(); - }); - t.start(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - canvasPanel = new JPanel(null); - jMenuBar1 = new JMenuBar(); - fileMenu = new JMenu(); - jMenuItem1 = new JMenuItem(); - viewMenu = new JMenu(); - windowMenu = new JMenu(); - - setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - setTitle("OCLIDE Built-In Emulator"); - - GroupLayout canvasPanelLayout = new GroupLayout(canvasPanel); - canvasPanel.setLayout(canvasPanelLayout); - canvasPanelLayout.setHorizontalGroup(canvasPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGap(0, 113, Short.MAX_VALUE) - ); - canvasPanelLayout.setVerticalGroup(canvasPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGap(0, 152, Short.MAX_VALUE) - ); - - graphics.setBackground(Color.BLACK); - canvasPanel.add(graphics); - - fileMenu.setText("File"); - - jMenuItem1.setText("jMenuItem1"); - fileMenu.add(jMenuItem1); - - jMenuBar1.add(fileMenu); - - viewMenu.setText("View"); - jMenuBar1.add(viewMenu); - - windowMenu.setText("Window"); - jMenuBar1.add(windowMenu); - - setJMenuBar(jMenuBar1); - - GroupLayout layout = new GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(canvasPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - ); - layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(canvasPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - ); - - pack(); - }// //GEN-END:initComponents - - public static void main(String[] args) { - new OcelotEmulatorFrame().setVisible(true); - graphics.start(); - } - - //Emulator class - class Emulator extends JPanel { - - private static final long serialVersionUID = 1L; - - //JComponent - private Color back = Color.BLACK; - private Color fore = Color.WHITE; - private final int CHAR_WIDTH = 9; - private final int CHAR_HEIGHT = 22; - private final Font font = Font.getFont("Monospaced Plain 16"); - //Ocelot - private Workspace world; - private NBTTagCompound emulation; - private Screen screen; - //Custom - private EmuLogger logger; - - //Emulator-specific - private Color[] colors = { //Data was taken from https://minecraft-ru.gamepedia.com/OpenComputers/Colors_API - new Color(255, 255, 255), //White - new Color(255, 127, 0), //Orange - new Color(255, 0, 255), //Magenta - new Color(0, 127, 127), //Lightblue - new Color(255, 255, 0), //Yellow - new Color(0, 255, 0),//Lime, - new Color(255, 127, 255), //Pink - new Color(85, 85, 85), //Gray - new Color(170, 170, 170), //Silver - new Color(0, 255, 255), //Cyan - new Color(127, 0, 127), //Purple - new Color(0, 0, 127), //Blue - new Color(127, 0, 0), //Brown - new Color(0, 127, 0), //Green - new Color(255, 0, 0), //Red - new Color(0, 0, 0) //Black - }; - - /** - * Launch emulator with a premade workspace - * - * @param workspace Workspace to deploy - */ - public Emulator() { - super(); - logger = new EmuLogger(); - } - - /** - * Launch emulator with a premade workspace - * - * @param workspaceDir File to get workspace from - */ - public Emulator(File workspaceDir) { - world = new Workspace(workspaceDir.toPath()); - start(); - } - - /** - * What to do when emulation starting - */ - public void start() { - Ocelot.initialize(); - world = new Workspace(new File(System.getProperty("user.dir") + "/Ocelot/test").toPath()); - Case computer = world.add(new Case(Tier.Three())); - CPU cpu = new CPU(Tier.Three()); - computer.add(cpu); - GraphicsCard gpu = new GraphicsCard(Tier.Two()); - computer.add(gpu); - Memory mem1 = new Memory(Tier.Six()); - computer.add(mem1); - Memory mem2 = new Memory(Tier.Three()); - computer.add(mem2); - HDDManaged hdd = new HDDManaged(Tier.Three()); - computer.add(hdd); - computer.add(Loot.OpenOsEEPROM().create()); - computer.add(Loot.OpenOsFloppy().create()); - screen = world.add(new Screen(Tier.Two())); - computer.connect(screen); - computer.setCustomData(new PersistableString("xxx")); - // - computer.turnOn(); - //Event handlers - EventBus.listenTo(BeepEvent.class, (Event v1) -> { - BeepEvent event = (BeepEvent) v1; - logger.log(Level.INFO, "Computer beeped with " + event.frequency() + " Hz for " + event.duration()); - return null; - }); - EventBus.listenTo(BeepPatternEvent.class, (Event v1) -> { - BeepPatternEvent event = (BeepPatternEvent) v1; - logger.log(Level.INFO, "Computer beeped with pattern " + event.pattern().toString()); - return null; - }); - EventBus.listenTo(FileSystemActivityEvent.class, (Event v1) -> { - FileSystemActivityEvent event = (FileSystemActivityEvent) v1; - logger.log(Level.INFO, "Filesystem actvity at " + event.address()); - return null; - }); - EventBus.listenTo(MachineCrashEvent.class, (Event v1) -> { - MachineCrashEvent event = (MachineCrashEvent) v1; - logger.log(Level.WARNING, "Machine crashed. Info:\n" + event.message()); - return null; - }); - EventBus.listenTo(RelayActivityEvent.class, (Event v1) -> { - RelayActivityEvent event = (RelayActivityEvent) v1; - logger.log(Level.INFO, "Relay activity at " + event.relay().toString()); - return null; - }); - // DO NOT MODIFY // - while (true) { - if (loop() != 1) { - break; - } else { - world.update(); - try { - Thread.sleep(50); - } catch (InterruptedException ex) { - System.out.println("[" + ru.VladTheMountain.emulator.Emulator.class.getName() + "]" + ex.getMessage()); - } - } - } - exit(); - } - - /** - * What to perform while working - * - * @return status of performed operation - */ - private int loop() { - repaint(); - System.out.println("Called repaint()"); - return 1; - } - - /** - * What to do when stopping the emulation - */ - private void stop() { - - // DO NOT MODIFY // - world.save(emulation); - } - - public void exit() { - stop(); - Ocelot.shutdown(); - } - - /** - * GPU-related event handling - * - * @param gr - */ - @Override - public void paintComponent(Graphics gr) { - super.paintComponent(gr); - System.out.println("paintComponent"); - gr.setColor(Color.BLACK); - EventBus.listenTo(TextBufferCopyEvent.class, (Event v1) -> { - TextBufferCopyEvent event = (TextBufferCopyEvent) v1; - logger.log(Level.INFO, "GPU: Copied area " + event.width() + "x" + event.height() + "at" + event.x() + ":" + event.y() + " to " + (event.x() + event.horizontalTranslation()) + ":" + (event.y() + event.verticalTranslation())); - gr.copyArea(event.x(), event.y(), event.width(), event.height(), event.x() + event.horizontalTranslation(), event.y() + event.verticalTranslation()); - return null; - }); - EventBus.listenTo(TextBufferFillEvent.class, (Event v1) -> { - TextBufferFillEvent event = (TextBufferFillEvent) v1; - logger.log(Level.INFO, "GPU: Filled area at " + event.x() + ":" + event.y() + " with size of " + event.width() + "x" + event.height()); - gr.fillRect(event.x(), event.y(), event.width(), event.height()); - return null; - }); - EventBus.listenTo(TextBufferSetBackgroundColorEvent.class, (Event v1) -> { - TextBufferSetBackgroundColorEvent event = (TextBufferSetBackgroundColorEvent) v1; - logger.log(Level.INFO, "GPU: Background set to " + event.color()); - this.setBackground(new Color(event.color())); - return null; - }); - EventBus.listenTo(TextBufferSetColorDepthEvent.class, (Event v1) -> { - TextBufferSetColorDepthEvent event = (TextBufferSetColorDepthEvent) v1; - logger.log(Level.INFO, "GPU: Set color depth to " + event.depth()); - return null; - }); - EventBus.listenTo(TextBufferSetEvent.class, (Event v1) -> { - TextBufferSetEvent event = (TextBufferSetEvent) v1; - logger.log(Level.INFO, "GPU: Printed string " + event.value() + " at " + event.x() + ":" + event.y()); - gr.drawString(event.value(), event.x() * this.CHAR_WIDTH, event.y() * this.CHAR_HEIGHT); - return null; - }); - EventBus.listenTo(TextBufferSetForegroundColorEvent.class, (Event v1) -> { - TextBufferSetForegroundColorEvent event = (TextBufferSetForegroundColorEvent) v1; - logger.log(Level.INFO, "GPU: Foreground set to " + event.color()); - gr.setColor(new Color(event.color())); - return null; - }); - EventBus.listenTo(TextBufferSetPaletteColorEvent.class, (Event v1) -> { - TextBufferSetPaletteColorEvent event = (TextBufferSetPaletteColorEvent) v1; - logger.log(Level.INFO, "GPU: Set palette color " + event.index()); - gr.setColor(colors[event.index()]); - return null; - }); - EventBus.listenTo(TextBufferSetResolutionEvent.class, (Event v1) -> { - TextBufferSetResolutionEvent event = (TextBufferSetResolutionEvent) v1; - logger.log(Level.INFO, "GPU: Resolution is set to " + event.width() + "x" + event.height()); - this.setSize(event.width() * this.CHAR_WIDTH, event.height() * this.CHAR_HEIGHT); - return null; - }); - EventBus.listenTo(TextBufferSetViewportEvent.class, (Event v1) -> { - TextBufferSetViewportEvent event = (TextBufferSetViewportEvent) v1; - // TODO - return null; - }); - logger.log(Level.WARNING, "GPU: Drawing screen"); - for (int i = 0; i < screen._data().buffer().length; i++) { - for (int j = 0; j < screen._data().buffer()[i].length; j++) { - gr.drawString(String.valueOf(screen._data().buffer()[i][j]), j * this.CHAR_WIDTH, i * this.CHAR_HEIGHT); - System.out.print(String.valueOf(screen._data().buffer()[i][j])); - } - System.out.print("\n"); - } - } - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private JPanel canvasPanel; - private JMenu fileMenu; - private JMenuBar jMenuBar1; - private JMenuItem jMenuItem1; - private JMenu viewMenu; - private JMenu windowMenu; - // End of variables declaration//GEN-END:variables -} diff --git a/src/ru/VladTheMountain/oclide/OCLIDE.java b/src/ru/VladTheMountain/oclide/OCLIDE.java index 978a597..3ca9f53 100644 --- a/src/ru/VladTheMountain/oclide/OCLIDE.java +++ b/src/ru/VladTheMountain/oclide/OCLIDE.java @@ -23,38 +23,41 @@ */ package ru.VladTheMountain.oclide; +import ru.VladTheMountain.oclide.ui.frames.EditorFrame; import java.awt.Graphics2D; import java.awt.SplashScreen; import java.util.logging.Level; import java.util.logging.Logger; -import ru.VladTheMountain.oclide.ui.frames.EditorFrame; /** + * Launchong script * * @author VladTheMountain */ public class OCLIDE { /** + * Main method of the application + * * @param args the command line arguments */ public static void main(String[] args) { - // DECOMMENT AT RELEASE final SplashScreen splash = SplashScreen.getSplashScreen(); if (splash == null) { - System.out.println("SplashScreen.getSplashScreen() returned null"); - return; - } - Graphics2D g = splash.createGraphics(); - if (g == null) { - System.out.println("g is null"); - return; + Logger.getLogger(OCLIDE.class.getName()).log(Level.INFO, "No splash was found to display, ignoring..."); + //return; + } else { + Graphics2D g = splash.createGraphics(); + if (g == null) { + Logger.getLogger(OCLIDE.class.getName()).log(Level.WARNING, "No suitable Graphics2D was found to display the splash"); + return; + } } try { Thread.sleep(2000); new EditorFrame().setVisible(true); } catch (InterruptedException ex) { - Logger.getLogger(OCLIDE.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(OCLIDE.class.getName()).log(Level.SEVERE, "Couldn't start main JFrame", ex); } } } diff --git a/src/ru/VladTheMountain/oclide/configurator/ocemu/ConfigMaker.java b/src/ru/VladTheMountain/oclide/configurators/ocemu/ConfigMaker.java similarity index 82% rename from src/ru/VladTheMountain/oclide/configurator/ocemu/ConfigMaker.java rename to src/ru/VladTheMountain/oclide/configurators/ocemu/ConfigMaker.java index b1030e7..be0ced3 100644 --- a/src/ru/VladTheMountain/oclide/configurator/ocemu/ConfigMaker.java +++ b/src/ru/VladTheMountain/oclide/configurators/ocemu/ConfigMaker.java @@ -21,13 +21,16 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package ru.VladTheMountain.oclide.configurator.ocemu; +package ru.VladTheMountain.oclide.configurators.ocemu; import java.io.File; import java.io.IOException; import java.nio.file.Files; +import java.util.Arrays; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.JOptionPane; -import ru.VladTheMountain.oclide.configurator.ocemu.component.OCEmuComponent; +import ru.VladTheMountain.oclide.configurators.ocemu.component.OCEmuComponent; /** * @@ -52,9 +55,14 @@ public class ConfigMaker { /** * Initialization constructor * - * @param comps + * @param comps array of OCEmuComponent + * @see ru.VladTheMountain.oclide.configurators.ocemu.component.OCEmuComponent */ public ConfigMaker(OCEmuComponent[] comps) { + if (comps == null || comps.length < 2) { + Logger.getLogger(ConfigMaker.class.getName()).log(Level.WARNING, "ConfigMaker received an incomplete configutation", comps); + JOptionPane.showMessageDialog(null, "Couldn't create ConfigMaker for OCEmu: Incomplete configuration:\n" + Arrays.toString(comps), "Caught " + "", JOptionPane.WARNING_MESSAGE); + } this.computerComponents = ""; for (OCEmuComponent comp : comps) { switch (comp.getComponentType()) { @@ -102,17 +110,19 @@ public ConfigMaker(OCEmuComponent[] comps) { + "{\"screen_sdl2\", " + "\"" + comp.getComponentAddress() + "\", " + "" + comp.getOptionAt(0) + ", " + "" + comp.getOptionAt(1) + ", " + "" + comp.getOptionAt(2) + ", " + "" + comp.getOptionAt(3) + "},\n"; break; + default: + Logger.getLogger(ConfigMaker.class.getName()).log(Level.SEVERE, "ConfigMaker received an invalid component type: {0}", comp.getComponentType()); + break; } + Logger.getLogger(this.getClass().getName()).log(Level.CONFIG, "Added component to OCEmu config:", comp.toString()); } } /** * Creates the new config file - * - * @throws IOException */ - public void createConfig() throws IOException { - String path = null; + public void createConfig() { + String path; if (System.getProperty("os.name").contains("Windows")) { path = System.getenv("APPDATA") + "\\OCEmu\\ocemu.cfg"; } else { @@ -123,7 +133,7 @@ public void createConfig() throws IOException { } } if (path == null) { - JOptionPane.showMessageDialog(null, "WARNING: Couldn't create config for your OS. Please create an issue about this problem at https://github.com/Vladg24YT/Oclide/issues", "Config creation error", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(null, "WARNING: Couldn't create path for config file for your OS. Please create an issue about this problem at https://github.com/Vladg24YT/Oclide/issues", "Config creation error", JOptionPane.ERROR_MESSAGE); return; } File config = new File(path); @@ -131,7 +141,12 @@ public void createConfig() throws IOException { if (!(new File(config.getParent()).exists())) { new File(config.getParent()).mkdirs(); } - config.createNewFile(); + try { + config.createNewFile(); + } catch (IOException ex) { + Logger.getLogger(ConfigMaker.class.getName()).log(Level.SEVERE, "Couldn't create config file:", ex); + JOptionPane.showMessageDialog(null, ex, "Caught " + ex.getClass().getName(), JOptionPane.ERROR_MESSAGE); + } } // String contents @@ -233,7 +248,12 @@ public void createConfig() throws IOException { + " }\n" + "}"; // - Files.write(config.toPath(), contents.getBytes()); + try { + Files.write(config.toPath(), contents.getBytes()); + } catch (IOException ex) { + Logger.getLogger(ConfigMaker.class.getName()).log(Level.SEVERE, "Couldn't write to config file", ex); + JOptionPane.showMessageDialog(null, ex, "Caught " + ex.getClass().getName(), JOptionPane.ERROR_MESSAGE); + } } /** @@ -241,16 +261,26 @@ public void createConfig() throws IOException { * * @param f Config gile * @return Array of {@link OCEmuComponent} - * @throws IOException */ - public OCEmuComponent[] readConfig(File f) throws IOException { - int lines = Files.readAllLines(f.toPath()).toArray().length; + public OCEmuComponent[] readConfig(File f) { + int lines = 0; + try { + lines = Files.readAllLines(f.toPath()).toArray().length; + } catch (IOException ex) { + Logger.getLogger(ConfigMaker.class.getName()).log(Level.SEVERE, null, ex); + JOptionPane.showMessageDialog(null, ex, "Caught " + ex.getClass().getName(), JOptionPane.ERROR_MESSAGE); + } String[] configContents = new String[lines]; - System.arraycopy(Files.readAllLines(f.toPath()).toArray(configContents), 0, configContents, 0, lines); + try { + System.arraycopy(Files.readAllLines(f.toPath()).toArray(configContents), 0, configContents, 0, lines); + } catch (IOException ex) { + Logger.getLogger(ConfigMaker.class.getName()).log(Level.SEVERE, null, ex); + JOptionPane.showMessageDialog(null, ex, "Caught " + ex.getClass().getName(), JOptionPane.ERROR_MESSAGE); + } OCEmuComponent[] tmp = {}; for (int i = 47; i < configContents.length; i++) { if (configContents[i].startsWith("{") && (configContents[i].endsWith("}") || configContents[i].endsWith("},"))) { - int type = 7; + byte type = 7; String address; String[] opts = new String[4]; int comma1 = configContents[i].indexOf(","); @@ -286,6 +316,9 @@ public OCEmuComponent[] readConfig(File f) throws IOException { case "screen": type = 8; break; + default: + Logger.getLogger(ConfigMaker.class.getName()).log(Level.WARNING, "ConfigMaker detected an invalid component type: {0}", configContents[i].substring(configContents[i].indexOf("\""), configContents[i].indexOf("\"", configContents[i].indexOf("\"")))); + break; } address = configContents[i].substring(comma1 + 2, comma2 - 1); opts[0] = configContents[i].substring(comma2 + 2, comma3 - 1); diff --git a/src/ru/VladTheMountain/oclide/configurator/ocemu/OCEmuLauncher.java b/src/ru/VladTheMountain/oclide/configurators/ocemu/OCEmuLauncher.java similarity index 67% rename from src/ru/VladTheMountain/oclide/configurator/ocemu/OCEmuLauncher.java rename to src/ru/VladTheMountain/oclide/configurators/ocemu/OCEmuLauncher.java index d603d44..2838fa5 100644 --- a/src/ru/VladTheMountain/oclide/configurator/ocemu/OCEmuLauncher.java +++ b/src/ru/VladTheMountain/oclide/configurators/ocemu/OCEmuLauncher.java @@ -21,19 +21,20 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package ru.VladTheMountain.oclide.configurator.ocemu; +package ru.VladTheMountain.oclide.configurators.ocemu; import javax.swing.JOptionPane; -import ru.VladTheMountain.oclide.configurator.ocemu.component.Computer; -import ru.VladTheMountain.oclide.configurator.ocemu.component.EEPROM; -import ru.VladTheMountain.oclide.configurator.ocemu.component.Filesystem; -import ru.VladTheMountain.oclide.configurator.ocemu.component.GPU; -import ru.VladTheMountain.oclide.configurator.ocemu.component.Internet; -import ru.VladTheMountain.oclide.configurator.ocemu.component.Keyboard; -import ru.VladTheMountain.oclide.configurator.ocemu.component.Modem; -import ru.VladTheMountain.oclide.configurator.ocemu.component.OCEmu; -import ru.VladTheMountain.oclide.configurator.ocemu.component.OCEmuComponent; -import ru.VladTheMountain.oclide.configurator.ocemu.component.Screen; +import li.cil.repack.org.luaj.vm2.lib.jse.JsePlatform; +import ru.VladTheMountain.oclide.configurators.ocemu.component.Computer; +import ru.VladTheMountain.oclide.configurators.ocemu.component.EEPROM; +import ru.VladTheMountain.oclide.configurators.ocemu.component.Filesystem; +import ru.VladTheMountain.oclide.configurators.ocemu.component.GPU; +import ru.VladTheMountain.oclide.configurators.ocemu.component.Internet; +import ru.VladTheMountain.oclide.configurators.ocemu.component.Keyboard; +import ru.VladTheMountain.oclide.configurators.ocemu.component.Modem; +import ru.VladTheMountain.oclide.configurators.ocemu.component.OCEmu; +import ru.VladTheMountain.oclide.configurators.ocemu.component.OCEmuComponent; +import ru.VladTheMountain.oclide.configurators.ocemu.component.Screen; /** * @@ -48,9 +49,9 @@ public class OCEmuLauncher { new GPU(0, 160, 50, 3), new Modem(1, false), new EEPROM(9, "lua/bios.lua"), - new Filesystem(7, ".machine/tmpfs", true), - new Filesystem("nil", "tmpfs", false), - new Filesystem(5, "nil", false), + new Filesystem(7, "tmpfs", ".machine/tmpfs", true, 0), + new Filesystem(-1, "tmpfs", "tmpfs", false, 0), + new Filesystem(5, "nil", "nil", false, 0), new Internet(), new Computer(), new OCEmu(), @@ -64,7 +65,6 @@ public class OCEmuLauncher { /*public OCEmuLauncher() { }*/ - /** * Launcher constructor. Starts OCEmu with {@link OCEmuComponent} as a * source for config @@ -82,7 +82,10 @@ public class OCEmuLauncher { * {@code JOptionPane.ERROR_MESSAGE} if the attempt fails */ public int reloadConfig() { - return JOptionPane.ERROR_MESSAGE; } + + public static String runOCEmu() { + return JsePlatform.standardGlobals().loadfile("OCEmu/boot.lua").call().tojstring(); + } } diff --git a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/Computer.java b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/Computer.java similarity index 95% rename from src/ru/VladTheMountain/oclide/configurator/ocemu/component/Computer.java rename to src/ru/VladTheMountain/oclide/configurators/ocemu/component/Computer.java index 3fb490d..57ff967 100644 --- a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/Computer.java +++ b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/Computer.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package ru.VladTheMountain.oclide.configurator.ocemu.component; +package ru.VladTheMountain.oclide.configurators.ocemu.component; import ru.VladTheMountain.oclide.util.UUIDGenerator; diff --git a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/EEPROM.java b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/EEPROM.java similarity index 95% rename from src/ru/VladTheMountain/oclide/configurator/ocemu/component/EEPROM.java rename to src/ru/VladTheMountain/oclide/configurators/ocemu/component/EEPROM.java index 449b2e9..706f751 100644 --- a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/EEPROM.java +++ b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/EEPROM.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package ru.VladTheMountain.oclide.configurator.ocemu.component; +package ru.VladTheMountain.oclide.configurators.ocemu.component; import ru.VladTheMountain.oclide.util.UUIDGenerator; diff --git a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/Filesystem.java b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/Filesystem.java similarity index 67% rename from src/ru/VladTheMountain/oclide/configurator/ocemu/component/Filesystem.java rename to src/ru/VladTheMountain/oclide/configurators/ocemu/component/Filesystem.java index e251ccc..01467e2 100644 --- a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/Filesystem.java +++ b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/Filesystem.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package ru.VladTheMountain.oclide.configurator.ocemu.component; +package ru.VladTheMountain.oclide.configurators.ocemu.component; import ru.VladTheMountain.oclide.util.UUIDGenerator; @@ -31,18 +31,27 @@ */ public class Filesystem extends OCEmuComponent { - public Filesystem(int i1, String s1, boolean b1) { - super(2, UUIDGenerator.create(), String.valueOf(i1), s1, String.valueOf(b1)); + /** + * Creates a new OCEmu machine component + * + * @param i1 unknown + * @param directory the directory, where the files will be stored + * @param label the name of the filesystem + * @param readOnly if it is read-only + * @param speed unknowns + */ + public Filesystem(int i1, String directory, String label, boolean readOnly, int speed) { + super(2, UUIDGenerator.create(), String.valueOf(i1), directory, label, String.valueOf(readOnly)); } /** * Only if the first parameter is {@code null} * - * @param i1 - * @param s1 - * @param b1 + * @param i1 i1 + * @param s1 s1 + * @param b1 b1 */ - public Filesystem(String i1, String s1, boolean b1) { + /*public Filesystem(String i1, String s1, boolean b1, int speed) { super(2, UUIDGenerator.create(), i1, s1, String.valueOf(b1)); - } + }*/ } diff --git a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/GPU.java b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/GPU.java similarity index 95% rename from src/ru/VladTheMountain/oclide/configurator/ocemu/component/GPU.java rename to src/ru/VladTheMountain/oclide/configurators/ocemu/component/GPU.java index b363a76..34978aa 100644 --- a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/GPU.java +++ b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/GPU.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package ru.VladTheMountain.oclide.configurator.ocemu.component; +package ru.VladTheMountain.oclide.configurators.ocemu.component; import ru.VladTheMountain.oclide.util.UUIDGenerator; diff --git a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/Internet.java b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/Internet.java similarity index 95% rename from src/ru/VladTheMountain/oclide/configurator/ocemu/component/Internet.java rename to src/ru/VladTheMountain/oclide/configurators/ocemu/component/Internet.java index aeb3471..8f6bd3d 100644 --- a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/Internet.java +++ b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/Internet.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package ru.VladTheMountain.oclide.configurator.ocemu.component; +package ru.VladTheMountain.oclide.configurators.ocemu.component; import ru.VladTheMountain.oclide.util.UUIDGenerator; diff --git a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/Keyboard.java b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/Keyboard.java similarity index 95% rename from src/ru/VladTheMountain/oclide/configurator/ocemu/component/Keyboard.java rename to src/ru/VladTheMountain/oclide/configurators/ocemu/component/Keyboard.java index 6f48194..8f10b1b 100644 --- a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/Keyboard.java +++ b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/Keyboard.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package ru.VladTheMountain.oclide.configurator.ocemu.component; +package ru.VladTheMountain.oclide.configurators.ocemu.component; import ru.VladTheMountain.oclide.util.UUIDGenerator; diff --git a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/Modem.java b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/Modem.java similarity index 95% rename from src/ru/VladTheMountain/oclide/configurator/ocemu/component/Modem.java rename to src/ru/VladTheMountain/oclide/configurators/ocemu/component/Modem.java index 15b32fa..088e691 100644 --- a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/Modem.java +++ b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/Modem.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package ru.VladTheMountain.oclide.configurator.ocemu.component; +package ru.VladTheMountain.oclide.configurators.ocemu.component; import ru.VladTheMountain.oclide.util.UUIDGenerator; diff --git a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/OCEmu.java b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/OCEmu.java similarity index 95% rename from src/ru/VladTheMountain/oclide/configurator/ocemu/component/OCEmu.java rename to src/ru/VladTheMountain/oclide/configurators/ocemu/component/OCEmu.java index c1ea23c..6796888 100644 --- a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/OCEmu.java +++ b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/OCEmu.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package ru.VladTheMountain.oclide.configurator.ocemu.component; +package ru.VladTheMountain.oclide.configurators.ocemu.component; import ru.VladTheMountain.oclide.util.UUIDGenerator; diff --git a/src/ru/VladTheMountain/oclide/configurators/ocemu/component/OCEmuComponent.java b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/OCEmuComponent.java new file mode 100644 index 0000000..1fa9699 --- /dev/null +++ b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/OCEmuComponent.java @@ -0,0 +1,98 @@ +/* + * The MIT License + * + * Copyright 2021 Vladislav Gorskii. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package ru.VladTheMountain.oclide.configurators.ocemu.component; + +import java.util.Arrays; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Superclass for all components used in OCEmu + * + * @author VladTheMountain + */ +public class OCEmuComponent { + + //FIELD 1 + private int type; + //FIELD 2 + private String address; + //the rest + private String[] opts; + + /** + * Creates a new OCEmu component of defined type, address and options. It is + * recommended to override the constructor in a sub-class, then call it from + * this class. + * + * @param componentType the type of the component, see + * {@link io.VladTheMountain.oclide.configurator.ocemu.ConfigMaker} to see + * which id corresponds to which component + * @param componentAddress the UUID of the component in OCEmu's machine + * @param options additional options/parameters that can be passed with the + * component (maximum of 5) + */ + public OCEmuComponent(int componentType, String componentAddress, String... options) { + if (componentAddress == null) { + Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Attempted to create an OCEmuComponent with no address. The result is unpredictable."); + } + this.type = componentType; + this.address = componentAddress; + this.opts = new String[4]; + System.arraycopy(options, 0, opts, 0, options.length); + } + + /** + * Returns component type + * + * @return int, which stores the component's type + */ + public int getComponentType() { + return type; + } + + /** + * Returns component address + * + * @return UUID as a String + */ + public String getComponentAddress() { + return address; + } + + /** + * Returns a specific parameter of the component + * + * @param pos position of the parameter (beginning with 0) + * @return value of the parameter + */ + public String getOptionAt(int pos) { + return opts[pos]; + } + + @Override + public String toString() { + return "OCEmuComponent {" + type + "," + address + "," + Arrays.toString(opts) + "}"; + } +} diff --git a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/Screen.java b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/Screen.java similarity index 92% rename from src/ru/VladTheMountain/oclide/configurator/ocemu/component/Screen.java rename to src/ru/VladTheMountain/oclide/configurators/ocemu/component/Screen.java index 26e728a..3046292 100644 --- a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/Screen.java +++ b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/Screen.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package ru.VladTheMountain.oclide.configurator.ocemu.component; +package ru.VladTheMountain.oclide.configurators.ocemu.component; import ru.VladTheMountain.oclide.util.UUIDGenerator; @@ -38,10 +38,10 @@ public Screen(int i1, int i2, int i3, int i4) { /** * Use only if the first param is null * - * @param i1 - * @param i2 - * @param i3 - * @param i4 + * @param i1 i1 + * @param i2 i2 + * @param i3 i3 + * @param i4 i4 */ public Screen(String i1, int i2, int i3, int i4) { super(8, UUIDGenerator.create(), i1, String.valueOf(i2), String.valueOf(i3), String.valueOf(i4)); diff --git a/src/ru/VladTheMountain/oclide/configurator/ocelot/OcelotDesktopLauncher.java b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/package-info.java similarity index 89% rename from src/ru/VladTheMountain/oclide/configurator/ocelot/OcelotDesktopLauncher.java rename to src/ru/VladTheMountain/oclide/configurators/ocemu/component/package-info.java index 2f75cfa..9c3d8fd 100644 --- a/src/ru/VladTheMountain/oclide/configurator/ocelot/OcelotDesktopLauncher.java +++ b/src/ru/VladTheMountain/oclide/configurators/ocemu/component/package-info.java @@ -21,13 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package ru.VladTheMountain.oclide.configurator.ocelot; - /** - * Util class for launching Ocelot Desktop + * Supportive classes that are used to create the configuration file. * * @author VladTheMountain */ -public class OcelotDesktopLauncher { - -} +package ru.VladTheMountain.oclide.configurators.ocemu.component; diff --git a/src/ru/VladTheMountain/oclide/configurators/ocemu/package-info.java b/src/ru/VladTheMountain/oclide/configurators/ocemu/package-info.java new file mode 100644 index 0000000..d5bf26c --- /dev/null +++ b/src/ru/VladTheMountain/oclide/configurators/ocemu/package-info.java @@ -0,0 +1,31 @@ +/* + * The MIT License + * + * Copyright 2021 VladTheMountain. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +/** + * The OCEmu launcher and other classes neccessary for its' proper + * functioning. + * + * @see io.VladTheMountain.oclide.configurator.ocemu.component + * @author VladTheMountain + */ +package ru.VladTheMountain.oclide.configurators.ocemu; diff --git a/src/ru/VladTheMountain/oclide/configurators/package-info.java b/src/ru/VladTheMountain/oclide/configurators/package-info.java new file mode 100644 index 0000000..6c246dd --- /dev/null +++ b/src/ru/VladTheMountain/oclide/configurators/package-info.java @@ -0,0 +1,29 @@ +/* + * The MIT License + * + * Copyright 2021 VladTheMountain. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +/** + * A bunch of packages containing tools to launch and configure supported emulators. + * + * @author VladTheMountain + */ +package ru.VladTheMountain.oclide.configurators; diff --git a/src/ru/VladTheMountain/oclide/editor/OCLIDECompletionProvider.java b/src/ru/VladTheMountain/oclide/editor/autocompletion/OCLIDECompletionProvider.java similarity index 59% rename from src/ru/VladTheMountain/oclide/editor/OCLIDECompletionProvider.java rename to src/ru/VladTheMountain/oclide/editor/autocompletion/OCLIDECompletionProvider.java index ea07584..ed1d962 100644 --- a/src/ru/VladTheMountain/oclide/editor/OCLIDECompletionProvider.java +++ b/src/ru/VladTheMountain/oclide/editor/autocompletion/OCLIDECompletionProvider.java @@ -21,11 +21,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package ru.VladTheMountain.oclide.editor; +package ru.VladTheMountain.oclide.editor.autocompletion; import java.util.Arrays; import java.util.Locale; import java.util.ResourceBundle; +import java.util.logging.Level; +import java.util.logging.Logger; import org.fife.ui.autocomplete.BasicCompletion; import org.fife.ui.autocomplete.CompletionProvider; import org.fife.ui.autocomplete.DefaultCompletionProvider; @@ -34,207 +36,226 @@ import org.fife.ui.autocomplete.ParameterizedCompletion.Parameter; /** - * This class provides an instance of {@link LanguageAwareProvider}, which - * contains autocompletion stuff for both Lua 5.3 and OpenOS 1.7 + * This class provides an instance of {@code LanguageAwareProvider} via + * {@link #getProvider()} method, which contains autocompletion stuff for both + * Lua 5.3 and OpenOS 1.7 * + * @see org.fife.ui.autocomplete.LanguageAwareCompletionProvider * @author VladTheMountain */ public class OCLIDECompletionProvider { + private static DefaultCompletionProvider defaultProvider; + + // 'Since' // + //Lua + private static final String LUA_52 = "Lua 5.2"; + private static final String LUA_53 = "Lua 5.3"; + //OpenOS + private static final String OPENOS_16 = "OpenOS 1.6"; + private static final String OPENOS_17 = "OpenOS 1.7"; + + /** + * Constructs and returns the {@code LanguageAwareProvider} + * + * @return An instance of {@code LanguageAwareProvider} with ready + * autocompletion rules + * @deprecated Will be reworked to be automated via Parser. + */ public static CompletionProvider getProvider() { - ResourceBundle autocompletion = ResourceBundle.getBundle("ru.VladTheMountain.oclide.resources.autocompletion.Autocompletion", Locale.getDefault()); - DefaultCompletionProvider defaultProvider = new DefaultCompletionProvider(); + ResourceBundle autocompletion = ResourceBundle.getBundle("io.VladTheMountain.oclide.resources.autocompletion.Autocompletion", Locale.getDefault()); + defaultProvider = new DefaultCompletionProvider(); defaultProvider.setAutoActivationRules(true, null); defaultProvider.setParameterizedCompletionParams('(', ", ", ')'); //Lua default - /* Do we really need those two global vars in autocompletion? */ + /* Do we really need these two global vars in autocompletion? */ defaultProvider.addCompletion(new BasicCompletion(defaultProvider, "_G")); defaultProvider.addCompletion(new BasicCompletion(defaultProvider, "_VERSION")); - createCompletion(defaultProvider, "assert", "Lua 5.3", autocompletion.getString("assert"), "v's arguments", new CustomParameter[][]{ + createCompletion("assert", LUA_52, autocompletion.getString("assert"), "v's arguments", new CustomParameter[][]{ {new CustomParameter("object", "v", true, "Object to return")}, {new CustomParameter("object", "v", false, "Object to return"), new CustomParameter("string", "message", true, "Message to print if 'v' is false")} }); - createCompletion(defaultProvider, "dofile", "Lua 5.3", autocompletion.getString("dofile"), "Chunk's return values", new CustomParameter[][]{ + createCompletion("dofile", LUA_52, autocompletion.getString("dofile"), "Chunk's return values", new CustomParameter[][]{ {new CustomParameter("string", "filename", true, "File to execute")}, {} }); - createCompletion(defaultProvider, "error", "Lua 5.3", autocompletion.getString("error"), "", new CustomParameter[][]{ + createCompletion("error", LUA_52, autocompletion.getString("error"), "", new CustomParameter[][]{ {new CustomParameter("string", "message", true, "Message to print")}, {new CustomParameter("string", "message", false, "Message to print"), new CustomParameter("number", "level", true, "Way of getting the error position")} }); - createCompletion(defaultProvider, "getmetatable", "Lua 5.3", autocompletion.getString("getmetatable"), "Returns 'object's __metatable field", new CustomParameter[][]{ + createCompletion("getmetatable", LUA_52, autocompletion.getString("getmetatable"), "Returns 'object's __metatable field", new CustomParameter[][]{ {new CustomParameter("table", "object", true, "Table to return __metatable value of")} }); - createCompletion(defaultProvider, "ipairs", "Lua 5.3", autocompletion.getString("ipairs"), "Returns three values - an iterator function, the table t, and 0", new CustomParameter[][]{ + createCompletion("ipairs", LUA_52, autocompletion.getString("ipairs"), "Returns three values - an iterator function, the table t, and 0", new CustomParameter[][]{ {new CustomParameter("table", "t", true, "Table to iterate through")} }); - createCompletion(defaultProvider, "load", "Lua 5.3", autocompletion.getString("load"), "Returns the compiled chunk as a function", new CustomParameter[][]{ + createCompletion("load", LUA_52, autocompletion.getString("load"), "Returns the compiled chunk as a function", new CustomParameter[][]{ {new CustomParameter("chunk", "chunk", true, "Chunk to load")}, {new CustomParameter("chunk", "chunk", false, "Chunk to load"), new CustomParameter("string", "chunkname", true, "The name of the chunk for error messages and debug information")}, {new CustomParameter("chunk", "chunk", false, "Chunk to load"), new CustomParameter("string", "chunkname", false, "The name of the chunk for error messages and debug information"), new CustomParameter("string", "mode", true, "Controls whether the chunk can be text or binary")}, {new CustomParameter("chunk", "chunk", false, "Chunk to load"), new CustomParameter("string", "chunkname", false, "The name of the chunk for error messages and debug information"), new CustomParameter("string", "mode", false, "Controls whether the chunk can be text or binary"), new CustomParameter("object", "env", true, "The value to set the first upvalue of the chunk to")} }); - createCompletion(defaultProvider, "loadfile", "Lua 5.3", autocompletion.getString("loadfile"), "The same as load()", new CustomParameter[][]{ + createCompletion("loadfile", LUA_52, autocompletion.getString("loadfile"), "The same as load()", new CustomParameter[][]{ {new CustomParameter("string", "filename", true, "The file to get the chunk from")}, {new CustomParameter("string", "filename", false, "The file to get the chunk from"), new CustomParameter("string", "mode", false, "Controls whether the chunk can be text or binary")}, {new CustomParameter("string", "filename", false, "The file to get the chunk from"), new CustomParameter("string", "mode", false, "Controls whether the chunk can be text or binary"), new CustomParameter("object", "env", true, "The value to set the first upvalue of the chunk to")}, {} }); - createCompletion(defaultProvider, "next", "Lua 5.3", autocompletion.getString("next"), "Returns the next index of the table and its associated value", new CustomParameter[][]{ + createCompletion("next", LUA_52, autocompletion.getString("next"), "Returns the next index of the table and its associated value", new CustomParameter[][]{ {new CustomParameter("table", "table", true, "The table to traverse all fields of")}, {new CustomParameter("table", "table", false, "The table to traverse all fields of"), new CustomParameter("number", "index", true, "The initial index")} }); - createCompletion(defaultProvider, "pairs", "Lua 5.3", autocompletion.getString("pairs"), "Returns next(t), t and nil", new CustomParameter[][]{ + createCompletion("pairs", LUA_52, autocompletion.getString("pairs"), "Returns next(t), t and nil", new CustomParameter[][]{ {new CustomParameter("table", "t", true, "The table to iterate through")} }); - createCompletion(defaultProvider, "pcall", "Lua 5.3", autocompletion.getString("pcall"), "Returns the status code of calling f(...)", new CustomParameter[][]{ + createCompletion("pcall", LUA_52, autocompletion.getString("pcall"), "Returns the status code of calling f(...)", new CustomParameter[][]{ {new CustomParameter("function", "f", true, "Function to call")}, {new CustomParameter("function", "f", false, "Function to call"), new CustomParameter("", "...", true, "Function arguments")} }); - createCompletion(defaultProvider, "print", "Lua 5.3", autocompletion.getString("print"), "", new CustomParameter[][]{ + createCompletion("print", LUA_52, autocompletion.getString("print"), "", new CustomParameter[][]{ {new CustomParameter("", "...", true, "Object(-s) to print")} }); - createCompletion(defaultProvider, "rawequal", "Lua 5.3", autocompletion.getString("rawequal"), "Returns boolean - result of __eq metamethod", new CustomParameter[][]{ + createCompletion("rawequal", LUA_52, autocompletion.getString("rawequal"), "Returns boolean - result of __eq metamethod", new CustomParameter[][]{ {new CustomParameter("object", "v1", false, "First object to compare"), new CustomParameter("object", "v2", true, "Second object to compare")} }); - createCompletion(defaultProvider, "rawget", "Lua 5.3", autocompletion.getString("rawget"), "Returns value at index of table", new CustomParameter[][]{ + createCompletion("rawget", LUA_52, autocompletion.getString("rawget"), "Returns value at index of table", new CustomParameter[][]{ {new CustomParameter("table", "table", false, "Table to get value from"), new CustomParameter("number", "index", true, "Index of the table to get value of")} }); - createCompletion(defaultProvider, "rawlen", "Lua 5.3", autocompletion.getString("rawlen"), "Returns the length of the object", new CustomParameter[][]{ + createCompletion("rawlen", LUA_52, autocompletion.getString("rawlen"), "Returns the length of the object", new CustomParameter[][]{ {new CustomParameter("table", "v", true, "Object to measure length of")} }); - createCompletion(defaultProvider, "rawset", "Lua 5.3", autocompletion.getString("rawset"), "Returns table", new CustomParameter[][]{ + createCompletion("rawset", LUA_52, autocompletion.getString("rawset"), "Returns table", new CustomParameter[][]{ {new CustomParameter("table", "table", false, "the table in which you need to change the value"), new CustomParameter("number", "index", false, "the index of the table's cell to change value of"), new CustomParameter("object", "value", true, "the new value of the table[index]")} }); - createCompletion(defaultProvider, "select", "Lua 5.3", autocompletion.getString("select"), "Returns argument index", new CustomParameter[][]{ + createCompletion("select", LUA_52, autocompletion.getString("select"), "Returns argument index", new CustomParameter[][]{ {new CustomParameter("number", "index", false, "the argument to return"), new CustomParameter("obejct", "...", true, "arguments")} }); - createCompletion(defaultProvider, "setmetatable", "Lua 5.3", autocompletion.getString("setmetatable"), "Returns table", new CustomParameter[][]{ + createCompletion("setmetatable", LUA_52, autocompletion.getString("setmetatable"), "Returns table", new CustomParameter[][]{ {new CustomParameter("table", "table", false, "table to set metatable for"), new CustomParameter("metatable", "metatable", true, "metatable to set")} }); - createCompletion(defaultProvider, "tonumber", "Lua 5.3", autocompletion.getString("tonumber"), "Returns e as a number", new CustomParameter[][]{ + createCompletion("tonumber", LUA_52, autocompletion.getString("tonumber"), "Returns e as a number", new CustomParameter[][]{ {new CustomParameter("object", "e", true, "object to translate to a number")}, {new CustomParameter("object", "e", false, "object to translate to a number"), new CustomParameter("number", "base", true, "the base number for e")} }); - createCompletion(defaultProvider, "tostring", "Lua 5.3", autocompletion.getString("tostring"), "Returns v as a string", new CustomParameter[][]{ + createCompletion("tostring", LUA_52, autocompletion.getString("tostring"), "Returns v as a string", new CustomParameter[][]{ {new CustomParameter("object", "v", true, "object to translate to a string")} }); - createCompletion(defaultProvider, "type", "Lua 5.3", autocompletion.getString("type"), "Returns the type of v", new CustomParameter[][]{ + createCompletion("type", LUA_52, autocompletion.getString("type"), "Returns the type of v", new CustomParameter[][]{ {new CustomParameter("object", "v", true, "object to get type of")} }); - createCompletion(defaultProvider, "xpcall", "Lua 5.3", autocompletion.getString("xpcall"), "Returns the same as pcall", new CustomParameter[][]{ + createCompletion("xpcall", LUA_52, autocompletion.getString("xpcall"), "Returns the same as pcall", new CustomParameter[][]{ {new CustomParameter("function", "f", false, "function to call"), new CustomParameter("object", "msgh", true, "message handler")}, {new CustomParameter("function", "f", false, "function to call"), new CustomParameter("object", "msgh", false, "message handler"), new CustomParameter("...", "args", true, "arguments to pass to f")} }); //Bit32 - createCompletion(defaultProvider, "bit32.arshift", "Lua 5.3", autocompletion.getString("bit32_arshift"), "Returns the number x shifted disp bits to the right", new CustomParameter[][]{ + createCompletion("bit32.arshift", LUA_52, autocompletion.getString("bit32_arshift"), "Returns the number x shifted disp bits to the right", new CustomParameter[][]{ {new CustomParameter("number", "x", false, "number to shift"), new CustomParameter("number", "disp", true, "how much to shift")} }); - createCompletion(defaultProvider, "bit32.band", "Lua 5.3", autocompletion.getString("bit32_band"), "Returns the bitwise and of its operands", new CustomParameter[][]{ + createCompletion("bit32.band", LUA_52, autocompletion.getString("bit32_band"), "Returns the bitwise and of its operands", new CustomParameter[][]{ {new CustomParameter("...", "", true, "operands")} }); - createCompletion(defaultProvider, "bit32.bnot", "Lua 5.3", autocompletion.getString("bit32_bnot"), "Returns the bitwise negation of x", new CustomParameter[][]{ + createCompletion("bit32.bnot", LUA_52, autocompletion.getString("bit32_bnot"), "Returns the bitwise negation of x", new CustomParameter[][]{ {new CustomParameter("object", "x", true, "operand")} }); - createCompletion(defaultProvider, "bit32.bor", "Lua 5.3", autocompletion.getString("bit32_bor"), "Returns the bitwise or of its operands", new CustomParameter[][]{ + createCompletion("bit32.bor", LUA_52, autocompletion.getString("bit32_bor"), "Returns the bitwise or of its operands", new CustomParameter[][]{ {new CustomParameter("...", "", true, "operands")} }); - createCompletion(defaultProvider, "bit32.btest", "Lua 5.3", autocompletion.getString("bit32_btest"), "Returns a boolean signaling whether the bitwise and of its operands is different from zero", new CustomParameter[][]{ + createCompletion("bit32.btest", LUA_52, autocompletion.getString("bit32_btest"), "Returns a boolean signaling whether the bitwise and of its operands is different from zero", new CustomParameter[][]{ {new CustomParameter("...", "", true, "operands")} }); - createCompletion(defaultProvider, "bit32.bxor", "Lua 5.3", autocompletion.getString("bit32_bxor"), "Returns the bitwise exclusive or of its operands", new CustomParameter[][]{ + createCompletion("bit32.bxor", LUA_52, autocompletion.getString("bit32_bxor"), "Returns the bitwise exclusive or of its operands", new CustomParameter[][]{ {new CustomParameter("...", "", true, "operands")} }); - createCompletion(defaultProvider, "bit32.extract", "Lua 5.3", autocompletion.getString("bit32_extract"), "Returns the unsigned number formed by the bits field to field + width - 1 from n", new CustomParameter[][]{ + createCompletion("bit32.extract", LUA_52, autocompletion.getString("bit32_extract"), "Returns the unsigned number formed by the bits field to field + width - 1 from n", new CustomParameter[][]{ {new CustomParameter("number", "n", false, ""), new CustomParameter("bits", "field", true, "")}, {new CustomParameter("number", "n", false, ""), new CustomParameter("bits", "field", false, ""), new CustomParameter("number", "width", true, "")} }); - createCompletion(defaultProvider, "bit32.replace", "Lua 5.3", autocompletion.getString("bit32_replace"), "Returns a copy of n with the bits field to field + width - 1 replaced by the value v", new CustomParameter[][]{ + createCompletion("bit32.replace", LUA_52, autocompletion.getString("bit32_replace"), "Returns a copy of n with the bits field to field + width - 1 replaced by the value v", new CustomParameter[][]{ {new CustomParameter("number", "n", false, ""), new CustomParameter("object", "v", false, "new value"), new CustomParameter("bits", "field", true, "")}, {new CustomParameter("number", "n", false, ""), new CustomParameter("object", "v", false, "new value"), new CustomParameter("bits", "field", false, ""), new CustomParameter("number", "width", true, "")} }); - createCompletion(defaultProvider, "bit32.lrotate", "Lua 5.3", autocompletion.getString("bit32_lrotate"), "Returns the number x rotated disp bits to the left", new CustomParameter[][]{ + createCompletion("bit32.lrotate", LUA_52, autocompletion.getString("bit32_lrotate"), "Returns the number x rotated disp bits to the left", new CustomParameter[][]{ {new CustomParameter("number", "x", false, "number to rotate"), new CustomParameter("number", "disp", true, "how much to shift")} }); - createCompletion(defaultProvider, "bit32.lshift", "Lua 5.3", autocompletion.getString("bit32_lshift"), "Returns the number x shifted disp bits to the left", new CustomParameter[][]{ + createCompletion("bit32.lshift", LUA_52, autocompletion.getString("bit32_lshift"), "Returns the number x shifted disp bits to the left", new CustomParameter[][]{ {new CustomParameter("number", "x", false, "number to shift"), new CustomParameter("number", "disp", true, "how much to shift")} }); - createCompletion(defaultProvider, "bit32.rrotate", "Lua 5.3", autocompletion.getString("bit32_rrotate"), "Returns the number x rotated disp bits to the right", new CustomParameter[][]{ + createCompletion("bit32.rrotate", LUA_52, autocompletion.getString("bit32_rrotate"), "Returns the number x rotated disp bits to the right", new CustomParameter[][]{ {new CustomParameter("number", "x", false, "number to rotate"), new CustomParameter("number", "disp", true, "how much to shift")} }); - createCompletion(defaultProvider, "bit32.rshift", "Lua 5.3", autocompletion.getString("bit32_rshift"), "Returns the number x shifted disp bits to the right", new CustomParameter[][]{ + createCompletion("bit32.rshift", LUA_52, autocompletion.getString("bit32_rshift"), "Returns the number x shifted disp bits to the right", new CustomParameter[][]{ {new CustomParameter("number", "x", false, "number to shift"), new CustomParameter("number", "disp", true, "how much to shift")} }); //Coroutine - createCompletion(defaultProvider, "coroutine.create", "Lua 5.3", autocompletion.getString("coroutine_create"), "Returns a new coroutine", new CustomParameter[][]{ + createCompletion("coroutine.create", LUA_52, autocompletion.getString("coroutine_create"), "Returns a new coroutine", new CustomParameter[][]{ {new CustomParameter("function", "f", true, "function to wrap into the coroutine")} }); - createCompletion(defaultProvider, "coroutine.resume", "Lua 5.3", autocompletion.getString("coroutine_resume"), "Returns function output", new CustomParameter[][]{ + createCompletion("coroutine.resume", LUA_52, autocompletion.getString("coroutine_resume"), "Returns function output", new CustomParameter[][]{ {new CustomParameter("coroutine", "co", true, "coroutine to continue execution of")}, {new CustomParameter("coroutine", "co", false, "coroutine to continue execution of"), new CustomParameter("...", "vals", true, "values to pass to the function")} }); - createCompletion(defaultProvider, "coroutine.running", "Lua 5.3", autocompletion.getString("coroutine_running"), "Returns the current coroutine + boolean", new CustomParameter[][]{ + createCompletion("coroutine.running", LUA_52, autocompletion.getString("coroutine_running"), "Returns the current coroutine + boolean", new CustomParameter[][]{ {} }); - createCompletion(defaultProvider, "coroutine.status", "Lua 5.3", autocompletion.getString("coroutine_status"), "Returns the status of the coroutine", new CustomParameter[][]{ + createCompletion("coroutine.status", LUA_52, autocompletion.getString("coroutine_status"), "Returns the status of the coroutine", new CustomParameter[][]{ {new CustomParameter("coroutine", "co", true, "coroutine to get status of")} }); - createCompletion(defaultProvider, "coroutine.wrap", "Lua 5.3", autocompletion.getString("coroutine_wrap"), "Returns a function that resumes the coroutine each time it is called", new CustomParameter[][]{ + createCompletion("coroutine.wrap", LUA_52, autocompletion.getString("coroutine_wrap"), "Returns a function that resumes the coroutine each time it is called", new CustomParameter[][]{ {new CustomParameter("function", "f", true, "function to wrap into the coroutine")} }); - createCompletion(defaultProvider, "coroutine.yield", "Lua 5.3", autocompletion.getString("coroutine_yield"), "", new CustomParameter[][]{ + createCompletion("coroutine.yield", LUA_52, autocompletion.getString("coroutine_yield"), "", new CustomParameter[][]{ {new CustomParameter("...", "", true, "arguments for coroutine.resume")} }); //Debug - createCompletion(defaultProvider, "debug.getinfo", "Lua 5.3", autocompletion.getString("debug_getinfo"), "Returns a table with information about a function", new CustomParameter[][]{ + createCompletion("debug.getinfo", LUA_52, autocompletion.getString("debug_getinfo"), "Returns a table with information about a function", new CustomParameter[][]{ {new CustomParameter("function", "f", true, "function to get information about")}, {new CustomParameter("function", "f", false, "function to get information about"), new CustomParameter("string", "what", true, "the string describing which fields to fill in")}, {new CustomParameter("thread", "thread", false, "the thread to get running level from"), new CustomParameter("function", "f", true, "function to get information about")}, {new CustomParameter("thread", "thread", false, "the thread to get running level from"), new CustomParameter("function", "f", false, "function to get information about"), new CustomParameter("string", "what", true, "the string describing which fields to fill in")} }); - createCompletion(defaultProvider, "debug.traceback", "Lua 5.3", autocompletion.getString("debug_traceback"), "Returns a string with a traceback of the call stack", new CustomParameter[][]{ + createCompletion("debug.traceback", LUA_52, autocompletion.getString("debug_traceback"), "Returns a string with a traceback of the call stack", new CustomParameter[][]{ {}, {new CustomParameter("string", "message", true, "message to return before traceback")}, {new CustomParameter("string", "message", false, "message to return before traceback"), new CustomParameter("number", "level", true, "at which level to start the traceback")}, @@ -244,13 +265,20 @@ public static CompletionProvider getProvider() { }); //IO - createCompletion(defaultProvider, "io.close", "Lua 5.3", autocompletion.getString("io_close"), "", new CustomParameter[][]{ + createCompletion("io.close", LUA_52, autocompletion.getString("io_close"), "", new CustomParameter[][]{ {}, {new CustomParameter("file", "file", true, "the file to close")} }); - - - + + createCompletion("io.flush", LUA_52, autocompletion.getString("io_flush"), "", new CustomParameter[][]{ + {} + }); + + createCompletion("io.input", LUA_52, autocompletion.getString("io_input"), "", new CustomParameter[][]{ + {}, + {new CustomParameter("file", "file", true, "the file to open in text mode")} + }); + //Math //OS //Package @@ -262,7 +290,7 @@ public static CompletionProvider getProvider() { //Computer //Event //UUID - createCompletion(defaultProvider, "uuid.next", "OpenOS 1.6", "Returns 128 bit random identifiers, represented as a hex value in a string grouped by 8, 4, 4, 4, and 12 hex characters, separated by dashes. e.g. 34eb7b28-14d3-4767-b326-dd1609ba92e. You might recognize this pattern as it is the same used for component addressing.", "Returns a new UUID", new CustomParameter[][]{ + createCompletion("uuid.next", OPENOS_16, "Returns 128 bit random identifiers, represented as a hex value in a string grouped by 8, 4, 4, 4, and 12 hex characters, separated by dashes. e.g. 34eb7b28-14d3-4767-b326-dd1609ba92e. You might recognize this pattern as it is the same used for component addressing.", "Returns a new UUID", new CustomParameter[][]{ {} }); //Filesystem @@ -283,30 +311,29 @@ public static CompletionProvider getProvider() { /* Component API */ // + Logger.getLogger(OCLIDECompletionProvider.class.getName()).log(Level.FINE, "Autocompletion complete"); LanguageAwareCompletionProvider p = new LanguageAwareCompletionProvider(defaultProvider); return p; } /** - * Creates a new FunctionCompletion with params + * Creates a new FunctionCompletion with all possible parameters * - * @param p DefaultCompletionProvider to add to * @param name Function name - * @param returnType Function return value's type * @param definedIn API version where function is first defined * @param shortDesc Function description * @param returnDesc Function return value's description * @param pars Function parameters' 2d-array */ - private static void createCompletion(DefaultCompletionProvider p, String name, String definedIn, String shortDesc, String returnDesc, CustomParameter[][] pars) { + private static void createCompletion(String name, String definedIn, String shortDesc, String returnDesc, CustomParameter[][] pars) { //Every possible parameter's variant for (CustomParameter[] par : pars) { - FunctionCompletion f = new FunctionCompletion(p, name, "function"); + FunctionCompletion f = new FunctionCompletion(defaultProvider, name, "function"); f.setDefinedIn(definedIn); f.setShortDescription(shortDesc); f.setReturnValueDescription(returnDesc); f.setParams(Arrays.asList(par)); - p.addCompletion(f); + defaultProvider.addCompletion(f); } } } @@ -314,6 +341,11 @@ private static void createCompletion(DefaultCompletionProvider p, String name, S class CustomParameter extends Parameter { /** + * A {@code CustomParameter} is an extended version of + * {@link org.fife.ui.autocomplete.ParameterizedCompletion.Parameter} that + * allows to add parameter's description right in the constructor. + * + * Yes, this is the only reason for this subclass to exist * * @param type Parameter's type * @param name Parameter's name diff --git a/src/ru/VladTheMountain/oclide/editor/autocompletion/package-info.java b/src/ru/VladTheMountain/oclide/editor/autocompletion/package-info.java new file mode 100644 index 0000000..dbf7d49 --- /dev/null +++ b/src/ru/VladTheMountain/oclide/editor/autocompletion/package-info.java @@ -0,0 +1,30 @@ +/* + * The MIT License + * + * Copyright 2021 VladTheMountain. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * Provides a single file which is used for autocompletion purposes + * + * @author VladTheMountain + */ +package ru.VladTheMountain.oclide.editor.autocompletion; diff --git a/src/ru/VladTheMountain/oclide/package-info.java b/src/ru/VladTheMountain/oclide/package-info.java new file mode 100644 index 0000000..c30f09f --- /dev/null +++ b/src/ru/VladTheMountain/oclide/package-info.java @@ -0,0 +1,34 @@ +/* + * The MIT License + * + * Copyright 2021 VladTheMountain. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +/** + * OCLIDE itself + * + * @see io.VladTheMountain.oclide.configurator + * @see io.VladTheMountain.oclide.editor + * @see io.VladTheMountain.oclide.resources + * @see io.VladTheMountain.oclide.ui + * @see io.VladTheMountain.oclide.util + * @author VladTheMountain + */ +package ru.VladTheMountain.oclide; diff --git a/src/ru/VladTheMountain/oclide/resources/autocompletion/Autocompletion.properties b/src/ru/VladTheMountain/oclide/resources/autocompletion/Autocompletion.properties index ee191be..8051bb3 100644 --- a/src/ru/VladTheMountain/oclide/resources/autocompletion/Autocompletion.properties +++ b/src/ru/VladTheMountain/oclide/resources/autocompletion/Autocompletion.properties @@ -1,37 +1,51 @@ #Basic -G = A global variable (not a function) that holds the global environment (see \u00a72.2). Lua itself does not use this variable; changing its value does not affect any environment, nor vice versa. -VERSION = A global variable (not a function) that holds a string containing the running Lua version. The current value of this variable is "Lua 5.3". +G =

A global variable (not a function) that holds the global environment (see \u00a72.2). Lua itself does not use this variable; changing its value does not affect any environment, nor vice versa.

+VERSION =

A global variable (not a function) that holds a string containing the running Lua version. The current value of this variable is "Lua 5.3".

-assert = Calls error if the value of its argument v is false (i.e., nil or false); otherwise, returns all its arguments. In case of error, message is the error object; when absent, it defaults to "assertion failed!" -dofile = Opens the named file and executes its contents as a Lua chunk. When called without arguments, dofile executes the contents of the standard input (stdin). Returns all values returned by the chunk. In case of errors, dofile propagates the error to its caller (that is, dofile does not run in protected mode). -error = Terminates the last protected function called and returns message as the error object. Function error never returns. Usually, error adds some information about the error position at the beginning of the message, if the message is a string. The level argument specifies how to get the error position. With level 1 (the default), the error position is where the error function was called. Level 2 points the error to where the function that called error was called; and so on. Passing a level 0 avoids the addition of error position information to the message. -getmetatable = If object does not have a metatable, returns nil. Otherwise, if the object's metatable has a __metatable field, returns the associated value. Otherwise, returns the metatable of the given object. -ipairs = Returns three values (an iterator function, the table t, and 0). -load = Loads a chunk. If chunk is a string, the chunk is this string. If chunk is a function, load calls it repeatedly to get the chunk pieces. Each call to chunk must return a string that concatenates with previous results. A return of an empty string, nil, or no value signals the end of the chunk. If there are no syntactic errors, returns the compiled chunk as a function; otherwise, returns nil plus the error message. If the resulting function has upvalues, the first upvalue is set to the value of env, if that parameter is given, or to the value of the global environment. Other upvalues are initialized with nil. (When you load a main chunk, the resulting function will always have exactly one upvalue, the _ENV variable (see \u00a72.2). However, when you load a binary chunk created from a function (see string.dump), the resulting function can have an arbitrary number of upvalues.) All upvalues are fresh, that is, they are not shared with any other function. chunkname is used as the name of the chunk for error messages and debug information (see \u00a74.9). When absent, it defaults to chunk, if chunk is a string, or to "=(load)" otherwise. The string mode controls whether the chunk can be text or binary (that is, a precompiled chunk). It may be the string "b" (only binary chunks), "t" (only text chunks), or "bt" (both binary and text). The default is "bt". Lua does not check the consistency of binary chunks. Maliciously crafted binary chunks can crash the interpreter. -loadfile = Similar to load, but gets the chunk from file filename or from the standard input, if no file name is given. -next = Allows a program to traverse all fields of a table. Its first argument is a table and its second argument is an index in this table. next returns the next index of the table and its associated value. When called with nil as its second argument, next returns an initial index and its associated value. When called with the last index, or with nil in an empty table, next returns nil. If the second argument is absent, then it is interpreted as nil. In particular, you can use next(t) to check whether a table is empty. The order in which the indices are enumerated is not specified, even for numeric indices. (To traverse a table in numerical order, use a numerical for.) The behavior of next is undefined if, during the traversal, you assign any value to a non-existent field in the table. You may however modify existing fields. In particular, you may clear existing fields. -pairs = If t has a metamethod __pairs, calls it with t as argument and returns the first three results from the call. Otherwise, returns three values: the next function, the table t, and nil. See function next for the caveats of modifying the table during its traversal. -pcall = Calls function f with the given arguments in protected mode. This means that any error inside f is not propagated; instead, pcall catches the error and returns a status code. Its first result is the status code (a boolean), which is true if the call succeeds without errors. In such case, pcall also returns all results from the call, after this first result. In case of any error, pcall returns false plus the error message. -print = Receives any number of arguments and prints their values to stdout, using the tostring function to convert each argument to a string. print is not intended for formatted output, but only as a quick way to show a value, for instance for debugging. For complete control over the output, use string.format and io.write. -rawequal = Checks whether v1 is equal to v2, without invoking the __eq metamethod. Returns a boolean. -rawget = Gets the real value of table[index], without invoking the __index metamethod. table must be a table; index may be any value. -rawlen = Returns the length of the object v, which must be a table or a string, without invoking the __len metamethod. Returns an integer. -rawset = Sets the real value of table[index] to value, without invoking the __newindex metamethod. table must be a table, index any value different from nil and NaN, and value any Lua value. This function returns table. -select = If index is a number, returns all arguments after argument number index; a negative number indexes from the end (-1 is the last argument). Otherwise, index must be the string "#", and select returns the total number of extra arguments it received. -setmetatable = Sets the metatable for the given table. (To change the metatable of other types from Lua code, you must use the debug library (\u00a76.10).) If metatable is nil, removes the metatable of the given table. If the original metatable has a __metatable field, raises an error. This function returns table. -tonumber = When called with no base, tonumber tries to convert its argument to a number. If the argument is already a number or a string convertible to a number, then tonumber returns this number; otherwise, it returns nil. The conversion of strings can result in integers or floats, according to the lexical conventions of Lua (see \u00a73.1). (The string may have leading and trailing spaces and a sign.) When called with base, then e must be a string to be interpreted as an integer numeral in that base. The base may be any integer between 2 and 36, inclusive. In bases above 10, the letter 'A' (in either upper or lower case) represents 10, 'B' represents 11, and so forth, with 'Z' representing 35. If the string e is not a valid numeral in the given base, the function returns nil. -tostring = Receives a value of any type and converts it to a string in a human-readable format. (For complete control of how numbers are converted, use string.format.) If the metatable of v has a __tostring field, then tostring calls the corresponding value with v as argument, and uses the result of the call as its result. -type = Returns the type of its only argument, coded as a string. The possible results of this function are "nil" (a string, not the value nil), "number", "string", "boolean", "table", "function", "thread", and "userdata". -xpcall = This function is similar to pcall, except that it sets a new message handler msgh. +assert =

Calls error if the value of its argument v is false (i.e., nil or false); otherwise, returns all its arguments. In case of error, message is the error object; when absent, it defaults to "assertion failed!"

+dofile =

Opens the named file and executes its contents as a Lua chunk. When called without arguments, dofile executes the contents of the standard input (stdin). Returns all values returned by the chunk. In case of errors, dofile propagates the error to its caller (that is, dofile does not run in protected mode).

+error =

Terminates the last protected function called and returns message as the error object. Function error never returns.

Usually, error adds some information about the error position at the beginning of the message, if the message is a string. The level argument specifies how to get the error position. With level 1 (the default), the error position is where the error function was called. Level 2 points the error to where the function that called error was called; and so on. Passing a level 0 avoids the addition of error position information to the message.

+getmetatable =

If object does not have a metatable, returns nil. Otherwise, if the object's metatable has a __metatable field, returns the associated value. Otherwise, returns the metatable of the given object.

+ipairs =

Returns three values (an iterator function, the table t, and 0) so that the construction

     for i,v in ipairs(t) do body end

will iterate over the key\u2013value pairs (1,t[1]), (2,t[2]), ..., up to the first nil value.

+load =

Loads a chunk.

If chunk is a string, the chunk is this string. If chunk is a function, load calls it repeatedly to get the chunk pieces. Each call to chunk must return a string that concatenates with previous results. A return of an empty string, nil, or no value signals the end of the chunk.

If there are no syntactic errors, returns the compiled chunk as a function; otherwise, returns nil plus the error message.

If the resulting function has upvalues, the first upvalue is set to the value of env, if that parameter is given, or to the value of the global environment. Other upvalues are initialized with nil. (When you load a main chunk, the resulting function will always have exactly one upvalue, the _ENV variable (see \u00a72.2). However, when you load a binary chunk created from a function (see string.dump), the resulting function can have an arbitrary number of upvalues.) All upvalues are fresh, that is, they are not shared with any other function.

chunkname is used as the name of the chunk for error messages and debug information (see \u00a74.9). When absent, it defaults to chunk, if chunk is a string, or to "=(load)" otherwise.

The string mode controls whether the chunk can be text or binary (that is, a precompiled chunk). It may be the string "b" (only binary chunks), "t" (only text chunks), or "bt" (both binary and text). The default is "bt".

Lua does not check the consistency of binary chunks. Maliciously crafted binary chunks can crash the interpreter.

+loadfile =

Similar to load, but gets the chunk from file filename or from the standard input, if no file name is given.

+next =

Allows a program to traverse all fields of a table. Its first argument is a table and its second argument is an index in this table. next returns the next index of the table and its associated value. When called with nil as its second argument, next returns an initial index and its associated value. When called with the last index, or with nil in an empty table, next returns nil. If the second argument is absent, then it is interpreted as nil. In particular, you can use next(t) to check whether a table is empty.

The order in which the indices are enumerated is not specified, even for numeric indices. (To traverse a table in numerical order, use a numerical for.)

The behavior of next is undefined if, during the traversal, you assign any value to a non-existent field in the table. You may however modify existing fields. In particular, you may clear existing fields.

+pairs =

If t has a metamethod __pairs, calls it with t as argument and returns the first three results from the call.

Otherwise, returns three values: the next function, the table t, and nil, so that the construction

     for k,v in pairs(t) do body end

will iterate over all key\u2013value pairs of table t.

See function next for the caveats of modifying the table during its traversal.

+pcall =

Calls function f with the given arguments in protected mode. This means that any error inside f is not propagated; instead, pcall catches the error and returns a status code. Its first result is the status code (a boolean), which is true if the call succeeds without errors. In such case, pcall also returns all results from the call, after this first result. In case of any error, pcall returns false plus the error message.

+print =

Receives any number of arguments and prints their values to stdout, using the tostring function to convert each argument to a string. print is not intended for formatted output, but only as a quick way to show a value, for instance for debugging. For complete control over the output, use string.format and io.write.

+rawequal =

Checks whether v1 is equal to v2, without invoking the __eq metamethod. Returns a boolean.

+rawget =

Gets the real value of table[index], without invoking the __index metamethod. table must be a table; index may be any value.

+rawlen =

Returns the length of the object v, which must be a table or a string, without invoking the __len metamethod. Returns an integer.

+rawset =

Sets the real value of table[index] to value, without invoking the __newindex metamethod. table must be a table, index any value different from nil and NaN, and value any Lua value.

This function returns table.

+select =

If index is a number, returns all arguments after argument number index; a negative number indexes from the end (-1 is the last argument). Otherwise, index must be the string "#", and select returns the total number of extra arguments it received.

+setmetatable =

Sets the metatable for the given table. (To change the metatable of other types from Lua code, you must use the debug library (\u00a76.10).) If metatable is nil, removes the metatable of the given table. If the original metatable has a __metatable field, raises an error.

This function returns table.

+tonumber =

When called with no base, tonumber tries to convert its argument to a number. If the argument is already a number or a string convertible to a number, then tonumber returns this number; otherwise, it returns nil.

The conversion of strings can result in integers or floats, according to the lexical conventions of Lua (see \u00a73.1). (The string may have leading and trailing spaces and a sign.)

When called with base, then e must be a string to be interpreted as an integer numeral in that base. The base may be any integer between 2 and 36, inclusive. In bases above 10, the letter 'A' (in either upper or lower case) represents 10, 'B' represents 11, and so forth, with 'Z' representing 35. If the string e is not a valid numeral in the given base, the function returns nil.

+tostring =

Receives a value of any type and converts it to a string in a human-readable format. (For complete control of how numbers are converted, use string.format.)

If the metatable of v has a __tostring field, then tostring calls the corresponding value with v as argument, and uses the result of the call as its result.

+type =

Returns the type of its only argument, coded as a string. The possible results of this function are "nil" (a string, not the value nil), "number", "string", "boolean", "table", "function", "thread", and "userdata".

+xpcall =

This function is similar to pcall, except that it sets a new message handler msgh.

+ +#Bit32 +bit32_arshift =

Returns the number x shifted disp bits to the right. The number disp may be any representable integer. Negative displacements shift to the left.

This shift operation is what is called arithmetic shift. Vacant bits on the left are filled with copies of the higher bit of x; vacant bits on the right are filled with zeros. In particular, displacements with absolute values higher than 31 result in zero or 0xFFFFFFFF (all original bits are shifted out).

+bit32_band =

Returns the bitwise and of its operands.

+bit32_bnot =

Returns the bitwise negation of x. For any integer x,the following identity holds:

     assert(bit32.bnot(x) == (-1 - x) % 2^32)
+bit32_bor =

Returns the bitwise or of its operands.

+bit32_btest =

Returns a boolean signaling whether the bitwise and of its operands is different from zero.

+bit32_bxor =

Returns the bitwise exclusive or of its operands.

+bit32_extract =

Returns the unsigned number formed by the bits field to field + width - 1 from n. Bits are numbered from 0 (least significant) to 31 (most significant). All accessed bits must be in the range [0, 31].

The default for width is 1.

+bit32_replace =

Returns a copy of n with the bits field to field + width - 1 replaced by the value v. See bit32.extract for details about field and width.

+bit32_lrotate =

Returns the number x rotated disp bits to the left. The number disp may be any representable integer.

For any valid displacement, the following identity holds:

     assert(bit32.lrotate(x, disp) == bit32.lrotate(x, disp % 32))

In particular, negative displacements rotate to the right.

+bit32_lshift =

Returns the number x shifted disp bits to the left. The number disp may be any representable integer. Negative displacements shift to the right. In any direction, vacant bits are filled with zeros. In particular, displacements with absolute values higher than 31 result in zero (all bits are shifted out).

For positive displacements, the following equality holds:

     assert(bit32.lshift(b, disp) == (b * 2^disp) % 2^32)
+bit32_rrotate =

Returns the number x rotated disp bits to the right. The number disp may be any representable integer.

For any valid displacement, the following identity holds:

     assert(bit32.rrotate(x, disp) == bit32.rrotate(x, disp % 32))

In particular, negative displacements rotate to the left.

+bit32_rshift =

Returns the number x shifted disp bits to the right. The number disp may be any representable integer. Negative displacements shift to the left. In any direction, vacant bits are filled with zeros. In particular, displacements with absolute values higher than 31 result in zero (all bits are shifted out).

For positive displacements, the following equality holds:

     assert(bit32.rshift(b, disp) == math.floor(b % 2^32 / 2^disp))
#Coroutine -coroutine_create = Creates a new coroutine, with body f. f must be a function. Returns this new coroutine, an object with type "thread". -coroutine_isyieldable = Returns true when the running coroutine can yield. A running coroutine is yieldable if it is not the main thread and it is not inside a non-yieldable C function. -coroutine_resume = Starts or continues the execution of coroutine co. The first time you resume a coroutine, it starts running its body. The values val1, ... are passed as the arguments to the body function. If the coroutine has yielded, resume restarts it; the values val1, ... are passed as the results from the yield. If the coroutine runs without any errors, resume returns true plus any values passed to yield (when the coroutine yields) or any values returned by the body function (when the coroutine terminates). If there is any error, resume returns false plus the error message. -coroutine_running = Returns the running coroutine plus a boolean, true when the running coroutine is the main one. -coroutine_status = Returns the status of coroutine co, as a string: "running", if the coroutine is running (that is, it called status); "suspended", if the coroutine is suspended in a call to yield, or if it has not started running yet; "normal" if the coroutine is active but not running (that is, it has resumed another coroutine); and "dead" if the coroutine has finished its body function, or if it has stopped with an error. -coroutine_wrap = Creates a new coroutine, with body f. f must be a function. Returns a function that resumes the coroutine each time it is called. Any arguments passed to the function behave as the extra arguments to resume. Returns the same values returned by resume, except the first boolean. In case of error, propagates the error. -coroutine_yield = Suspends the execution of the calling coroutine. Any arguments to yield are passed as extra results to resume. +coroutine_create =

Creates a new coroutine, with body f. f must be a function. Returns this new coroutine, an object with type "thread".

+coroutine_isyieldable =

Returns true when the running coroutine can yield.

A running coroutine is yieldable if it is not the main thread and it is not inside a non-yieldable C function.

+coroutine_resume =

Starts or continues the execution of coroutine co. The first time you resume a coroutine, it starts running its body. The values val1, ... are passed as the arguments to the body function. If the coroutine has yielded, resume restarts it; the values val1, ... are passed as the results from the yield.

If the coroutine runs without any errors, resume returns true plus any values passed to yield (when the coroutine yields) or any values returned by the body function (when the coroutine terminates). If there is any error, resume returns false plus the error message.

+coroutine_running =

Returns the running coroutine plus a boolean, true when the running coroutine is the main one.

+coroutine_status =

Returns the status of coroutine co, as a string: "running", if the coroutine is running (that is, it called status); "suspended", if the coroutine is suspended in a call to yield, or if it has not started running yet; "normal" if the coroutine is active but not running (that is, it has resumed another coroutine); and "dead" if the coroutine has finished its body function, or if it has stopped with an error.

+coroutine_wrap =

Creates a new coroutine, with body f. f must be a function. Returns a function that resumes the coroutine each time it is called. Any arguments passed to the function behave as the extra arguments to resume. Returns the same values returned by resume, except the first boolean. In case of error, propagates the error.

+coroutine_yield =

Suspends the execution of the calling coroutine. Any arguments to yield are passed as extra results to resume.

#Debug debug_getinfo = Returns a table with information about a function. You can give the function directly or you can give a number as the value of f, which means the function running at level f of the call stack of the given thread: level 0 is the current function (getinfo itself); level 1 is the function that called getinfo (except for tail calls, which do not count on the stack); and so on. If f is a number larger than the number of active functions, then getinfo returns nil. The returned table can contain all the fields returned by lua_getinfo, with the string what describing which fields to fill in. The default for what is to get all information available, except the table of valid lines. If present, the option 'f' adds a field named func with the function itself. If present, the option 'L' adds a field named activelines with the table of valid lines. For instance, the expression debug.getinfo(1,"n").name returns a name for the current function, if a reasonable name can be found, and the expression debug.getinfo(print) returns a table with all available information about the print function. @@ -92,12 +106,12 @@ os_time = Returns the current time when called without arguments, or a time repr os_tmpname = Returns a string with a file name that can be used for a temporary file. The file must be explicitly opened before its use and explicitly removed when no longer needed. In POSIX systems, this function also creates a file with that name, to avoid security risks. (Someone else might create the file with wrong permissions in the time between getting the name and creating the file.) You still have to open the file to use it and to remove it (even if you do not use it). When possible, you may prefer to use io.tmpfile, which automatically removes the file when the program ends. #Package -require = Loads the given module. The function starts by looking into the package.loaded table to determine whether modname is already loaded. If it is, then require returns the value stored at package.loaded[modname]. Otherwise, it tries to find a loader for the module. To find a loader, require is guided by the package.searchers sequence. By changing this sequence, we can change how require looks for a module. The following explanation is based on the default configuration for package.searchers. First require queries package.preload[modname]. If it has a value, this value (which must be a function) is the loader. Otherwise require searches for a Lua loader using the path stored in package.path. If that also fails, it searches for a C loader using the path stored in package.cpath. If that also fails, it tries an all-in-one loader (see package.searchers). Once a loader is found, require calls the loader with two arguments: modname and an extra value dependent on how it got the loader. (If the loader came from a file, this extra value is the file name.) If the loader returns any non-nil value, require assigns the returned value to package.loaded[modname]. If the loader does not return a non-nil value and has not assigned any value to package.loaded[modname], then require assigns true to this entry. In any case, require returns the final value of package.loaded[modname]. If there is any error loading or running the module, or if it cannot find any loader for the module, then require raises an error. -package_loaded = A table used by require to control which modules are already loaded. When you require a module modname and package.loaded[modname] is not false, require simply returns the value stored there. This variable is only a reference to the real table; assignments to this variable do not change the table used by require. -package_path = The path used by require to search for a Lua loader. At start-up, Lua initializes this variable with the value of the environment variable LUA_PATH_5_3 or the environment variable LUA_PATH or with a default path defined in luaconf.h, if those environment variables are not defined. Any ";;" in the value of the environment variable is replaced by the default path. -package_preload = A table to store loaders for specific modules (see require). This variable is only a reference to the real table; assignments to this variable do not change the table used by require. -package_searchers = A table used by require to control how to load modules. Each entry in this table is a searcher function. When looking for a module, require calls each of these searchers in ascending order, with the module name (the argument given to require) as its sole parameter. The function can return another function (the module loader) plus an extra value that will be passed to that loader, or a string explaining why it did not find that module (or nil if it has nothing to say). Lua initializes this table with four searcher functions. The first searcher simply looks for a loader in the package.preload table. The second searcher looks for a loader as a Lua library, using the path stored at package.path. The search is done as described in function package.searchpath. The third searcher looks for a loader as a C library, using the path given by the variable package.cpath. Again, the search is done as described in function package.searchpath. For instance, if the C path is the string "./?.so;./?.dll;/usr/local/?/init.so" the searcher for module foo will try to open the files ./foo.so, ./foo.dll, and /usr/local/foo/init.so, in that order. Once it finds a C library, this searcher first uses a dynamic link facility to link the application with the library. Then it tries to find a C function inside the library to be used as the loader. The name of this C function is the string "luaopen_" concatenated with a copy of the module name where each dot is replaced by an underscore. Moreover, if the module name has a hyphen, its suffix after (and including) the first hyphen is removed. For instance, if the module name is a.b.c-v2.1, the function name will be luaopen_a_b_c. The fourth searcher tries an all-in-one loader. It searches the C path for a library for the root name of the given module. For instance, when requiring a.b.c, it will search for a C library for a. If found, it looks into it for an open function for the submodule; in our example, that would be luaopen_a_b_c. With this facility, a package can pack several C submodules into one single library, with each submodule keeping its original open function. All searchers except the first one (preload) return as the extra value the file name where the module was found, as returned by package.searchpath. The first searcher returns no extra value. -package_searchpath = Searches for the given name in the given path. A path is a string containing a sequence of templates separated by semicolons. For each template, the function replaces each interrogation mark (if any) in the template with a copy of name wherein all occurrences of sep (a dot, by default) were replaced by rep (the system's directory separator, by default), and then tries to open the resulting file name. For instance, if the path is the string "./?.lua;./?.lc;/usr/local/?/init.lua" the search for the name foo.a will try to open the files ./foo/a.lua, ./foo/a.lc, and /usr/local/foo/a/init.lua, in that order. Returns the resulting name of the first file that it can open in read mode (after closing the file), or nil plus an error message if none succeeds. (This error message lists all file names it tried to open.) +require =

Loads the given module. The function starts by looking into the package.loaded table to determine whether modname is already loaded. If it is, then require returns the value stored at package.loaded[modname]. Otherwise, it tries to find a loader for the module.

To find a loader, require is guided by the package.searchers sequence. By changing this sequence, we can change how require looks for a module. The following explanation is based on the default configuration for package.searchers.

First require queries package.preload[modname]. If it has a value, this value (which must be a function) is the loader. Otherwise require searches for a Lua loader using the path stored in package.path. If that also fails, it searches for a C loader using the path stored in package.cpath. If that also fails, it tries an all-in-one loader (see package.searchers).

Once a loader is found, require calls the loader with two arguments: modname and an extra value dependent on how it got the loader. (If the loader came from a file, this extra value is the file name.) If the loader returns any non-nil value, require assigns the returned value to package.loaded[modname]. If the loader does not return a non-nil value and has not assigned any value to package.loaded[modname], then require assigns true to this entry. In any case, require returns the final value of package.loaded[modname].

If there is any error loading or running the module, or if it cannot find any loader for the module, then require raises an error.

+package_loaded =

A table used by require to control which modules are already loaded. When you require a module modname and package.loaded[modname] is not false, require simply returns the value stored there.

This variable is only a reference to the real table; assignments to this variable do not change the table used by require.

+package_path =

The path used by require to search for a Lua loader.

At start-up, Lua initializes this variable with the value of the environment variable LUA_PATH_5_3 or the environment variable LUA_PATH or with a default path defined in luaconf.h, if those environment variables are not defined. Any ";;" in the value of the environment variable is replaced by the default path.

+package_preload =

A table to store loaders for specific modules (see require).

This variable is only a reference to the real table; assignments to this variable do not change the table used by require.

+package_searchers =

A table used by require to control how to load modules.

Each entry in this table is a searcher function. When looking for a module, require calls each of these searchers in ascending order, with the module name (the argument given to require) as its sole parameter. The function can return another function (the module loader) plus an extra value that will be passed to that loader, or a string explaining why it did not find that module (or nil if it has nothing to say).

Lua initializes this table with four searcher functions.

The first searcher simply looks for a loader in the package.preload table.

The second searcher looks for a loader as a Lua library, using the path stored at package.path. The search is done as described in function package.searchpath.

The third searcher looks for a loader as a C library, using the path given by the variable package.cpath. Again, the search is done as described in function package.searchpath. For instance, if the C path is the string

     "./?.so;./?.dll;/usr/local/?/init.so"

the searcher for module foo will try to open the files ./foo.so, ./foo.dll, and /usr/local/foo/init.so, in that order. Once it finds a C library, this searcher first uses a dynamic link facility to link the application with the library. Then it tries to find a C function inside the library to be used as the loader. The name of this C function is the string "luaopen_" concatenated with a copy of the module name where each dot is replaced by an underscore. Moreover, if the module name has a hyphen, its suffix after (and including) the first hyphen is removed. For instance, if the module name is a.b.c-v2.1, the function name will be luaopen_a_b_c.

The fourth searcher tries an all-in-one loader. It searches the C path for a library for the root name of the given module. For instance, when requiring a.b.c, it will search for a C library for a. If found, it looks into it for an open function for the submodule; in our example, that would be luaopen_a_b_c. With this facility, a package can pack several C submodules into one single library, with each submodule keeping its original open function.

All searchers except the first one (preload) return as the extra value the file name where the module was found, as returned by package.searchpath. The first searcher returns no extra value.

+package_searchpath =

Searches for the given name in the given path.

A path is a string containing a sequence of templates separated by semicolons. For each template, the function replaces each interrogation mark (if any) in the template with a copy of name wherein all occurrences of sep (a dot, by default) were replaced by rep (the system's directory separator, by default), and then tries to open the resulting file name.

For instance, if the path is the string

     "./?.lua;./?.lc;/usr/local/?/init.lua"

the search for the name foo.a will try to open the files ./foo/a.lua, ./foo/a.lc, and /usr/local/foo/a/init.lua, in that order.

Returns the resulting name of the first file that it can open in read mode (after closing the file), or nil plus an error message if none succeeds. (This error message lists all file names it tried to open.)

#String string_byte = Returns the internal numeric codes of the characters s[i], s[i+1], ..., s[j]. The default value for i is 1; the default value for j is i. These indices are corrected following the same rules of function string.sub. Numeric codes are not necessarily portable across platforms. diff --git a/src/ru/VladTheMountain/emulator/EmuLogger.java b/src/ru/VladTheMountain/oclide/resources/autocompletion/package-info.java similarity index 81% rename from src/ru/VladTheMountain/emulator/EmuLogger.java rename to src/ru/VladTheMountain/oclide/resources/autocompletion/package-info.java index 601bfcd..0f1a9dd 100644 --- a/src/ru/VladTheMountain/emulator/EmuLogger.java +++ b/src/ru/VladTheMountain/oclide/resources/autocompletion/package-info.java @@ -21,18 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package ru.VladTheMountain.emulator; - -import java.time.LocalTime; -import java.util.logging.Level; - /** + * Internationalization files which are used by the code autocompletion provider * + * @see io.VladTheMountain.oclide.editor.OCLIDECompletionProvider * @author VladTheMountain */ -public class EmuLogger { - - public void log(Level lvl, String msg) { - System.out.println("[" + LocalTime.now() + "][Ocelot/" + lvl.getName() + "] " + msg); - } -} +package ru.VladTheMountain.oclide.resources.autocompletion; diff --git a/src/ru/VladTheMountain/oclide/resources/configurator/code/CODE.properties b/src/ru/VladTheMountain/oclide/resources/configurator/code/CODE.properties deleted file mode 100644 index 8b13789..0000000 --- a/src/ru/VladTheMountain/oclide/resources/configurator/code/CODE.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/ru/VladTheMountain/oclide/resources/configurator/ocelot/Ocelot.properties b/src/ru/VladTheMountain/oclide/resources/configurator/ocelot/Ocelot.properties deleted file mode 100644 index 8b13789..0000000 --- a/src/ru/VladTheMountain/oclide/resources/configurator/ocelot/Ocelot.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/ru/VladTheMountain/oclide/resources/configurator/ocemulator/OCEmulator.properties b/src/ru/VladTheMountain/oclide/resources/configurator/ocemulator/OCEmulator.properties deleted file mode 100644 index 8b13789..0000000 --- a/src/ru/VladTheMountain/oclide/resources/configurator/ocemulator/OCEmulator.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/ru/VladTheMountain/oclide/resources/dialog/Dialog.properties b/src/ru/VladTheMountain/oclide/resources/dialog/Dialog.properties index 700f926..6b05274 100644 --- a/src/ru/VladTheMountain/oclide/resources/dialog/Dialog.properties +++ b/src/ru/VladTheMountain/oclide/resources/dialog/Dialog.properties @@ -1,3 +1,28 @@ +# The MIT License +# +# Copyright 2021 VladTheMountain. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + createProject_Title = Creating new project createProject_tabProjType = Project Type createProject_tabProjConfiguration = Project Configuration + + +about_title = About diff --git a/src/ru/VladTheMountain/oclide/resources/configurator/aurum/Aurum.properties b/src/ru/VladTheMountain/oclide/resources/dialog/Dialog_ru_RU.properties similarity index 91% rename from src/ru/VladTheMountain/oclide/resources/configurator/aurum/Aurum.properties rename to src/ru/VladTheMountain/oclide/resources/dialog/Dialog_ru_RU.properties index 22bc12b..90cf70b 100644 --- a/src/ru/VladTheMountain/oclide/resources/configurator/aurum/Aurum.properties +++ b/src/ru/VladTheMountain/oclide/resources/dialog/Dialog_ru_RU.properties @@ -20,3 +20,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. + +# The 'About' Dialog +about_title = \u041e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \ No newline at end of file diff --git a/src/ru/VladTheMountain/oclide/resources/editor/Editor.properties b/src/ru/VladTheMountain/oclide/resources/editor/Editor.properties index a144a0f..f7b9db7 100644 --- a/src/ru/VladTheMountain/oclide/resources/editor/Editor.properties +++ b/src/ru/VladTheMountain/oclide/resources/editor/Editor.properties @@ -1,11 +1,34 @@ +# The MIT License +# +# Copyright 2021 VladTheMountain. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + # General IDE Strings appTitle = OCLIDE - OpenComputers Lua Integrated Development Environment -# IDE UI Tooltips -projects = Projects +# UI +tabIDEOutput = IDE Output +treeProjects = Projects # Menu bar -fileMenu = File +menuFile = File menuItemCreateProject = Create Project menuItemOpenProject = Open Project menuItemCreateFile = Create File @@ -15,9 +38,37 @@ menuItemDeleteProject = Delete Project menuItemExit = Exit menuEdit = Edit +menuItemUndo = Undo +menuItemRedo = Redo +menuItemCut = Cut +menuItemCopy = Copy +menuItemPaste = Paste +menuItemFind = Find... -menuRun = Run +menuDeploy = Run +menuItemDeployToEmulator = Deploy to Emulator... +menuItemOCEmu = Run OCEmu +menuItemOcelot = Run Ocelot +menuItemOCEmulator = Run OCEmulator +menuItemAurum = Run Aurum +menuItemCODE = Run CODE +menuItemDeployToVM = Deploy to VM... +menuItemOCVM = Run OCVM +menuItemOpenComputersVM = Run OpenComputersVM +menuItemDeployToMinecraft = Deploy to a Minecraft World menuHelp = Help - +menuItemAbout = About +menuItemWiki = Wiki menuItemSettings = Settings + +# Toolbar +tooltipCreateProject = Create project +tooltipOpenProject = Open project +tooltipCreateFile = Create file +tooltipSaveFile = Save file +tooltipDeleteProject = Delete project +tooltipUndo = Undo +tooltipRedo = Redo +tooltipOCEmu = Run OCEmu +tooltipOcelot = Run Ocelot \ No newline at end of file diff --git a/src/ru/VladTheMountain/oclide/resources/editor/Editor_ru_RU.properties b/src/ru/VladTheMountain/oclide/resources/editor/Editor_ru_RU.properties index 455d3cf..a58a14d 100644 --- a/src/ru/VladTheMountain/oclide/resources/editor/Editor_ru_RU.properties +++ b/src/ru/VladTheMountain/oclide/resources/editor/Editor_ru_RU.properties @@ -1,23 +1,74 @@ +# The MIT License +# +# Copyright 2021 VladTheMountain. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + # General IDE Strings appTitle = OCLIDE - OpenComputers Lua Integrated Development Environment -# IDE UI Tooltips -projects = Projects +# UI +tabIDEOutput = \u0412\u044b\u0432\u043e\u0434 IDE +treeProjects = \u041f\u0440\u043e\u0435\u043a\u0442\u044b # Menu bar -fileMenu = \u0424\u0430\u0439\u043b -menuItemCreateProject = Create Project -menuItemOpenProject = Open Project -menuItemCreateFile = Create File -menuItemOpenFile = Open File -menuItemSaveFile = Save -menuItemDeleteProject = Delete Project -menuItemExit = Exit +menuFile = \u0424\u0430\u0439\u043b +menuItemCreateProject = \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 +menuItemOpenProject = \u041e\u0442\u043a\u0440\u044b\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 +menuItemCreateFile = \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0430\u0439\u043b +menuItemOpenFile = \u041e\u0442\u043a\u0440\u044b\u0442\u044c \u0444\u0430\u0439\u043b +menuItemSaveFile = \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0444\u0430\u0439\u043b +menuItemDeleteProject = \u0423\u0434\u0430\u043b\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 +menuItemExit = \u0412\u044b\u0439\u0442\u0438 -menuEdit = Edit +menuEdit = \u041f\u0440\u0430\u0432\u043a\u0430 +menuItemUndo = \u041e\u0442\u043c\u0435\u043d\u0438\u0442\u044c +menuItemRedo = \u0412\u0435\u0440\u043d\u0443\u0442\u044c +menuItemCut = \u0412\u044b\u0440\u0435\u0437\u0430\u0442\u044c +menuItemCopy = \u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c +menuItemPaste = \u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044c +menuItemFind = \u041d\u0430\u0439\u0442\u0438... -menuRun = Run +menuDeploy = \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c +menuItemDeployToEmulator = \u0420\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0432 \u044d\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u0435... +menuItemOCEmu = \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c OCEmu +menuItemOcelot = \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c Ocelot +menuItemOCEmulator = \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c OCEmulator +menuItemAurum = \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c Aurum +menuItemCODE = \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c CODE +menuItemDeployToVM = \u0420\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0432 VM... +menuItemOCVM = \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c OCVM +menuItemOpenComputersVM = \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c OpenComputersVM +menuItemDeployToMinecraft = \u0420\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0432 \u043c\u0438\u0440\u0435 Minecraft -menuHelp = Help +menuHelp = \u041f\u043e\u043c\u043e\u0449\u044c +menuItemAbout = \u041e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 +menuItemWiki = \u0412\u0438\u043a\u0438 +menuItemSettings = \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 -menuItemSettings = Settings +# Toolbar +tooltipCreateProject = \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 +tooltipOpenProject = \u041e\u0442\u043a\u0440\u044b\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 +tooltipCreateFile = \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0430\u0439\u043b +tooltipSaveFile = \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0444\u0430\u0439\u043b +tooltipDeleteProject = \u0423\u0434\u0430\u043b\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 +tooltipUndo = \u041e\u0442\u043c\u0435\u043d\u0438\u0442\u044c +tooltipRedo = \u0412\u0435\u0440\u043d\u0443\u0442\u044c +tooltipOCEmu = \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c OCEmu +tooltipOcelot = \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c Ocelot \ No newline at end of file diff --git a/src/ru/VladTheMountain/oclide/resources/package-info.java b/src/ru/VladTheMountain/oclide/resources/package-info.java new file mode 100644 index 0000000..ec57f42 --- /dev/null +++ b/src/ru/VladTheMountain/oclide/resources/package-info.java @@ -0,0 +1,29 @@ +/* + * The MIT License + * + * Copyright 2021 VladTheMountain. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +/** + * Different pictures, icons and internationalization files + * + * @author VladTheMountain + */ +package ru.VladTheMountain.oclide.resources; diff --git a/src/ru/VladTheMountain/oclide/ui/configurators/AurumEmulatorForm.form b/src/ru/VladTheMountain/oclide/ui/configurators/AurumEmulatorForm.form deleted file mode 100644 index 8d28fa5..0000000 --- a/src/ru/VladTheMountain/oclide/ui/configurators/AurumEmulatorForm.form +++ /dev/null @@ -1,35 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/src/ru/VladTheMountain/oclide/ui/configurators/AurumEmulatorForm.java b/src/ru/VladTheMountain/oclide/ui/configurators/AurumEmulatorForm.java deleted file mode 100644 index 129ac10..0000000 --- a/src/ru/VladTheMountain/oclide/ui/configurators/AurumEmulatorForm.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * The MIT License - * - * Copyright 2021 Vladislav Gorskii. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package ru.VladTheMountain.oclide.ui.configurators; - -import java.util.Locale; -import java.util.ResourceBundle; -import javax.swing.GroupLayout; -import javax.swing.WindowConstants; - -/** - * AurumEmulator by Alexey Gutnik - * - * PLACEHOLDER CLASS - * - * @author VladTheMountain - */ -public class AurumEmulatorForm extends javax.swing.JFrame { - - final ResourceBundle localiztionResource = ResourceBundle.getBundle("ru.VladTheMountain.oclide.resources.configurator.aurum.Aurum", Locale.getDefault()); - private static final long serialVersionUID = 1L; - - /** - * Creates new form AurumEmulatorForm - */ - public AurumEmulatorForm() { - initComponents(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - - GroupLayout layout = new GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGap(0, 400, Short.MAX_VALUE) - ); - layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGap(0, 300, Short.MAX_VALUE) - ); - - pack(); - }// //GEN-END:initComponents - - // Variables declaration - do not modify//GEN-BEGIN:variables - // End of variables declaration//GEN-END:variables -} diff --git a/src/ru/VladTheMountain/oclide/ui/configurators/CODEForm.form b/src/ru/VladTheMountain/oclide/ui/configurators/CODEForm.form deleted file mode 100644 index 8d28fa5..0000000 --- a/src/ru/VladTheMountain/oclide/ui/configurators/CODEForm.form +++ /dev/null @@ -1,35 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/src/ru/VladTheMountain/oclide/ui/configurators/CODEForm.java b/src/ru/VladTheMountain/oclide/ui/configurators/CODEForm.java deleted file mode 100644 index 03aaf4b..0000000 --- a/src/ru/VladTheMountain/oclide/ui/configurators/CODEForm.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * The MIT License - * - * Copyright 2021 Vladislav Gorskii. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package ru.VladTheMountain.oclide.ui.configurators; - -import java.util.Locale; -import java.util.ResourceBundle; -import javax.swing.GroupLayout; -import javax.swing.WindowConstants; - -/** - * CODE by Avevad - * - * Emulator configurator UI. - * - * @author VladTheMountain - */ -public class CODEForm extends javax.swing.JFrame { - - final ResourceBundle localiztionResource = ResourceBundle.getBundle("ru.VladTheMountain.oclide.resources.configurator.code.CODE", Locale.getDefault()); - private static final long serialVersionUID = 1L; - - /** - * Creates new form CODEForm - */ - public CODEForm() { - initComponents(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - - GroupLayout layout = new GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGap(0, 400, Short.MAX_VALUE) - ); - layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGap(0, 300, Short.MAX_VALUE) - ); - - pack(); - }// //GEN-END:initComponents - - // Variables declaration - do not modify//GEN-BEGIN:variables - // End of variables declaration//GEN-END:variables -} diff --git a/src/ru/VladTheMountain/oclide/ui/configurators/OCEmuForm.java b/src/ru/VladTheMountain/oclide/ui/configurators/OCEmuForm.java index 35e2d0c..9668df9 100644 --- a/src/ru/VladTheMountain/oclide/ui/configurators/OCEmuForm.java +++ b/src/ru/VladTheMountain/oclide/ui/configurators/OCEmuForm.java @@ -27,10 +27,8 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; -import java.io.BufferedReader; import java.io.File; import java.io.IOException; -import java.io.InputStreamReader; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.StandardCopyOption; @@ -68,9 +66,9 @@ import javax.swing.event.ListSelectionListener; import javax.swing.filechooser.FileFilter; import org.apache.commons.io.FileUtils; -import ru.VladTheMountain.oclide.configurator.ocemu.ConfigMaker; -import ru.VladTheMountain.oclide.configurator.ocemu.OCEmuLauncher; -import ru.VladTheMountain.oclide.configurator.ocemu.component.OCEmuComponent; +import ru.VladTheMountain.oclide.configurators.ocemu.ConfigMaker; +import ru.VladTheMountain.oclide.configurators.ocemu.OCEmuLauncher; +import ru.VladTheMountain.oclide.configurators.ocemu.component.OCEmuComponent; import ru.VladTheMountain.oclide.util.UUIDGenerator; /** @@ -89,7 +87,6 @@ public class OCEmuForm extends javax.swing.JFrame { /** * Creates new form ConfiguratorForm - * */ public OCEmuForm() { Timer t = new Timer(300, (ActionEvent e) -> { @@ -100,11 +97,7 @@ public OCEmuForm() { this.componentsArray = new OCEmuComponent[OCEmuLauncher.DEFAULT.length]; System.arraycopy(OCEmuLauncher.DEFAULT, 0, componentsArray, 0, OCEmuLauncher.DEFAULT.length); } else { - try { - new ConfigMaker(this.componentsArray).readConfig(new File("OCEmu/.machine/ocemu.cfg")); - } catch (IOException ex) { - Logger.getLogger(OCEmuForm.class.getName()).log(Level.SEVERE, null, ex); - } + new ConfigMaker(this.componentsArray).readConfig(new File("OCEmu/.machine/ocemu.cfg")); } updateComponentList(); t.start(); @@ -113,7 +106,9 @@ public OCEmuForm() { /** * Adds a new component to the list * - * @param c + * @param c an OCEmuComponent to add + * @see + * ru.VladTheMountain.oclide.configurators.ocemu.component.OCEmuComponent */ private void addComponent(OCEmuComponent c) { OCEmuComponent[] tmp = new OCEmuComponent[this.componentsArray.length + 1]; @@ -127,7 +122,7 @@ private void addComponent(OCEmuComponent c) { /** * Deletes a component at {@code index} * - * @param index + * @param index the index of the component to delete */ private void deleteComponent(int index) { OCEmuComponent[] tmp = new OCEmuComponent[this.componentsArray.length]; @@ -139,7 +134,7 @@ private void deleteComponent(int index) { } /** - * Updates componentList {@link JTree} + * Updates componentList {@code JTree} */ private void updateComponentList() { DefaultListModel model = new DefaultListModel<>(); @@ -165,14 +160,16 @@ private void installOpenOS() { Files.copy(new File("OCEmu/loot/openos/.prop").toPath(), new File(machineDir.getAbsoluteFile() + "/.prop").toPath(), StandardCopyOption.REPLACE_EXISTING); Files.copy(new File("OCEmu/loot/openos/init.lua").toPath(), new File(machineDir.getAbsoluteFile() + "/init.lua").toPath(), StandardCopyOption.REPLACE_EXISTING); } catch (IOException ex) { - Logger.getLogger(OCEmuForm.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(OCEmuForm.class.getName()).log(Level.SEVERE, "Error when installing OpenOS", ex); + JOptionPane.showMessageDialog(null, ex, "Caught " + ex.getClass().getName(), JOptionPane.ERROR_MESSAGE); } + Logger.getLogger(this.getClass().getName()).log(Level.FINER, "OpenOS is installed"); } /** * Updates description and option fields * - * @param type + * @param c the OCEmuComponent to view */ private void updateFields(OCEmuComponent c) { switch (c.getComponentType()) { @@ -313,8 +310,8 @@ private void updateFields(OCEmuComponent c) { /** * Recursively gets all files in the project folder * - * @param file Project folder as a {@link File} - * @param n Project's tree node + * @param src Project folder as a {@code File} + * @param targ Project's tree node */ private static void recursivelyCopyFiles(File src, File targ) { File[] files = src.listFiles(); @@ -326,13 +323,15 @@ private static void recursivelyCopyFiles(File src, File targ) { try { Files.copy(f.toPath(), new File(targ.getAbsolutePath() + FileSystems.getDefault().getSeparator() + f.getName()).toPath()); } catch (IOException ex) { - Logger.getLogger(OCEmuForm.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(OCEmuForm.class.getName()).log(Level.SEVERE, "Error when copying file " + f.getPath(), ex); + JOptionPane.showMessageDialog(null, ex, "Caught " + ex.getClass().getName(), JOptionPane.ERROR_MESSAGE); } } else { try { FileUtils.copyDirectory(f, targ); } catch (IOException ex) { - Logger.getLogger(OCEmuForm.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(OCEmuForm.class.getName()).log(Level.SEVERE, "Error when copying folder " + f.getPath(), ex); + JOptionPane.showMessageDialog(null, ex, "Caught " + ex.getClass().getName(), JOptionPane.ERROR_MESSAGE); } } if (f.isDirectory()) { @@ -652,59 +651,68 @@ private void cancelButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_can }//GEN-LAST:event_cancelButtonActionPerformed private void launchButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_launchButtonActionPerformed + Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Setting up OCEmu workspace..."); + System.out.println("Setting up OCEmu workspace..."); boolean isOSInstalled = false; String OpenOSUUID = "tmpfs"; File machineFolder = new File("OCEmu" + FileSystems.getDefault().getSeparator() + ".machine"); + // The following code should search through all the directories near the OCLIDE.jar to find 'init.lua' file if (machineFolder.exists() && machineFolder.listFiles().length > 0) { - /*for (File file : machineFolder.listFiles()) { + for (File file : machineFolder.listFiles()) { if (file.isDirectory()) { for (String current : file.list()) { - //Well, technically it allows to setup ANY OS, compatible with Lua BIOS EEPROM bootloader script + //Well, technically it means that ANY OS, compatible with Lua BIOS EEPROM bootloader script can be installed if (current.equals("init.lua")) { isOSInstalled = true; OpenOSUUID = file.getName(); } } } - }*/ + } + // If no OS is installed, installing OpenOS + if (isOSInstalled) { + Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Found a Lua BIOS-compatable OS"); + } else { + Logger.getLogger(this.getClass().getName()).log(Level.FINE, "No OS found. installing OpenOS"); + installOpenOS(); + } } else { machineFolder.mkdirs(); + Logger.getLogger(this.getClass().getName()).log(Level.FINE, "No filesystem found, creating..."); } - System.out.println("OpenOS installed = " + isOSInstalled); - if (!(isOSInstalled)) { - installOpenOS(); - } - System.out.println("OpenOS is installed"); - //Creating config - try { - new ConfigMaker(this.componentsArray).createConfig(); - } catch (IOException ex) { - Logger.getLogger(OCEmuForm.class.getName()).log(Level.SEVERE, null, ex); - } + // Creating OCEmu config + new ConfigMaker(this.componentsArray).createConfig(); System.out.println("Config ready"); - //Files' copy + Logger.getLogger(this.getClass().getName()).log(Level.INFO, "OCEmu config ready"); + // Copying all projects' files if (new File("projects").exists()) { try { //recursivelyCopyFiles(new File("projects"), new File("OCEmu"+FileSystems.getDefault().getSeparator()+".machine"+FileSystems.getDefault().getSeparator()+OpenOSUUID+FileSystems.getDefault().getSeparator()+"home")); FileUtils.copyDirectory(new File("projects"), new File(/*System.getenv("APPDATA") + FileSystems.getDefault().getSeparator() + "OCEmu"*/".machine" + FileSystems.getDefault().getSeparator() + OpenOSUUID + FileSystems.getDefault().getSeparator() + "home")); - System.out.println("Copied " + new File("projects").getAbsolutePath() + " to " + new File(/*System.getenv("APPDATA") + FileSystems.getDefault().getSeparator() + "OCEmu"*/".machine" + FileSystems.getDefault().getSeparator() + OpenOSUUID + FileSystems.getDefault().getSeparator() + "home").getAbsolutePath()); + Logger.getLogger(this.getClass().getName()).log(Level.FINEST, "Copied " + new File("projects").getAbsolutePath() + " to " + new File(/*System.getenv("APPDATA") + FileSystems.getDefault().getSeparator() + "OCEmu"*/".machine" + FileSystems.getDefault().getSeparator() + OpenOSUUID + FileSystems.getDefault().getSeparator() + "home").getAbsolutePath()); } catch (IOException ex) { - Logger.getLogger(OCEmuForm.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Failed to copy projects' files", ex); + JOptionPane.showMessageDialog(null, ex, "Caught " + ex.getClass().getName(), JOptionPane.ERROR_MESSAGE); } } System.out.println("Files copied"); - // - Thread t = new Thread() { + Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Project files copied"); + // Creating a new thread, where OCEmu will be launched + /*Thread t = new Thread() { @Override public void run() { + // Creating a process ProcessBuilder pb; pb = System.getProperty("os.name").contains("Windows") ? new ProcessBuilder("cmd.exe", "/c", "start", "/D", "OCEmu", "OCEmu\\OCEmu.exe") : new ProcessBuilder("lua", "OCEmu/boot.lua", "./.machine"); pb.redirectErrorStream(true).inheritIO(); try { + // Starting the process... Process p = pb.start(); + Logger.getLogger(this.getClass().getName()).log(Level.INFO, "Starting OCEmu..."); + System.out.println("Starting OCEmu..."); + // ...and rerouting the output into System.Out BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream())); String outLine; - Logger.getLogger(OCEmuForm.class.getName()).log(Level.INFO, "Starting OCEmu..."); while (true) { outLine = r.readLine(); if (outLine == null) { @@ -712,13 +720,18 @@ public void run() { } System.out.println(outLine); } + Logger.getLogger(this.getClass().getName()).log(Level.FINE, "System.out redirected"); + System.out.println("System.out redirected"); } catch (IOException ex) { - Logger.getLogger(OCEmuForm.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Couldn't start OCEmu process", ex); + JOptionPane.showMessageDialog(null, ex, "Caught " + ex.getClass().getName(), JOptionPane.ERROR_MESSAGE); } } - }; - t.start(); - System.out.println("Tread started"); + };*/ + // Starting the thread + //t.start(); + System.out.println(OCEmuLauncher.runOCEmu()); + Logger.getLogger(this.getClass().getName()).log(Level.FINE, "OCEmu Thread started"); }//GEN-LAST:event_launchButtonActionPerformed private void exitItemActionPerformed(ActionEvent evt) {//GEN-FIRST:event_exitItemActionPerformed @@ -727,21 +740,13 @@ private void exitItemActionPerformed(ActionEvent evt) {//GEN-FIRST:event_exitIte private void importConfigItemActionPerformed(ActionEvent evt) {//GEN-FIRST:event_importConfigItemActionPerformed if (this.configChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { - try { - new ConfigMaker(this.componentsArray).readConfig(this.configChooser.getSelectedFile()); - } catch (IOException ex) { - Logger.getLogger(OCEmuForm.class.getName()).log(Level.SEVERE, null, ex); - } + new ConfigMaker(this.componentsArray).readConfig(this.configChooser.getSelectedFile()); updateComponentList(); } }//GEN-LAST:event_importConfigItemActionPerformed private void saveConfigItemActionPerformed(ActionEvent evt) {//GEN-FIRST:event_saveConfigItemActionPerformed - try { - new ConfigMaker(this.componentsArray).createConfig(); - } catch (IOException ex) { - Logger.getLogger(OCEmuForm.class.getName()).log(Level.SEVERE, null, ex); - } + new ConfigMaker(this.componentsArray).createConfig(); }//GEN-LAST:event_saveConfigItemActionPerformed private void componentTypeComboBoxActionPerformed(ActionEvent evt) {//GEN-FIRST:event_componentTypeComboBoxActionPerformed @@ -749,13 +754,9 @@ private void componentTypeComboBoxActionPerformed(ActionEvent evt) {//GEN-FIRST: }//GEN-LAST:event_componentTypeComboBoxActionPerformed private void resetConfigItemActionPerformed(ActionEvent evt) {//GEN-FIRST:event_resetConfigItemActionPerformed - try { - new ConfigMaker(OCEmuLauncher.DEFAULT).createConfig(); - this.componentsArray = new OCEmuComponent[OCEmuLauncher.DEFAULT.length]; - System.arraycopy(OCEmuLauncher.DEFAULT, 0, this.componentsArray, 0, OCEmuLauncher.DEFAULT.length); - } catch (IOException ex) { - Logger.getLogger(OCEmuForm.class.getName()).log(Level.SEVERE, null, ex); - } + new ConfigMaker(OCEmuLauncher.DEFAULT).createConfig(); + this.componentsArray = new OCEmuComponent[OCEmuLauncher.DEFAULT.length]; + System.arraycopy(OCEmuLauncher.DEFAULT, 0, this.componentsArray, 0, OCEmuLauncher.DEFAULT.length); updateComponentList(); }//GEN-LAST:event_resetConfigItemActionPerformed @@ -773,13 +774,13 @@ private void jMenuItem2ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jMenu // Variables declaration - do not modify//GEN-BEGIN:variables private JButton cancelButton; - private JTextField componentAddressField; - private JTextArea componentDescriptionArea; - private JList componentList; + JTextField componentAddressField; + JTextArea componentDescriptionArea; + JList componentList; private JMenu componentMenu; private JPanel componentSettingsPanel; - private JComboBox componentTypeComboBox; - private JFileChooser configChooser; + JComboBox componentTypeComboBox; + JFileChooser configChooser; private JPanel controlPanel; private JPanel descriptionPanel; private JMenuItem exitItem; @@ -800,10 +801,10 @@ private void jMenuItem2ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jMenu private JPopupMenu.Separator jSeparator1; private JPopupMenu.Separator jSeparator2; private JButton launchButton; - private JTextField option1Field; - private JTextField option2Field; - private JTextField option3Field; - private JTextField option4Field; + JTextField option1Field; + JTextField option2Field; + JTextField option3Field; + JTextField option4Field; private JMenuItem resetConfigItem; private JMenuItem saveConfigItem; // End of variables declaration//GEN-END:variables diff --git a/src/ru/VladTheMountain/oclide/ui/configurators/OCEmulatorForm.form b/src/ru/VladTheMountain/oclide/ui/configurators/OCEmulatorForm.form deleted file mode 100644 index 8d28fa5..0000000 --- a/src/ru/VladTheMountain/oclide/ui/configurators/OCEmulatorForm.form +++ /dev/null @@ -1,35 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/src/ru/VladTheMountain/oclide/ui/configurators/OCEmulatorForm.java b/src/ru/VladTheMountain/oclide/ui/configurators/OCEmulatorForm.java deleted file mode 100644 index efe2e24..0000000 --- a/src/ru/VladTheMountain/oclide/ui/configurators/OCEmulatorForm.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * The MIT License - * - * Copyright 2021 Vladislav Gorskii. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package ru.VladTheMountain.oclide.ui.configurators; - -import java.util.Locale; -import java.util.ResourceBundle; -import javax.swing.GroupLayout; -import javax.swing.WindowConstants; - -/** - * - * @author VladTheMountain - */ -public class OCEmulatorForm extends javax.swing.JFrame { - - final ResourceBundle localiztionResource = ResourceBundle.getBundle("ru.VladTheMountain.oclide.resources.configurator.ocemulator.OCEmulator", Locale.getDefault()); - - private static final long serialVersionUID = 1L; - - /** - * Creates new form OCEmulatorForm - */ - public OCEmulatorForm() { - initComponents(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - - GroupLayout layout = new GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGap(0, 400, Short.MAX_VALUE) - ); - layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGap(0, 300, Short.MAX_VALUE) - ); - - pack(); - }// //GEN-END:initComponents - - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - /* Set the Nimbus look and feel */ - // - /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. - * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html - */ - try { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { - javax.swing.UIManager.setLookAndFeel(info.getClassName()); - break; - } - } - } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(OCEmulatorForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(OCEmulatorForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(OCEmulatorForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(OCEmulatorForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } - // - - /* Create and display the form */ - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - new OCEmulatorForm().setVisible(true); - } - }); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - // End of variables declaration//GEN-END:variables -} diff --git a/src/ru/VladTheMountain/oclide/ui/configurators/OcelotDesktopForm.form b/src/ru/VladTheMountain/oclide/ui/configurators/OcelotDesktopForm.form deleted file mode 100644 index 36f8617..0000000 --- a/src/ru/VladTheMountain/oclide/ui/configurators/OcelotDesktopForm.form +++ /dev/null @@ -1,580 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/ru/VladTheMountain/oclide/ui/configurators/OcelotDesktopForm.java b/src/ru/VladTheMountain/oclide/ui/configurators/OcelotDesktopForm.java deleted file mode 100644 index ed96263..0000000 --- a/src/ru/VladTheMountain/oclide/ui/configurators/OcelotDesktopForm.java +++ /dev/null @@ -1,408 +0,0 @@ -/* - * The MIT License - * - * Copyright 2021 Vladislav Gorskii. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package ru.VladTheMountain.oclide.ui.configurators; - -import java.awt.Dimension; -import java.awt.Font; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.util.Locale; -import java.util.ResourceBundle; -import javax.swing.BorderFactory; -import javax.swing.ButtonGroup; -import javax.swing.DefaultComboBoxModel; -import javax.swing.GroupLayout; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JRadioButton; -import javax.swing.JTextField; -import javax.swing.KeyStroke; -import javax.swing.LayoutStyle; -import javax.swing.WindowConstants; -import javax.swing.border.TitledBorder; -import ru.VladTheMountain.emulator.ui.OcelotEmulatorFrame; - -/** - * Ocelot Desktop by LeshaInc - * - * Workspace configurator UI. - * - * @author VladTheMountain - */ -public class OcelotDesktopForm extends javax.swing.JFrame { - - final ResourceBundle localiztionResource = ResourceBundle.getBundle("ru.VladTheMountain.oclide.resources.configurator.ocelot.Ocelot", Locale.getDefault()); - private static final long serialVersionUID = 1L; - - /** - * Creates new form ConfiguratorForm - */ - public OcelotDesktopForm() { - initComponents(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - eepromButtons = new ButtonGroup(); - controlPanel = new JPanel(); - launchButton = new JButton(); - cancelButton = new JButton(); - extensionsPanel = new JPanel(); - architecturePanel = new JPanel(); - eepromPanel = new JPanel(); - luaEEPROMButton = new JRadioButton(); - customEEPROMButton = new JRadioButton(); - customEEPROMField = new JTextField(); - jLabel2 = new JLabel(); - JComboBox floppyComboBox = new JComboBox<>(); - jLabel3 = new JLabel(); - JComboBox caseTierComboBox = new JComboBox<>(); - primaryPanel = new JPanel(); - jLabel1 = new JLabel(); - JComboBox processingUnitComboBox = new JComboBox<>(); - jLabel4 = new JLabel(); - jLabel5 = new JLabel(); - JComboBox memorySlot1ComboBox = new JComboBox<>(); - JComboBox memorySlot2ComboBox = new JComboBox<>(); - secondaryPanel = new JPanel(); - jMenuBar1 = new JMenuBar(); - fileMenu = new JMenu(); - clearConfigItem = new JMenuItem(); - importConfigItem = new JMenuItem(); - saveConfigItem = new JMenuItem(); - jSeparator1 = new JPopupMenu.Separator(); - exitConfigItem = new JMenuItem(); - helpMenu = new JMenu(); - helpItem = new JMenuItem(); - - setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - setTitle("OCEmu Configuration"); - setAlwaysOnTop(true); - - controlPanel.setBorder(BorderFactory.createEtchedBorder()); - - launchButton.setText("Launch Ocelot"); - launchButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - launchButtonActionPerformed(evt); - } - }); - - cancelButton.setText("Cancel"); - - GroupLayout controlPanelLayout = new GroupLayout(controlPanel); - controlPanel.setLayout(controlPanelLayout); - controlPanelLayout.setHorizontalGroup(controlPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(GroupLayout.Alignment.TRAILING, controlPanelLayout.createSequentialGroup() - .addContainerGap() - .addComponent(cancelButton) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(launchButton) - .addContainerGap()) - ); - controlPanelLayout.setVerticalGroup(controlPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(GroupLayout.Alignment.TRAILING, controlPanelLayout.createSequentialGroup() - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(controlPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(launchButton) - .addComponent(cancelButton)) - .addContainerGap()) - ); - - extensionsPanel.setBorder(BorderFactory.createTitledBorder(null, "Storage", TitledBorder.LEFT, TitledBorder.TOP, new Font("Segoe UI", 1, 14))); // NOI18N - extensionsPanel.setFont(new Font("Segoe UI", 0, 12)); // NOI18N - extensionsPanel.setMinimumSize(new Dimension(200, 200)); - - GroupLayout extensionsPanelLayout = new GroupLayout(extensionsPanel); - extensionsPanel.setLayout(extensionsPanelLayout); - extensionsPanelLayout.setHorizontalGroup(extensionsPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGap(0, 0, Short.MAX_VALUE) - ); - extensionsPanelLayout.setVerticalGroup(extensionsPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGap(0, 171, Short.MAX_VALUE) - ); - - architecturePanel.setBorder(BorderFactory.createTitledBorder(null, "Architecture", TitledBorder.LEFT, TitledBorder.TOP, new Font("Segoe UI", 1, 14))); // NOI18N - architecturePanel.setFont(new Font("Segoe UI", 0, 12)); // NOI18N - architecturePanel.setMinimumSize(new Dimension(200, 200)); - - eepromPanel.setBorder(BorderFactory.createTitledBorder(null, "EEPROM", TitledBorder.LEFT, TitledBorder.TOP, new Font("Segoe UI", 1, 11))); // NOI18N - - eepromButtons.add(luaEEPROMButton); - luaEEPROMButton.setFont(new Font("Segoe UI", 0, 12)); // NOI18N - luaEEPROMButton.setSelected(true); - luaEEPROMButton.setText("Lua BIOS"); - - eepromButtons.add(customEEPROMButton); - customEEPROMButton.setFont(new Font("Segoe UI", 0, 12)); // NOI18N - customEEPROMButton.setText(" AdvLoader"); - - customEEPROMField.setEditable(false); - customEEPROMField.setFont(new Font("Monospaced", 0, 10)); // NOI18N - customEEPROMField.setToolTipText("Path to custom EEPROM script"); - customEEPROMField.setOpaque(false); - - GroupLayout eepromPanelLayout = new GroupLayout(eepromPanel); - eepromPanel.setLayout(eepromPanelLayout); - eepromPanelLayout.setHorizontalGroup(eepromPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(customEEPROMField) - .addComponent(customEEPROMButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(luaEEPROMButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - ); - eepromPanelLayout.setVerticalGroup(eepromPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(eepromPanelLayout.createSequentialGroup() - .addComponent(luaEEPROMButton) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(customEEPROMButton) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(customEEPROMField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addGap(0, 11, Short.MAX_VALUE)) - ); - - jLabel2.setFont(new Font("Segoe UI", 0, 12)); // NOI18N - jLabel2.setLabelFor(floppyComboBox); - jLabel2.setText("Floppy:"); - - floppyComboBox.setFont(new Font("Segoe UI", 0, 12)); // NOI18N - floppyComboBox.setModel(new DefaultComboBoxModel<>(new String[] { "OpenOS", "Plan9k", "OPPM", "OpenLoader", "Network", "OpenIRC", "Data Card Software", "Empty" })); - - jLabel3.setFont(new Font("Segoe UI", 0, 12)); // NOI18N - jLabel3.setLabelFor(caseTierComboBox); - jLabel3.setText("Case type:"); - jLabel3.setToolTipText(""); - - caseTierComboBox.setFont(new Font("Segoe UI", 0, 12)); // NOI18N - caseTierComboBox.setModel(new DefaultComboBoxModel<>(new String[] { "Case Tier 1", "Case Tier 2", "Case Tier 3", "Case Creative" })); - - GroupLayout architecturePanelLayout = new GroupLayout(architecturePanel); - architecturePanel.setLayout(architecturePanelLayout); - architecturePanelLayout.setHorizontalGroup(architecturePanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(architecturePanelLayout.createSequentialGroup() - .addContainerGap() - .addGroup(architecturePanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(eepromPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(architecturePanelLayout.createSequentialGroup() - .addGroup(architecturePanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false) - .addComponent(jLabel3, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE) - .addGroup(architecturePanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING, false) - .addComponent(floppyComboBox, 0, 1, Short.MAX_VALUE) - .addComponent(caseTierComboBox, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) - .addContainerGap()) - ); - architecturePanelLayout.setVerticalGroup(architecturePanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(GroupLayout.Alignment.TRAILING, architecturePanelLayout.createSequentialGroup() - .addContainerGap() - .addGroup(architecturePanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(jLabel3) - .addComponent(caseTierComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(architecturePanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(jLabel2) - .addComponent(floppyComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(eepromPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - ); - - primaryPanel.setBorder(BorderFactory.createTitledBorder(null, "Primary Components", TitledBorder.LEFT, TitledBorder.TOP, new Font("Segoe UI", 1, 14))); // NOI18N - primaryPanel.setFont(new Font("Segoe UI", 0, 12)); // NOI18N - primaryPanel.setMinimumSize(new Dimension(200, 200)); - - jLabel1.setFont(new Font("Segoe UI", 0, 12)); // NOI18N - jLabel1.setLabelFor(processingUnitComboBox); - jLabel1.setText("Processing Unit:"); - - processingUnitComboBox.setFont(new Font("Segoe UI", 0, 12)); // NOI18N - processingUnitComboBox.setModel(new DefaultComboBoxModel<>(new String[] { "CPU Tier 1", "CPU Tier 2", "CPU Tier 3", "APU Tier 2", "APU Tier 3", "APU Creative" })); - - jLabel4.setFont(new Font("Segoe UI", 0, 12)); // NOI18N - jLabel4.setText("Memory Slot 1:"); - - jLabel5.setFont(new Font("Segoe UI", 0, 12)); // NOI18N - jLabel5.setText("Memory Slot 2:"); - - memorySlot1ComboBox.setFont(new Font("Segoe UI", 0, 12)); // NOI18N - memorySlot1ComboBox.setModel(new DefaultComboBoxModel<>(new String[] { "Tier 1", "Tier 1.5", "Tier 2", "Tier 2.5", "Tier 3", "Tier 3.5" })); - - memorySlot2ComboBox.setFont(new Font("Segoe UI", 0, 12)); // NOI18N - memorySlot2ComboBox.setModel(new DefaultComboBoxModel<>(new String[] { "Tier 1", "Tier 1.5", "Tier 2", "Tier 2.5", "Tier 3", "Tier 3.5" })); - - GroupLayout primaryPanelLayout = new GroupLayout(primaryPanel); - primaryPanel.setLayout(primaryPanelLayout); - primaryPanelLayout.setHorizontalGroup(primaryPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(primaryPanelLayout.createSequentialGroup() - .addContainerGap() - .addGroup(primaryPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(primaryPanelLayout.createSequentialGroup() - .addGroup(primaryPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(jLabel5) - .addComponent(jLabel4)) - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGroup(primaryPanelLayout.createSequentialGroup() - .addComponent(jLabel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGap(5, 5, 5))) - .addGroup(primaryPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(processingUnitComboBox, 0, 1, Short.MAX_VALUE) - .addComponent(memorySlot2ComboBox, 0, 95, Short.MAX_VALUE) - .addComponent(memorySlot1ComboBox, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addContainerGap()) - ); - primaryPanelLayout.setVerticalGroup(primaryPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(primaryPanelLayout.createSequentialGroup() - .addContainerGap() - .addGroup(primaryPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(jLabel1) - .addComponent(processingUnitComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(primaryPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(jLabel4) - .addComponent(memorySlot1ComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(primaryPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(jLabel5) - .addComponent(memorySlot2ComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - secondaryPanel.setBorder(BorderFactory.createTitledBorder(null, "Secondary Components", TitledBorder.LEFT, TitledBorder.TOP, new Font("Segoe UI", 1, 14))); // NOI18N - secondaryPanel.setFont(new Font("Segoe UI", 0, 12)); // NOI18N - secondaryPanel.setMinimumSize(new Dimension(200, 200)); - - GroupLayout secondaryPanelLayout = new GroupLayout(secondaryPanel); - secondaryPanel.setLayout(secondaryPanelLayout); - secondaryPanelLayout.setHorizontalGroup(secondaryPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGap(0, 0, Short.MAX_VALUE) - ); - secondaryPanelLayout.setVerticalGroup(secondaryPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGap(0, 0, Short.MAX_VALUE) - ); - - fileMenu.setText("File"); - - clearConfigItem.setText("Clear configuration"); - fileMenu.add(clearConfigItem); - - importConfigItem.setText("Import from file"); - fileMenu.add(importConfigItem); - - saveConfigItem.setText("Save to file"); - fileMenu.add(saveConfigItem); - fileMenu.add(jSeparator1); - - exitConfigItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)); - exitConfigItem.setText("Exit configurator"); - fileMenu.add(exitConfigItem); - - jMenuBar1.add(fileMenu); - - helpMenu.setText("Help"); - - helpItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); - helpItem.setText("Help"); - helpMenu.add(helpItem); - - jMenuBar1.add(helpMenu); - - setJMenuBar(jMenuBar1); - - GroupLayout layout = new GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(controlPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false) - .addComponent(extensionsPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(architecturePanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(secondaryPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(primaryPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) - ); - layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(architecturePanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(primaryPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false) - .addComponent(extensionsPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(secondaryPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(controlPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, 0)) - ); - - pack(); - setLocationRelativeTo(null); - }// //GEN-END:initComponents - - private void launchButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_launchButtonActionPerformed - new OcelotEmulatorFrame().setVisible(true); - }//GEN-LAST:event_launchButtonActionPerformed - - // Variables declaration - do not modify//GEN-BEGIN:variables - private JPanel architecturePanel; - private JButton cancelButton; - private JMenuItem clearConfigItem; - private JPanel controlPanel; - private JRadioButton customEEPROMButton; - private JTextField customEEPROMField; - private ButtonGroup eepromButtons; - private JPanel eepromPanel; - private JMenuItem exitConfigItem; - private JPanel extensionsPanel; - private JMenu fileMenu; - private JMenuItem helpItem; - private JMenu helpMenu; - private JMenuItem importConfigItem; - private JLabel jLabel1; - private JLabel jLabel2; - private JLabel jLabel3; - private JLabel jLabel4; - private JLabel jLabel5; - private JMenuBar jMenuBar1; - private JPopupMenu.Separator jSeparator1; - private JButton launchButton; - private JRadioButton luaEEPROMButton; - private JPanel primaryPanel; - private JMenuItem saveConfigItem; - private JPanel secondaryPanel; - // End of variables declaration//GEN-END:variables -} diff --git a/src/ru/VladTheMountain/oclide/ui/configurators/package-info.java b/src/ru/VladTheMountain/oclide/ui/configurators/package-info.java new file mode 100644 index 0000000..2dc84bc --- /dev/null +++ b/src/ru/VladTheMountain/oclide/ui/configurators/package-info.java @@ -0,0 +1,29 @@ +/* + * The MIT License + * + * Copyright 2021 VladTheMountain. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +/** + * Configurator and launcher-related UI forms + * + * @author VladTheMountain + */ +package ru.VladTheMountain.oclide.ui.configurators; diff --git a/src/ru/VladTheMountain/oclide/ui/dialogs/AboutDialog.java b/src/ru/VladTheMountain/oclide/ui/dialogs/AboutDialog.java index 7a64ab2..59e0829 100644 --- a/src/ru/VladTheMountain/oclide/ui/dialogs/AboutDialog.java +++ b/src/ru/VladTheMountain/oclide/ui/dialogs/AboutDialog.java @@ -36,18 +36,35 @@ */ public class AboutDialog { - final ResourceBundle localiztionResource = ResourceBundle.getBundle("ru.VladTheMountain.oclide.resources.dialog.Dialog", Locale.getDefault()); - + final ResourceBundle localizationResource = ResourceBundle.getBundle("io.VladTheMountain.oclide.resources.dialog.Dialog", Locale.getDefault()); + + /** + * + * @param parent parent JFrame + */ public AboutDialog(JFrame parent) { JOptionPane.showMessageDialog(parent, - "OCLIDE RC1-1.0.0\n" - + "THIS VERSION IS FOR INDEV PREVIEW PURPOSES ONLY. DO NOT DISTRIBUTE." - + "Copyright (c) VladTheMountain (Vladislav Gorskii) 2021.\n" - + "\n" - + "OCLIDE (OpenComputers Lua Integrated Development Environment) is an open-source Lua IDE for developing software for OpenComputers Minecraft mod.\n" - + "This program and it's source, until otherwise noted, are distributed under the MIT License.\n" - + "\n" - + "" - ); + "" + + "

OCLIDE beta 0.1.0

" + + "
Copyright (c) VladTheMountain (Vladislav Gorskii) 2021.
" + + "

" + + "OCLIDE (OpenComputers Lua Integrated Development Environment) is an open-source Lua IDE for developing software for OpenComputers Minecraft mod.
" + + "This program and it's source, until otherwise stated, are distributed under the MIT License." + + "


" + + "Lua 5.2 and Lua 5.3 documentation is taken from official Lua website lua.org" + + "

" + + "

Special thanks to:

" + + "", + localizationResource.getString("about_title"), JOptionPane.INFORMATION_MESSAGE); } } diff --git a/src/ru/VladTheMountain/oclide/ui/dialogs/CreateNewProjectDialog.java b/src/ru/VladTheMountain/oclide/ui/dialogs/CreateNewProjectDialog.java index a488e6b..ba62ea4 100644 --- a/src/ru/VladTheMountain/oclide/ui/dialogs/CreateNewProjectDialog.java +++ b/src/ru/VladTheMountain/oclide/ui/dialogs/CreateNewProjectDialog.java @@ -30,10 +30,13 @@ import java.nio.file.FileSystems; import java.util.Locale; import java.util.ResourceBundle; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.AbstractListModel; import javax.swing.BorderFactory; import javax.swing.GroupLayout; import javax.swing.JButton; +import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; @@ -57,16 +60,16 @@ * * @author VladTheMountain */ -public class CreateNewProjectDialog extends javax.swing.JDialog { - - final ResourceBundle localiztionResource = ResourceBundle.getBundle("ru.VladTheMountain.oclide.resources.dialog.Dialog", Locale.getDefault()); +public class CreateNewProjectDialog extends JDialog { + + final ResourceBundle localiztionResource = ResourceBundle.getBundle("io.VladTheMountain.oclide.resources.dialog.Dialog", Locale.getDefault()); private static final long serialVersionUID = 1L; /** * Creates new form createNewProject * - * @param parent + * @param parent parent JFrame */ public CreateNewProjectDialog(java.awt.Frame parent) { super(parent, true); @@ -429,6 +432,9 @@ private void projectTypeListValueChanged(ListSelectionEvent evt) {//GEN-FIRST:ev case 2: this.descriptionText.setText("Creates a new project with /lib/ folder.\nAllows to customize the name of the library."); break; + default: + Logger.getLogger(CreateNewProjectDialog.class.getName()).log(Level.SEVERE, "Something's wrong at projectTypeListValueChanged - wrong index: {0}", this.projectTypeList.getSelectedIndex()); + break; } }//GEN-LAST:event_projectTypeListValueChanged diff --git a/src/ru/VladTheMountain/oclide/ui/dialogs/MachineChooserDialog.java b/src/ru/VladTheMountain/oclide/ui/dialogs/MachineChooserDialog.java index 368a91a..991e58d 100644 --- a/src/ru/VladTheMountain/oclide/ui/dialogs/MachineChooserDialog.java +++ b/src/ru/VladTheMountain/oclide/ui/dialogs/MachineChooserDialog.java @@ -31,6 +31,7 @@ import javax.swing.GroupLayout; import javax.swing.JButton; import javax.swing.JComboBox; +import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.LayoutStyle; @@ -38,9 +39,9 @@ * * @author Vladi */ -public class MachineChooserDialog extends javax.swing.JDialog { - - final ResourceBundle localiztionResource = ResourceBundle.getBundle("ru.VladTheMountain.oclide.resources.dialog.Dialog", Locale.getDefault()); +public class MachineChooserDialog extends JDialog { + + final ResourceBundle localiztionResource = ResourceBundle.getBundle("io.VladTheMountain.oclide.resources.dialog.Dialog", Locale.getDefault()); private static final long serialVersionUID = 1L; private String[] fileSystemList; @@ -49,8 +50,11 @@ public class MachineChooserDialog extends javax.swing.JDialog { /** * Creates new form MachineChooser * - * @param parent - * @param modal + * @param parent parent JFrame + * @param modal specifies whether dialog blocks user input to other + * top-level windows when shown. If {@code true}, the modality type property + * is set to {@code DEFAULT_MODALITY_TYPE}, otherwise the dialog is + * modeless. * @param fs Array of filesystem UUIDs */ public MachineChooserDialog(java.awt.Frame parent, boolean modal, String[] fs) { @@ -59,7 +63,7 @@ public MachineChooserDialog(java.awt.Frame parent, boolean modal, String[] fs) { System.arraycopy(fs, 0, this.fileSystemList, 0, fs.length); selectedFS = null; initComponents(); - this.setDefaultCloseOperation(javax.swing.JDialog.DISPOSE_ON_CLOSE); + this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); this.setVisible(true); } diff --git a/src/ru/VladTheMountain/oclide/ui/dialogs/OpenFileFileChooser.java b/src/ru/VladTheMountain/oclide/ui/dialogs/OpenFileFileChooser.java index 228e59c..35685b1 100644 --- a/src/ru/VladTheMountain/oclide/ui/dialogs/OpenFileFileChooser.java +++ b/src/ru/VladTheMountain/oclide/ui/dialogs/OpenFileFileChooser.java @@ -35,11 +35,14 @@ * @author VladTheMountain */ public class OpenFileFileChooser extends JFileChooser { - - final ResourceBundle localiztionResource = ResourceBundle.getBundle("ru.VladTheMountain.oclide.resources.dialog.Dialog", Locale.getDefault()); + + final ResourceBundle localiztionResource = ResourceBundle.getBundle("io.VladTheMountain.oclide.resources.dialog.Dialog", Locale.getDefault()); private static final long serialVersionUID = 1L; + /** + * + */ public OpenFileFileChooser() { this.setApproveButtonText("Open"); this.setApproveButtonToolTipText("Open selected file"); diff --git a/src/ru/VladTheMountain/oclide/ui/dialogs/ProjectFileChooser.java b/src/ru/VladTheMountain/oclide/ui/dialogs/ProjectFileChooser.java index d6d30a5..9bc5180 100644 --- a/src/ru/VladTheMountain/oclide/ui/dialogs/ProjectFileChooser.java +++ b/src/ru/VladTheMountain/oclide/ui/dialogs/ProjectFileChooser.java @@ -33,11 +33,14 @@ * @author VladTheMountain */ public class ProjectFileChooser extends JFileChooser { - - final ResourceBundle localiztionResource = ResourceBundle.getBundle("ru.VladTheMountain.oclide.resources.dialog.Dialog", Locale.getDefault()); + + final ResourceBundle localiztionResource = ResourceBundle.getBundle("io.VladTheMountain.oclide.resources.dialog.Dialog", Locale.getDefault()); private static final long serialVersionUID = 1L; + /** + * + */ public ProjectFileChooser() { this.setCurrentDirectory(new File(System.getProperty("user.home"))); this.setFileSelectionMode(DIRECTORIES_ONLY); diff --git a/src/ru/VladTheMountain/oclide/ui/dialogs/package-info.java b/src/ru/VladTheMountain/oclide/ui/dialogs/package-info.java new file mode 100644 index 0000000..78937e3 --- /dev/null +++ b/src/ru/VladTheMountain/oclide/ui/dialogs/package-info.java @@ -0,0 +1,30 @@ +/* + * The MIT License + * + * Copyright 2021 VladTheMountain. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +/** + * Dialog-related UI forms + * + * @see io.VladTheMountain.oclide.ui.frames.EditorFrame + * @author VladTheMountain + */ +package ru.VladTheMountain.oclide.ui.dialogs; diff --git a/src/ru/VladTheMountain/oclide/ui/frames/EditorFrame.form b/src/ru/VladTheMountain/oclide/ui/frames/EditorFrame.form index 217642e..1001619 100644 --- a/src/ru/VladTheMountain/oclide/ui/frames/EditorFrame.form +++ b/src/ru/VladTheMountain/oclide/ui/frames/EditorFrame.form @@ -11,7 +11,7 @@ - + @@ -22,7 +22,7 @@ - + @@ -47,7 +47,7 @@ - + @@ -58,7 +58,7 @@ - + @@ -73,7 +73,7 @@ - + @@ -96,7 +96,7 @@ - + @@ -109,7 +109,7 @@ - + @@ -133,7 +133,7 @@ - + @@ -143,9 +143,11 @@ - + + + + - @@ -157,9 +159,11 @@ - + + + + - @@ -170,9 +174,11 @@ - + + + + - @@ -181,9 +187,11 @@ - + + + + - @@ -197,9 +205,11 @@ - + + + + - @@ -213,9 +223,11 @@ - + + + + - @@ -225,7 +237,9 @@ - + + + @@ -235,7 +249,9 @@ - + + + @@ -244,9 +260,11 @@ - + + + + - @@ -255,9 +273,11 @@ - + + + + - @@ -268,9 +288,11 @@ - + + + + - @@ -282,9 +304,11 @@ - + + + + - @@ -296,9 +320,11 @@ - + + + + - @@ -311,7 +337,9 @@ - + + + @@ -321,20 +349,26 @@ - + + + - + + + - + + + + - @@ -343,9 +377,11 @@ - + + + + - @@ -353,7 +389,10 @@ - + + + + @@ -361,7 +400,10 @@ - + + + + @@ -369,7 +411,10 @@ - + + + + @@ -379,17 +424,25 @@ - + + + - + + + + - + + + + @@ -398,19 +451,26 @@ - + + + + - + + + - + + + @@ -418,7 +478,10 @@ - + + + + @@ -426,9 +489,11 @@ - + + + + - @@ -472,7 +537,7 @@ - + @@ -486,7 +551,7 @@ - + @@ -539,8 +604,10 @@ - - + + + + @@ -580,6 +647,9 @@ + + + @@ -593,6 +663,7 @@ + @@ -640,9 +711,11 @@ - + + + + - @@ -654,9 +727,11 @@ - + + + + - @@ -668,9 +743,11 @@ - + + + + - @@ -682,9 +759,11 @@ - + + + + - @@ -696,9 +775,11 @@ - + + + + - @@ -720,9 +801,11 @@ - + + + + - @@ -731,9 +814,11 @@ - + + + + - @@ -752,9 +837,11 @@ - + + + + - @@ -766,9 +853,11 @@ - + + + + - diff --git a/src/ru/VladTheMountain/oclide/ui/frames/EditorFrame.java b/src/ru/VladTheMountain/oclide/ui/frames/EditorFrame.java index 143cdc1..6a25aa1 100644 --- a/src/ru/VladTheMountain/oclide/ui/frames/EditorFrame.java +++ b/src/ru/VladTheMountain/oclide/ui/frames/EditorFrame.java @@ -23,6 +23,9 @@ */ package ru.VladTheMountain.oclide.ui.frames; +//import io.VladTheMountain.emulator.ui.OcelotEmulatorFrame; +//import io.VladTheMountain.oclide.ui.configurators.AurumEmulatorForm; +//import io.VladTheMountain.oclide.ui.configurators.CODEForm; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -32,6 +35,7 @@ import java.awt.event.MouseEvent; import java.io.BufferedReader; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; @@ -76,24 +80,25 @@ import org.fife.ui.rsyntaxtextarea.SyntaxConstants; import org.fife.ui.rtextarea.RTextScrollPane; import org.fife.ui.rtextarea.ToolTipSupplier; -import ru.VladTheMountain.emulator.ui.OcelotEmulatorFrame; -import ru.VladTheMountain.oclide.editor.OCLIDECompletionProvider; -import ru.VladTheMountain.oclide.ui.configurators.AurumEmulatorForm; -import ru.VladTheMountain.oclide.ui.configurators.CODEForm; +import ru.VladTheMountain.oclide.editor.autocompletion.OCLIDECompletionProvider; import ru.VladTheMountain.oclide.ui.configurators.OCEmuForm; +import ru.VladTheMountain.oclide.ui.dialogs.AboutDialog; import ru.VladTheMountain.oclide.ui.dialogs.CreateNewProjectDialog; import ru.VladTheMountain.oclide.ui.dialogs.OpenFileFileChooser; import ru.VladTheMountain.oclide.ui.dialogs.ProjectFileChooser; import ru.VladTheMountain.oclide.util.ConsoleOutputStream; /** + * Probably the most important and complicated class in the whole application. + * It describes main Frame's UI, it's logic and sets {@link ActionListener}s for + * almost every dialog present in {@code io.VladTheMountain.oclide.ui.dialogs} * * @author VladTheMountain */ public class EditorFrame extends JFrame { - final ResourceBundle localiztionResource = ResourceBundle.getBundle("ru.VladTheMountain.oclide.resources.editor.Editor", Locale.getDefault()); - + final static ResourceBundle localizationResource = ResourceBundle.getBundle("ru.VladTheMountain.oclide.resources.editor.Editor", Locale.getDefault()); + private static final long serialVersionUID = 1L; /** @@ -103,7 +108,8 @@ public EditorFrame() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { - Logger.getLogger(EditorFrame.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(EditorFrame.class.getName()).log(Level.SEVERE, "Error while configuring L&F: ", ex); + JOptionPane.showMessageDialog(this, ex, "Caught " + ex.getClass().getName(), JOptionPane.ERROR_MESSAGE); } initComponents(); System.setOut(new PrintStream(new ConsoleOutputStream(outputTextArea))); @@ -118,9 +124,14 @@ private void newFile(File file) { try { file.createNewFile(); } catch (IOException ex) { - Logger.getLogger(EditorFrame.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(EditorFrame.class.getName()).log(Level.SEVERE, "Error while creating a new file: ", ex); + JOptionPane.showMessageDialog(this, ex, "Caught " + ex.getClass().getName(), JOptionPane.ERROR_MESSAGE); + } + try { + openFile(file); //:D + } catch (FileNotFoundException ex) { + Logger.getLogger(EditorFrame.class.getName()).log(Level.SEVERE, "File not found", ex); } - openFile(file); //:D } /** @@ -129,15 +140,17 @@ private void newFile(File file) { * * @param file the {@link File}, which contents are to read */ - private void openFile(File file) { + private void openFile(File file) throws FileNotFoundException { if (!(file.exists())) { JOptionPane.showMessageDialog(this, "The requested file " + file.getAbsolutePath() + " does not exist.", "File does not exist", JOptionPane.ERROR_MESSAGE); + throw new FileNotFoundException("The requested file does not exist"); } String fileContent = ""; try { fileContent = new String(Files.readAllBytes(file.toPath())); } catch (IOException ex) { Logger.getLogger(EditorFrame.class.getName()).log(Level.SEVERE, null, ex); + JOptionPane.showMessageDialog(null, ex, "Caught " + ex.getClass().getName(), JOptionPane.ERROR_MESSAGE); } RSyntaxTextArea newFile = new RSyntaxTextArea(fileContent); newFile.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_LUA); @@ -178,13 +191,15 @@ private void saveFile(File f) { try { f.createNewFile(); } catch (IOException ex) { - Logger.getLogger(EditorFrame.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(EditorFrame.class.getName()).log(Level.SEVERE, "Error while creating new file: ", ex); + JOptionPane.showMessageDialog(null, ex, "Caught " + ex.getClass().getName(), JOptionPane.ERROR_MESSAGE); } } try { Files.write(f.toPath(), this.editorTabs.getComponentAt(this.editorTabs.getSelectedIndex()).getAccessibleContext().getAccessibleChild(0).getAccessibleContext().getAccessibleChild(0).getAccessibleContext().getAccessibleDescription().getBytes()); } catch (IOException ex) { - Logger.getLogger(EditorFrame.class.getName()).log(Level.SEVERE, null, ex); + Logger.getLogger(EditorFrame.class.getName()).log(Level.SEVERE, "Error while writing into file: ", ex); + JOptionPane.showMessageDialog(null, ex, "Caught " + ex.getClass().getName(), JOptionPane.ERROR_MESSAGE); } updateProjectsTree(); } @@ -210,7 +225,7 @@ public static void createProject(String name, String projectDir) { */ private static void updateProjectsTree() { //Tree values - DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Projects"); + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(localizationResource.getString("treeProjects")); DefaultTreeModel projTreeModel = new DefaultTreeModel(rootNode); //Files' bullsh*t File projectsDir = new File("projects"); @@ -340,7 +355,7 @@ private void initComponents() { jSeparator11 = new JPopupMenu.Separator(); settingsMenuItem = new JMenuItem(); - popupSaveFile.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/save_icon&16.png"))); // NOI18N + popupSaveFile.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/save_icon&16.png"))); // NOI18N popupSaveFile.setText("Save current file"); popupSaveFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { @@ -349,7 +364,7 @@ public void actionPerformed(ActionEvent evt) { }); fileManagementPopup.add(popupSaveFile); - popupCloseFile.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/doc_delete_icon&16.png"))); // NOI18N + popupCloseFile.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/doc_delete_icon&16.png"))); // NOI18N popupCloseFile.setText("Close current file"); popupCloseFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { @@ -361,7 +376,7 @@ public void actionPerformed(ActionEvent evt) { newMenu.setText("Add..."); newMenu.setToolTipText(""); - addFileMenuItem.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/document_icon&16.png"))); // NOI18N + addFileMenuItem.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/document_icon&16.png"))); // NOI18N addFileMenuItem.setText("File"); addFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { @@ -370,7 +385,7 @@ public void actionPerformed(ActionEvent evt) { }); newMenu.add(addFileMenuItem); - addFolderMenuItem.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/folder_icon&16.png"))); // NOI18N + addFolderMenuItem.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/folder_icon&16.png"))); // NOI18N addFolderMenuItem.setText("Folder"); addFolderMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { @@ -382,7 +397,7 @@ public void actionPerformed(ActionEvent evt) { projectManagementPopup.add(newMenu); projectManagementPopup.add(jSeparator7); - runInOCEmu.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/app_window_shell&16.png"))); // NOI18N + runInOCEmu.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/app_window_shell&16.png"))); // NOI18N runInOCEmu.setText("Launch OCEmu"); runInOCEmu.setToolTipText(""); runInOCEmu.addActionListener(new ActionListener() { @@ -402,7 +417,7 @@ public void actionPerformed(ActionEvent evt) { }); projectManagementPopup.add(renameMenuItem); - deleteMenuItem.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/folder_delete_icon&16.png"))); // NOI18N + deleteMenuItem.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/folder_delete_icon&16.png"))); // NOI18N deleteMenuItem.setText("Delete"); deleteMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { @@ -412,7 +427,7 @@ public void actionPerformed(ActionEvent evt) { projectManagementPopup.add(deleteMenuItem); projectManagementPopup.add(jSeparator9); - propertiesMenuItem.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/cogs_icon&16.png"))); // NOI18N + propertiesMenuItem.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/cogs_icon&16.png"))); // NOI18N propertiesMenuItem.setText("Properties"); propertiesMenuItem.setToolTipText(""); propertiesMenuItem.addActionListener(new ActionListener() { @@ -446,7 +461,7 @@ public void mouseClicked(MouseEvent evt) { outputTextArea.setRows(5); jScrollPane2.setViewportView(outputTextArea); - jTabbedPane1.addTab("IDE Output", jScrollPane2); + jTabbedPane1.addTab(localizationResource.getString("tabIDEOutput"), jScrollPane2); jSplitPane3.setBottomComponent(jTabbedPane1); @@ -455,10 +470,13 @@ public void mouseClicked(MouseEvent evt) { jSplitPane2.setOrientation(JSplitPane.VERTICAL_SPLIT); jSplitPane2.setResizeWeight(1.0); + jScrollPane1.setEnabled(false); + variableTree.setModel(new DefaultTreeModel(new DefaultMutableTreeNode( this.editorTabs.getSelectedIndex()==-1 ? "Variables" : this.editorTabs.getTitleAt(this.editorTabs.getSelectedIndex())))); +variableTree.setEnabled(false); jScrollPane1.setViewportView(variableTree); jSplitPane2.setBottomComponent(jScrollPane1); @@ -480,8 +498,8 @@ public void mouseClicked(MouseEvent evt) { projectToolbar.setFloatable(false); projectToolbar.setRollover(true); - newProjectButton.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/folder_plus_icon&24.png"))); // NOI18N - newProjectButton.setToolTipText("Create a new project"); + newProjectButton.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/folder_plus_icon&24.png"))); // NOI18N + newProjectButton.setToolTipText(localizationResource.getString("tooltipCreateProject")); newProjectButton.setFocusable(false); newProjectButton.setHorizontalTextPosition(SwingConstants.CENTER); newProjectButton.setVerticalTextPosition(SwingConstants.BOTTOM); @@ -492,8 +510,8 @@ public void actionPerformed(ActionEvent evt) { }); projectToolbar.add(newProjectButton); - openProjectButton.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/folder_open_icon&24.png"))); // NOI18N - openProjectButton.setToolTipText("Open project"); + openProjectButton.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/folder_open_icon&24.png"))); // NOI18N + openProjectButton.setToolTipText(localizationResource.getString("tooltipOpenProject")); openProjectButton.setFocusable(false); openProjectButton.setHorizontalTextPosition(SwingConstants.CENTER); openProjectButton.setVerticalTextPosition(SwingConstants.BOTTOM); @@ -504,8 +522,8 @@ public void actionPerformed(ActionEvent evt) { }); projectToolbar.add(openProjectButton); - addFileButton.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/doc_plus_icon&24.png"))); // NOI18N - addFileButton.setToolTipText("Add a file"); + addFileButton.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/doc_plus_icon&24.png"))); // NOI18N + addFileButton.setToolTipText(localizationResource.getString("tooltipCreateFile")); addFileButton.setFocusable(false); addFileButton.setHorizontalTextPosition(SwingConstants.CENTER); addFileButton.setVerticalTextPosition(SwingConstants.BOTTOM); @@ -516,8 +534,8 @@ public void actionPerformed(ActionEvent evt) { }); projectToolbar.add(addFileButton); - saveButton.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/save_icon&24.png"))); // NOI18N - saveButton.setToolTipText("Save current file"); + saveButton.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/save_icon&24.png"))); // NOI18N + saveButton.setToolTipText(localizationResource.getString("tooltipSaveFile")); saveButton.setFocusable(false); saveButton.setHorizontalTextPosition(SwingConstants.CENTER); saveButton.setVerticalTextPosition(SwingConstants.BOTTOM); @@ -528,8 +546,8 @@ public void actionPerformed(ActionEvent evt) { }); projectToolbar.add(saveButton); - deleteProjectButton.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/folder_delete_icon&24.png"))); // NOI18N - deleteProjectButton.setToolTipText("Delete project"); + deleteProjectButton.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/folder_delete_icon&24.png"))); // NOI18N + deleteProjectButton.setToolTipText(localizationResource.getString("tooltipDeleteProject")); deleteProjectButton.setFocusable(false); deleteProjectButton.setHorizontalTextPosition(SwingConstants.CENTER); deleteProjectButton.setVerticalTextPosition(SwingConstants.BOTTOM); @@ -543,15 +561,15 @@ public void actionPerformed(ActionEvent evt) { undoRedoToolbar.setFloatable(false); undoRedoToolbar.setRollover(true); - undoButton.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/undo_icon&24.png"))); // NOI18N - undoButton.setToolTipText("Undo"); + undoButton.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/undo_icon&24.png"))); // NOI18N + undoButton.setToolTipText(localizationResource.getString("tooltipUndo")); undoButton.setFocusable(false); undoButton.setHorizontalTextPosition(SwingConstants.CENTER); undoButton.setVerticalTextPosition(SwingConstants.BOTTOM); undoRedoToolbar.add(undoButton); - redoButton.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/redo_icon&24.png"))); // NOI18N - redoButton.setToolTipText("Redo"); + redoButton.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/redo_icon&24.png"))); // NOI18N + redoButton.setToolTipText(localizationResource.getString("tooltipRedo")); redoButton.setFocusable(false); redoButton.setHorizontalTextPosition(SwingConstants.CENTER); redoButton.setVerticalTextPosition(SwingConstants.BOTTOM); @@ -560,8 +578,8 @@ public void actionPerformed(ActionEvent evt) { jToolBar1.setFloatable(false); jToolBar1.setRollover(true); - runOCEmuButton.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/app_window_shell&24.png"))); // NOI18N - runOCEmuButton.setToolTipText("Launch OCEmu"); + runOCEmuButton.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/app_window_shell&24.png"))); // NOI18N + runOCEmuButton.setToolTipText(localizationResource.getString("tooltipOCEmu")); runOCEmuButton.setFocusable(false); runOCEmuButton.setHorizontalTextPosition(SwingConstants.CENTER); runOCEmuButton.setVerticalTextPosition(SwingConstants.BOTTOM); @@ -572,8 +590,8 @@ public void actionPerformed(ActionEvent evt) { }); jToolBar1.add(runOCEmuButton); - runOcelotButton.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/app_window_black&24.png"))); // NOI18N - runOcelotButton.setToolTipText("Launch Ocelot Desktop"); + runOcelotButton.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/app_window_black&24.png"))); // NOI18N + runOcelotButton.setToolTipText(localizationResource.getString("tooltipOcelot")); runOcelotButton.setVerticalTextPosition(SwingConstants.BOTTOM); runOcelotButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { @@ -582,11 +600,11 @@ public void actionPerformed(ActionEvent evt) { }); jToolBar1.add(runOcelotButton); - fileMenu.setText(localiztionResource.getString("fileMenu")); + fileMenu.setText(localizationResource.getString("menuFile")); - createProject.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK)); - createProject.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/folder_plus_icon&16.png"))); // NOI18N - createProject.setText("Create project"); + createProject.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK)); + createProject.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/folder_plus_icon&16.png"))); // NOI18N + createProject.setText(localizationResource.getString("menuItemCreateProject")); createProject.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { createProjectActionPerformed(evt); @@ -594,9 +612,9 @@ public void actionPerformed(ActionEvent evt) { }); fileMenu.add(createProject); - openProject.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK)); - openProject.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/folder_open_icon&16.png"))); // NOI18N - openProject.setText("Open project"); + openProject.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK)); + openProject.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/folder_open_icon&16.png"))); // NOI18N + openProject.setText(localizationResource.getString("menuItemOpenProject")); openProject.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { openProjectActionPerformed(evt); @@ -605,8 +623,8 @@ public void actionPerformed(ActionEvent evt) { fileMenu.add(openProject); fileMenu.add(jSeparator1); - createFile.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/doc_plus_icon&16.png"))); // NOI18N - createFile.setText("Create file"); + createFile.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/doc_plus_icon&16.png"))); // NOI18N + createFile.setText(localizationResource.getString("menuItemCreateFile")); createFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { createFileActionPerformed(evt); @@ -614,8 +632,8 @@ public void actionPerformed(ActionEvent evt) { }); fileMenu.add(createFile); - openFile.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/document_icon&16.png"))); // NOI18N - openFile.setText("Open file"); + openFile.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/document_icon&16.png"))); // NOI18N + openFile.setText(localizationResource.getString("menuItemOpenFile")); openFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { openFileActionPerformed(evt); @@ -624,9 +642,9 @@ public void actionPerformed(ActionEvent evt) { fileMenu.add(openFile); fileMenu.add(jSeparator10); - save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK)); - save.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/save_icon&16.png"))); // NOI18N - save.setText("Save"); + save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)); + save.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/save_icon&16.png"))); // NOI18N + save.setText(localizationResource.getString("menuItemSaveFile")); save.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { saveActionPerformed(evt); @@ -635,9 +653,9 @@ public void actionPerformed(ActionEvent evt) { fileMenu.add(save); fileMenu.add(jSeparator6); - deleteProject.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, InputEvent.CTRL_MASK)); - deleteProject.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/folder_delete_icon&16.png"))); // NOI18N - deleteProject.setText("Delete project"); + deleteProject.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, InputEvent.CTRL_DOWN_MASK)); + deleteProject.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/folder_delete_icon&16.png"))); // NOI18N + deleteProject.setText(localizationResource.getString("menuItemDeleteProject")); deleteProject.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { deleteProjectActionPerformed(evt); @@ -646,7 +664,7 @@ public void actionPerformed(ActionEvent evt) { fileMenu.add(deleteProject); fileMenu.add(jSeparator2); - exit.setText("Exit"); + exit.setText(localizationResource.getString("menuItemExit")); exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { exitActionPerformed(evt); @@ -656,22 +674,22 @@ public void actionPerformed(ActionEvent evt) { menuBar.add(fileMenu); - editMenu.setText("Edit"); + editMenu.setText(localizationResource.getString("menuEdit")); - undo.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK)); - undo.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/undo_icon&16.png"))); // NOI18N - undo.setText("Undo"); + undo.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK)); + undo.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/undo_icon&16.png"))); // NOI18N + undo.setText(localizationResource.getString("menuItemUndo")); editMenu.add(undo); - redo.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_MASK)); - redo.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/redo_icon&16.png"))); // NOI18N - redo.setText("Redo"); + redo.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_DOWN_MASK)); + redo.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/redo_icon&16.png"))); // NOI18N + redo.setText(localizationResource.getString("menuItemRedo")); editMenu.add(redo); editMenu.add(jSeparator3); - cut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK)); - cut.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/clipboard_cut_icon&16.png"))); // NOI18N - cut.setText("Cut"); + cut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_DOWN_MASK)); + cut.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/clipboard_cut_icon&16.png"))); // NOI18N + cut.setText(localizationResource.getString("menuItemCut")); cut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { cutActionPerformed(evt); @@ -679,9 +697,9 @@ public void actionPerformed(ActionEvent evt) { }); editMenu.add(cut); - copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK)); - copy.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/clipboard_copy_icon&16.png"))); // NOI18N - copy.setText("Copy"); + copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK)); + copy.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/clipboard_copy_icon&16.png"))); // NOI18N + copy.setText(localizationResource.getString("menuItemCopy")); copy.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { copyActionPerformed(evt); @@ -689,9 +707,9 @@ public void actionPerformed(ActionEvent evt) { }); editMenu.add(copy); - paste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK)); - paste.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/clipboard_past_icon&16.png"))); // NOI18N - paste.setText("Paste"); + paste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_DOWN_MASK)); + paste.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/clipboard_past_icon&16.png"))); // NOI18N + paste.setText(localizationResource.getString("menuItemPaste")); paste.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { pasteActionPerformed(evt); @@ -700,8 +718,8 @@ public void actionPerformed(ActionEvent evt) { editMenu.add(paste); editMenu.add(jSeparator4); - find.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_MASK)); - find.setText("Find..."); + find.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK)); + find.setText(localizationResource.getString("menuItemFind")); find.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { findActionPerformed(evt); @@ -711,12 +729,12 @@ public void actionPerformed(ActionEvent evt) { menuBar.add(editMenu); - runMenu.setText("Deploy"); + runMenu.setText(localizationResource.getString("menuDeploy")); - emulatorMenu.setText("Deploy to Emulator"); + emulatorMenu.setText(localizationResource.getString("menuItemDeployToEmulator")); - ocemuMenuItem.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/app_window_shell&16.png"))); // NOI18N - ocemuMenuItem.setText("Run OCEmu"); + ocemuMenuItem.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/app_window_shell&16.png"))); // NOI18N + ocemuMenuItem.setText(localizationResource.getString("menuItemOCEmu")); ocemuMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { ocemuMenuItemActionPerformed(evt); @@ -724,8 +742,8 @@ public void actionPerformed(ActionEvent evt) { }); emulatorMenu.add(ocemuMenuItem); - ocelotMenuItem.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/app_window_black&16.png"))); // NOI18N - ocelotMenuItem.setText("Run Ocelot"); + ocelotMenuItem.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/app_window_black&16.png"))); // NOI18N + ocelotMenuItem.setText(localizationResource.getString("menuItemOcelot")); ocelotMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { ocelotMenuItemActionPerformed(evt); @@ -733,7 +751,8 @@ public void actionPerformed(ActionEvent evt) { }); emulatorMenu.add(ocelotMenuItem); - ocemulatorMenuItem.setText("Run OCEmulator"); + ocemulatorMenuItem.setText(localizationResource.getString("menuItemOCEmulator")); + ocemulatorMenuItem.setEnabled(false); ocemulatorMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { ocemulatorMenuItemActionPerformed(evt); @@ -741,7 +760,8 @@ public void actionPerformed(ActionEvent evt) { }); emulatorMenu.add(ocemulatorMenuItem); - aurumMenuItem.setText("Run Aurum Emulator"); + aurumMenuItem.setText(localizationResource.getString("menuItemAurum")); + aurumMenuItem.setEnabled(false); aurumMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { aurumMenuItemActionPerformed(evt); @@ -749,7 +769,8 @@ public void actionPerformed(ActionEvent evt) { }); emulatorMenu.add(aurumMenuItem); - codeMenuItem.setText("Run CODE"); + codeMenuItem.setText(localizationResource.getString("menuItemCODE")); + codeMenuItem.setEnabled(false); codeMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { codeMenuItemActionPerformed(evt); @@ -759,25 +780,28 @@ public void actionPerformed(ActionEvent evt) { runMenu.add(emulatorMenu); - vmMenu.setText("Deploy to VM"); + vmMenu.setText(localizationResource.getString("menuItemDeployToVM")); - ocvmMenuItem.setText("Run OCVM"); + ocvmMenuItem.setText(localizationResource.getString("menuItemOCVM")); + ocvmMenuItem.setEnabled(false); vmMenu.add(ocvmMenuItem); - ocvmFXMenuItem.setText("Run OpenComputersVM"); + ocvmFXMenuItem.setText(localizationResource.getString("menuItemOpenComputersVM")); + ocvmFXMenuItem.setEnabled(false); vmMenu.add(ocvmFXMenuItem); runMenu.add(vmMenu); runMenu.add(jSeparator5); - jMenuItem1.setText("Deploy to Minecraft world..."); + jMenuItem1.setText(localizationResource.getString("menuItemDeployToMinecraft")); + jMenuItem1.setEnabled(false); runMenu.add(jMenuItem1); menuBar.add(runMenu); - helpMenu.setText("Help"); + helpMenu.setText(localizationResource.getString("menuHelp")); - aboutMenuItem.setText("About"); + aboutMenuItem.setText(localizationResource.getString("menuItemAbout")); aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { aboutMenuItemActionPerformed(evt); @@ -785,12 +809,13 @@ public void actionPerformed(ActionEvent evt) { }); helpMenu.add(aboutMenuItem); - wikiMenuItem.setText("Wiki"); + wikiMenuItem.setText(localizationResource.getString("menuItemWiki")); + wikiMenuItem.setEnabled(false); helpMenu.add(wikiMenuItem); helpMenu.add(jSeparator11); - settingsMenuItem.setIcon(new ImageIcon(getClass().getResource("/ru/VladTheMountain/oclide/resources/assets/icons/cogs_icon&16.png"))); // NOI18N - settingsMenuItem.setText("Settings"); + settingsMenuItem.setIcon(new ImageIcon(getClass().getResource("/io/VladTheMountain/oclide/resources/assets/icons/cogs_icon&16.png"))); // NOI18N + settingsMenuItem.setText(localizationResource.getString("menuItemSettings")); settingsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { settingsMenuItemActionPerformed(evt); @@ -811,7 +836,7 @@ public void actionPerformed(ActionEvent evt) { .addComponent(undoRedoToolbar, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent(jToolBar1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addContainerGap(270, Short.MAX_VALUE)) + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(jSplitPane1) ); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) @@ -821,7 +846,7 @@ public void actionPerformed(ActionEvent evt) { .addComponent(projectToolbar, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jToolBar1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jSplitPane1, GroupLayout.DEFAULT_SIZE, 488, Short.MAX_VALUE) + .addComponent(jSplitPane1, GroupLayout.DEFAULT_SIZE, 464, Short.MAX_VALUE) .addContainerGap()) ); @@ -830,15 +855,11 @@ public void actionPerformed(ActionEvent evt) { }// //GEN-END:initComponents private void ocemuMenuItemActionPerformed(ActionEvent evt) {//GEN-FIRST:event_ocemuMenuItemActionPerformed - try { - runOCEmu(); - } catch (IOException ex) { - Logger.getLogger(EditorFrame.class.getName()).log(Level.SEVERE, null, ex); - } + runOCEmu(); }//GEN-LAST:event_ocemuMenuItemActionPerformed private void aboutMenuItemActionPerformed(ActionEvent evt) {//GEN-FIRST:event_aboutMenuItemActionPerformed - new SettingsFrame().setVisible(true); + new AboutDialog(this); }//GEN-LAST:event_aboutMenuItemActionPerformed private void createProjectActionPerformed(ActionEvent evt) {//GEN-FIRST:event_createProjectActionPerformed @@ -877,6 +898,7 @@ private void openProjectActionPerformed(ActionEvent evt) {//GEN-FIRST:event_open FileUtils.copyDirectory(dir, new File("projects")); } catch (IOException ex) { Logger.getLogger(EditorFrame.class.getName()).log(Level.SEVERE, null, ex); + JOptionPane.showMessageDialog(null, ex, "Caught " + ex.getClass().getName(), JOptionPane.ERROR_MESSAGE); } updateProjectsTree(); } @@ -919,16 +941,16 @@ private void projectsTreeMouseClicked(MouseEvent evt) {//GEN-FIRST:event_project if (evt.getButton() == MouseEvent.BUTTON3 && projectsTree.getSelectionPath().getParentPath() == projectsTree.getPathForRow(0)) { this.projectManagementPopup.show(projectsTree, evt.getX(), evt.getY()); } else if (projectsTree.getSelectionCount() != 0 && FileSystems.getDefault().getPath("", projectsTree.getSelectionPath().toString().substring(1, projectsTree.getSelectionPath().toString().length() - 1).split(", ")).toFile().isFile() && evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 2) { - this.openFile(FileSystems.getDefault().getPath("", projectsTree.getSelectionPath().toString().substring(1, projectsTree.getSelectionPath().toString().length() - 1).split(", ")).toFile()); + try { + this.openFile(FileSystems.getDefault().getPath("", projectsTree.getSelectionPath().toString().substring(1, projectsTree.getSelectionPath().toString().length() - 1).split(", ")).toFile()); + } catch (FileNotFoundException ex) { + Logger.getLogger(EditorFrame.class.getName()).log(Level.SEVERE, "File not found", ex); + } } }//GEN-LAST:event_projectsTreeMouseClicked private void runInOCEmuActionPerformed(ActionEvent evt) {//GEN-FIRST:event_runInOCEmuActionPerformed - try { - runOCEmu(); - } catch (IOException ex) { - Logger.getLogger(EditorFrame.class.getName()).log(Level.SEVERE, null, ex); - } + runOCEmu(); }//GEN-LAST:event_runInOCEmuActionPerformed private void newProjectButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_newProjectButtonActionPerformed @@ -978,22 +1000,22 @@ private void deleteProjectButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:ev }//GEN-LAST:event_deleteProjectButtonActionPerformed private void runOCEmuButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_runOCEmuButtonActionPerformed - try { - runOCEmu(); - } catch (IOException ex) { - Logger.getLogger(EditorFrame.class.getName()).log(Level.SEVERE, null, ex); - } + runOCEmu(); }//GEN-LAST:event_runOCEmuButtonActionPerformed private void runOcelotButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_runOcelotButtonActionPerformed - //runOcelot(); - new OcelotEmulatorFrame().setVisible(true); + runOcelot(); + //new OcelotEmulatorFrame().setVisible(true); }//GEN-LAST:event_runOcelotButtonActionPerformed private void openFileActionPerformed(ActionEvent evt) {//GEN-FIRST:event_openFileActionPerformed JFileChooser fileChooser = new OpenFileFileChooser(); if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { - openFile(fileChooser.getSelectedFile()); + try { + openFile(fileChooser.getSelectedFile()); + } catch (FileNotFoundException ex) { + Logger.getLogger(EditorFrame.class.getName()).log(Level.SEVERE, "File not found", ex); + } } }//GEN-LAST:event_openFileActionPerformed @@ -1006,41 +1028,53 @@ private void ocemulatorMenuItemActionPerformed(ActionEvent evt) {//GEN-FIRST:eve }//GEN-LAST:event_ocemulatorMenuItemActionPerformed private void aurumMenuItemActionPerformed(ActionEvent evt) {//GEN-FIRST:event_aurumMenuItemActionPerformed - Thread aurum = new Thread() { + /*Thread aurum = new Thread() { @Override public void run() { new AurumEmulatorForm().setVisible(true); } }; - aurum.start(); + aurum.start();*/ + throw new UnsupportedOperationException("Not supported yet"); }//GEN-LAST:event_aurumMenuItemActionPerformed private void codeMenuItemActionPerformed(ActionEvent evt) {//GEN-FIRST:event_codeMenuItemActionPerformed - Thread code = new Thread() { + /*Thread code = new Thread() { @Override public void run() { new CODEForm().setVisible(true); } }; - code.start(); + code.start();*/ + throw new UnsupportedOperationException("Not supported yet"); }//GEN-LAST:event_codeMenuItemActionPerformed private void settingsMenuItemActionPerformed(ActionEvent evt) {//GEN-FIRST:event_settingsMenuItemActionPerformed new SettingsFrame().setVisible(true); }//GEN-LAST:event_settingsMenuItemActionPerformed - private void runOCEmu() throws IOException { - if (projectsTree.getSelectionPath().getPath().length > 1 && projectsTree.getSelectionPath().getPath().length < 3) { - if (String.valueOf(projectsTree.getSelectionPath().getPath()[1]) == null || "".equals(String.valueOf(projectsTree.getSelectionPath().getPath()[1]))) { - JOptionPane.showMessageDialog(this, "Invalid project selection.", "Error: Can't run OCEmu", JOptionPane.ERROR_MESSAGE); - } else { - new OCEmuForm().setVisible(true); + /** + * Attempts to open + * {@link io.VladTheMountain.oclide.configurator.ocemu.OCEmuLauncher} + */ + private void runOCEmu() { + if (projectsTree.getSelectionPath() != null) { + if (projectsTree.getSelectionPath().getPath().length > 1 && projectsTree.getSelectionPath().getPath().length < 3) { + if (String.valueOf(projectsTree.getSelectionPath().getPath()[1]) == null || "".equals(String.valueOf(projectsTree.getSelectionPath().getPath()[1]))) { + JOptionPane.showMessageDialog(this, "Invalid project selection.", "Error: Can't run OCEmu", JOptionPane.ERROR_MESSAGE); + } else { + new OCEmuForm().setVisible(true); + } } } else { JOptionPane.showMessageDialog(this, "No project chosen. Please select a project folder in the file tree and then launch OCEmu.", "Project not set", JOptionPane.ERROR_MESSAGE); } } + /** + * Attempts to create a new instance of {@link java.lang.Process} with + * Ocelot Desktop running in it + */ private void runOcelot() { try { ProcessBuilder pb = new ProcessBuilder("java", "-jar", "Ocelot" + FileSystems.getDefault().getSeparator() + "ocelot.jar"); @@ -1058,6 +1092,7 @@ private void runOcelot() { } } catch (IOException ex) { Logger.getLogger(EditorFrame.class.getName()).log(Level.SEVERE, null, ex); + JOptionPane.showMessageDialog(null, ex, "Caught " + ex.getClass().getName(), JOptionPane.ERROR_MESSAGE); } } diff --git a/src/ru/VladTheMountain/oclide/ui/frames/ModulesFrame.form b/src/ru/VladTheMountain/oclide/ui/frames/ModulesFrame.form deleted file mode 100644 index 77f61d6..0000000 --- a/src/ru/VladTheMountain/oclide/ui/frames/ModulesFrame.form +++ /dev/null @@ -1,290 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/src/ru/VladTheMountain/oclide/ui/frames/ModulesFrame.java b/src/ru/VladTheMountain/oclide/ui/frames/ModulesFrame.java deleted file mode 100644 index 31f8f56..0000000 --- a/src/ru/VladTheMountain/oclide/ui/frames/ModulesFrame.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * The MIT License - * - * Copyright 2021 Vladislav Gorskii. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package ru.VladTheMountain.oclide.ui.frames; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Locale; -import java.util.ResourceBundle; -import javax.swing.AbstractListModel; -import javax.swing.GroupLayout; -import javax.swing.JButton; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JProgressBar; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; -import javax.swing.JTabbedPane; -import javax.swing.JTextPane; -import javax.swing.LayoutStyle; -import javax.swing.WindowConstants; - -/** - * - * @author VladTheMountain - */ -public class ModulesFrame extends javax.swing.JFrame { - - final ResourceBundle localiztionResource = ResourceBundle.getBundle("ru.VladTheMountain.oclide.resources.dialog.Dialog", Locale.getDefault()); - private static final long serialVersionUID = 1L; - - /** - * Creates new form ModulesFrame - */ - public ModulesFrame() { - initComponents(); - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents - private void initComponents() { - - controlPanel = new JPanel(); - okButton = new JButton(); - cancelButton = new JButton(); - progressBar = new JProgressBar(); - statusLabel = new JLabel(); - jTabbedPane1 = new JTabbedPane(); - installedModules = new JPanel(); - jSplitPane1 = new JSplitPane(); - jScrollPane1 = new JScrollPane(); - installedModuleList = new JList<>(); - jScrollPane2 = new JScrollPane(); - infoInstalledTextPane = new JTextPane(); - availablePanel = new JPanel(); - jSplitPane2 = new JSplitPane(); - jScrollPane3 = new JScrollPane(); - installedModuleList1 = new JList<>(); - jScrollPane4 = new JScrollPane(); - infoAvailableTextPane = new JTextPane(); - customPanel = new JPanel(); - - setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - setTitle("OCLIDE Settings"); - - okButton.setText("OK"); - - cancelButton.setText("Cancel"); - cancelButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - cancelButtonActionPerformed(evt); - } - }); - - statusLabel.setText("jLabel1"); - - GroupLayout controlPanelLayout = new GroupLayout(controlPanel); - controlPanel.setLayout(controlPanelLayout); - controlPanelLayout.setHorizontalGroup(controlPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(GroupLayout.Alignment.TRAILING, controlPanelLayout.createSequentialGroup() - .addContainerGap() - .addGroup(controlPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(progressBar, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addComponent(statusLabel)) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(cancelButton) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(okButton) - .addContainerGap()) - ); - controlPanelLayout.setVerticalGroup(controlPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(controlPanelLayout.createSequentialGroup() - .addGroup(controlPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(GroupLayout.Alignment.TRAILING, controlPanelLayout.createSequentialGroup() - .addGap(0, 4, Short.MAX_VALUE) - .addComponent(statusLabel) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(progressBar, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addGroup(controlPanelLayout.createSequentialGroup() - .addContainerGap(15, Short.MAX_VALUE) - .addGroup(controlPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE) - .addComponent(cancelButton) - .addComponent(okButton)))) - .addContainerGap()) - ); - - installedModuleList.setModel(new AbstractListModel() { - String[] strings = { "OCEmu", "Ocelot Brain", "Ocelot Desktop", "CODE", "Aurum Emulator", "OCEmulator", "OCVM", "OpenComputers VM" }; - public int getSize() { return strings.length; } - public String getElementAt(int i) { return strings[i]; } - }); - jScrollPane1.setViewportView(installedModuleList); - - jSplitPane1.setLeftComponent(jScrollPane1); - - jScrollPane2.setViewportView(infoInstalledTextPane); - - jSplitPane1.setRightComponent(jScrollPane2); - - GroupLayout installedModulesLayout = new GroupLayout(installedModules); - installedModules.setLayout(installedModulesLayout); - installedModulesLayout.setHorizontalGroup(installedModulesLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(jSplitPane1) - ); - installedModulesLayout.setVerticalGroup(installedModulesLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(jSplitPane1) - ); - - jTabbedPane1.addTab("Installed", installedModules); - - installedModuleList1.setModel(new AbstractListModel() { - String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; - public int getSize() { return strings.length; } - public String getElementAt(int i) { return strings[i]; } - }); - jScrollPane3.setViewportView(installedModuleList1); - - jSplitPane2.setLeftComponent(jScrollPane3); - - jScrollPane4.setViewportView(infoAvailableTextPane); - - jSplitPane2.setRightComponent(jScrollPane4); - - GroupLayout availablePanelLayout = new GroupLayout(availablePanel); - availablePanel.setLayout(availablePanelLayout); - availablePanelLayout.setHorizontalGroup(availablePanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(jSplitPane2) - ); - availablePanelLayout.setVerticalGroup(availablePanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(jSplitPane2) - ); - - jTabbedPane1.addTab("Available", availablePanel); - - GroupLayout customPanelLayout = new GroupLayout(customPanel); - customPanel.setLayout(customPanelLayout); - customPanelLayout.setHorizontalGroup(customPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGap(0, 375, Short.MAX_VALUE) - ); - customPanelLayout.setVerticalGroup(customPanelLayout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGap(0, 206, Short.MAX_VALUE) - ); - - jTabbedPane1.addTab("Custom", customPanel); - - GroupLayout layout = new GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addComponent(controlPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(jTabbedPane1) - .addContainerGap()) - ); - layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) - .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addContainerGap() - .addComponent(jTabbedPane1, GroupLayout.PREFERRED_SIZE, 234, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) - .addComponent(controlPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - ); - - pack(); - }// //GEN-END:initComponents - - private void cancelButtonActionPerformed(ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed - this.dispose(); - }//GEN-LAST:event_cancelButtonActionPerformed - - // Variables declaration - do not modify//GEN-BEGIN:variables - private JPanel availablePanel; - private JButton cancelButton; - private JPanel controlPanel; - private JPanel customPanel; - private JTextPane infoAvailableTextPane; - private JTextPane infoInstalledTextPane; - private JList installedModuleList; - private JList installedModuleList1; - private JPanel installedModules; - private JScrollPane jScrollPane1; - private JScrollPane jScrollPane2; - private JScrollPane jScrollPane3; - private JScrollPane jScrollPane4; - private JSplitPane jSplitPane1; - private JSplitPane jSplitPane2; - private JTabbedPane jTabbedPane1; - private JButton okButton; - private JProgressBar progressBar; - private JLabel statusLabel; - // End of variables declaration//GEN-END:variables -} diff --git a/src/ru/VladTheMountain/oclide/ui/frames/SettingsFrame.form b/src/ru/VladTheMountain/oclide/ui/frames/SettingsFrame.form index eaf1a97..d2cee5e 100644 --- a/src/ru/VladTheMountain/oclide/ui/frames/SettingsFrame.form +++ b/src/ru/VladTheMountain/oclide/ui/frames/SettingsFrame.form @@ -759,7 +759,7 @@ - + diff --git a/src/ru/VladTheMountain/oclide/ui/frames/SettingsFrame.java b/src/ru/VladTheMountain/oclide/ui/frames/SettingsFrame.java index 15ff9d7..c5b653a 100644 --- a/src/ru/VladTheMountain/oclide/ui/frames/SettingsFrame.java +++ b/src/ru/VladTheMountain/oclide/ui/frames/SettingsFrame.java @@ -55,7 +55,7 @@ */ public class SettingsFrame extends javax.swing.JFrame { - final ResourceBundle localiztionResource = ResourceBundle.getBundle("ru.VladTheMountain.oclide.resources.dialog.Dialog", Locale.getDefault()); + final ResourceBundle localiztionResource = ResourceBundle.getBundle("io.VladTheMountain.oclide.resources.dialog.Dialog", Locale.getDefault()); private static final long serialVersionUID = 1L; /** @@ -444,7 +444,7 @@ public void actionPerformed(ActionEvent evt) { jLabel7.setText("Lua path:"); - luaPathField.setText(System.getenv("LUA_PATH").length()<2 ? "LUA_PATH not set in current environment" : System.getenv("LUA_PATH")); + luaPathField.setText(/*System.getenv("LUA_PATH").length()<2 ? "LUA_PATH not set in current environment" : System.getenv("LUA_PATH")*/"LUA_PATH"); GroupLayout luaPanelLayout = new GroupLayout(luaPanel); luaPanel.setLayout(luaPanelLayout); diff --git a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/OCEmuComponent.java b/src/ru/VladTheMountain/oclide/ui/package-info.java similarity index 62% rename from src/ru/VladTheMountain/oclide/configurator/ocemu/component/OCEmuComponent.java rename to src/ru/VladTheMountain/oclide/ui/package-info.java index 93e7382..5366a9a 100644 --- a/src/ru/VladTheMountain/oclide/configurator/ocemu/component/OCEmuComponent.java +++ b/src/ru/VladTheMountain/oclide/ui/package-info.java @@ -21,37 +21,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package ru.VladTheMountain.oclide.configurator.ocemu.component; - /** + * Swing forms for OCLIDE * + * @see io.VladTheMountain.oclide.ui.configurators + * @see io.VladTheMountain.oclide.ui.dialogs + * @see io.VladTheMountain.oclide.ui.frames * @author VladTheMountain */ -public class OCEmuComponent { - - //FIELD 1 - private int type; - //FIELD 2 - private String address; - //the rest - private String[] opts; - - public OCEmuComponent(int componentType, String componentAddress, String... options) { - this.type = componentType; - this.address = componentAddress; - this.opts = new String[4]; - System.arraycopy(options, 0, opts, 0, options.length); - } - - public int getComponentType() { - return type; - } - - public String getComponentAddress() { - return address; - } - - public String getOptionAt(int pos) { - return opts[pos]; - } -} +package ru.VladTheMountain.oclide.ui; diff --git a/src/ru/VladTheMountain/oclide/util/ConsoleOutputStream.java b/src/ru/VladTheMountain/oclide/util/ConsoleOutputStream.java index 07572ae..6a69dcb 100644 --- a/src/ru/VladTheMountain/oclide/util/ConsoleOutputStream.java +++ b/src/ru/VladTheMountain/oclide/util/ConsoleOutputStream.java @@ -25,10 +25,12 @@ import java.io.IOException; import java.io.OutputStream; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.JTextArea; /** - * Util class for redirecting {@link System.out} to {@code outputArea} + * Util class for redirecting {@code System.out} to {@code outputArea} * * @author VladTheMountain */ @@ -37,6 +39,9 @@ public class ConsoleOutputStream extends OutputStream { private JTextArea target; public ConsoleOutputStream(JTextArea area) { + if (area == null) { + Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "No JTextArea was specified"); + } target = area; } diff --git a/src/ru/VladTheMountain/oclide/util/ModuleLoader.java b/src/ru/VladTheMountain/oclide/util/ModuleLoader.java deleted file mode 100644 index 125f862..0000000 --- a/src/ru/VladTheMountain/oclide/util/ModuleLoader.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * The MIT License - * - * Copyright 2021 Vladislav Gosrkii. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package ru.VladTheMountain.oclide.util; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.StandardCopyOption; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Downloads binaries from https://github.com/OCLIDE-Modules/ - * - * @author VladTheMountain - */ -public class ModuleLoader { - - /** - * Downloads OCEmu build from https://github.com/OCLIDE-Modules/OCLIDE-OCEmu - * to OCEmu folder - */ - public static void downloadOCEmu() { - if (System.getProperty("os.name").toLowerCase().contains("windows")) { - try { - recursivelyCopyFiles(new File(new URL("https://github.com/OCLIDE-Modules/OCLIDE-OCEmu/ocemu-windows").toURI()), new File(System.getProperty("user.dir") + FileSystems.getDefault().getSeparator() + "OCEmu")); - } catch (MalformedURLException | URISyntaxException ex) { - Logger.getLogger(ModuleLoader.class.getName()).log(Level.SEVERE, null, ex); - } - } else { - - } - } - - //Util - private static void recursivelyCopyFiles(File src, File targ) { - File[] files = src.listFiles(); - if (files == null) { - return; - } - for (File f : files) { - if (f.isFile()) { - try { - Files.copy(f.toPath(), new File(targ.getAbsolutePath() + FileSystems.getDefault().getSeparator() + f.getName()).toPath(), StandardCopyOption.REPLACE_EXISTING); - } catch (IOException ex) { - Logger.getLogger(ModuleLoader.class.getName()).log(Level.SEVERE, null, ex); - } - } else { - /*try { - FileUtils.copyDirectory(f, targ); - } catch (IOException ex) { - Logger.getLogger(ModuleLoader.class.getName()).log(Level.SEVERE, null, ex); - }*/ - } - if (f.isDirectory()) { - recursivelyCopyFiles(src, targ); - } - } - } -} diff --git a/src/ru/VladTheMountain/oclide/util/UUIDGenerator.java b/src/ru/VladTheMountain/oclide/util/UUIDGenerator.java index 851abdb..2121fba 100644 --- a/src/ru/VladTheMountain/oclide/util/UUIDGenerator.java +++ b/src/ru/VladTheMountain/oclide/util/UUIDGenerator.java @@ -26,13 +26,13 @@ /** * Uses MightyPirates' original {@code UUID} library to generate component UUIDs * - * @author VladTheMountain + * @author MightyPirates */ public class UUIDGenerator { /** * - * @return the same result as OpenOS' {@code uuid.next()} + * @return the same result as OpenOS' {@code uuid.next()} - a string containing a UUID */ public static String create() { return li.cil.repack.org.luaj.vm2.lib.jse.JsePlatform.standardGlobals().load("local sets = {4, 2, 2, 2, 6}\n" diff --git a/src/ru/VladTheMountain/oclide/util/package-info.java b/src/ru/VladTheMountain/oclide/util/package-info.java index 5f5d70c..058c795 100644 --- a/src/ru/VladTheMountain/oclide/util/package-info.java +++ b/src/ru/VladTheMountain/oclide/util/package-info.java @@ -21,8 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ - /** - * Just a bunch of random classes used all around OCLIDE's code + * Just a bunch of random classes used all around OCLIDE's code. + * + * @author VladTheMountain */ -package ru.VladTheMountain.oclide.util; \ No newline at end of file +package ru.VladTheMountain.oclide.util;