From 00c53ca60c6c71b38c4910ae9169bf8e5b8dbf0f Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Tue, 20 Sep 2016 01:29:16 -0400 Subject: [PATCH] Committing everything just because it compiles... far from completed --- .../Core/Accessors/FileAccessor.java | 8 +- .../Core/DataFormatReference.java | 6 +- .../UniversalEditor/Core/Document.java | 30 +++++++ .../UniversalEditor/Core/IO/BitConverter.java | 4 +- .../UniversalEditor/Core/IO/Writer.java | 3 +- .../Core/ObjectModelReference.java | 10 +-- .../net/alcetech/UniversalEditor/Program.java | 86 ++++++++++++------- .../UniversalEditor/Windows/MainWindow.java | 48 ++++++----- 8 files changed, 129 insertions(+), 66 deletions(-) diff --git a/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/Accessors/FileAccessor.java b/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/Accessors/FileAccessor.java index ea0a77df..1c3925de 100644 --- a/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/Accessors/FileAccessor.java +++ b/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/Accessors/FileAccessor.java @@ -9,7 +9,13 @@ public class FileAccessor extends Accessor { private RandomAccessFile _file = null; - public FileAccessor() + public static FileAccessor fromFile(File file) throws FileNotFoundException { + FileAccessor fa = new FileAccessor(); + fa._file = new RandomAccessFile(file, "rw"); + return fa; + } + + private FileAccessor() { } public FileAccessor(String fileName) diff --git a/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/DataFormatReference.java b/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/DataFormatReference.java index 688f2783..181e135f 100644 --- a/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/DataFormatReference.java +++ b/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/DataFormatReference.java @@ -1,7 +1,7 @@ package net.alcetech.UniversalEditor.Core; -import net.alcetech.Core.NotImplementedException; -import net.alcetech.Core.Collections.ObjectModel.Collection; +import net.alcetech.ApplicationFramework.Exceptions.*; +import net.alcetech.ApplicationFramework.Collections.ObjectModel.*; public class DataFormatReference { @@ -11,7 +11,7 @@ public class DataFormatReference mvarTypeName = typeName; } - public DataFormat Create() + public DataFormat Create() throws NotImplementedException { throw new NotImplementedException(); } diff --git a/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/Document.java b/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/Document.java index 2afdf0b8..0be95b3c 100644 --- a/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/Document.java +++ b/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/Document.java @@ -6,7 +6,37 @@ public class Document public Accessor getInputAccessor() { return mvarInputAccessor; } public void setInputAccessor(Accessor value) { mvarInputAccessor = value; } + private Accessor mvarOutputAccessor = null; + public Accessor getOutputAccessor() { return mvarOutputAccessor; } + public void setOutputAccessor(Accessor value) { mvarOutputAccessor = value; } + + public void setAccessor(Accessor value) { + setInputAccessor(value); + setOutputAccessor(value); + } + + private DataFormat mvarInputDataFormat = null; + public DataFormat getInputDataFormat() { return mvarInputDataFormat; } + public void setInputDataFormat(DataFormat value) { mvarInputDataFormat = value; } + + private DataFormat mvarOutputDataFormat = null; + public DataFormat getOutputDataFormat() { return mvarOutputDataFormat; } + public void setOutputDataFormat(DataFormat value) { mvarOutputDataFormat = value; } + + public void setDataFormat(DataFormat value) { + setInputDataFormat(value); + setOutputDataFormat(value); + } + private ObjectModel mvarObjectModel = null; public ObjectModel getObjectModel() { return mvarObjectModel; } public void setObjectModel(ObjectModel value) { mvarObjectModel = value; } + + public static Document load(ObjectModel objectModel, DataFormat dataFormat, Accessor accessor) { + Document document = new Document(); + document.setObjectModel(objectModel); + document.setDataFormat(dataFormat); + document.setAccessor(accessor); + return document; + } } diff --git a/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/IO/BitConverter.java b/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/IO/BitConverter.java index 10c45a0e..2987ed70 100644 --- a/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/IO/BitConverter.java +++ b/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/IO/BitConverter.java @@ -1,6 +1,6 @@ package net.alcetech.UniversalEditor.Core.IO; -import net.alcetech.Core.NotImplementedException; +import net.alcetech.ApplicationFramework.Exceptions.*; public class BitConverter { @@ -44,7 +44,7 @@ public class BitConverter (byte)((value & (0xFF << 56)) >> 56) }; } - public static byte[] getBytes(float value) + public static byte[] getBytes(float value) throws NotImplementedException { throw new NotImplementedException(); /* diff --git a/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/IO/Writer.java b/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/IO/Writer.java index 9c5f7cf5..a59e2a96 100644 --- a/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/IO/Writer.java +++ b/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/IO/Writer.java @@ -2,6 +2,7 @@ package net.alcetech.UniversalEditor.Core.IO; import java.io.IOException; +import net.alcetech.ApplicationFramework.Exceptions.NotImplementedException; import net.alcetech.UniversalEditor.Core.*; public class Writer @@ -94,7 +95,7 @@ public class Writer } writeByteArray(buffer); } - public void writeSingle(float value) throws IOException + public void writeSingle(float value) throws IOException, NotImplementedException { byte[] _buffer = BitConverter.getBytes(value); byte[] buffer = new byte[4]; diff --git a/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/ObjectModelReference.java b/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/ObjectModelReference.java index 259346b6..27b9187a 100644 --- a/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/ObjectModelReference.java +++ b/Java/net.alcetech.UniversalEditor.Core/src/net/alcetech/UniversalEditor/Core/ObjectModelReference.java @@ -1,14 +1,13 @@ package net.alcetech.UniversalEditor.Core; -import net.alcetech.Core.NotImplementedException; -import net.alcetech.Core.Collections.Generic.Dictionary; +import net.alcetech.ApplicationFramework.Collections.Generic.Dictionary; public class ObjectModelReference { private static Dictionary, ObjectModelReference> _omrsByClass = new Dictionary, ObjectModelReference>(); public static ObjectModelReference fromClass(Class clazz) { - if (_omrsByClass.containsKey(clazz)) return _omrsByClass.getValueByKey(clazz); + if (_omrsByClass.containsKey(clazz)) return _omrsByClass.get(clazz); return null; } @@ -18,8 +17,9 @@ public class ObjectModelReference mvarTypeName = typeName; } - public ObjectModel Create() + public ObjectModel Create() throws InstantiationException, IllegalAccessException, ClassNotFoundException { - throw new NotImplementedException(); + Object newInst = Class.forName(this.mvarTypeName).newInstance(); + return (ObjectModel)newInst; } } diff --git a/Java/net.alcetech.UniversalEditor/src/net/alcetech/UniversalEditor/Program.java b/Java/net.alcetech.UniversalEditor/src/net/alcetech/UniversalEditor/Program.java index 44e9e247..49486ae7 100644 --- a/Java/net.alcetech.UniversalEditor/src/net/alcetech/UniversalEditor/Program.java +++ b/Java/net.alcetech.UniversalEditor/src/net/alcetech/UniversalEditor/Program.java @@ -1,8 +1,10 @@ package net.alcetech.UniversalEditor; -import net.alcetech.Core.*; +import net.alcetech.ApplicationFramework.*; +import net.alcetech.ApplicationFramework.CommandItems.*; +import net.alcetech.ApplicationFramework.Theming.*; + import net.alcetech.UniversalEditor.Windows.*; -import net.alcetech.UserInterface.Theming.*; import net.alcetech.UniversalEditor.Core.Accessors.*; import net.alcetech.UniversalEditor.Core.IO.*; import net.alcetech.UniversalEditor.ObjectModels.Markup.*; @@ -12,7 +14,7 @@ public class Program { public static void main(String[] args) { - ThemeManager.Initialize(); + ThemeManager.initialize(); FileAccessor fa = new FileAccessor("/var/tmp/test.xml"); @@ -33,49 +35,71 @@ public class Program } */ - Command mnuFile = new Command("mnuFile", "_File"); - Command mnuFileExit = new Command("mnuFileExit", "E_xit"); + Command mnuFile = new Command("File", "_File"); + Command mnuFileExit = new Command("FileExit", "E_xit"); + + mnuFile.addItem(new CommandReferenceCommandItem("FileExit")); - Command mnuEdit = new Command("mnuEdit", "_Edit"); - Command mnuView = new Command("mnuView", "_View"); - Command mnuProject = new Command("mnuProject", "_Project"); - Command mnuBuild = new Command("mnuBuild", "_Build"); - Command mnuDebug = new Command("mnuDebug", "_Debug"); - Command mnuTools = new Command("mnuTools", "_Tools"); - Command mnuWindow = new Command("mnuWindow", "_Window"); - Command mnuHelp = new Command("mnuHelp", "_Help"); + Command mnuEdit = new Command("Edit", "_Edit"); + Command mnuEditCut = new Command("EditCut", "Cu_t"); + Command mnuEditCopy = new Command("EditCopy", "_Copy"); + Command mnuEditPaste = new Command("EditPaste", "_Paste"); - mnuFile.getCommandCollection().add(new CommandReferenceCommandItem("mnuFileExit")); + mnuEdit.addItem(new CommandReferenceCommandItem("EditCut")); + mnuEdit.addItem(new CommandReferenceCommandItem("EditCopy")); + mnuEdit.addItem(new CommandReferenceCommandItem("EditPaste")); - Application.getCommandCollection().add(mnuFile); - Application.getCommandCollection().add(mnuFileExit); + Command mnuView = new Command("View", "_View"); + Command mnuProject = new Command("Project", "_Project"); + Command mnuBuild = new Command("Build", "_Build"); + Command mnuDebug = new Command("Debug", "_Debug"); + Command mnuTools = new Command("Tools", "_Tools"); + Command mnuWindow = new Command("Window", "_Window"); + Command mnuHelp = new Command("Help", "_Help"); - Application.getCommandCollection().add(mnuEdit); - Application.getCommandCollection().add(mnuView); - Application.getCommandCollection().add(mnuProject); - Application.getCommandCollection().add(mnuBuild); - Application.getCommandCollection().add(mnuDebug); - Application.getCommandCollection().add(mnuTools); - Application.getCommandCollection().add(mnuWindow); - Application.getCommandCollection().add(mnuHelp); + Application.addCommand(mnuFile); + Application.addCommand(mnuFileExit); - Application.addCommandListener(new ICommandListener() + Application.addCommand(mnuEdit); + Application.addCommand(mnuEditCut); + Application.addCommand(mnuEditCopy); + Application.addCommand(mnuEditPaste); + + Application.addCommand(mnuView); + Application.addCommand(mnuProject); + Application.addCommand(mnuBuild); + Application.addCommand(mnuDebug); + Application.addCommand(mnuTools); + Application.addCommand(mnuWindow); + Application.addCommand(mnuHelp); + + Application.addMainMenuCommandItem(new CommandReferenceCommandItem("File")); + Application.addMainMenuCommandItem(new CommandReferenceCommandItem("Edit")); + Application.addMainMenuCommandItem(new CommandReferenceCommandItem("View")); + Application.addMainMenuCommandItem(new CommandReferenceCommandItem("Project")); + Application.addMainMenuCommandItem(new CommandReferenceCommandItem("Build")); + Application.addMainMenuCommandItem(new CommandReferenceCommandItem("Debug")); + Application.addMainMenuCommandItem(new CommandReferenceCommandItem("Tools")); + Application.addMainMenuCommandItem(new CommandReferenceCommandItem("Window")); + Application.addMainMenuCommandItem(new CommandReferenceCommandItem("Help")); + + Application.addCommandListener(new CommandListener() { @Override - public void onCommandExecuted(CommandEventArgs e) - { + public void commandExecuted(Command item) { + // TODO Auto-generated method stub - System.out.println("Command '" + e.getCommand().getName() + "' executed!"); + System.out.println("Command '" + item.getID() + "' executed!"); - if (e.getCommand().getName() == "mnuFileExit") + if (item.getID() == "FileExit") { - Application.exit(); + Application.stop(); } } }); MarkupObjectModel mom = new MarkupObjectModel(); - mom.getElementCollection().add(new MarkupTagElement("test", "honduras")); + mom.addElement(new MarkupTagElement("test", "honduras")); MainWindow mw = new MainWindow(); mw.setVisible(true); diff --git a/Java/net.alcetech.UniversalEditor/src/net/alcetech/UniversalEditor/Windows/MainWindow.java b/Java/net.alcetech.UniversalEditor/src/net/alcetech/UniversalEditor/Windows/MainWindow.java index 0a3b300d..1079defb 100644 --- a/Java/net.alcetech.UniversalEditor/src/net/alcetech/UniversalEditor/Windows/MainWindow.java +++ b/Java/net.alcetech.UniversalEditor/src/net/alcetech/UniversalEditor/Windows/MainWindow.java @@ -8,37 +8,38 @@ import java.awt.event.*; import javax.swing.*; -import net.alcetech.Core.*; -import net.alcetech.UserInterface.*; -import net.alcetech.UserInterface.Controls.*; -import net.alcetech.UserInterface.Theming.ThemeManager; +import net.alcetech.ApplicationFramework.*; +import net.alcetech.ApplicationFramework.CommandItems.*; +import net.alcetech.ApplicationFramework.UserInterface.*; +import net.alcetech.ApplicationFramework.UserInterface.Dialogs.*; +import net.alcetech.ApplicationFramework.UserInterface.Theming.ThemeManager; -public class MainWindow extends Window +public class MainWindow extends net.alcetech.ApplicationFramework.UserInterface.MainWindow { - private CommandBarContainer commandBarContainer = new CommandBarContainer(); - - private DockingWindowContainer dwc = new DockingWindowContainer(); + // private CommandBarContainer commandBarContainer = new CommandBarContainer(); + // private DockingWindowContainer dwc = new DockingWindowContainer(); private void InitializeComponent() { - this.setIconImages(ThemeManager.GetThemedIconImages("MainIcon")); + // this.setIconImages(ThemeManager.GetThemedIconImages("MainIcon")); this.setSize(800, 600); this.setTitle("Universal Editor"); - CommandBar cbMenuBar = new CommandBar(); + // CommandBar cbMenuBar = new CommandBar(); // this is a menu bar, so set the default display style to text only + /* cbMenuBar.setDefaultCommandDisplayStyle(CommandDisplayStyle.TextOnly); - cbMenuBar.getCommandCollection().add(new CommandReferenceCommandItem("mnuFile")); - cbMenuBar.getCommandCollection().add(new CommandReferenceCommandItem("mnuEdit")); - cbMenuBar.getCommandCollection().add(new CommandReferenceCommandItem("mnuView")); - cbMenuBar.getCommandCollection().add(new CommandReferenceCommandItem("mnuProject")); - cbMenuBar.getCommandCollection().add(new CommandReferenceCommandItem("mnuBuild")); - cbMenuBar.getCommandCollection().add(new CommandReferenceCommandItem("mnuDebug")); - cbMenuBar.getCommandCollection().add(new CommandReferenceCommandItem("mnuTools")); - cbMenuBar.getCommandCollection().add(new CommandReferenceCommandItem("mnuWindow")); - cbMenuBar.getCommandCollection().add(new CommandReferenceCommandItem("mnuHelp")); + cbMenuBar.addItem(new CommandReferenceCommandItem("mnuFile")); + cbMenuBar.addItem(new CommandReferenceCommandItem("mnuEdit")); + cbMenuBar.addItem(new CommandReferenceCommandItem("mnuView")); + cbMenuBar.addItem(new CommandReferenceCommandItem("mnuProject")); + cbMenuBar.addItem(new CommandReferenceCommandItem("mnuBuild")); + cbMenuBar.addItem(new CommandReferenceCommandItem("mnuDebug")); + cbMenuBar.addItem(new CommandReferenceCommandItem("mnuTools")); + cbMenuBar.addItem(new CommandReferenceCommandItem("mnuWindow")); + cbMenuBar.addItem(new CommandReferenceCommandItem("mnuHelp")); this.commandBarContainer.add(cbMenuBar, BorderLayout.NORTH); @@ -48,6 +49,7 @@ public class MainWindow extends Window dwc.getWindowCollection().add("Start Page", new JTextArea()); dwc.getWindowCollection().add("X11R2", new JButton()); + */ } public MainWindow() @@ -57,18 +59,18 @@ public class MainWindow extends Window protected void OnClosing(CancelEventArgs e) { - MessageDialogResult result = MessageDialog.ShowDialog(this, "You have unsaved changes. Do you wish to save your changes before closing this window?", "Close Program", MessageDialogButtons.YesNoCancel); + DialogResult result = MessageDialog.ShowDialog(this, "You have unsaved changes. Do you wish to save your changes before closing this window?", "Close Program", StockButtonType.YES_NO_CANCEL); switch (result) { - case Yes: + case YES: { break; } - case No: + case NO: { break; } - case Cancel: + case CANCEL: { e.cancel(); break;