use of org.eclipse.swt.layout.RowLayout in project knime-core by knime.
the class WizardNodeView method callOpenView.
/**
* {@inheritDoc}
*/
@Override
public final void callOpenView(final String title, final Rectangle knimeWindowBounds) {
m_title = (title == null ? "View" : title);
Display display = getDisplay();
m_shell = new Shell(display, SWT.SHELL_TRIM);
m_shell.setText(m_title);
m_shell.setImage(ImageRepository.getIconImage(SharedImages.KNIME));
GridLayout layout = new GridLayout();
layout.numColumns = 1;
m_shell.setLayout(layout);
m_browser = new Browser(m_shell, SWT.NONE);
m_browser.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
m_browser.setText(getViewCreator().createMessageHTML("Loading view..."), true);
Composite buttonComposite = new Composite(m_shell, SWT.NONE);
buttonComposite.setLayoutData(new GridData(GridData.END, GridData.END, false, false));
buttonComposite.setLayout(new RowLayout());
ToolBar toolBar = new ToolBar(buttonComposite, SWT.BORDER | SWT.HORIZONTAL);
ToolItem resetButton = new ToolItem(toolBar, SWT.PUSH);
resetButton.setText("Reset");
resetButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
// Could only call if actual settings have been changed,
// however there might be things in views that one can change
// which do not get saved, then it's nice to trigger the event anyways.
/*if (checkSettingsChanged()) {*/
modelChanged();
/*}*/
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
ToolItem applyButton = new ToolItem(toolBar, SWT.DROP_DOWN);
applyButton.setText("Apply");
applyButton.setToolTipText("Applies the current settings and triggers a re-execute of the node.");
DropdownSelectionListener applyListener = new DropdownSelectionListener(applyButton);
String aTTooltip = "Applies the current settings and triggers a re-execute of the node.";
applyListener.add("Apply temporarily", aTTooltip, new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
applyTriggered(false);
}
});
String nDTooltip = "Applies the current settings as the node default settings and triggers a re-execute of the node.";
applyListener.add("Apply as new default", nDTooltip, new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
applyTriggered(true);
}
});
applyButton.addSelectionListener(applyListener);
applyButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (e.detail != SWT.ARROW) {
if (checkSettingsChanged()) {
showApplyDialog();
}
}
}
});
new ToolItem(toolBar, SWT.SEPARATOR);
ToolItem closeButton = new ToolItem(toolBar, SWT.DROP_DOWN);
closeButton.setText("Close");
closeButton.setToolTipText("Closes the view.");
DropdownSelectionListener closeListener = new DropdownSelectionListener(closeButton);
String cDTooltip = "Closes the view and discards any changes made.";
closeListener.add("Close && Discard", cDTooltip, new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
m_shell.dispose();
}
});
String cATooltip = "Closes the view, applies the current settings and triggers a re-execute of the node.";
closeListener.add("Close && Apply temporarily", cATooltip, new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (applyTriggered(false)) {
m_shell.dispose();
}
}
});
String cTTooltip = "Closes the view, applies the current settings as node defaults and triggers a re-execute of the node.";
closeListener.add("Close && Apply as new default", cTTooltip, new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (applyTriggered(true)) {
m_shell.dispose();
}
}
});
closeButton.addSelectionListener(closeListener);
closeButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (e.detail != SWT.ARROW) {
if (checkSettingsChanged()) {
/*MessageDialogWithToggle dialog =
MessageDialogWithToggle.openOkCancelConfirm(m_browser.getShell(), "Discard Settings",
"View settings have changed and will be lost. Do you want to continue?",
"Do not ask again", false, null, null);*/
if (!showCloseDialog()) {
return;
}
}
m_shell.dispose();
}
}
});
m_shell.addListener(SWT.Close, new Listener() {
@Override
public void handleEvent(final Event event) {
if (checkSettingsChanged()) {
event.doit = showCloseDialog();
}
}
});
// TODO: make initial size dynamic
m_shell.setSize(1024, 768);
Point middle = new Point(knimeWindowBounds.width / 2, knimeWindowBounds.height / 2);
// Left upper point for window
Point newLocation = new Point(middle.x - (m_shell.getSize().x / 2) + knimeWindowBounds.x, middle.y - (m_shell.getSize().y / 2) + knimeWindowBounds.y);
m_shell.setLocation(newLocation.x, newLocation.y);
m_shell.addDisposeListener(new org.eclipse.swt.events.DisposeListener() {
@Override
public void widgetDisposed(final DisposeEvent e) {
callCloseView();
}
});
m_shell.open();
display.asyncExec(new Runnable() {
@Override
public void run() {
m_browser.addProgressListener(new ProgressListener() {
@Override
public void completed(final ProgressEvent event) {
if (m_viewSet && !m_initialized) {
WizardNode<REP, VAL> model = getModel();
WizardViewCreator<REP, VAL> creator = getViewCreator();
String initCall = creator.createInitJSViewMethodCall(model.getViewRepresentation(), model.getViewValue());
initCall = creator.wrapInTryCatch(initCall);
// The execute call might fire the completed event again in some browsers!
m_initialized = true;
m_browser.execute(initCall);
}
}
@Override
public void changed(final ProgressEvent event) {
// do nothing
}
});
setBrowserURL();
}
});
}
use of org.eclipse.swt.layout.RowLayout in project yamcs-studio by yamcs.
the class ImportPastCommandsDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout(2, false);
layout.marginHeight = 20;
layout.marginWidth = 20;
layout.verticalSpacing = 2;
container.setLayout(layout);
Label lbl = new Label(container, SWT.NONE);
lbl.setText("Start:");
Composite startComposite = new Composite(container, SWT.NONE);
RowLayout rl = new RowLayout();
rl.marginLeft = 0;
rl.marginTop = 0;
rl.marginBottom = 0;
rl.center = true;
startComposite.setLayout(rl);
startDate = new DateTime(startComposite, SWT.DATE | SWT.LONG | SWT.DROP_DOWN | SWT.BORDER);
startDate.addListener(SWT.Selection, e -> validate());
startTime = new DateTime(startComposite, SWT.TIME | SWT.LONG | SWT.BORDER);
startTime.addListener(SWT.Selection, e -> validate());
if (startTimeValue != null) {
startDate.setDate(startTimeValue.get(Calendar.YEAR), startTimeValue.get(Calendar.MONTH), startTimeValue.get(Calendar.DAY_OF_MONTH));
startTime.setTime(startTimeValue.get(Calendar.HOUR_OF_DAY), startTimeValue.get(Calendar.MINUTE), startTimeValue.get(Calendar.SECOND));
}
lbl = new Label(container, SWT.NONE);
lbl.setText("Stop:");
Composite stopComposite = new Composite(container, SWT.NONE);
rl = new RowLayout();
rl.marginLeft = 0;
rl.marginTop = 0;
rl.marginBottom = 0;
rl.center = true;
rl.fill = true;
stopComposite.setLayout(rl);
stopDate = new DateTime(stopComposite, SWT.DATE | SWT.LONG | SWT.DROP_DOWN | SWT.BORDER);
stopDate.addListener(SWT.Selection, e -> validate());
stopTime = new DateTime(stopComposite, SWT.TIME | SWT.LONG | SWT.BORDER);
stopTime.addListener(SWT.Selection, e -> validate());
if (stopTimeValue != null) {
stopDate.setDate(stopTimeValue.get(Calendar.YEAR), stopTimeValue.get(Calendar.MONTH), stopTimeValue.get(Calendar.DAY_OF_MONTH));
stopTime.setTime(stopTimeValue.get(Calendar.HOUR_OF_DAY), stopTimeValue.get(Calendar.MINUTE), stopTimeValue.get(Calendar.SECOND));
}
return container;
}
use of org.eclipse.swt.layout.RowLayout in project yamcs-studio by yamcs.
the class CreateAnnotationDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout(2, false);
layout.marginHeight = 20;
layout.marginWidth = 20;
layout.verticalSpacing = 2;
container.setLayout(layout);
Label lbl = new Label(container, SWT.NONE);
lbl.setText("Name");
Composite tagAndColorWrapper = new Composite(container, SWT.NONE);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
tagAndColorWrapper.setLayoutData(gd);
GridLayout gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
tagAndColorWrapper.setLayout(gl);
tag = new Text(tagAndColorWrapper, SWT.BORDER);
tag.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
tag.setText(tagValue);
// Some ugly tricks to get a border around a label, which should have been a button in the first place
// but at least OSX doesn't support buttons with custom backgrounds. May be getting time to draw GC ourselves..
Composite labelBorder = new Composite(tagAndColorWrapper, SWT.BORDER);
labelBorder.setLayout(new FillLayout());
colorSelector = new Label(labelBorder, SWT.NONE);
colorSelector.setText(" ");
colorSelector.setCursor(handCursor);
colorSelector.setBackground(resourceManager.createColor(colorValue));
colorSelector.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
ColorDialog colorDialog = new ColorDialog(colorSelector.getShell());
colorDialog.setRGB(colorSelector.getBackground().getRGB());
RGB newColor = colorDialog.open();
if (newColor != null)
colorSelector.setBackground(resourceManager.createColor(newColor));
}
});
lbl = new Label(container, SWT.NONE);
lbl.setText("Description");
gd = new GridData();
gd.verticalAlignment = SWT.TOP;
lbl.setLayoutData(gd);
description = new Text(container, SWT.MULTI | SWT.BORDER);
gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = description.getLineHeight() * 3;
description.setLayoutData(gd);
description.setText(descriptionValue);
Composite startLabelWrapper = new Composite(container, SWT.NONE);
gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
startLabelWrapper.setLayout(gl);
lbl = new Label(startLabelWrapper, SWT.NONE);
lbl.setText("Start");
startClosed = new Button(startLabelWrapper, SWT.CHECK | SWT.NONE);
startClosed.setSelection(true);
startClosed.addListener(SWT.Selection, e -> {
startDate.setVisible(startClosed.getSelection());
startTime.setVisible(startClosed.getSelection());
validate();
});
Composite startComposite = new Composite(container, SWT.NONE);
RowLayout rl = new RowLayout();
rl.marginLeft = 0;
rl.marginTop = 0;
rl.marginBottom = 0;
rl.center = true;
startComposite.setLayout(rl);
startDate = new DateTime(startComposite, SWT.DATE | SWT.LONG | SWT.DROP_DOWN | SWT.BORDER);
startDate.addListener(SWT.Selection, e -> validate());
startTime = new DateTime(startComposite, SWT.TIME | SWT.LONG | SWT.BORDER);
startTime.addListener(SWT.Selection, e -> validate());
if (startTimeValue != null) {
startDate.setDate(startTimeValue.get(Calendar.YEAR), startTimeValue.get(Calendar.MONTH), startTimeValue.get(Calendar.DAY_OF_MONTH));
startTime.setTime(startTimeValue.get(Calendar.HOUR_OF_DAY), startTimeValue.get(Calendar.MINUTE), startTimeValue.get(Calendar.SECOND));
}
Composite stopLabelWrapper = new Composite(container, SWT.NONE);
gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
stopLabelWrapper.setLayout(gl);
lbl = new Label(stopLabelWrapper, SWT.NONE);
lbl.setText("Stop");
stopClosed = new Button(stopLabelWrapper, SWT.CHECK | SWT.NONE);
stopClosed.setSelection(true);
stopClosed.addListener(SWT.Selection, e -> {
stopDate.setVisible(stopClosed.getSelection());
stopTime.setVisible(stopClosed.getSelection());
validate();
});
Composite stopComposite = new Composite(container, SWT.NONE);
rl = new RowLayout();
rl.marginLeft = 0;
rl.marginTop = 0;
rl.marginBottom = 0;
rl.center = true;
rl.fill = true;
stopComposite.setLayout(rl);
stopDate = new DateTime(stopComposite, SWT.DATE | SWT.LONG | SWT.DROP_DOWN | SWT.BORDER);
stopDate.addListener(SWT.Selection, e -> validate());
stopTime = new DateTime(stopComposite, SWT.TIME | SWT.LONG | SWT.BORDER);
stopTime.addListener(SWT.Selection, e -> validate());
if (stopTimeValue != null) {
stopDate.setDate(stopTimeValue.get(Calendar.YEAR), stopTimeValue.get(Calendar.MONTH), stopTimeValue.get(Calendar.DAY_OF_MONTH));
stopTime.setTime(stopTimeValue.get(Calendar.HOUR_OF_DAY), stopTimeValue.get(Calendar.MINUTE), stopTimeValue.get(Calendar.SECOND));
}
return container;
}
use of org.eclipse.swt.layout.RowLayout in project yamcs-studio by yamcs.
the class CreateReplayDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout(2, false);
layout.marginHeight = 20;
layout.marginWidth = 20;
layout.verticalSpacing = 2;
container.setLayout(layout);
Label lbl = new Label(container, SWT.NONE);
lbl.setText("Start At:");
Composite startComposite = new Composite(container, SWT.NONE);
RowLayout rl = new RowLayout();
rl.marginLeft = 0;
rl.marginTop = 0;
rl.marginBottom = 0;
rl.center = true;
startComposite.setLayout(rl);
startDate = new DateTime(startComposite, SWT.DATE | SWT.LONG | SWT.DROP_DOWN | SWT.BORDER);
startTime = new DateTime(startComposite, SWT.TIME | SWT.LONG | SWT.BORDER);
if (startTimeValue != null) {
startDate.setDate(startTimeValue.get(Calendar.YEAR), startTimeValue.get(Calendar.MONTH), startTimeValue.get(Calendar.DAY_OF_MONTH));
startTime.setTime(startTimeValue.get(Calendar.HOUR_OF_DAY), startTimeValue.get(Calendar.MINUTE), startTimeValue.get(Calendar.SECOND));
}
lbl = new Label(container, SWT.NONE);
lbl.setText("Name:");
name = new Text(container, SWT.BORDER);
name.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
name.setText(nameValue);
return container;
}
use of org.eclipse.swt.layout.RowLayout in project yamcs-studio by yamcs.
the class CustomizeRangeDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout(2, false);
layout.marginHeight = 20;
layout.marginWidth = 20;
layout.verticalSpacing = 2;
container.setLayout(layout);
Composite startLabelWrapper = new Composite(container, SWT.NONE);
GridLayout gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
startLabelWrapper.setLayout(gl);
Label lbl = new Label(startLabelWrapper, SWT.NONE);
lbl.setText("Start");
startClosed = new Button(startLabelWrapper, SWT.CHECK | SWT.NONE);
startClosed.addListener(SWT.Selection, e -> {
startDate.setVisible(startClosed.getSelection());
startTime.setVisible(startClosed.getSelection());
validate();
});
startClosed.setSelection(startClosedValue);
Composite startComposite = new Composite(container, SWT.NONE);
RowLayout rl = new RowLayout();
rl.marginLeft = 0;
rl.marginTop = 0;
rl.marginBottom = 0;
rl.center = true;
startComposite.setLayout(rl);
startDate = new DateTime(startComposite, SWT.DATE | SWT.LONG | SWT.DROP_DOWN | SWT.BORDER);
startDate.addListener(SWT.Selection, e -> validate());
startTime = new DateTime(startComposite, SWT.TIME | SWT.LONG | SWT.BORDER);
startTime.addListener(SWT.Selection, e -> validate());
if (startTimeValue != null) {
startDate.setDate(startTimeValue.get(Calendar.YEAR), startTimeValue.get(Calendar.MONTH), startTimeValue.get(Calendar.DAY_OF_MONTH));
startTime.setTime(startTimeValue.get(Calendar.HOUR_OF_DAY), startTimeValue.get(Calendar.MINUTE), startTimeValue.get(Calendar.SECOND));
}
startDate.setVisible(startClosedValue);
startTime.setVisible(startClosedValue);
Composite stopLabelWrapper = new Composite(container, SWT.NONE);
gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
stopLabelWrapper.setLayout(gl);
lbl = new Label(stopLabelWrapper, SWT.NONE);
lbl.setText("Stop");
stopClosed = new Button(stopLabelWrapper, SWT.CHECK | SWT.NONE);
stopClosed.addListener(SWT.Selection, e -> {
stopDate.setVisible(stopClosed.getSelection());
stopTime.setVisible(stopClosed.getSelection());
validate();
});
stopClosed.setSelection(stopClosedValue);
Composite stopComposite = new Composite(container, SWT.NONE);
rl = new RowLayout();
rl.marginLeft = 0;
rl.marginTop = 0;
rl.marginBottom = 0;
rl.center = true;
rl.fill = true;
stopComposite.setLayout(rl);
stopDate = new DateTime(stopComposite, SWT.DATE | SWT.LONG | SWT.DROP_DOWN | SWT.BORDER);
stopDate.addListener(SWT.Selection, e -> validate());
stopTime = new DateTime(stopComposite, SWT.TIME | SWT.LONG | SWT.BORDER);
stopTime.addListener(SWT.Selection, e -> validate());
if (stopTimeValue != null) {
stopDate.setDate(stopTimeValue.get(Calendar.YEAR), stopTimeValue.get(Calendar.MONTH), stopTimeValue.get(Calendar.DAY_OF_MONTH));
stopTime.setTime(stopTimeValue.get(Calendar.HOUR_OF_DAY), stopTimeValue.get(Calendar.MINUTE), stopTimeValue.get(Calendar.SECOND));
}
stopDate.setVisible(stopClosedValue);
stopTime.setVisible(stopClosedValue);
return container;
}
Aggregations