/** * Returns the image for the given node if that node is in an alarm state. * * @param node the node. * @return the image. */ @Nonnull private Image getAlarmImageFor(@Nonnull final IAlarmTreeNode node) { final EpicsAlarmSeverity activeAlarmSeverity = node.getAlarmSeverity(); final EpicsAlarmSeverity unacknowledgedAlarmSeverity = node.getUnacknowledgedAlarmSeverity(); final String[] iconNames = getIconNames(activeAlarmSeverity, unacknowledgedAlarmSeverity); return createImage(iconNames); }
@Nonnull private String getName(@Nonnull final IAlarmTreeNode node) { String result = node.getName(); if (isDirectChildOfRoot(node) && (node.getSource() == TreeNodeSource.XML)) { result = result + " [XML]"; } return result; }
/** * Adds the context menu actions. * * @param menuManager the menu manager. */ private void fillContextMenu(@Nullable final IMenuManager menuManager) { if (menuManager == null) { MessageDialog.openError( getSite().getShell(), Messages.AlarmTreeView_MessageDialog_ContextMenu_Error_Title, Messages.AlarmTreeView_MessageDialog_ContextMenu_Error_Message); return; } final IStructuredSelection selection = (IStructuredSelection) _viewer.getSelection(); if (selection.size() > 0) { menuManager.add(_acknowledgeAction); } if (selection.size() == 1) { menuManager.add(_runCssAlarmDisplayAction); menuManager.add(_runCssDisplayAction); menuManager.add(_openCssStripChartAction); menuManager.add(_showHelpGuidanceAction); menuManager.add(_showHelpPageAction); menuManager.add(new Separator(Messages.AlarmTreeView_Menu_Separator_Edit)); menuManager.add(_deleteNodeAction); final Object selected = selection.getFirstElement(); if (selected instanceof SubtreeNode) { menuManager.add(_retrieveInitialStateAction); } final IAlarmTreeNode firstElement = (IAlarmTreeNode) selection.getFirstElement(); final LdapEpicsAlarmcfgConfiguration oc = firstElement.getTreeNodeConfiguration(); if (!LdapEpicsAlarmcfgConfiguration.RECORD.equals(oc)) { menuManager.add(_createRecordAction); menuManager.add(_createComponentAction); } if (!LdapEpicsAlarmcfgConfiguration.FACILITY.equals(oc)) { menuManager.add(_renameAction); } else { menuManager.add(_saveAsXmlFileAction); } } // adds a separator after which contributed actions from other plug-ins // will be displayed menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); }
private boolean isDirectChildOfRoot(@Nonnull final IAlarmTreeNode node) { IAlarmTreeNode parent = node.getParent(); return (parent != null) && (parent.getSource() == TreeNodeSource.ROOT); }