use of org.eclipse.jface.resource.LocalResourceManager in project yamcs-studio by yamcs.
the class CommandStackView method createPartControl.
@Override
public void createPartControl(Composite parent) {
GridLayout gl = new GridLayout();
gl.marginHeight = 0;
gl.marginWidth = 0;
gl.verticalSpacing = 1;
parent.setLayout(gl);
ResourceManager resourceManager = new LocalResourceManager(JFaceResources.getResources(), parent);
errorBackgroundColor = resourceManager.createColor(new RGB(255, 221, 221));
bracketStyler = new Styler() {
@Override
public void applyStyles(TextStyle textStyle) {
textStyle.font = JFaceResources.getTextFont();
}
};
argNameStyler = new Styler() {
@Override
public void applyStyles(TextStyle textStyle) {
textStyle.font = JFaceResources.getTextFont();
textStyle.foreground = Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY);
}
};
numberStyler = new Styler() {
@Override
public void applyStyles(TextStyle textStyle) {
textStyle.font = JFaceResources.getTextFont();
textStyle.foreground = Display.getDefault().getSystemColor(SWT.COLOR_BLUE);
}
};
errorStyler = new Styler() {
@Override
public void applyStyles(TextStyle textStyle) {
textStyle.font = JFaceResources.getTextFont();
textStyle.foreground = Display.getDefault().getSystemColor(SWT.COLOR_BLUE);
textStyle.underline = true;
textStyle.underlineColor = Display.getDefault().getSystemColor(SWT.COLOR_RED);
textStyle.underlineStyle = SWT.UNDERLINE_ERROR;
}
};
issuedStyler = new Styler() {
@Override
public void applyStyles(TextStyle textStyle) {
textStyle.font = JFaceResources.getFontRegistry().getItalic(JFaceResources.TEXT_FONT);
textStyle.foreground = Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
}
};
skippedStyler = new Styler() {
@Override
public void applyStyles(TextStyle textStyle) {
textStyle.font = JFaceResources.getFontRegistry().getItalic(JFaceResources.TEXT_FONT);
textStyle.foreground = Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
textStyle.strikeout = true;
textStyle.strikeoutColor = textStyle.foreground;
}
};
Composite tableWrapper = new Composite(parent, SWT.NONE);
tableWrapper.setLayoutData(new GridData(GridData.FILL_BOTH));
TableColumnLayout tcl = new TableColumnLayout();
tableWrapper.setLayout(tcl);
commandTableViewer = new CommandStackTableViewer(tableWrapper, tcl, this);
commandTableViewer.addDoubleClickListener(evt -> {
IStructuredSelection sel = (IStructuredSelection) evt.getSelection();
if (sel.getFirstElement() != null) {
StackedCommand cmd = (StackedCommand) sel.getFirstElement();
if (cmd.getStackedState() != StackedState.ISSUED && cmd.getStackedState() != StackedState.SKIPPED) {
EditStackedCommandDialog dialog = new EditStackedCommandDialog(parent.getShell(), cmd);
if (dialog.open() == Window.OK) {
refreshState();
}
}
}
});
Composite controls = new Composite(parent, SWT.NONE);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 30;
controls.setLayoutData(gd);
gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
controls.setLayout(gl);
controls.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
Composite bottomLeft = new Composite(controls, SWT.NONE);
gd = new GridData(GridData.FILL_BOTH);
gd.verticalAlignment = SWT.CENTER;
bottomLeft.setLayoutData(gd);
gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
gl.horizontalSpacing = 0;
gl.verticalSpacing = 0;
bottomLeft.setLayout(gl);
messageLabel = new Label(bottomLeft, SWT.NONE);
messageLabel.setText("");
messageLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Composite bottomRight = new Composite(controls, SWT.NONE);
gd = new GridData(GridData.FILL_BOTH);
gd.verticalAlignment = SWT.CENTER;
gd.horizontalAlignment = SWT.RIGHT;
bottomRight.setLayoutData(gd);
gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
gl.horizontalSpacing = 0;
gl.verticalSpacing = 0;
bottomRight.setLayout(gl);
armButton = new Button(bottomRight, SWT.TOGGLE);
armButton.setText("1. Arm");
armButton.setToolTipText("Arm the selected command");
armButton.setEnabled(false);
armButton.addListener(SWT.Selection, evt -> {
if (armButton.getSelection()) {
ICommandService commandService = (ICommandService) getViewSite().getService(ICommandService.class);
IEvaluationService evaluationService = (IEvaluationService) getViewSite().getService(IEvaluationService.class);
Command cmd = commandService.getCommand("org.yamcs.studio.commanding.stack.arm");
try {
cmd.executeWithChecks(new ExecutionEvent(cmd, new HashMap<String, String>(), null, evaluationService.getCurrentState()));
} catch (Exception e) {
log.log(Level.SEVERE, "Could not execute command", e);
}
} else {
CommandStack stack = CommandStack.getInstance();
if (stack.getActiveCommand() != null && stack.getActiveCommand().isArmed()) {
stack.getActiveCommand().setStackedState(StackedState.DISARMED);
}
}
});
issueButton = new Button(bottomRight, SWT.NONE);
issueButton.setText("2. Issue");
issueButton.setToolTipText("Issue the selected command");
issueButton.setEnabled(false);
issueButton.addListener(SWT.Selection, evt -> {
ICommandService commandService = (ICommandService) getViewSite().getService(ICommandService.class);
IEvaluationService evaluationService = (IEvaluationService) getViewSite().getService(IEvaluationService.class);
Command cmd = commandService.getCommand("org.yamcs.studio.commanding.stack.issue");
try {
cmd.executeWithChecks(new ExecutionEvent(cmd, new HashMap<String, String>(), null, evaluationService.getCurrentState()));
} catch (Exception e) {
log.log(Level.SEVERE, "Could not execute command", e);
}
});
commandTableViewer.addSelectionChangedListener(evt -> {
IStructuredSelection sel = (IStructuredSelection) evt.getSelection();
updateMessagePanel(sel);
CommandStack stack = CommandStack.getInstance();
armButton.setSelection(false);
stack.disarmArmed();
if (sel.isEmpty() || !stack.isValid() || !sel.getFirstElement().equals(stack.getActiveCommand())) {
armButton.setEnabled(false);
issueButton.setEnabled(false);
} else if (stack.hasRemaining()) {
setButtonEnable(armButton, true);
}
refreshState();
});
getViewSite().setSelectionProvider(commandTableViewer);
// Set up connection state, and listen to changes
connectionStateProvider = RCPUtils.findSourceProvider(getViewSite(), ConnectionStateProvider.STATE_KEY_CONNECTED, ConnectionStateProvider.class);
connectionStateProvider.addSourceProviderListener(new ISourceProviderListener() {
@Override
public void sourceChanged(int sourcePriority, String sourceName, Object sourceValue) {
refreshState();
}
@Override
@SuppressWarnings("rawtypes")
public void sourceChanged(int sourcePriority, Map sourceValuesByName) {
refreshState();
}
});
// Add the popup menu for pasting commands
addPopupMenu();
// Set initial state
refreshState();
CommandingCatalogue.getInstance().addCommandHistoryListener(cmdhistEntry -> {
Display.getDefault().asyncExec(() -> processCommandHistoryEntry(cmdhistEntry));
});
}
use of org.eclipse.jface.resource.LocalResourceManager in project yamcs-studio by yamcs.
the class CommandHistoryView method createPartControl.
@Override
public void createPartControl(Composite parent) {
resourceManager = new LocalResourceManager(JFaceResources.getResources(), parent);
greenBubble = resourceManager.createImage(RCPUtils.getImageDescriptor(CommandHistoryView.class, "icons/obj16/ok.png"));
redBubble = resourceManager.createImage(RCPUtils.getImageDescriptor(CommandHistoryView.class, "icons/obj16/nok.png"));
grayBubble = resourceManager.createImage(RCPUtils.getImageDescriptor(CommandHistoryView.class, "icons/obj16/undef.png"));
waitingImage = resourceManager.createImage(RCPUtils.getImageDescriptor(CommandHistoryView.class, "icons/obj16/waiting.png"));
headerCompleteImage = resourceManager.createImage(RCPUtils.getImageDescriptor(CommandHistoryView.class, "icons/obj16/header_complete.png"));
checkmarkImage = resourceManager.createImage(RCPUtils.getImageDescriptor(CommandHistoryView.class, "icons/obj16/checkmark.gif"));
errorImage = resourceManager.createImage(RCPUtils.getImageDescriptor(CommandHistoryView.class, "icons/obj16/error_tsk.png"));
prevImage = resourceManager.createImage(RCPUtils.getImageDescriptor(CommandHistoryView.class, "icons/obj16/event_prev.png"));
nextImage = resourceManager.createImage(RCPUtils.getImageDescriptor(CommandHistoryView.class, "icons/obj16/event_next.png"));
createActions();
tableLayout = new TableLayout();
tableViewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
tableViewer.getTable().setLayout(tableLayout);
tableViewer.getTable().setHeaderVisible(true);
tableViewer.getTable().setLinesVisible(true);
addFixedColumns();
tableContentProvider = new CommandHistoryRecordContentProvider(tableViewer);
tableViewer.setContentProvider(tableContentProvider);
// ! otherwise refresh() deletes everything...
tableViewer.setInput(tableContentProvider);
tableViewerComparator = new CommandHistoryViewerComparator();
tableViewer.setComparator(tableViewerComparator);
// Register context menu. Commands are added in plugin.xml
MenuManager menuManager = new MenuManager();
Menu menu = menuManager.createContextMenu(tableViewer.getTable());
tableViewer.getTable().setMenu(menu);
getSite().registerContextMenu(menuManager, tableViewer);
// Default action is to open Command properties
tableViewer.getTable().addListener(SWT.MouseDoubleClick, evt -> {
RCPUtils.runCommand(CommandHistory.CMD_COMMAND_PROPERTIES);
});
updateSummaryLine();
getViewSite().setSelectionProvider(tableViewer);
CommandingCatalogue.getInstance().addCommandHistoryListener(cmdhistEntry -> {
Display.getDefault().asyncExec(() -> processCommandHistoryEntry(cmdhistEntry));
});
}
use of org.eclipse.jface.resource.LocalResourceManager in project yamcs-studio by yamcs.
the class AddToStackWizardPage1 method createControl.
@Override
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
setControl(composite);
GridLayout gl = new GridLayout();
gl.marginHeight = 0;
gl.marginWidth = 0;
composite.setLayout(gl);
// add filter box
Text searchbox = new Text(composite, SWT.SEARCH | SWT.BORDER | SWT.ICON_CANCEL);
searchbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// build tree table
ResourceManager resourceManager = new LocalResourceManager(JFaceResources.getResources(), composite);
level1Image = resourceManager.createImage(RCPUtils.getImageDescriptor(AddToStackWizardPage1.class, "icons/level1s.png"));
level2Image = resourceManager.createImage(RCPUtils.getImageDescriptor(AddToStackWizardPage1.class, "icons/level2s.png"));
level3Image = resourceManager.createImage(RCPUtils.getImageDescriptor(AddToStackWizardPage1.class, "icons/level3s.png"));
level4Image = resourceManager.createImage(RCPUtils.getImageDescriptor(AddToStackWizardPage1.class, "icons/level4s.png"));
level5Image = resourceManager.createImage(RCPUtils.getImageDescriptor(AddToStackWizardPage1.class, "icons/level5s.png"));
Composite tableWrapper = new Composite(composite, SWT.NONE);
tcl = new TreeColumnLayout();
tableWrapper.setLayoutData(new GridData(GridData.FILL_BOTH));
tableWrapper.setLayout(tcl);
commandsTreeTable = new TreeViewer(tableWrapper, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
commandsTreeTable.getTree().setHeaderVisible(true);
commandsTreeTable.getTree().setLinesVisible(false);
// column xtce path
TreeViewerColumn pathColumn = new TreeViewerColumn(commandsTreeTable, SWT.NONE);
pathColumn.getColumn().setText(COL_PATH);
pathColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
CommandInfo cmd = (CommandInfo) element;
return cmd.getName();
}
});
tcl.setColumnData(pathColumn.getColumn(), new ColumnPixelData(COLUMN_WIDTH));
// column significance
TreeViewerColumn significanceColumn = new TreeViewerColumn(commandsTreeTable, SWT.NONE);
significanceColumn.getColumn().setText(COL_SIGN);
significanceColumn.getColumn().setToolTipText("Significance Level");
significanceColumn.getColumn().setAlignment(SWT.CENTER);
significanceColumn.setLabelProvider(new CenteredImageLabelProvider() {
@Override
public Image getImage(Object element) {
CommandInfo cmd = (CommandInfo) element;
if (cmd.getSignificance() == null)
return null;
switch(cmd.getSignificance().getConsequenceLevel()) {
case WATCH:
return level1Image;
case WARNING:
return level2Image;
case DISTRESS:
return level3Image;
case CRITICAL:
return level4Image;
case SEVERE:
return level5Image;
default:
return null;
}
}
});
tcl.setColumnData(significanceColumn.getColumn(), new ColumnPixelData(40));
// column qualified name
TreeViewerColumn nameColumn = new TreeViewerColumn(commandsTreeTable, SWT.NONE);
nameColumn.getColumn().setText(COL_QNAME);
nameColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
CommandInfo cmd = (CommandInfo) element;
if (cmd.getAbstract()) {
// show a blank line if the command is abstract
return "";
}
return cmd.getQualifiedName();
}
});
tcl.setColumnData(nameColumn.getColumn(), new ColumnPixelData(COLUMN_WIDTH));
// on item selection update significance message and page completion status
commandsTreeTable.addSelectionChangedListener(evt -> {
IStructuredSelection sel = (IStructuredSelection) evt.getSelection();
if (sel.isEmpty()) {
setMessage(null);
return;
}
CommandInfo cmd = (CommandInfo) sel.getFirstElement();
setMessage(getMessage(cmd));
command.setMetaCommand(cmd);
command.setSelectedAliase(cmd.getQualifiedName());
setPageComplete(!cmd.getAbstract());
});
CommandTreeContentProvider commandTreeContentProvider = new CommandTreeContentProvider();
commandsTreeTable.setContentProvider(commandTreeContentProvider);
// load command list
Collection<CommandInfo> commandInfos = new ArrayList<>();
CommandingCatalogue.getInstance().getMetaCommands().forEach(cmd -> {
// add aliases columns
for (NamedObjectId alias : cmd.getAliasList()) {
String namespace = alias.getNamespace();
if (!namespaces.contains(namespace) && !namespace.startsWith("/")) {
namespaces.add(namespace);
addAliasColumn(namespace);
}
}
commandInfos.add(cmd);
});
commandsTreeTable.setInput(commandInfos);
commandsTreeTable.expandAll();
// with a small hack to display full data on the first column
for (TreeColumn tc : commandsTreeTable.getTree().getColumns()) tc.pack();
pathColumn.getColumn().setWidth(pathColumn.getColumn().getWidth() + 11 * commandTreeContentProvider.nbLevels);
for (TreeColumn tc : commandsTreeTable.getTree().getColumns()) {
if (tc.getWidth() > COLUMN_MAX_WIDTH)
tc.setWidth(COLUMN_MAX_WIDTH);
}
// filter
CommandInfoTreeViewerFilter filter = new CommandInfoTreeViewerFilter(commandTreeContentProvider);
commandsTreeTable.addFilter(filter);
searchbox.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent ke) {
filter.setSearchTerm(searchbox.getText());
commandsTreeTable.refresh();
commandsTreeTable.expandAll();
}
});
commandsTreeTable.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object o1, Object o2) {
CommandInfo c1 = (CommandInfo) o1;
CommandInfo c2 = (CommandInfo) o2;
return c1.getQualifiedName().compareTo(c2.getQualifiedName());
}
});
}
use of org.eclipse.jface.resource.LocalResourceManager in project yamcs-studio by yamcs.
the class ConnectionsDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
parent.getShell().setText("Yamcs Server Connections");
Composite contentArea = new Composite(parent, SWT.NONE);
GridLayout gl = new GridLayout();
gl.marginHeight = 0;
gl.verticalSpacing = 0;
contentArea.setLayout(gl);
ResourceManager resourceManager = new LocalResourceManager(JFaceResources.getResources(), contentArea);
ToolBar editBar = new ToolBar(contentArea, SWT.NO_FOCUS);
addServerButton = new ToolItem(editBar, SWT.NONE);
addServerButton.setImage(resourceManager.createImage(RCPUtils.getImageDescriptor(ConnectionsDialog.class, "icons/obj16/server_add.png")));
addServerButton.setToolTipText("Add Connection");
addServerButton.addListener(SWT.Selection, evt -> {
addServer();
updateState();
});
removeServerButton = new ToolItem(editBar, SWT.NONE);
removeServerButton.setImage(resourceManager.createImage(RCPUtils.getImageDescriptor(ConnectionsDialog.class, "icons/obj16/server_remove.png")));
removeServerButton.setToolTipText("Delete Connection");
removeServerButton.addListener(SWT.Selection, evt -> {
removeSelectedServer();
updateState();
});
editBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
SashForm sash = new SashForm(contentArea, SWT.HORIZONTAL);
sash.setLayoutData(new GridData(GridData.FILL_BOTH));
sash.setLayout(new FillLayout());
createServerPanel(sash, resourceManager);
// Create right side, but wrap it in another composite to force
// dimensions even when invisible
Composite detailPanelWrapper = new Composite(sash, SWT.NONE);
gl = new GridLayout();
gl.marginHeight = 0;
gl.marginWidth = 0;
detailPanelWrapper.setLayout(gl);
createDetailPanel(detailPanelWrapper, resourceManager);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 250;
detailPanel.setLayoutData(gd);
sash.setWeights(new int[] { 55, 45 });
ConnectionPreferences.getConfigurations().forEach(conf -> {
connViewer.add(conf);
});
YamcsConfiguration lastConf = ConnectionPreferences.getLastUsedConfiguration();
if (lastConf != null)
selectServer(lastConf);
else
selectFirstServer();
updateState();
return contentArea;
}
use of org.eclipse.jface.resource.LocalResourceManager in project yamcs-studio by yamcs.
the class LoginDialog method create.
@Override
public void create() {
super.create();
setTitle("Connect to " + nvl(conf.getName(), conf.getPrimaryConnectionString()));
setMessage("Please provide your credentials");
ResourceManager resourceManager = new LocalResourceManager(JFaceResources.getResources(), getShell());
Image titleImage = resourceManager.createImage(RCPUtils.getImageDescriptor(LoginDialog.class, "icons/yamcs_banner.png"));
setTitleImage(titleImage);
}
Aggregations