@PersistState public void savePersistState(MApplication application) { LOG.debug("persistState:"); final Map<String, String> persistedState = application.getPersistedState(); persistedState.put(IPersistenceKey.TERMINAL_SUPPRESS_LINES, "" + showSuppressedLines); persistedState.put(IPersistenceKey.TERMINAL_GRBL_STATE, "" + showGrblStateLines); persistedState.put(IPersistenceKey.TERMINAL_GRBL_MODES, "" + showGcodeModeLines); }
private void restorePersistedState(MApplication application, MPart part) { final Map<String, String> persistedState = application.getPersistedState(); showSuppressedLines = toolbox.parseBoolean(persistedState.get(IPersistenceKey.TERMINAL_SUPPRESS_LINES)); showGrblStateLines = toolbox.parseBoolean(persistedState.get(IPersistenceKey.TERMINAL_GRBL_STATE)); showGcodeModeLines = toolbox.parseBoolean(persistedState.get(IPersistenceKey.TERMINAL_GRBL_MODES)); // set the state of the direct menu items according to persisted state // find the two direct menu items final MToolBar toolbar = part.getToolbar(); List<MToolBarElement> toolBarChildren = toolbar.getChildren(); for (MToolBarElement child : toolBarChildren) { if (child instanceof MHandledToolItem && child .getElementId() .equals("de.jungierek.grblrunner.handledtoolitem.terminal.togglesuppresslines")) { LOG.debug( "restorePersistedState: child=" + child.getElementId() + " class=" + child.getClass()); MMenu menu = ((MHandledToolItem) child).getMenu(); if (menu != null) { List<MMenuElement> items = menu.getChildren(); for (MMenuElement item : items) { LOG.debug( "restorePersistedState: item=" + item.getElementId() + "class=" + child.getClass()); switch (item.getElementId()) { case "de.jungierek.grblrunner.directmenuitem.togglesuppresslines.grblstate": ((MMenuItem) item).setSelected(showGrblStateLines); break; case "de.jungierek.grblrunner.directmenuitem.togglesuppresslines.gcodestate": ((MMenuItem) item).setSelected(showGcodeModeLines); break; default: break; } } } } } }