use of org.eclipse.swt.widgets.Display in project bndtools by bndtools.
the class LaunchStatusHandler method handleStatus.
public Boolean handleStatus(final IStatus status, Object source) throws CoreException {
if (status.isOK())
return true;
final AtomicBoolean result = new AtomicBoolean();
Runnable uitask = new Runnable() {
public void run() {
LaunchStatusDialog dialog = new LaunchStatusDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), status);
int response = dialog.open();
result.set(response == Window.OK);
}
};
Display display = PlatformUI.getWorkbench().getDisplay();
if (display.getThread() == Thread.currentThread())
uitask.run();
else
display.syncExec(uitask);
return result.get();
}
use of org.eclipse.swt.widgets.Display in project bndtools by bndtools.
the class JAREntryPart method loadContent.
protected void loadContent() {
if (displayJob != null && displayJob.getState() != Job.NONE)
displayJob.cancel();
if (zipEntry != null && !zipEntry.isDirectory()) {
IEditorInput input = editor.getEditorInput();
final Display display = text.getDisplay();
final URI uri = URIHelper.retrieveFileURI(input);
if (uri != null) {
displayJob = new Job("Load zip content") {
@Override
protected IStatus run(IProgressMonitor monitor) {
File ioFile = new File(uri);
try (ZipFile zipFile = new ZipFile(ioFile)) {
final StringWriter writer = new StringWriter();
if (showAsText)
readAsText(zipFile, zipEntry, charsets[selectedCharset], writer, 1024 * 20, monitor);
else
readAsHex(zipFile, zipEntry, writer, 1024 * 20, 2, monitor);
display.asyncExec(new Runnable() {
@Override
public void run() {
setContent(writer.toString());
}
});
return Status.OK_STATUS;
} catch (IOException e) {
Status status = new Status(IStatus.ERROR, PluginConstants.PLUGIN_ID, 0, "I/O error reading JAR file contents", e);
// ErrorDialog.openError(getManagedForm().getForm().getShell(), "Error", null, status);
return status;
}
}
};
displayJob.schedule();
}
} else {
setContent("");
}
}
use of org.eclipse.swt.widgets.Display in project cogtool by cogtool.
the class WindowsImageTransfer method main.
public static void main(String[] args) throws Exception {
Display display = new Display();
Shell shell = new Shell(display);
Clipboard c = new Clipboard(display);
System.out.println("types on the clipboard: " + Arrays.asList(c.getAvailableTypeNames()));
Object o = c.getContents(WindowsImageTransfer.getInstance());
ImageData d = (ImageData) o;
if (d == null) {
System.out.println("no image found on clipboard. try hitting the printscreen key, or using MS Paint to put an image on the clipboard.");
return;
}
//Change what's on the clipboard to show we can also put images on the
// clipboard.
c.setContents(new Object[] { "howdy" }, new Transfer[] { TextTransfer.getInstance() });
System.out.println("types on the clipboard: " + Arrays.asList(c.getAvailableTypeNames()));
//now put the ImageData back onto the clipboard.
c.setContents(new Object[] { d }, new Transfer[] { WindowsImageTransfer.getInstance() });
System.out.println("types on the clipboard: " + Arrays.asList(c.getAvailableTypeNames()));
//now read the CF_DIB (ImageData) back off the clipboard.
// and display it by using it as the image for the button.
ImageData imgData = (ImageData) c.getContents(WindowsImageTransfer.getInstance());
Image img = new Image(display, imgData);
Button button = new Button(shell, SWT.NONE);
button.setImage(img);
shell.pack();
button.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
button.dispose();
}
use of org.eclipse.swt.widgets.Display in project translationstudio8 by heartsome.
the class TSTitleAreaDialog method createTitleArea.
/**
* Creates the dialog's title area.
*
* @param parent
* the SWT parent for the title area widgets
* @return Control with the highest x axis value.
*/
private Control createTitleArea(Composite parent) {
// add a dispose listener
parent.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
if (titleAreaColor != null) {
titleAreaColor.dispose();
}
}
});
// Determine the background color of the title bar
Display display = parent.getDisplay();
Color background;
Color foreground;
if (titleAreaRGB != null) {
titleAreaColor = new Color(display, titleAreaRGB);
background = titleAreaColor;
foreground = null;
} else {
background = JFaceColors.getBannerBackground(display);
foreground = JFaceColors.getBannerForeground(display);
}
parent.setBackground(background);
int verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
int horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
// Dialog image @ right
titleImageLabel = new Label(parent, SWT.CENTER);
titleImageLabel.setBackground(background);
if (titleAreaImage == null)
titleImageLabel.setImage(JFaceResources.getImage(DLG_IMG_TITLE_BANNER));
else
titleImageLabel.setImage(titleAreaImage);
FormData imageData = new FormData();
imageData.top = new FormAttachment(0, 0);
// Note: do not use horizontalSpacing on the right as that would be a
// regression from
// the R2.x style where there was no margin on the right and images are
// flush to the right
// hand side. see reopened comments in 41172
// horizontalSpacing
imageData.right = new FormAttachment(100, 0);
titleImageLabel.setLayoutData(imageData);
// Title label @ top, left
titleLabel = new Label(parent, SWT.LEFT);
JFaceColors.setColors(titleLabel, foreground, background);
titleLabel.setFont(JFaceResources.getBannerFont());
//$NON-NLS-1$
titleLabel.setText(" ");
FormData titleData = new FormData();
titleData.top = new FormAttachment(0, verticalSpacing);
titleData.right = new FormAttachment(titleImageLabel);
titleData.left = new FormAttachment(0, horizontalSpacing);
titleLabel.setLayoutData(titleData);
// Message image @ bottom, left
messageImageLabel = new Label(parent, SWT.CENTER);
messageImageLabel.setBackground(background);
// Message label @ bottom, center
messageLabel = new Label(parent, SWT.WRAP | SWT.READ_ONLY);
JFaceColors.setColors(messageLabel, foreground, background);
// two lines//$NON-NLS-1$
messageLabel.setText(" \n ");
messageLabel.setFont(JFaceResources.getDialogFont());
messageLabel.setBackground(JFaceColors.getBannerBackground(Display.getDefault()));
messageLabelHeight = messageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
// Filler labels
leftFillerLabel = new Label(parent, SWT.CENTER);
leftFillerLabel.setBackground(background);
bottomFillerLabel = new Label(parent, SWT.CENTER);
bottomFillerLabel.setBackground(background);
setLayoutsForNormalMessage(verticalSpacing, horizontalSpacing);
determineTitleImageLargest();
if (titleImageLargest)
return titleImageLabel;
return messageLabel;
}
use of org.eclipse.swt.widgets.Display in project translationstudio8 by heartsome.
the class InnerTag method main.
/**
* 各种标记绘制样式效果。
* @param args
* ;
*/
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setSize(800, 600);
GridLayout gl = new GridLayout();
shell.setLayout(gl);
//
// Color borderColor = new Color(display, 0, 255, 255);
// Color textBgColor = new Color(display, 0, 205, 205);
// Color indexBgColor = new Color(display, 0, 139, 139);
// Color textFgColor = new Color(display, 0, 104, 139);
// Color indexFgColor = borderColor;
//
// Font font = new Font(Display.getDefault(), "Arial", 8, SWT.BOLD);
//
// InnerTag tag1 = new InnerTag(shell, SWT.NONE, "<ph id=\"1\" /><this>& is a ph text.</ph>", "ph",
// 4333,
// STANDALONE, FULL);
// tag1.initColor(textFgColor, textBgColor, indexFgColor, indexBgColor, borderColor);
// tag1.setFont(font);
// tag1.pack();
//
// InnerTag tag2 = new InnerTag(shell, SWT.NONE, "<ph id=\"2\" />this is a ph text.</ph>", "ph", 2, STANDALONE,
// SIMPLE);
// tag2.initColor(textFgColor, textBgColor, indexFgColor, indexBgColor, borderColor);
// tag2.setFont(font);
// tag2.pack();
//
// InnerTag tag3 = new InnerTag(shell, SWT.NONE, "<ph id=\"3\" />this is a ph text.</ph>", "ph", 3, STANDALONE,
// INDEX);
// tag3.initColor(textFgColor, textBgColor, indexFgColor, indexBgColor, borderColor);
// tag3.setFont(font);
// tag3.pack();
//
// InnerTag tag4 = new InnerTag(shell, SWT.NONE, "<bx id=\"1\" />", "bx", 4, START, FULL);
// tag4.initColor(textFgColor, textBgColor, indexFgColor, indexBgColor, borderColor);
// tag4.setFont(font);
// tag4.pack();
//
// InnerTag tag5 = new InnerTag(shell, SWT.NONE, "<bx id=\"2\" />", "bx", 5, START, SIMPLE);
// tag5.initColor(textFgColor, textBgColor, indexFgColor, indexBgColor, borderColor);
// tag5.setFont(font);
// tag5.pack();
//
// InnerTag tag6 = new InnerTag(shell, SWT.NONE, "<bx id=\"3\" />", "bx", 6, START, INDEX);
// tag6.initColor(textFgColor, textBgColor, indexFgColor, indexBgColor, borderColor);
// tag6.setFont(font);
// tag6.pack();
//
// InnerTag tag7 = new InnerTag(shell, SWT.NONE, "<ex id=\"3\" />", "ex", 6, END, INDEX);
// tag7.initColor(textFgColor, textBgColor, indexFgColor, indexBgColor, borderColor);
// tag7.setFont(font);
// tag7.pack();
//
// InnerTag tag8 = new InnerTag(shell, SWT.NONE, "<ex id=\"2\" />", "ex", 5, END, SIMPLE);
// tag8.initColor(textFgColor, textBgColor, indexFgColor, indexBgColor, borderColor);
// tag8.setFont(font);
// tag8.pack();
// //
// InnerTagControl tag9 = new InnerTagControl(shell, SWT.NONE, "", "", 4, STANDALONE, TagStyle.FULL);
// tag9.initColor(textFgColor, textBgColor, indexFgColor, indexBgColor, borderColor);
// tag9.setFont(font);
// tag9.pack();
//
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
Aggregations