use of org.eclipse.swt.widgets.ColorDialog in project org.csstudio.display.builder by kasemir.
the class DataBrowserPropertySheetPage method createMiscTab.
/**
* Create tab for misc. config items (update period, colors)
* @param tabs
*/
private void createMiscTab(final TabFolder tab_folder) {
final TabItem misc_tab = new TabItem(tab_folder, 0);
misc_tab.setText(Messages.Miscellaneous);
final Composite parent = new Composite(tab_folder, 0);
parent.setLayout(new GridLayout(4, false));
// Title: ______ Title Font: [Sans|14|1]
Label label = new Label(parent, 0);
label.setText(Messages.TitleLbl);
label.setLayoutData(new GridData());
title = new Text(parent, SWT.BORDER);
title.setToolTipText(Messages.TitleTT);
title.setLayoutData(new GridData(SWT.FILL, 0, true, false));
title.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
new ChangeTitleCommand(model, operations_manager, title.getText());
}
});
label = new Label(parent, 0);
label.setText(Messages.TitleFontLbl);
label.setLayoutData(new GridData());
title_font = new Button(parent, SWT.PUSH);
title_font.setToolTipText(Messages.TitleFontTT);
title_font.setLayoutData(new GridData(SWT.FILL, 0, true, false));
title_font.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
final FontDialog dialog = new FontDialog(parent.getShell());
dialog.setFontList(new FontData[] { model.getTitleFont() });
final FontData selected = dialog.open();
if (selected != null)
new ChangeTitleFontCommand(model, operations_manager, selected);
}
});
// Redraw period: ______ Label Font: [Sans|10|2]
label = new Label(parent, 0);
label.setText(Messages.UpdatePeriodLbl);
label.setLayoutData(new GridData());
update_period = new Text(parent, SWT.BORDER);
update_period.setToolTipText(Messages.UpdatePeriodTT);
update_period.setLayoutData(new GridData(SWT.FILL, 0, true, false));
update_period.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
try {
final double period = Double.parseDouble(update_period.getText().trim());
new ChangeUpdatePeriodCommand(model, operations_manager, period);
} catch (Exception ex) {
update_period.setText(Double.toString(model.getUpdatePeriod()));
}
}
});
label = new Label(parent, 0);
label.setText(Messages.LabelFontLbl);
label.setLayoutData(new GridData());
label_font = new Button(parent, SWT.PUSH);
label_font.setToolTipText(Messages.LabelFontTT);
label_font.setLayoutData(new GridData(SWT.FILL, 0, true, false));
label_font.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
final FontDialog dialog = new FontDialog(parent.getShell());
dialog.setFontList(new FontData[] { model.getLabelFont() });
final FontData selected = dialog.open();
if (selected != null)
new ChangeLabelFontCommand(model, operations_manager, selected);
}
});
// Scroll Step [secs]: ______ Scale Font: [Sans|9|0]
label = new Label(parent, 0);
label.setText(Messages.ScrollStepLbl);
label.setLayoutData(new GridData());
scroll_step = new Text(parent, SWT.BORDER);
scroll_step.setToolTipText(Messages.ScrollStepTT);
scroll_step.setLayoutData(new GridData(SWT.FILL, 0, true, false));
scroll_step.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
try {
final Duration step = Duration.ofMillis(Math.round(Double.parseDouble(scroll_step.getText().trim()) * 1000.0));
new ChangeScrollStepCommand(model, operations_manager, step);
} catch (Exception ex) {
scroll_step.setText(Double.toString(model.getScrollStep().toMillis() / 1000.0));
}
}
});
label = new Label(parent, 0);
label.setText(Messages.ScaleFontLbl);
label.setLayoutData(new GridData());
scale_font = new Button(parent, SWT.PUSH);
scale_font.setToolTipText(Messages.AxesFontTT);
scale_font.setLayoutData(new GridData(SWT.FILL, 0, true, false));
scale_font.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
final FontDialog dialog = new FontDialog(parent.getShell());
dialog.setFontList(new FontData[] { model.getScaleFont() });
final FontData selected = dialog.open();
if (selected != null)
new ChangeScaleFontCommand(model, operations_manager, selected);
}
});
// Empty label to fill 2 grib boxes to alight the legend font below the rest of the fonts
label = new Label(parent, 0);
label = new Label(parent, 0);
label = new Label(parent, 0);
label.setText(Messages.LegendFontLbl);
label.setLayoutData(new GridData());
legend_font = new Button(parent, SWT.PUSH);
legend_font.setToolTipText(Messages.LegendFontTT);
legend_font.setLayoutData(new GridData(SWT.FILL, 0, true, false));
legend_font.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
final FontDialog dialog = new FontDialog(parent.getShell());
dialog.setFontList(new FontData[] { model.getLegendFont() });
final FontData selected = dialog.open();
if (selected != null)
new ChangeLegendFontCommand(model, operations_manager, selected);
}
});
// Background Color: ______
label = new Label(parent, 0);
label.setText(Messages.BackgroundColorLbl);
label.setLayoutData(new GridData());
background = new ColorBlob(parent, model.getPlotBackground());
background.setToolTipText(Messages.BackgroundColorTT);
final GridData gd = new GridData();
gd.minimumWidth = 80;
gd.widthHint = 80;
gd.heightHint = 15;
gd.horizontalSpan = 3;
background.setLayoutData(gd);
background.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
final ColorDialog dialog = new ColorDialog(parent.getShell());
dialog.setRGB(model.getPlotBackground());
final RGB value = dialog.open();
if (value != null)
new ChangePlotBackgroundCommand(model, operations_manager, value);
}
});
// Save Changes: [x]
label = new Label(parent, 0);
label.setText(Messages.SaveChangesLbl);
label.setLayoutData(new GridData());
save_changes = new Button(parent, SWT.CHECK);
save_changes.setToolTipText(Messages.SaveChangesTT);
save_changes.setLayoutData(new GridData(SWT.LEFT, 0, true, false, 3, 1));
save_changes.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
new ChangeSaveChangesCommand(model, operations_manager, save_changes.getSelection());
}
});
misc_tab.setControl(parent);
model_listener.changedTitle();
model_listener.changedColorsOrFonts();
model_listener.changedSaveChangesBehavior(model.shouldSaveChanges());
model_listener.changedTiming();
}
use of org.eclipse.swt.widgets.ColorDialog in project org.csstudio.display.builder by kasemir.
the class EditItemsDialog method createDialogArea.
@Override
protected Control createDialogArea(final Composite parent) {
final Composite composite = (Composite) super.createDialogArea(parent);
composite.setLayout(new GridLayout(3, false));
Label label = new Label(composite, SWT.NONE);
label.setText(Messages.ApplyChanges);
label.setLayoutData(new GridData(SWT.LEFT, 0, true, false, 3, 1));
// Show property
chkApplyShow = new Button(composite, SWT.CHECK);
chkApplyShow.setLayoutData(new GridData());
label = new Label(composite, SWT.NONE);
label.setText(Messages.TraceVisibility);
label.setLayoutData(new GridData());
chkShow = new Button(composite, SWT.CHECK);
chkShow.setToolTipText(Messages.TraceVisibilityTT);
if (!items.isEmpty())
chkShow.setSelection(items.get(0).isVisible());
chkShow.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
chkApplyShow.setSelection(true);
}
});
chkShow.setLayoutData(new GridData());
// Item property
chkApplyItem = new Button(composite, SWT.CHECK);
chkApplyItem.setLayoutData(new GridData());
label = new Label(composite, SWT.NONE);
label.setText(Messages.ItemName);
label.setLayoutData(new GridData());
textItem = new Text(composite, SWT.SINGLE | SWT.BORDER);
textItem.setToolTipText(Messages.ItemNameTT);
if (!items.isEmpty())
textItem.setText(items.get(0).getName());
textItem.addModifyListener((ModifyEvent e) -> chkApplyItem.setSelection(true));
textItem.setLayoutData(new GridData(SWT.FILL, 0, true, false));
// Display name property
chkApplyDisplayName = new Button(composite, SWT.CHECK);
chkApplyDisplayName.setLayoutData(new GridData());
label = new Label(composite, SWT.NONE);
label.setText(Messages.TraceDisplayName);
label.setLayoutData(new GridData());
textDisplayName = new Text(composite, SWT.SINGLE | SWT.BORDER);
textDisplayName.setToolTipText(Messages.TraceDisplayNameTT);
if (!items.isEmpty())
textDisplayName.setText(items.get(0).getDisplayName());
textDisplayName.addModifyListener((ModifyEvent e) -> chkApplyDisplayName.setSelection(true));
textDisplayName.setLayoutData(new GridData(SWT.FILL, 0, true, false));
// Color property
chkApplyColor = new Button(composite, SWT.CHECK);
chkApplyColor.setLayoutData(new GridData());
label = new Label(composite, SWT.NONE);
label.setText(Messages.Color);
label.setLayoutData(new GridData());
blobColor = new ColorBlob(composite, new RGB(0, 0, 0));
blobColor.setToolTipText(Messages.ColorTT);
// TODO: this should probably use Javafx color instead of SWT...
if (!items.isEmpty())
blobColor.setColor(SWTMediaPool.getRGB(items.get(0).getPaintColor()));
blobColor.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
ColorDialog dialog = new ColorDialog(getShell());
RGB color = dialog.open();
if (color != null) {
blobColor.setColor(color);
chkApplyColor.setSelection(true);
}
}
});
GridData gd = new GridData(SWT.LEFT, 0, true, false);
gd.widthHint = 40;
gd.heightHint = 15;
blobColor.setLayoutData(gd);
// Scan period property
chkApplyScan = new Button(composite, SWT.CHECK);
chkApplyScan.setLayoutData(new GridData());
label = new Label(composite, SWT.NONE);
label.setText(Messages.ScanPeriod);
label.setLayoutData(new GridData());
textScan = new Text(composite, SWT.SINGLE | SWT.BORDER);
textScan.setToolTipText(Messages.ScanPeriodTT);
boolean enableScan = false;
for (ModelItem item : items) {
if (item instanceof PVItem) {
textScan.setText(Double.toString(((PVItem) item).getScanPeriod()));
enableScan = true;
break;
}
}
chkApplyScan.setEnabled(enableScan);
textScan.setEnabled(enableScan);
textScan.addVerifyListener(new NumericalVerifyListener(textScan, true));
textScan.addModifyListener((ModifyEvent e) -> chkApplyScan.setSelection(true));
textScan.setLayoutData(new GridData(SWT.FILL, 0, true, false));
// Buffer size property
chkApplyBufferSize = new Button(composite, SWT.CHECK);
chkApplyBufferSize.setLayoutData(new GridData());
label = new Label(composite, SWT.NONE);
label.setText(Messages.LiveSampleBufferSize);
label.setLayoutData(new GridData());
textBufferSize = new Text(composite, SWT.SINGLE | SWT.BORDER);
boolean enableBufferSize = false;
for (ModelItem item : items) {
if (item instanceof PVItem) {
textBufferSize.setText(Integer.toString(((PVItem) item).getLiveCapacity()));
enableBufferSize = true;
break;
}
}
chkApplyBufferSize.setEnabled(enableBufferSize);
textBufferSize.setEnabled(enableBufferSize);
textBufferSize.addVerifyListener(new NumericalVerifyListener(textBufferSize, false));
textBufferSize.addModifyListener((ModifyEvent e) -> chkApplyBufferSize.setSelection(true));
textBufferSize.setLayoutData(new GridData(SWT.FILL, 0, true, false));
// Width property
chkApplyWidth = new Button(composite, SWT.CHECK);
chkApplyWidth.setLayoutData(new GridData());
label = new Label(composite, SWT.NONE);
label.setText(Messages.TraceLineWidth);
label.setLayoutData(new GridData());
textWidth = new Text(composite, SWT.SINGLE | SWT.BORDER);
textWidth.setToolTipText(Messages.TraceLineWidthTT);
if (!items.isEmpty())
textWidth.setText(Integer.toString(items.get(0).getLineWidth()));
textWidth.addVerifyListener(new NumericalVerifyListener(textWidth, false));
textWidth.addModifyListener((ModifyEvent e) -> chkApplyWidth.setSelection(true));
textWidth.setLayoutData(new GridData(SWT.FILL, 0, true, false));
// Axis property
chkApplyAxis = new Button(composite, SWT.CHECK);
chkApplyAxis.setLayoutData(new GridData());
label = new Label(composite, SWT.NONE);
label.setText(Messages.Axis);
label.setLayoutData(new GridData());
cmbAxis = new Combo(composite, SWT.READ_ONLY);
cmbAxis.setToolTipText(Messages.AxisTT);
int i = 0;
for (AxisConfig axis : axes) {
cmbAxis.add(axis.getName());
if (items.size() >= 0 && items.get(0).getAxisIndex() == i)
cmbAxis.select(i);
++i;
}
cmbAxis.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
chkApplyAxis.setSelection(true);
}
});
cmbAxis.setLayoutData(new GridData(SWT.FILL, 0, true, false));
// Trace type property
chkApplyTraceType = new Button(composite, SWT.CHECK);
chkApplyTraceType.setLayoutData(new GridData());
label = new Label(composite, SWT.NONE);
label.setText(Messages.TraceType);
label.setLayoutData(new GridData());
cmbTraceType = new Combo(composite, SWT.READ_ONLY);
cmbTraceType.setToolTipText(Messages.TraceTypeTT);
for (i = 0; i < TraceType.values().length; i++) {
TraceType type = TraceType.values()[i];
cmbTraceType.add(type.toString());
if (items.size() >= 1 && type == items.get(0).getTraceType())
cmbTraceType.select(i);
}
cmbTraceType.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
chkApplyTraceType.setSelection(true);
}
});
cmbTraceType.setLayoutData(new GridData(SWT.FILL, 0, true, false));
// Request property
chkApplyRequest = new Button(composite, SWT.CHECK);
chkApplyRequest.setLayoutData(new GridData());
label = new Label(composite, SWT.NONE);
label.setText(Messages.RequestType);
label.setLayoutData(new GridData());
cmbRequest = new Combo(composite, SWT.READ_ONLY);
cmbRequest.setToolTipText(Messages.RequestTypeTT);
RequestType defaultType = RequestType.OPTIMIZED;
boolean enableRequest = false;
for (ModelItem item : items) {
if (item instanceof PVItem) {
defaultType = ((PVItem) item).getRequestType();
enableRequest = true;
break;
}
}
chkApplyRequest.setEnabled(enableRequest);
cmbRequest.setEnabled(enableRequest);
if (enableRequest) {
for (i = 0; i < RequestType.values().length; i++) {
RequestType type = RequestType.values()[i];
cmbRequest.add(type.toString());
if (type == defaultType)
cmbRequest.select(i);
}
}
cmbRequest.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
chkApplyRequest.setSelection(true);
}
});
cmbRequest.setLayoutData(new GridData(SWT.FILL, 0, true, false));
// Index property
chkApplyIndex = new Button(composite, SWT.CHECK);
chkApplyIndex.setLayoutData(new GridData());
label = new Label(composite, SWT.NONE);
label.setText(Messages.WaveformIndex);
label.setLayoutData(new GridData());
textIndex = new Text(composite, SWT.SINGLE | SWT.BORDER);
textIndex.setToolTipText(Messages.WaveformIndexColTT);
if (!items.isEmpty())
textIndex.setText(Integer.toString(items.get(0).getWaveformIndex()));
textIndex.addVerifyListener(new NumericalVerifyListener(textIndex, false));
textIndex.addModifyListener((ModifyEvent e) -> chkApplyIndex.setSelection(true));
textIndex.setLayoutData(new GridData(SWT.FILL, 0, true, false));
return composite;
}
use of org.eclipse.swt.widgets.ColorDialog in project mdw-designer by CenturyLinkCloud.
the class ProcessDesignPreferencePage method createContents.
protected Control createContents(Composite parent) {
// allow delete archived processes
allowDeleteArchivedProcessesCheckbox = createCheckbox(parent, "Allow Drag/Delete of Archived Processes and Assets", 3);
// allow asset names without extensions
allowAssetNamesWithoutExtensionsCheckbox = createCheckbox(parent, "Allow Asset Names without Extensions (MDW <= 5.2)", 3);
// validate process versions
validateProcessVersionsCheckbox = createCheckbox(parent, "Validate Process Versions (VCS Assets, MDW < 6.0)", 3);
// double click to open subprocs and scripts
doubleClickOpensSubprocsAndScriptsCheckbox = createCheckbox(parent, "Double Click Opens Subprocesses and Scripts", 3);
// double click to open subprocs and scripts
inferSmartSubprocVersionSpecCheckbox = createCheckbox(parent, "Infer Smart Subprocess/Asset Version Spec (MDW >= 5.5)", 3);
// compare conflicting assets during import
compareConflictingAssetsCheckbox = createCheckbox(parent, "Compare Conflicting Assets during Import (MDW >= 5.2)", 3);
// internal editor for excel
embeddedEditorForExcelCheckbox = createCheckbox(parent, "Use Embedded Editor for Excel Spreadsheet Assets", 3);
// warn when override attributes will not be carried forward
warnOverrideAttrsNotCarriedForwardCheckbox = createCheckbox(parent, "Warn when Override Attributes not Carried Forward (VCS Assets)", 3);
createSpacer(parent, 2, 1);
Group resetGroup = new Group(parent, SWT.NONE);
resetGroup.setText("Reminder prompts when saving temporary artifacts");
GridLayout gl = new GridLayout();
gl.numColumns = 2;
resetGroup.setLayout(gl);
GridData gd = new GridData();
gd.horizontalAlignment = GridData.BEGINNING;
gd.widthHint = 400;
resetGroup.setLayoutData(gd);
Button resetArtifactNagButton = createButton(resetGroup, " Reset ");
resetArtifactNagButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
String prefsKey = "MdwDocumentationSuppressSaveNag";
prefsStore.setValue(prefsKey, false);
prefsKey = "MdwJava CodeSuppressSaveNag";
prefsStore.setValue(prefsKey, false);
prefsKey = "MdwScriptSuppressSaveNag";
prefsStore.setValue(prefsKey, false);
prefsKey = "MdwTransformSuppressSaveNag";
prefsStore.setValue(prefsKey, false);
}
});
createLabel(resetGroup, "(Remind me to save related processes)", 1);
createSpacer(parent, 2, 1);
Group readOnlyGroup = new Group(parent, SWT.NONE);
readOnlyGroup.setText("Background Color for Read-Only Processes");
gl = new GridLayout();
gl.numColumns = 2;
readOnlyGroup.setLayout(gl);
gd = new GridData();
gd.horizontalAlignment = GridData.BEGINNING;
gd.widthHint = 400;
readOnlyGroup.setLayoutData(gd);
colorDialog = new ColorDialog(getShell());
colorDialog.setText("Select the background color for read-only processes.");
Button colorDialogButton = createButton(readOnlyGroup, "Select...");
colorDialogButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
RGB bgRgb = colorDialog.open();
if (bgRgb != null)
readOnlyBackgroundRgb = bgRgb;
}
});
createLabel(readOnlyGroup, "(Requires Process Re-Open)", 1);
createSpacer(parent, 2, 1);
Group tempGroup = new Group(parent, SWT.NONE);
tempGroup.setText("Workspace Temporary Resources");
gl = new GridLayout();
gl.numColumns = 2;
tempGroup.setLayout(gl);
gd = new GridData();
gd.horizontalAlignment = GridData.BEGINNING;
gd.widthHint = 400;
tempGroup.setLayoutData(gd);
// temp resource location
createLabel(tempGroup, "Temp Location (relative to project folder)");
tempResourceLocationText = createTextField(tempGroup, 250, 2);
createSpacer(tempGroup, 2, 1);
// previous temp file versions to retain
previousTempFileVersionsSpinner = createSpinner(tempGroup, 1, 50);
createLabel(tempGroup, "Archive Versions of Temp Files to Retain", 1);
createSpacer(tempGroup, 2, 1);
// auto load script libraries on edit
loadScriptLibsOnEditCheckbox = createCheckbox(tempGroup, "Auto-Load Dynamic Java and Script Libraries on Edit", 2);
initializeValues();
return new Composite(parent, SWT.NULL);
}
use of org.eclipse.swt.widgets.ColorDialog in project mdw-designer by CenturyLinkCloud.
the class ServerConsolePreferencePage method createContents.
@Override
protected Control createContents(Composite parent) {
Composite composite = createComposite(parent, 1);
Group serverConsoleGroup = new Group(composite, SWT.NONE);
serverConsoleGroup.setText("Server Runner Console");
GridLayout gl = new GridLayout();
gl.numColumns = 2;
serverConsoleGroup.setLayout(gl);
GridData gd = new GridData();
gd.horizontalAlignment = GridData.BEGINNING;
gd.widthHint = 400;
serverConsoleGroup.setLayoutData(gd);
createSpacer(serverConsoleGroup, 2, 2);
createLabel(serverConsoleGroup, "Buffer Size (Chars)", 1);
bufferSizeText = createTextField(serverConsoleGroup, 150);
createSpacer(serverConsoleGroup, 2, 5);
fontDialog = new FontDialog(getShell());
fontDialog.setText("Select the font to display for Server Console output.");
Button fontDialogButton = createButton(serverConsoleGroup, "Output Font...");
fontDialogButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
FontData fd = fontDialog.open();
if (fd != null) {
fontData = fd;
fontRgb = fontDialog.getRGB();
}
}
});
colorDialog = new ColorDialog(getShell());
colorDialog.setText("Select the background color for Server Console output.");
Button colorDialogButton = createButton(serverConsoleGroup, "Background Color...");
colorDialogButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
RGB bgRgb = colorDialog.open();
if (bgRgb != null)
backgroundRgb = bgRgb;
}
});
createSpacer(serverConsoleGroup, 2, 2);
// client shell configuration
Group clientShellGroup = new Group(composite, SWT.NONE);
clientShellGroup.setText("Admin Shell Config");
gl = new GridLayout();
gl.numColumns = 3;
clientShellGroup.setLayout(gl);
gd = new GridData();
gd.horizontalAlignment = GridData.BEGINNING;
gd.widthHint = 400;
gd.verticalIndent = 5;
clientShellGroup.setLayoutData(gd);
karafClientRadio = new Button(clientShellGroup, SWT.RADIO | SWT.LEFT);
karafClientRadio.setText("SSH Client");
gd = new GridData(GridData.BEGINNING);
gd.horizontalSpan = 3;
karafClientRadio.setLayoutData(gd);
karafClientRadio.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean selected = karafClientRadio.getSelection();
if (selected) {
puttyExeText.setText("");
puttyExePath = null;
puttyExeText.setEnabled(false);
puttyExeBrowse.setEnabled(false);
clientShell = ClientShell.Karaf;
}
}
});
puttyClientRadio = new Button(clientShellGroup, SWT.RADIO | SWT.LEFT);
puttyClientRadio.setText("Putty Executable");
puttyClientRadio.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean selected = puttyClientRadio.getSelection();
if (selected) {
puttyExeText.setEnabled(true);
puttyExeBrowse.setEnabled(true);
clientShell = ClientShell.Putty;
}
}
});
puttyExeText = new Text(clientShellGroup, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.BEGINNING | GridData.FILL_HORIZONTAL);
puttyExeText.setLayoutData(gd);
puttyExeText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
puttyExePath = puttyExeText.getText().trim();
}
});
puttyExeBrowse = new Button(clientShellGroup, SWT.PUSH);
puttyExeBrowse.setText("Browse...");
puttyExeBrowse.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
FileDialog dlg = new FileDialog(getShell());
puttyExePath = dlg.open();
puttyExeText.setText(puttyExePath == null ? "" : puttyExePath);
}
});
initializeValues();
return new Composite(parent, SWT.NULL);
}
use of org.eclipse.swt.widgets.ColorDialog in project dbeaver by serge-rider.
the class SetPartColorAction method createColorCommand.
private Command createColorCommand(final Object[] objects) {
return new Command() {
private final Map<ICustomizablePart, Color> oldColors = new HashMap<>();
private Color newColor;
@Override
public void execute() {
final Shell shell = UIUtils.createCenteredShell(getWorkbenchPart().getSite().getShell());
try {
ColorDialog colorDialog = new ColorDialog(shell);
RGB color = colorDialog.open();
if (color == null) {
return;
}
newColor = new Color(Display.getCurrent(), color);
for (Object item : objects) {
if (item instanceof ICustomizablePart) {
ICustomizablePart colorizedPart = (ICustomizablePart) item;
oldColors.put(colorizedPart, colorizedPart.getCustomBackgroundColor());
colorizedPart.setCustomBackgroundColor(newColor);
}
}
} finally {
UIUtils.disposeCenteredShell(shell);
}
}
@Override
public void undo() {
for (Object item : objects) {
if (item instanceof ICustomizablePart) {
ICustomizablePart colorizedPart = (ICustomizablePart) item;
colorizedPart.setCustomBackgroundColor(oldColors.get(colorizedPart));
}
}
}
@Override
public void redo() {
for (Object item : objects) {
if (item instanceof ICustomizablePart) {
ICustomizablePart colorizedPart = (ICustomizablePart) item;
colorizedPart.setCustomBackgroundColor(newColor);
}
}
}
};
}
Aggregations