use of org.eclipse.swt.widgets.MessageBox in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_MessageBox method setUp.
@Override
@Before
public void setUp() {
super.setUp();
messageBox = new MessageBox(shell, SWT.NULL);
setDialog(messageBox);
}
use of org.eclipse.swt.widgets.MessageBox in project eclipse.platform.swt by eclipse.
the class FileViewer method doDefaultFileAction.
/**
* Performs the default action on a set of files.
*
* @param files the array of files to process
*/
void doDefaultFileAction(File[] files) {
// only uses the 1st file (for now)
if (files.length == 0)
return;
final File file = files[0];
if (file.isDirectory()) {
notifySelectedDirectory(file);
} else {
final String fileName = file.getAbsolutePath();
if (!Program.launch(fileName)) {
MessageBox dialog = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
dialog.setMessage(getResourceString("error.FailedLaunch.message", new Object[] { fileName }));
dialog.setText(shell.getText());
dialog.open();
}
}
}
use of org.eclipse.swt.widgets.MessageBox in project eclipse.platform.swt by eclipse.
the class FileViewer method createHelpMenu.
/**
* Creates the Help Menu.
*
* @param parent the parent menu
*/
private void createHelpMenu(Menu parent) {
Menu menu = new Menu(parent);
MenuItem header = new MenuItem(parent, SWT.CASCADE);
header.setText(getResourceString("menu.Help.text"));
header.setMenu(menu);
MenuItem item = new MenuItem(menu, SWT.PUSH);
item.setText(getResourceString("menu.Help.About.text"));
item.addSelectionListener(widgetSelectedAdapter(e -> {
MessageBox box = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
box.setText(getResourceString("dialog.About.title"));
box.setMessage(getResourceString("dialog.About.description", new Object[] { System.getProperty("os.name") }));
box.open();
}));
}
use of org.eclipse.swt.widgets.MessageBox in project eclipse.platform.swt by eclipse.
the class FileViewer method createToolBar.
/**
* Creates the toolbar
*
* @param shell the shell on which to attach the toolbar
* @param layoutData the layout data
*/
private void createToolBar(final Shell shell, Object layoutData) {
toolBar = new ToolBar(shell, SWT.NONE);
toolBar.setLayoutData(layoutData);
ToolItem item = new ToolItem(toolBar, SWT.SEPARATOR);
item = new ToolItem(toolBar, SWT.PUSH);
item.setImage(iconCache.stockImages[iconCache.cmdParent]);
item.setToolTipText(getResourceString("tool.Parent.tiptext"));
item.addSelectionListener(widgetSelectedAdapter(e -> doParent()));
item = new ToolItem(toolBar, SWT.PUSH);
item.setImage(iconCache.stockImages[iconCache.cmdRefresh]);
item.setToolTipText(getResourceString("tool.Refresh.tiptext"));
item.addSelectionListener(widgetSelectedAdapter(e -> doRefresh()));
SelectionListener unimplementedListener = widgetSelectedAdapter(e -> {
MessageBox box = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
box.setText(getResourceString("dialog.NotImplemented.title"));
box.setMessage(getResourceString("dialog.ActionNotImplemented.description"));
box.open();
});
item = new ToolItem(toolBar, SWT.SEPARATOR);
item = new ToolItem(toolBar, SWT.PUSH);
item.setImage(iconCache.stockImages[iconCache.cmdCut]);
item.setToolTipText(getResourceString("tool.Cut.tiptext"));
item.addSelectionListener(unimplementedListener);
item = new ToolItem(toolBar, SWT.PUSH);
item.setImage(iconCache.stockImages[iconCache.cmdCopy]);
item.setToolTipText(getResourceString("tool.Copy.tiptext"));
item.addSelectionListener(unimplementedListener);
item = new ToolItem(toolBar, SWT.PUSH);
item.setImage(iconCache.stockImages[iconCache.cmdPaste]);
item.setToolTipText(getResourceString("tool.Paste.tiptext"));
item.addSelectionListener(unimplementedListener);
item = new ToolItem(toolBar, SWT.SEPARATOR);
item = new ToolItem(toolBar, SWT.PUSH);
item.setImage(iconCache.stockImages[iconCache.cmdDelete]);
item.setToolTipText(getResourceString("tool.Delete.tiptext"));
item.addSelectionListener(unimplementedListener);
item = new ToolItem(toolBar, SWT.PUSH);
item.setImage(iconCache.stockImages[iconCache.cmdRename]);
item.setToolTipText(getResourceString("tool.Rename.tiptext"));
item.addSelectionListener(unimplementedListener);
item = new ToolItem(toolBar, SWT.SEPARATOR);
item = new ToolItem(toolBar, SWT.PUSH);
item.setImage(iconCache.stockImages[iconCache.cmdSearch]);
item.setToolTipText(getResourceString("tool.Search.tiptext"));
item.addSelectionListener(unimplementedListener);
item = new ToolItem(toolBar, SWT.PUSH);
item.setImage(iconCache.stockImages[iconCache.cmdPrint]);
item.setToolTipText(getResourceString("tool.Print.tiptext"));
item.addSelectionListener(unimplementedListener);
}
use of org.eclipse.swt.widgets.MessageBox in project eclipse.platform.swt by eclipse.
the class AdvancedGraphics method open.
public Shell open(final Display display) {
final Shell shell = new Shell(display);
// $NON-NLS-1$
shell.setText(RESOURCE_BUNDLE.getString("AdvancedGraphics"));
try {
Path path = new Path(display);
path.dispose();
} catch (SWTException e) {
MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
// $NON-NLS-1$
dialog.setText(RESOURCE_BUNDLE.getString("Warning"));
// $NON-NLS-1$
dialog.setMessage(RESOURCE_BUNDLE.getString("LibNotFound"));
dialog.open();
shell.dispose();
return null;
}
FontData fd = shell.getFont().getFontData()[0];
final Font font = new Font(display, fd.getName(), 96, SWT.BOLD | SWT.ITALIC);
final Image image = loadImage(display, AdvancedGraphics.class, "irmaos.jpg");
final Rectangle rect = image.getBounds();
shell.addListener(SWT.Paint, event -> {
GC gc = event.gc;
Transform tr = new Transform(display);
tr.translate(rect.width / 4, rect.height / 2);
tr.rotate(-30);
if (image != null) {
gc.drawImage(image, 0, 0, rect.width, rect.height, 0, 0, rect.width, rect.height);
}
gc.setAlpha(100);
gc.setTransform(tr);
Path path = new Path(display);
path.addString("SWT", 0, 0, font);
gc.setBackground(display.getSystemColor(SWT.COLOR_GREEN));
gc.setForeground(display.getSystemColor(SWT.COLOR_BLUE));
gc.fillPath(path);
gc.drawPath(path);
tr.dispose();
path.dispose();
});
shell.setSize(shell.computeSize(rect.width, rect.height));
shell.open();
shell.addListener(SWT.Dispose, event -> {
if (image != null)
image.dispose();
font.dispose();
});
return shell;
}
Aggregations