Search in sources :

Example 96 with Display

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();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Display(org.eclipse.swt.widgets.Display)

Example 97 with Display

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("");
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IOException(java.io.IOException) URI(java.net.URI) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ZipFile(java.util.zip.ZipFile) StringWriter(java.io.StringWriter) Job(org.eclipse.core.runtime.jobs.Job) ZipFile(java.util.zip.ZipFile) File(java.io.File) IEditorInput(org.eclipse.ui.IEditorInput) Display(org.eclipse.swt.widgets.Display)

Example 98 with Display

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();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) ImageData(org.eclipse.swt.graphics.ImageData) Clipboard(org.eclipse.swt.dnd.Clipboard) Image(org.eclipse.swt.graphics.Image) Display(org.eclipse.swt.widgets.Display)

Example 99 with Display

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;
}
Also used : FormData(org.eclipse.swt.layout.FormData) DisposeListener(org.eclipse.swt.events.DisposeListener) Color(org.eclipse.swt.graphics.Color) Label(org.eclipse.swt.widgets.Label) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Point(org.eclipse.swt.graphics.Point) FormAttachment(org.eclipse.swt.layout.FormAttachment) Display(org.eclipse.swt.widgets.Display)

Example 100 with Display

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\" />&lt;this&gt;&amp; 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();
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) Display(org.eclipse.swt.widgets.Display)

Aggregations

Display (org.eclipse.swt.widgets.Display)191 Shell (org.eclipse.swt.widgets.Shell)49 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)28 InvocationTargetException (java.lang.reflect.InvocationTargetException)25 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)22 Point (org.eclipse.swt.graphics.Point)17 ITask (com.cubrid.common.core.task.ITask)15 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)15 Color (org.eclipse.swt.graphics.Color)15 GridLayout (org.eclipse.swt.layout.GridLayout)14 Button (org.eclipse.swt.widgets.Button)14 FillLayout (org.eclipse.swt.layout.FillLayout)13 GridData (org.eclipse.swt.layout.GridData)12 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)11 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)11 IStatus (org.eclipse.core.runtime.IStatus)11 Status (org.eclipse.core.runtime.Status)11 Composite (org.eclipse.swt.widgets.Composite)11 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)10 ArrayList (java.util.ArrayList)10