Added Wizard for mem file creation
authorFabian Stemmler <stemmler@in.tum.de>
Sat, 5 Oct 2019 19:58:55 +0000 (21:58 +0200)
committerFabian Stemmler <stemmler@in.tum.de>
Sat, 5 Oct 2019 19:58:55 +0000 (21:58 +0200)
plugins/net.mograsim.plugin.core/OSGI-INF/l10n/bundle.properties
plugins/net.mograsim.plugin.core/plugin.xml
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/BasicNewWizard.java [new file with mode: 0644]
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/NewWizardMEM.java [new file with mode: 0644]
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/NewWizardMPM.java
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/wizards/newWizards/WizardPageMPM.java [deleted file]

index 8bec772..93b9390 100644 (file)
@@ -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
index 8e00c1f..0eaf8d4 100644 (file)
                        <description>%wizards.newWizards.mpm.desc</description>
                        <selection class="org.eclipse.core.resources.IResource"/>
                </wizard>
+               <wizard
+                       id="net.mograsim.plugin.wizards.newWizards.NewWizardMEM"
+                       name="%wizards.newWizards.mem.name"
+                       class="net.mograsim.plugin.wizards.newWizards.NewWizardMEM"
+                       category="net.mograsim.plugin.wizards.newWizards.category"
+                       icon="icons/mograsim/blue-orange/icon_blue-orange_16.png">
+                       <description>%wizards.newWizards.mem.desc</description>
+                       <selection class="org.eclipse.core.resources.IResource"/>
+               </wizard>
        </extension>
  <extension
        point="org.eclipse.debug.core.launchConfigurationTypes">
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 (file)
index 0000000..4238315
--- /dev/null
@@ -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 (file)
index 0000000..8160947
--- /dev/null
@@ -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";
+       }
+}
index c18e9a1..723a502 100644 (file)
@@ -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 (file)
index 4614e26..0000000
+++ /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");
-       }
-}