use of org.eclipse.swt.widgets.FontDialog 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.FontDialog 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.FontDialog in project eclipse.platform.swt by eclipse.
the class DialogTab method createControlWidgets.
/**
* Creates the "Control" widget children.
*/
@Override
void createControlWidgets() {
/* Create the combo */
String[] strings = { ControlExample.getResourceString("ColorDialog"), ControlExample.getResourceString("DirectoryDialog"), ControlExample.getResourceString("FileDialog"), ControlExample.getResourceString("FontDialog"), ControlExample.getResourceString("PrintDialog"), ControlExample.getResourceString("MessageBox") };
dialogCombo = new Combo(dialogStyleGroup, SWT.READ_ONLY);
dialogCombo.setItems(strings);
dialogCombo.setText(strings[0]);
dialogCombo.setVisibleItemCount(strings.length);
/* Create the create dialog button */
createButton = new Button(dialogStyleGroup, SWT.NONE);
createButton.setText(ControlExample.getResourceString("Create_Dialog"));
createButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
/* Create a group for the various dialog button style controls */
Group buttonStyleGroup = new Group(controlGroup, SWT.NONE);
buttonStyleGroup.setLayout(new GridLayout());
buttonStyleGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
buttonStyleGroup.setText(ControlExample.getResourceString("Button_Styles"));
/* Create the button style buttons */
okButton = new Button(buttonStyleGroup, SWT.CHECK);
okButton.setText("SWT.OK");
cancelButton = new Button(buttonStyleGroup, SWT.CHECK);
cancelButton.setText("SWT.CANCEL");
yesButton = new Button(buttonStyleGroup, SWT.CHECK);
yesButton.setText("SWT.YES");
noButton = new Button(buttonStyleGroup, SWT.CHECK);
noButton.setText("SWT.NO");
retryButton = new Button(buttonStyleGroup, SWT.CHECK);
retryButton.setText("SWT.RETRY");
abortButton = new Button(buttonStyleGroup, SWT.CHECK);
abortButton.setText("SWT.ABORT");
ignoreButton = new Button(buttonStyleGroup, SWT.CHECK);
ignoreButton.setText("SWT.IGNORE");
/* Create a group for the icon style controls */
Group iconStyleGroup = new Group(controlGroup, SWT.NONE);
iconStyleGroup.setLayout(new GridLayout());
iconStyleGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
iconStyleGroup.setText(ControlExample.getResourceString("Icon_Styles"));
/* Create the icon style buttons */
iconErrorButton = new Button(iconStyleGroup, SWT.RADIO);
iconErrorButton.setText("SWT.ICON_ERROR");
iconInformationButton = new Button(iconStyleGroup, SWT.RADIO);
iconInformationButton.setText("SWT.ICON_INFORMATION");
iconQuestionButton = new Button(iconStyleGroup, SWT.RADIO);
iconQuestionButton.setText("SWT.ICON_QUESTION");
iconWarningButton = new Button(iconStyleGroup, SWT.RADIO);
iconWarningButton.setText("SWT.ICON_WARNING");
iconWorkingButton = new Button(iconStyleGroup, SWT.RADIO);
iconWorkingButton.setText("SWT.ICON_WORKING");
noIconButton = new Button(iconStyleGroup, SWT.RADIO);
noIconButton.setText(ControlExample.getResourceString("No_Icon"));
/* Create a group for the modal style controls */
Group modalStyleGroup = new Group(controlGroup, SWT.NONE);
modalStyleGroup.setLayout(new GridLayout());
modalStyleGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
modalStyleGroup.setText(ControlExample.getResourceString("Modal_Styles"));
/* Create the modal style buttons */
primaryModalButton = new Button(modalStyleGroup, SWT.RADIO);
primaryModalButton.setText("SWT.PRIMARY_MODAL");
applicationModalButton = new Button(modalStyleGroup, SWT.RADIO);
applicationModalButton.setText("SWT.APPLICATION_MODAL");
systemModalButton = new Button(modalStyleGroup, SWT.RADIO);
systemModalButton.setText("SWT.SYSTEM_MODAL");
/* Create a group for the file dialog style controls */
Group fileDialogStyleGroup = new Group(controlGroup, SWT.NONE);
fileDialogStyleGroup.setLayout(new GridLayout());
fileDialogStyleGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
fileDialogStyleGroup.setText(ControlExample.getResourceString("File_Dialog_Styles"));
/* Create the file dialog style buttons */
openButton = new Button(fileDialogStyleGroup, SWT.RADIO);
openButton.setText("SWT.OPEN");
saveButton = new Button(fileDialogStyleGroup, SWT.RADIO);
saveButton.setText("SWT.SAVE");
multiButton = new Button(fileDialogStyleGroup, SWT.CHECK);
multiButton.setText("SWT.MULTI");
/* Create the orientation group */
if (RTL_SUPPORT_ENABLE) {
createOrientationGroup();
}
/* Create a group for other style and setting controls */
Group otherGroup = new Group(controlGroup, SWT.NONE);
otherGroup.setLayout(new GridLayout());
otherGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
otherGroup.setText(ControlExample.getResourceString("Other"));
/* Create the other style and setting controls */
sheetButton = new Button(otherGroup, SWT.CHECK);
sheetButton.setText("SWT.SHEET");
usePreviousResultButton = new Button(otherGroup, SWT.CHECK);
usePreviousResultButton.setText(ControlExample.getResourceString("Use_Previous_Result"));
effectsVisibleButton = new Button(otherGroup, SWT.CHECK);
effectsVisibleButton.setText("FontDialog.setEffectsVisible");
/* Add the listeners */
dialogCombo.addSelectionListener(widgetSelectedAdapter(event -> dialogSelected(event)));
createButton.addSelectionListener(widgetSelectedAdapter(event -> createButtonSelected(event)));
SelectionListener buttonStyleListener = widgetSelectedAdapter(event -> buttonStyleSelected(event));
okButton.addSelectionListener(buttonStyleListener);
cancelButton.addSelectionListener(buttonStyleListener);
yesButton.addSelectionListener(buttonStyleListener);
noButton.addSelectionListener(buttonStyleListener);
retryButton.addSelectionListener(buttonStyleListener);
abortButton.addSelectionListener(buttonStyleListener);
ignoreButton.addSelectionListener(buttonStyleListener);
/* Set default values for style buttons */
okButton.setEnabled(false);
cancelButton.setEnabled(false);
yesButton.setEnabled(false);
noButton.setEnabled(false);
retryButton.setEnabled(false);
abortButton.setEnabled(false);
ignoreButton.setEnabled(false);
iconErrorButton.setEnabled(false);
iconInformationButton.setEnabled(false);
iconQuestionButton.setEnabled(false);
iconWarningButton.setEnabled(false);
iconWorkingButton.setEnabled(false);
noIconButton.setEnabled(false);
saveButton.setEnabled(false);
openButton.setEnabled(false);
openButton.setSelection(true);
multiButton.setEnabled(false);
noIconButton.setSelection(true);
effectsVisibleButton.setEnabled(false);
effectsVisibleButton.setSelection(true);
}
use of org.eclipse.swt.widgets.FontDialog in project eclipse.platform.swt by eclipse.
the class TextEditor method createMenuBar.
void createMenuBar() {
Menu menu = new Menu(shell, SWT.BAR);
shell.setMenuBar(menu);
MenuItem fileItem = new MenuItem(menu, SWT.CASCADE);
Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
// $NON-NLS-1$
fileItem.setText(getResourceString("File_menuitem"));
fileItem.setMenu(fileMenu);
MenuItem openItem = new MenuItem(fileMenu, SWT.PUSH);
// $NON-NLS-1$
openItem.setText(getResourceString("Open_menuitem"));
openItem.addSelectionListener(widgetSelectedAdapter(event -> {
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
// $NON-NLS-1$
dialog.setFilterNames(new String[] { getResourceString("Text_Documents") });
// $NON-NLS-1$
dialog.setFilterExtensions(new String[] { "*.txt" });
String name = dialog.open();
if (name == null)
return;
fileName = name;
try (FileInputStream file = new FileInputStream(name)) {
styledText.setText(openFile(file));
} catch (IOException e) {
// $NON-NLS-1$
showError(getResourceString("Error"), e.getMessage());
}
}));
final MenuItem saveItem = new MenuItem(fileMenu, SWT.PUSH);
// $NON-NLS-1$
saveItem.setText(getResourceString("Save_menuitem"));
saveItem.addSelectionListener(widgetSelectedAdapter(event -> saveFile()));
fileMenu.addMenuListener(new MenuAdapter() {
@Override
public void menuShown(MenuEvent event) {
saveItem.setEnabled(fileName != null);
}
});
MenuItem saveAsItem = new MenuItem(fileMenu, SWT.PUSH);
// $NON-NLS-1$
saveAsItem.setText(getResourceString("SaveAs_menuitem"));
saveAsItem.addSelectionListener(widgetSelectedAdapter(event -> {
FileDialog dialog = new FileDialog(shell, SWT.SAVE);
// $NON-NLS-1$
dialog.setFilterNames(new String[] { getResourceString("Text_Documents") });
// $NON-NLS-1$
dialog.setFilterExtensions(new String[] { "*.txt" });
if (fileName != null)
dialog.setFileName(fileName);
String name = dialog.open();
if (name != null) {
fileName = name;
saveFile();
}
}));
new MenuItem(fileMenu, SWT.SEPARATOR);
MenuItem exitItem = new MenuItem(fileMenu, SWT.PUSH);
// $NON-NLS-1$
exitItem.setText(getResourceString("Exit_menuitem"));
exitItem.addSelectionListener(widgetSelectedAdapter(event -> shell.dispose()));
MenuItem editItem = new MenuItem(menu, SWT.CASCADE);
final Menu editMenu = new Menu(shell, SWT.DROP_DOWN);
// $NON-NLS-1$
editItem.setText(getResourceString("Edit_menuitem"));
editItem.setMenu(editMenu);
final MenuItem cutItem = new MenuItem(editMenu, SWT.PUSH);
// $NON-NLS-1$
cutItem.setText(getResourceString("Cut_menuitem"));
cutItem.setImage(iCut);
cutItem.setAccelerator(SWT.MOD1 | 'x');
cutItem.addSelectionListener(widgetSelectedAdapter(event -> styledText.cut()));
final MenuItem copyItem = new MenuItem(editMenu, SWT.PUSH);
// $NON-NLS-1$
copyItem.setText(getResourceString("Copy_menuitem"));
copyItem.setImage(iCopy);
copyItem.setAccelerator(SWT.MOD1 | 'c');
copyItem.addSelectionListener(widgetSelectedAdapter(event -> styledText.copy()));
MenuItem pasteItem = new MenuItem(editMenu, SWT.PUSH);
// $NON-NLS-1$
pasteItem.setText(getResourceString("Paste_menuitem"));
pasteItem.setImage(iPaste);
pasteItem.setAccelerator(SWT.MOD1 | 'v');
pasteItem.addSelectionListener(widgetSelectedAdapter(event -> styledText.paste()));
new MenuItem(editMenu, SWT.SEPARATOR);
final MenuItem selectAllItem = new MenuItem(editMenu, SWT.PUSH);
// $NON-NLS-1$
selectAllItem.setText(getResourceString("SelectAll_menuitem"));
selectAllItem.setAccelerator(SWT.MOD1 | 'a');
selectAllItem.addSelectionListener(widgetSelectedAdapter(event -> styledText.selectAll()));
editMenu.addMenuListener(menuShownAdapter(event -> {
int selectionCount = styledText.getSelectionCount();
cutItem.setEnabled(selectionCount > 0);
copyItem.setEnabled(selectionCount > 0);
selectAllItem.setEnabled(selectionCount < styledText.getCharCount());
}));
MenuItem wrapItem = new MenuItem(editMenu, SWT.CHECK);
// $NON-NLS-1$
wrapItem.setText(getResourceString("Wrap_menuitem"));
wrapItem.addSelectionListener(widgetSelectedAdapter(event -> {
MenuItem item = (MenuItem) event.widget;
boolean enabled = item.getSelection();
styledText.setWordWrap(enabled);
editMenu.getItem(6).setEnabled(enabled);
editMenu.getItem(8).setEnabled(enabled);
leftAlignmentItem.setEnabled(enabled);
centerAlignmentItem.setEnabled(enabled);
rightAlignmentItem.setEnabled(enabled);
justifyAlignmentItem.setEnabled(enabled);
blockSelectionItem.setEnabled(!enabled);
}));
MenuItem justifyItem = new MenuItem(editMenu, SWT.CHECK);
// $NON-NLS-1$
justifyItem.setText(getResourceString("Justify_menuitem"));
justifyItem.addSelectionListener(widgetSelectedAdapter(event -> {
MenuItem item = (MenuItem) event.widget;
styledText.setJustify(item.getSelection());
updateToolBar();
}));
justifyItem.setEnabled(false);
MenuItem setFontItem = new MenuItem(editMenu, SWT.PUSH);
// $NON-NLS-1$
setFontItem.setText(getResourceString("SetFont_menuitem"));
setFontItem.addSelectionListener(widgetSelectedAdapter(event -> {
FontDialog fontDialog = new FontDialog(shell);
fontDialog.setFontList(styledText.getFont().getFontData());
FontData data = fontDialog.open();
if (data != null) {
Font newFont = new Font(display, data);
styledText.setFont(newFont);
if (font != null)
font.dispose();
font = newFont;
updateToolBar();
}
}));
MenuItem alignmentItem = new MenuItem(editMenu, SWT.CASCADE);
// $NON-NLS-1$
alignmentItem.setText(getResourceString("Alignment_menuitem"));
Menu alignmentMenu = new Menu(shell, SWT.DROP_DOWN);
alignmentItem.setMenu(alignmentMenu);
final MenuItem leftAlignmentItem = new MenuItem(alignmentMenu, SWT.RADIO);
// $NON-NLS-1$
leftAlignmentItem.setText(getResourceString("Left_menuitem"));
leftAlignmentItem.setSelection(true);
leftAlignmentItem.addSelectionListener(widgetSelectedAdapter(event -> {
styledText.setAlignment(SWT.LEFT);
updateToolBar();
}));
alignmentItem.setEnabled(false);
final MenuItem centerAlignmentItem = new MenuItem(alignmentMenu, SWT.RADIO);
// $NON-NLS-1$
centerAlignmentItem.setText(getResourceString("Center_menuitem"));
centerAlignmentItem.addSelectionListener(widgetSelectedAdapter(event -> {
styledText.setAlignment(SWT.CENTER);
updateToolBar();
}));
MenuItem rightAlignmentItem = new MenuItem(alignmentMenu, SWT.RADIO);
// $NON-NLS-1$
rightAlignmentItem.setText(getResourceString("Right_menuitem"));
rightAlignmentItem.addSelectionListener(widgetSelectedAdapter(event -> {
styledText.setAlignment(SWT.RIGHT);
updateToolBar();
}));
MenuItem editOrientationItem = new MenuItem(editMenu, SWT.CASCADE);
// $NON-NLS-1$
editOrientationItem.setText(getResourceString("Orientation_menuitem"));
Menu editOrientationMenu = new Menu(shell, SWT.DROP_DOWN);
editOrientationItem.setMenu(editOrientationMenu);
MenuItem leftToRightItem = new MenuItem(editOrientationMenu, SWT.RADIO);
// $NON-NLS-1$
leftToRightItem.setText(getResourceString("LeftToRight_menuitem"));
leftToRightItem.addSelectionListener(widgetSelectedAdapter(event -> styledText.setOrientation(SWT.LEFT_TO_RIGHT)));
leftToRightItem.setSelection(true);
MenuItem rightToLeftItem = new MenuItem(editOrientationMenu, SWT.RADIO);
// $NON-NLS-1$
rightToLeftItem.setText(getResourceString("RightToLeft_menuitem"));
rightToLeftItem.addSelectionListener(widgetSelectedAdapter(event -> styledText.setOrientation(SWT.RIGHT_TO_LEFT)));
new MenuItem(editMenu, SWT.SEPARATOR);
MenuItem insertObjectItem = new MenuItem(editMenu, SWT.CASCADE);
// $NON-NLS-1$
insertObjectItem.setText(getResourceString("InsertObject_menuitem"));
Menu insertObjectMenu = new Menu(shell, SWT.DROP_DOWN);
insertObjectItem.setMenu(insertObjectMenu);
MenuItem insertControlItem = new MenuItem(insertObjectMenu, SWT.CASCADE);
// $NON-NLS-1$
insertControlItem.setText(getResourceString("Controls_menuitem"));
Menu controlChoice = new Menu(shell, SWT.DROP_DOWN);
insertControlItem.setMenu(controlChoice);
MenuItem buttonItem = new MenuItem(controlChoice, SWT.PUSH);
// $NON-NLS-1$
buttonItem.setText(getResourceString("Button_menuitem"));
MenuItem comboItem = new MenuItem(controlChoice, SWT.PUSH);
// $NON-NLS-1$
comboItem.setText(getResourceString("Combo_menuitem"));
buttonItem.addSelectionListener(widgetSelectedAdapter(event -> {
Button button = new Button(styledText, SWT.PUSH);
// $NON-NLS-1$
button.setText(getResourceString("Button_menuitem"));
addControl(button);
}));
comboItem.addSelectionListener(widgetSelectedAdapter(event -> {
Combo combo = new Combo(styledText, SWT.NONE);
// $NON-NLS-1$
combo.setText(getResourceString("Combo_menuitem"));
addControl(combo);
}));
MenuItem insertImageItem = new MenuItem(insertObjectMenu, SWT.PUSH);
// $NON-NLS-1$
insertImageItem.setText(getResourceString("Image_menuitem"));
insertImageItem.addSelectionListener(widgetSelectedAdapter(event -> {
FileDialog fileDialog = new FileDialog(shell, SWT.OPEN);
String fileName = fileDialog.open();
if (fileName != null) {
try {
Image image = new Image(display, fileName);
addImage(image);
} catch (Exception e) {
// $NON-NLS-1$
showError(getResourceString("Bad_image"), e.getMessage());
}
}
}));
if (SAMPLE_TEXT) {
new MenuItem(editMenu, SWT.SEPARATOR);
MenuItem loadProfileItem = new MenuItem(editMenu, SWT.CASCADE);
// $NON-NLS-1$
loadProfileItem.setText(getResourceString("LoadProfile_menuitem"));
Menu loadProfileMenu = new Menu(shell, SWT.DROP_DOWN);
loadProfileItem.setMenu(loadProfileMenu);
SelectionListener adapter = widgetSelectedAdapter(event -> {
int profile = Integer.parseInt((String) event.widget.getData());
loadProfile(profile);
});
MenuItem profileItem = new MenuItem(loadProfileMenu, SWT.PUSH);
// $NON-NLS-1$
profileItem.setText(getResourceString("Profile1_menuitem"));
// $NON-NLS-1$
profileItem.setData("1");
profileItem.addSelectionListener(adapter);
profileItem = new MenuItem(loadProfileMenu, SWT.PUSH);
// $NON-NLS-1$
profileItem.setText(getResourceString("Profile2_menuitem"));
// $NON-NLS-1$
profileItem.setData("2");
profileItem.addSelectionListener(adapter);
profileItem = new MenuItem(loadProfileMenu, SWT.PUSH);
// $NON-NLS-1$
profileItem.setText(getResourceString("Profile3_menuitem"));
// $NON-NLS-1$
profileItem.setData("3");
profileItem.addSelectionListener(adapter);
profileItem = new MenuItem(loadProfileMenu, SWT.PUSH);
// $NON-NLS-1$
profileItem.setText(getResourceString("Profile4_menuitem"));
// $NON-NLS-1$
profileItem.setData("4");
profileItem.addSelectionListener(adapter);
}
}
use of org.eclipse.swt.widgets.FontDialog in project org.csstudio.display.builder by kasemir.
the class FontCellEditor method activate.
/**
* Opens the color dialog.
*/
@Override
public void activate() {
final FontDialog dialog = new FontDialog(shell);
if (value != null)
dialog.setFontList(new FontData[] { value });
value = dialog.open();
if (value != null)
fireApplyEditorValue();
}
Aggregations