eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
-formatter_profile=_Eclipse ajusted old
+formatter_profile=_MoGraSim
formatter_settings_version=16
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
org.eclipse.ui.themes;bundle-version="1.2.400",
net.mograsim.logic.ui;bundle-version="0.1.0";visibility:=reexport,
net.mograsim.logic.ui.am2900;bundle-version="0.1.0";visibility:=reexport,
- javax.annotation;bundle-version="1.0.0"
+ javax.annotation;bundle-version="1.0.0",
+ net.mograsim.preferences;bundle-version="0.1.0"
Bundle-RequiredExecutionEnvironment: JavaSE-11
Automatic-Module-Name: net.mograsim.plugin.core
Bundle-Vendor: Mograsim Team
<extension
point="org.eclipse.ui.themes">
<themeElementCategory
- class="net.mograsim.plugin.MograsimPreview"
+ class="net.mograsim.plugin.SimulationPreview"
id="net.mograsim.plugin.mograsim"
label="%themeElementCategory.label">
</themeElementCategory>
+ <themeElementCategory
+ class="net.mograsim.plugin.SimulationPreview"
+ id="net.mograsim.logic.ui"
+ label="Simulation"
+ parentId="net.mograsim.plugin.mograsim">
+ </themeElementCategory>
<colorDefinition
- categoryId="net.mograsim.plugin.mograsim"
- defaultsTo="COLOR_WHITE"
+ categoryId="net.mograsim.logic.ui"
id="net.mograsim.plugin.sim_backgound"
isEditable="true"
- label="%colorDefinition.label">
+ label="%colorDefinition.label"
+ value="COLOR_WHITE">
<description>
%colorDefinition.description
</description>
</colorDefinition>
<colorDefinition
- categoryId="net.mograsim.plugin.mograsim"
- defaultsTo="COLOR_BLACK"
+ categoryId="net.mograsim.logic.ui"
id="net.mograsim.plugin.sim_text_color"
isEditable="true"
- label="%colorDefinition.label.0">
+ label="%colorDefinition.label.0"
+ value="COLOR_BLACK">
+ </colorDefinition>
+ <colorDefinition
+ categoryId="net.mograsim.logic.ui"
+ id="net.mograsim.logic.ui.color.bit.one"
+ isEditable="true"
+ label="Simulation Farbe 1"
+ value="COLOR_GREEN">
+ </colorDefinition>
+ <colorDefinition
+ categoryId="net.mograsim.logic.ui"
+ id="net.mograsim.logic.ui.color.bit.u"
+ isEditable="true"
+ label="Simulation Farbe U"
+ value="COLOR_CYAN">
+ </colorDefinition>
+ <colorDefinition
+ categoryId="net.mograsim.logic.ui"
+ id="net.mograsim.logic.ui.color.bit.x"
+ isEditable="true"
+ label="Simulation Farbe X"
+ value="COLOR_RED">
+ </colorDefinition>
+ <colorDefinition
+ categoryId="net.mograsim.logic.ui"
+ id="net.mograsim.logic.ui.color.bit.z"
+ isEditable="true"
+ label="Simulation Farbe Z"
+ value="COLOR_YELLOW">
+ </colorDefinition>
+ <colorDefinition
+ categoryId="net.mograsim.logic.ui"
+ id="net.mograsim.logic.ui.color.bit.zero"
+ isEditable="true"
+ label="Simulation Farbe 0"
+ value="COLOR_GRAY">
</colorDefinition>
<colorDefinition
categoryId="net.mograsim.plugin.mograsim"
- defaultsTo="COLOR_GREEN"
id="net.mograsim.plugin.asm_comment_color"
isEditable="true"
- label="%colorDefinition.label.1">
+ label="%colorDefinition.label.1"
+ value="COLOR_GREEN">
</colorDefinition>
<colorDefinition
categoryId="net.mograsim.plugin.mograsim"
- defaultsTo="COLOR_BLUE"
id="net.mograsim.plugin.asm_label_color"
isEditable="true"
- label="%colorDefinition.label.2">
+ label="%colorDefinition.label.2"
+ value="COLOR_BLUE">
</colorDefinition>
<colorDefinition
categoryId="net.mograsim.plugin.mograsim"
- defaultsTo="COLOR_RED"
id="net.mograsim.plugin.asm_operation_color"
isEditable="true"
- label="%colorDefinition.label.3">
+ label="%colorDefinition.label.3"
+ value="COLOR_RED">
</colorDefinition>
<colorDefinition
categoryId="net.mograsim.plugin.mograsim"
- defaultsTo="COLOR_MAGENTA"
id="net.mograsim.plugin.asm_number_color"
isEditable="true"
- label="%colorDefinition.label.4">
+ label="%colorDefinition.label.4"
+ value="COLOR_MAGENTA">
</colorDefinition>
<fontDefinition
categoryId="net.mograsim.plugin.mograsim"
+++ /dev/null
-package net.mograsim.plugin;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.themes.ITheme;
-import org.eclipse.ui.themes.IThemePreview;
-
-import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
-import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInput;
-import net.mograsim.logic.core.timeline.Timeline;
-import net.mograsim.logic.ui.LogicExecuter;
-import net.mograsim.logic.ui.LogicUICanvas;
-import net.mograsim.logic.ui.model.ViewModelModifiable;
-import net.mograsim.logic.ui.model.components.GUIManualSwitch;
-import net.mograsim.logic.ui.model.components.GUINotGate;
-import net.mograsim.logic.ui.model.components.GUIOrGate;
-import net.mograsim.logic.ui.model.wires.GUIWire;
-import net.mograsim.logic.ui.model.wires.WireCrossPoint;
-import net.mograsim.logic.ui.modeladapter.LogicModelParameters;
-import net.mograsim.logic.ui.modeladapter.ViewLogicModelAdapter;
-
-public class MograsimPreview implements IThemePreview
-{
-
- private LogicUICanvas ui;
- private LogicExecuter exec;
-
- @Override
- @SuppressWarnings("unused")
- public void createControl(Composite parent, ITheme currentTheme)
- {
- ViewModelModifiable model = new ViewModelModifiable();
- LogicModelParameters params = new LogicModelParameters();
- params.gateProcessTime = 50;
- params.wireTravelTime = 10;
-
- GUIManualSwitch rIn = new GUIManualSwitch(model);
- rIn.moveTo(10, 10);
- GUIManualSwitch sIn = new GUIManualSwitch(model);
- sIn.moveTo(10, 70);
-
- GUIOrGate or1 = new GUIOrGate(model, 1);
- or1.moveTo(70, 12.5);
- new GUIWire(model, rIn.getOutputPin(), or1.getPin("A"));
-
- GUIOrGate or2 = new GUIOrGate(model, 1);
- or2.moveTo(70, 62.5);
- new GUIWire(model, sIn.getOutputPin(), or2.getPin("B"));
-
- GUINotGate not1 = new GUINotGate(model, 1);
- not1.moveTo(110, 17.5);
- new GUIWire(model, or1.getPin("Y"), not1.getPin("A"));
-
- GUINotGate not2 = new GUINotGate(model, 1);
- not2.moveTo(110, 67.5);
- new GUIWire(model, or2.getPin("Y"), not2.getPin("A"));
-
- WireCrossPoint p1 = new WireCrossPoint(model, 1);
- p1.moveCenterTo(140, 22.5);
- new GUIWire(model, not1.getPin("Y"), p1);
- new GUIWire(model, p1, or2.getPin("A"), new Point(140, 35), new Point(50, 60), new Point(50, 67.5));
-
- WireCrossPoint p2 = new WireCrossPoint(model, 1);
- p2.moveCenterTo(140, 72.5);
- new GUIWire(model, not2.getPin("Y"), p2);
- new GUIWire(model, p2, or1.getPin("B"), new Point(140, 60), new Point(50, 35), new Point(50, 27.5));
-
- WireCrossPoint o1 = new WireCrossPoint(model, 1);
- o1.moveCenterTo(150, 22.5);
- new GUIWire(model, p1, o1);
-
- WireCrossPoint o2 = new WireCrossPoint(model, 1);
- o2.moveCenterTo(150, 72.5);
- new GUIWire(model, p2, o2);
-
- Timeline t = ViewLogicModelAdapter.convert(model, params);
- exec = new LogicExecuter(t);
-
- rIn.clicked(0, 0);
-
- ui = new LogicUICanvas(parent, SWT.NONE, model);
- ZoomableCanvasUserInput userInput = new ZoomableCanvasUserInput(ui);
- userInput.buttonDrag = 3;
- userInput.buttonZoom = 2;
- userInput.enableUserInput();
- update(currentTheme);
- currentTheme.getColorRegistry().addListener(e -> update(currentTheme));
-
- ui.zoomSteps(12, 10, 10);
- exec.startLiveExecution();
- }
-
- private void update(ITheme currentTheme)
- {
- ui.setBackground(currentTheme.getColorRegistry().get("net.mograsim.plugin.sim_backgound"));
- ui.setForeground(currentTheme.getColorRegistry().get("net.mograsim.plugin.sim_text_color"));
- }
-
- @Override
- public void dispose()
- {
- exec.stopLiveExecution();
- }
-}
--- /dev/null
+package net.mograsim.plugin;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.themes.ITheme;
+import org.eclipse.ui.themes.IThemePreview;
+
+import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
+import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInput;
+import net.mograsim.logic.core.timeline.Timeline;
+import net.mograsim.logic.ui.LogicExecuter;
+import net.mograsim.logic.ui.LogicUICanvas;
+import net.mograsim.logic.ui.model.ViewModelModifiable;
+import net.mograsim.logic.ui.model.components.GUIManualSwitch;
+import net.mograsim.logic.ui.model.components.GUINotGate;
+import net.mograsim.logic.ui.model.components.GUIOrGate;
+import net.mograsim.logic.ui.model.wires.GUIWire;
+import net.mograsim.logic.ui.model.wires.WireCrossPoint;
+import net.mograsim.logic.ui.modeladapter.LogicModelParameters;
+import net.mograsim.logic.ui.modeladapter.ViewLogicModelAdapter;
+
+public class SimulationPreview implements IThemePreview
+{
+
+ private LogicUICanvas ui;
+ private LogicExecuter exec;
+
+ @Override
+ @SuppressWarnings("unused")
+ public void createControl(Composite parent, ITheme currentTheme)
+ {
+ ViewModelModifiable model = new ViewModelModifiable();
+ LogicModelParameters params = new LogicModelParameters();
+ params.gateProcessTime = 50;
+ params.wireTravelTime = 10;
+
+ GUIManualSwitch rIn = new GUIManualSwitch(model);
+ rIn.moveTo(10, 10);
+ GUIManualSwitch sIn = new GUIManualSwitch(model);
+ sIn.moveTo(10, 70);
+
+ GUIOrGate or1 = new GUIOrGate(model, 1);
+ or1.moveTo(70, 12.5);
+ new GUIWire(model, rIn.getOutputPin(), or1.getPin("A"));
+
+ GUIOrGate or2 = new GUIOrGate(model, 1);
+ or2.moveTo(70, 62.5);
+ new GUIWire(model, sIn.getOutputPin(), or2.getPin("B"));
+
+ GUINotGate not1 = new GUINotGate(model, 1);
+ not1.moveTo(110, 17.5);
+ new GUIWire(model, or1.getPin("Y"), not1.getPin("A"));
+
+ GUINotGate not2 = new GUINotGate(model, 1);
+ not2.moveTo(110, 67.5);
+ new GUIWire(model, or2.getPin("Y"), not2.getPin("A"));
+
+ WireCrossPoint p1 = new WireCrossPoint(model, 1);
+ p1.moveCenterTo(140, 22.5);
+ new GUIWire(model, not1.getPin("Y"), p1);
+ new GUIWire(model, p1, or2.getPin("A"), new Point(140, 35), new Point(50, 60), new Point(50, 67.5));
+
+ WireCrossPoint p2 = new WireCrossPoint(model, 1);
+ p2.moveCenterTo(140, 72.5);
+ new GUIWire(model, not2.getPin("Y"), p2);
+ new GUIWire(model, p2, or1.getPin("B"), new Point(140, 60), new Point(50, 35), new Point(50, 27.5));
+
+ WireCrossPoint o1 = new WireCrossPoint(model, 1);
+ o1.moveCenterTo(150, 22.5);
+ new GUIWire(model, p1, o1);
+
+ WireCrossPoint o2 = new WireCrossPoint(model, 1);
+ o2.moveCenterTo(150, 72.5);
+ new GUIWire(model, p2, o2);
+
+ Timeline t = ViewLogicModelAdapter.convert(model, params);
+ exec = new LogicExecuter(t);
+
+ rIn.clicked(0, 0);
+
+ ui = new LogicUICanvas(parent, SWT.NONE, model);
+ ZoomableCanvasUserInput userInput = new ZoomableCanvasUserInput(ui);
+ userInput.buttonDrag = 3;
+ userInput.buttonZoom = 2;
+ userInput.enableUserInput();
+ update(currentTheme);
+ currentTheme.getColorRegistry().addListener(e -> update(currentTheme));
+
+ ui.zoomSteps(12, 10, 10);
+ exec.startLiveExecution();
+ }
+
+ private void update(ITheme currentTheme)
+ {
+ ui.setBackground(currentTheme.getColorRegistry().get("net.mograsim.plugin.sim_backgound"));
+ ui.setForeground(currentTheme.getColorRegistry().get("net.mograsim.plugin.sim_text_color"));
+ }
+
+ @Override
+ public void dispose()
+ {
+ exec.stopLiveExecution();
+ }
+}
import javax.inject.Inject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.jface.resource.ColorRegistry;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.statushandlers.StatusManager;
import org.eclipse.ui.themes.ITheme;
import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInput;
import net.mograsim.logic.ui.model.wires.GUIWire;
import net.mograsim.logic.ui.modeladapter.LogicModelParameters;
import net.mograsim.logic.ui.modeladapter.ViewLogicModelAdapter;
+import net.mograsim.preferences.ColorDefinition;
+import net.mograsim.preferences.ColorDefinition.BuiltInColor;
+import net.mograsim.preferences.Preferences;
public class LogicUIPart extends ViewPart
{
@Override
public void createPartControl(Composite parent)
{
+ // set preferences
+ Preferences.setPreferences(new Preferences()
+ {
+ @Override
+ public ColorDefinition getColorDefinition(String name)
+ {
+ RGB rgb = getColorRegistry().getRGB(name);
+ if (rgb == null)
+ {
+ StatusManager.getManager().handle(new Status(IStatus.ERROR, "net.mograsim.plugin.core", "No color for name " + name));
+ return new ColorDefinition(BuiltInColor.COLOR_BLACK);
+ }
+ return new ColorDefinition(rgb.red, rgb.green, rgb.blue);
+ }
+
+ @Override
+ public Color getColor(String name)
+ {
+ return getColorRegistry().get(name);
+ }
+
+ private ColorRegistry getColorRegistry()
+ {
+ return PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
+ }
+ });
+
// setup view model
ViewModelModifiable viewModel = new ViewModelModifiable();
createTestbench(viewModel);