From d031a0434011f1e8577de35ba1a5c0b6649beef4 Mon Sep 17 00:00:00 2001 From: Fabian Stemmler Date: Sat, 5 Oct 2019 21:58:55 +0200 Subject: [PATCH] Added Wizard for mem file creation --- .../OSGI-INF/l10n/bundle.properties | 2 + plugins/net.mograsim.plugin.core/plugin.xml | 9 +++++ .../wizards/newWizards/BasicNewWizard.java | 40 +++++++++++++++++++ .../wizards/newWizards/NewWizardMEM.java | 17 ++++++++ .../wizards/newWizards/NewWizardMPM.java | 32 ++------------- .../wizards/newWizards/WizardPageMPM.java | 14 ------- 6 files changed, 72 insertions(+), 42 deletions(-) create mode 100644 plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/BasicNewWizard.java create mode 100644 plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/NewWizardMEM.java delete mode 100644 plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/WizardPageMPM.java diff --git a/plugins/net.mograsim.plugin.core/OSGI-INF/l10n/bundle.properties b/plugins/net.mograsim.plugin.core/OSGI-INF/l10n/bundle.properties index 8bec7721..93b9390a 100644 --- a/plugins/net.mograsim.plugin.core/OSGI-INF/l10n/bundle.properties +++ b/plugins/net.mograsim.plugin.core/OSGI-INF/l10n/bundle.properties @@ -43,4 +43,6 @@ view.name.1 = Memory wizards.newWizards.category = Mograsim wizards.newWizards.mpm.name = Microprogram Memory wizards.newWizards.mpm.desc = Creates a default new Microprogram Memory +wizards.newWizards.mem.name = Main Memory +wizards.newWizards.mem.desc = Creates a default new Main Memory Bundle-Vendor.0 = Mograsim Team \ No newline at end of file diff --git a/plugins/net.mograsim.plugin.core/plugin.xml b/plugins/net.mograsim.plugin.core/plugin.xml index 8e00c1f6..0eaf8d49 100644 --- a/plugins/net.mograsim.plugin.core/plugin.xml +++ b/plugins/net.mograsim.plugin.core/plugin.xml @@ -409,6 +409,15 @@ %wizards.newWizards.mpm.desc + + %wizards.newWizards.mem.desc + + diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/BasicNewWizard.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/BasicNewWizard.java new file mode 100644 index 00000000..42383157 --- /dev/null +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/BasicNewWizard.java @@ -0,0 +1,40 @@ +package net.mograsim.plugin.wizards.newWizards; + +import org.eclipse.core.resources.IFile; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.dialogs.WizardNewFileCreationPage; + +public abstract class BasicNewWizard extends Wizard implements INewWizard +{ + private IStructuredSelection selection; + private WizardNewFileCreationPage page; + + public void setFileExtension(String fileExtension) + { + page.setFileExtension(fileExtension); + } + + @Override + public void init(IWorkbench workbench, IStructuredSelection selection) + { + this.selection = selection; + } + + @Override + public void addPages() + { + addPage(page = new WizardNewFileCreationPage("Create", selection)); + } + + @Override + public boolean performFinish() + { + IFile file = page.createNewFile(); + if (file != null) + return true; + return false; + } +} diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/NewWizardMEM.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/NewWizardMEM.java new file mode 100644 index 00000000..8160947d --- /dev/null +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/NewWizardMEM.java @@ -0,0 +1,17 @@ +package net.mograsim.plugin.wizards.newWizards; + +public class NewWizardMEM extends BasicNewWizard +{ + @Override + public boolean performFinish() + { + setFileExtension("mem"); + return super.performFinish(); + } + + @Override + public String getWindowTitle() + { + return "Create new Main Memory"; + } +} diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/NewWizardMPM.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/NewWizardMPM.java index c18e9a18..723a5021 100644 --- a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/NewWizardMPM.java +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/NewWizardMPM.java @@ -1,27 +1,12 @@ package net.mograsim.plugin.wizards.newWizards; -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.Wizard; -import org.eclipse.ui.INewWizard; -import org.eclipse.ui.IWorkbench; - -public class NewWizardMPM extends Wizard implements INewWizard +public class NewWizardMPM extends BasicNewWizard { - - private IStructuredSelection selection; - private WizardPageMPM page; - - @Override - public void init(IWorkbench workbench, IStructuredSelection selection) - { - this.selection = selection; - } - @Override - public void addPages() + public boolean performFinish() { - addPage(page = new WizardPageMPM(selection)); + setFileExtension("mpm"); + return super.performFinish(); } @Override @@ -29,13 +14,4 @@ public class NewWizardMPM extends Wizard implements INewWizard { return "Create new Microprogram Memory"; } - - @Override - public boolean performFinish() - { - IFile file = page.createNewFile(); - if (file != null) - return true; - return false; - } } diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/WizardPageMPM.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/WizardPageMPM.java deleted file mode 100644 index 4614e265..00000000 --- a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/WizardPageMPM.java +++ /dev/null @@ -1,14 +0,0 @@ -package net.mograsim.plugin.wizards.newWizards; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.dialogs.WizardNewFileCreationPage; - -public class WizardPageMPM extends WizardNewFileCreationPage -{ - - public WizardPageMPM(IStructuredSelection selection) - { - super("Create ", selection); - setFileExtension("mpm"); - } -} -- 2.17.1