extension.name.1 = XML Problem
decorator.label = Resource Decorator
themeElementCategory.label = Mograsim
+themeElementCategory.label.0 = Simulation
+themeElementCategory.label.1 = Microinstructions
colorDefinition.label = Simulation Background
colorDefinition.description = The Background of the Simulation Visualisation
colorDefinition.label.0 = Simulation Foreground Color
colorDefinition.label.8 = Simulation Color Z
colorDefinition.label.9 = Simulation Color 0
colorDefinition.label.10 = Simulation text color
+colorDefinition.label.11 = Modified Cell Background Color
+colorDefinition.label.12 = Modified Cell Foreground Color
fontDefinition.label = Assembler Operation Style
view.name.0 = Simulation View
view.name.1 = Memory
wizards.newWizards.category = Mograsim
wizards.newWizards.mpm.name = Microprogram Memory
wizards.newWizards.mpm.desc = Creates a default new Microprogram Memory
-themeElementCategory.label.0 = Simulation
Bundle-Vendor.0 = Mograsim Team
\ No newline at end of file
label="%themeElementCategory.label.0"
parentId="net.mograsim.plugin.mograsim">
</themeElementCategory>
+ <themeElementCategory
+ class="net.mograsim.plugin.SimulationPreview"
+ id="net.mograsim.plugin.mi"
+ label="%themeElementCategory.label.1">
+ </themeElementCategory>
<colorDefinition
categoryId="net.mograsim.logic.model"
id="net.mograsim.logic.model.color.background"
isEditable="true"
label="%fontDefinition.label">
</fontDefinition>
+ <colorDefinition
+ categoryId="net.mograsim.plugin.mi"
+ id="net.mograsim.plugin.modified_cell_bg_color"
+ isEditable="true"
+ label="%colorDefinition.label.11"
+ value="COLOR_BLUE">
+ </colorDefinition>
+ <colorDefinition
+ categoryId="net.mograsim.plugin.mi"
+ id="net.mograsim.plugin.modified_cell_fg_color"
+ isEditable="true"
+ label="%colorDefinition.label.12"
+ value="COLOR_WHITE">
+ </colorDefinition>
</extension>
<extension
point="org.eclipse.ui.preferencePages">
private void addInstructionPreviewControlWidgets(Composite parent)
{
- instPreview = new InstructionTable(parent, new DisplaySettings());
+ instPreview = new InstructionTable(parent, new DisplaySettings(), getSite().getWorkbenchWindow().getWorkbench().getThemeManager());
instPreview.getTableViewer().getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
instPreview.setContentProvider(new ActiveInstructionPreviewContentProvider(instPreview.getTableViewer()));
}
--- /dev/null
+package net.mograsim.plugin.tables.mi;
+
+import org.eclipse.jface.resource.ColorRegistry;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.ui.themes.IThemeManager;
+
+public class ColorProvider
+{
+ private final TableViewer viewer;
+ private final IThemeManager themeManager;
+ private ColorRegistry cRegistry;
+
+ private final static String modifBackground = "net.mograsim.plugin.modified_cell_bg_color",
+ modifForeground = "net.mograsim.plugin.modified_cell_fg_color";
+ private final IPropertyChangeListener updateListener;
+
+ public ColorProvider(TableViewer viewer, IThemeManager themeManager)
+ {
+ this.viewer = viewer;
+ this.themeManager = themeManager;
+ this.cRegistry = themeManager.getCurrentTheme().getColorRegistry();
+ updateListener = e ->
+ {
+ switch (e.getProperty())
+ {
+ case IThemeManager.CHANGE_CURRENT_THEME:
+ cRegistry = themeManager.getCurrentTheme().getColorRegistry();
+ //$FALL-THROUGH$
+ case modifBackground:
+ case modifForeground:
+ viewer.refresh();
+ break;
+ default:
+ break;
+ }
+ };
+ themeManager.addPropertyChangeListener(updateListener);
+ }
+
+ public Color getBackground(Object element, int index)
+ {
+ InstructionTableRow row = (InstructionTableRow) element;
+
+ return row.data.getCell(row.address).getParameter(index).isDefault() ? viewer.getTable().getBackground()
+ : cRegistry.get(modifBackground);
+ }
+
+ public Color getForeground(Object element, int index)
+ {
+ InstructionTableRow row = (InstructionTableRow) element;
+ return row.data.getCell(row.address).getParameter(index).isDefault() ? viewer.getTable().getForeground()
+ : cRegistry.get(modifForeground);
+ }
+
+ public void dispose()
+ {
+ themeManager.removePropertyChangeListener(updateListener);
+ }
+}
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.themes.IThemeManager;
import net.mograsim.machine.mi.MicroInstructionDefinition;
import net.mograsim.machine.mi.MicroInstructionMemory;
public class InstructionTable
{
- protected DisplaySettings displaySettings;
- protected LazyTableViewer viewer;
+ protected final DisplaySettings displaySettings;
+ protected final LazyTableViewer viewer;
private TableViewerColumn[] columns = new TableViewerColumn[0];
private MicroInstructionDefinition miDef;
private MicroInstructionMemory memory;
private InstructionTableContentProvider provider;
+ private final ColorProvider cProv;
- public InstructionTable(Composite parent, DisplaySettings displaySettings)
+ public InstructionTable(Composite parent, DisplaySettings displaySettings, IThemeManager themeManager)
{
viewer = new LazyTableViewer(parent, SWT.FULL_SELECTION | SWT.BORDER | SWT.VIRTUAL);
this.displaySettings = displaySettings;
+ this.cProv = new ColorProvider(viewer, themeManager);
Table table = viewer.getTable();
table.setHeaderVisible(true);
{
case BOOLEAN_IMMEDIATE:
support = new BooleanEditingSupport(viewer, miDef, index);
- provider = new ParameterLabelProvider(index);
+ provider = new ParameterLabelProvider(cProv, index);
break;
case INTEGER_IMMEDIATE:
support = new IntegerEditingSupport(viewer, miDef, index, displaySettings, this.provider);
- provider = new IntegerColumnLabelProvider(displaySettings, index);
+ provider = new IntegerColumnLabelProvider(displaySettings, cProv, index);
break;
case MNEMONIC:
support = new MnemonicEditingSupport(viewer, miDef, index, this.provider);
- provider = new ParameterLabelProvider(index);
+ provider = new ParameterLabelProvider(cProv, index);
break;
default:
throw new IllegalStateException(
{
Display.getDefault().asyncExec(() -> viewer.refresh());
}
+
+ public void dispose()
+ {
+ cProv.dispose();
+ viewer.getTable().dispose();
+ }
}
new RadixSelector(parent, displaySettings);
addActivationButton(parent);
-
- table = new InstructionTable(parent, displaySettings);
+ table = new InstructionTable(parent, displaySettings, getSite().getWorkbenchWindow().getWorkbench().getThemeManager());
table.setContentProvider(provider);
table.bindMicroInstructionMemory(memory);
{
highlight((int) (address - memory.getDefinition().getMinimalAddress()));
}
+
+ @Override
+ public void dispose()
+ {
+ table.dispose();
+ super.dispose();
+ }
}
import java.math.BigInteger;
+import org.eclipse.swt.graphics.Color;
+
import net.mograsim.machine.mi.parameters.IntegerImmediate;
import net.mograsim.plugin.tables.DisplaySettings;
import net.mograsim.plugin.tables.NumberColumnLabelProvider;
public class IntegerColumnLabelProvider extends NumberColumnLabelProvider
{
- private int index;
+ private final int index;
+ private final ColorProvider cProv;
- public IntegerColumnLabelProvider(DisplaySettings displaySettings, int index)
+ public IntegerColumnLabelProvider(DisplaySettings displaySettings, ColorProvider cProv, int index)
{
super(displaySettings);
+ this.cProv = cProv;
this.index = index;
}
.getExpectedBits();
}
+ @Override
+ public Color getBackground(Object element)
+ {
+ return cProv.getBackground(element, index);
+ }
+
+ @Override
+ public Color getForeground(Object element)
+ {
+ return cProv.getForeground(element, index);
+ }
}
package net.mograsim.plugin.tables.mi;
import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.swt.graphics.Color;
public class ParameterLabelProvider extends ColumnLabelProvider
{
private final int index;
+ private final ColorProvider cProv;
- public ParameterLabelProvider(int index)
+ public ParameterLabelProvider(ColorProvider cProv, int index)
{
super();
this.index = index;
+ this.cProv = cProv;
}
@Override
InstructionTableRow row = (InstructionTableRow) element;
return row.data.getCell(row.address).getParameter(index).toString();
}
+
+ @Override
+ public Color getBackground(Object element)
+ {
+ return cProv.getBackground(element, index);
+ }
+
+ @Override
+ public Color getForeground(Object element)
+ {
+ return cProv.getForeground(element, index);
+ }
}