themeElementCategory.label = Mograsim
themeElementCategory.label.0 = Simulation
themeElementCategory.label.1 = Microinstructions
+themeElementCategory.label.2 = Memory
colorDefinition.label = Simulation Background
colorDefinition.description = The Background of the Simulation Visualisation
colorDefinition.label.0 = Simulation Foreground Color
colorDefinition.label.14 = Highlighted Cell Foreground Color
fontDefinition.label = Assembler Operation Style
fontDefinition.label.0 = Table Font
+fontDefinition.label.1 = Table Font
view.name.0 = Simulation View
view.name.1 = Memory
wizards.newWizards.category = Mograsim
label="%themeElementCategory.label.1"
parentId="net.mograsim.plugin.mograsim">
</themeElementCategory>
+ <themeElementCategory
+ class="net.mograsim.plugin.SimulationPreview"
+ id="net.mograsim.plugin.memory"
+ label="%themeElementCategory.label.2"
+ parentId="net.mograsim.plugin.mograsim">
+ </themeElementCategory>
<colorDefinition
categoryId="net.mograsim.logic.model"
id="net.mograsim.logic.model.color.background"
</fontDefinition>
<colorDefinition
categoryId="net.mograsim.plugin.mi"
- id="net.mograsim.plugin.modified_cell_bg_color"
+ id="net.mograsim.plugin.mi.modified_cell_bg_color"
isEditable="true"
label="%colorDefinition.label.11"
value="COLOR_GREEN">
</colorDefinition>
<colorDefinition
categoryId="net.mograsim.plugin.mi"
- id="net.mograsim.plugin.modified_cell_fg_color"
+ id="net.mograsim.plugin.mi.modified_cell_fg_color"
isEditable="true"
label="%colorDefinition.label.12"
value="COLOR_BLACK">
</colorDefinition>
- <fontDefinition
- categoryId="net.mograsim.plugin.mi"
- id="net.mograsim.plugin.table_font"
- isEditable="true"
- label="%fontDefinition.label.0">
- </fontDefinition>
<colorDefinition
categoryId="net.mograsim.plugin.mi"
- id="net.mograsim.plugin.highlighted_cell_bg_color"
+ id="net.mograsim.plugin.mi.highlighted_cell_bg_color"
isEditable="true"
label="%colorDefinition.label.13"
value="COLOR_YELLOW">
</colorDefinition>
<colorDefinition
categoryId="net.mograsim.plugin.mi"
- id="net.mograsim.plugin.highlighted_cell_fg_color"
+ id="net.mograsim.plugin.mi.highlighted_cell_fg_color"
isEditable="true"
label="%colorDefinition.label.14"
value="COLOR_BLACK">
</colorDefinition>
+ <fontDefinition
+ categoryId="net.mograsim.plugin.mi"
+ id="net.mograsim.plugin.mi.table_font"
+ isEditable="true"
+ label="%fontDefinition.label.0">
+ </fontDefinition>
+ <fontDefinition
+ categoryId="net.mograsim.plugin.memory"
+ id="net.mograsim.plugin.memory.table_font"
+ isEditable="true"
+ label="%fontDefinition.label.1">
+ </fontDefinition>
</extension>
<extension
point="org.eclipse.ui.preferencePages">
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.SafeRunnable;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.EditorPart;
+import org.eclipse.ui.themes.ITheme;
+import org.eclipse.ui.themes.IThemeManager;
import net.mograsim.machine.MainMemory;
import net.mograsim.machine.MainMemoryDefinition;
private final MemoryCellModifiedListener memListener;
+ private final static String font = "net.mograsim.plugin.memory.table_font";
+ private IPropertyChangeListener fontChangeListener;
+
public MemoryEditor()
{
memListener = this::cellModified;
table.setLinesVisible(true);
viewer.setUseHashlookup(true);
viewer.setContentProvider(provider);
- getSite().setSelectionProvider(viewer);// TODO what does this?
+ getSite().setSelectionProvider(viewer);// TODO what does this do?
viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 7, 1));
+
+ IThemeManager themeManager = getSite().getWorkbenchWindow().getWorkbench().getThemeManager();
+ themeManager.addPropertyChangeListener(fontChangeListener = (e) ->
+ {
+ if (IThemeManager.CHANGE_CURRENT_THEME.equals(e.getProperty()) || font.equals(e.getProperty()))
+ {
+ updateFont(themeManager.getCurrentTheme());
+ viewer.refresh();
+ }
+ });
+ updateFont(themeManager.getCurrentTheme());
+
if (memory != null)
viewer.setInput(memory);
}
+ private void updateFont(ITheme theme)
+ {
+ viewer.getTable().setFont(theme.getFontRegistry().get(font));
+ }
+
private void createColumns()
{
TableViewerColumn addrCol = createTableViewerColumn("Address", 100);
@Override
public void dispose()
{
+ getSite().getWorkbenchWindow().getWorkbench().getThemeManager().removePropertyChangeListener(fontChangeListener);
if (memory != null)
memory.deregisterCellModifiedListener(memListener);
super.dispose();
private Font boldItalic, bold, italic, normal;
private Color modifBackground, modifForeground, highlightBackground, highlightForeground;
- private final static String font = "net.mograsim.plugin.table_font",
- colorModifBackground = "net.mograsim.plugin.modified_cell_bg_color",
- colorModifForeground = "net.mograsim.plugin.modified_cell_fg_color",
- colorHighlightForeground = "net.mograsim.plugin.highlighted_cell_fg_color",
- colorHighlightBackground = "net.mograsim.plugin.highlighted_cell_bg_color";
+ private final static String font = "net.mograsim.plugin.mi.table_font",
+ colorModifBackground = "net.mograsim.plugin.mi.modified_cell_bg_color",
+ colorModifForeground = "net.mograsim.plugin.mi.modified_cell_fg_color",
+ colorHighlightForeground = "net.mograsim.plugin.mi.highlighted_cell_fg_color",
+ colorHighlightBackground = "net.mograsim.plugin.mi.highlighted_cell_bg_color";
private final IPropertyChangeListener updateListener;
public FontAndColorHelper(TableViewer viewer, IThemeManager themeManager)