Java 类org.eclipse.swt.SWTError 实例源码

项目:openaudible    文件:AudibleBrowser.java   
public AudibleBrowser(Composite parent, String url) {
    this.parent = parent;
    try {
        browser = new Browser(parent, SWT.BORDER);
        browser.addTitleListener(event -> getShell().setText(event.title));
    } catch (SWTError e) {
        error = e;
        /* Browser widget could not be instantiated */
        parent.setLayout(new FillLayout());
        Label label = new Label(parent, SWT.CENTER | SWT.WRAP);
        label.setText(getResourceString("BrowserNotCreated"));
        // label.requestLayout();
        return;
    }
    initResources();
    if (url.length() > 0)
        browser.setUrl(getResourceString(url));

    if (true)
        show(false, null, null, true, true, true, true);
    else
        show(false, null, null, false, false, false, false);

}
项目:gama    文件:CopyAction.java   
/**
 * Set the clipboard contents. Prompt to retry if clipboard is busy.
 *
 * @param resources
 *            the resources to copy to the clipboard
 * @param fileNames
 *            file names of the resources to copy to the clipboard
 * @param names
 *            string representation of all names
 */
private void setClipboard(final IResource[] resources, final String[] fileNames, final String names) {
    try {
        // set the clipboard contents
        if (fileNames.length > 0) {
            clipboard.setContents(new Object[] { resources, fileNames, names }, new Transfer[] {
                    ResourceTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance() });
        } else {
            clipboard.setContents(new Object[] { resources, names },
                    new Transfer[] { ResourceTransfer.getInstance(), TextTransfer.getInstance() });
        }
    } catch (final SWTError e) {
        if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) { throw e; }
        if (MessageDialog.openQuestion(shell, "Problem with copy title", // TODO //$NON-NLS-1$
                                                                            // ResourceNavigatorMessages.CopyToClipboardProblemDialog_title,
                "Problem with copy.")) { //$NON-NLS-1$
            setClipboard(resources, fileNames, names);
        }
    }
}
项目:Hydrograph    文件:PropertyDialog.java   
@Override
protected void configureShell(Shell newShell) {
    super.configureShell(newShell);     
    String imagePath = null;
    //TODO Please uncomment below code before build.
    try{
        newShell.setImage(ImagePathConstant.APP_ICON.getImageFromRegistry());
        if(OSValidator.isMac()){
            newShell.setMinimumSize(new Point(500, 500));
        }else{
            newShell.setMinimumSize(new Point(500, 525));
        }

    }catch(SWTError e){
        logger.debug("Unable to access image" , e);
    }
}
项目:DarwinSPL    文件:DwprofileBrowserInformationControl.java   
/**
 * <p>
 * Tells whether the SWT Browser widget and hence this information control is
 * available.
 * </p>
 * 
 * @param parent the parent component used for checking or <code>null</code> if
 * none
 * 
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailable(Composite parent) {
    if (!fgAvailabilityChecked) {
        try {
            Browser browser= new Browser(parent, SWT.NONE);
            browser.dispose();
            fgIsAvailable= true;

            Slider sliderV= new Slider(parent, SWT.VERTICAL);
            Slider sliderH= new Slider(parent, SWT.HORIZONTAL);
            int width= sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
            int height= sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
            fgScrollBarSize= new Point(width, height);
            sliderV.dispose();
            sliderH.dispose();
        } catch (SWTError er) {
            fgIsAvailable= false;
        } finally {
            fgAvailabilityChecked= true;
        }
    }

    return fgIsAvailable;
}
项目:DarwinSPL    文件:HyexpressionBrowserInformationControl.java   
/**
 * <p>
 * Tells whether the SWT Browser widget and hence this information control is
 * available.
 * </p>
 * 
 * @param parent the parent component used for checking or <code>null</code> if
 * none
 * 
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailable(Composite parent) {
    if (!fgAvailabilityChecked) {
        try {
            Browser browser= new Browser(parent, SWT.NONE);
            browser.dispose();
            fgIsAvailable= true;

            Slider sliderV= new Slider(parent, SWT.VERTICAL);
            Slider sliderH= new Slider(parent, SWT.HORIZONTAL);
            int width= sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
            int height= sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
            fgScrollBarSize= new Point(width, height);
            sliderV.dispose();
            sliderH.dispose();
        } catch (SWTError er) {
            fgIsAvailable= false;
        } finally {
            fgAvailabilityChecked= true;
        }
    }

    return fgIsAvailable;
}
项目:DarwinSPL    文件:HyvalidityformulaBrowserInformationControl.java   
/**
 * <p>
 * Tells whether the SWT Browser widget and hence this information control is
 * available.
 * </p>
 * 
 * @param parent the parent component used for checking or <code>null</code> if
 * none
 * 
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailable(Composite parent) {
    if (!fgAvailabilityChecked) {
        try {
            Browser browser= new Browser(parent, SWT.NONE);
            browser.dispose();
            fgIsAvailable= true;

            Slider sliderV= new Slider(parent, SWT.VERTICAL);
            Slider sliderH= new Slider(parent, SWT.HORIZONTAL);
            int width= sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
            int height= sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
            fgScrollBarSize= new Point(width, height);
            sliderV.dispose();
            sliderH.dispose();
        } catch (SWTError er) {
            fgIsAvailable= false;
        } finally {
            fgAvailabilityChecked= true;
        }
    }

    return fgIsAvailable;
}
项目:DarwinSPL    文件:HydatavalueBrowserInformationControl.java   
/**
 * <p>
 * Tells whether the SWT Browser widget and hence this information control is
 * available.
 * </p>
 * 
 * @param parent the parent component used for checking or <code>null</code> if
 * none
 * 
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailable(Composite parent) {
    if (!fgAvailabilityChecked) {
        try {
            Browser browser= new Browser(parent, SWT.NONE);
            browser.dispose();
            fgIsAvailable= true;

            Slider sliderV= new Slider(parent, SWT.VERTICAL);
            Slider sliderH= new Slider(parent, SWT.HORIZONTAL);
            int width= sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
            int height= sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
            fgScrollBarSize= new Point(width, height);
            sliderV.dispose();
            sliderH.dispose();
        } catch (SWTError er) {
            fgIsAvailable= false;
        } finally {
            fgAvailabilityChecked= true;
        }
    }

    return fgIsAvailable;
}
项目:DarwinSPL    文件:HymappingBrowserInformationControl.java   
/**
 * <p>
 * Tells whether the SWT Browser widget and hence this information control is
 * available.
 * </p>
 * 
 * @param parent the parent component used for checking or <code>null</code> if
 * none
 * 
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailable(Composite parent) {
    if (!fgAvailabilityChecked) {
        try {
            Browser browser= new Browser(parent, SWT.NONE);
            browser.dispose();
            fgIsAvailable= true;

            Slider sliderV= new Slider(parent, SWT.VERTICAL);
            Slider sliderH= new Slider(parent, SWT.HORIZONTAL);
            int width= sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
            int height= sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
            fgScrollBarSize= new Point(width, height);
            sliderV.dispose();
            sliderH.dispose();
        } catch (SWTError er) {
            fgIsAvailable= false;
        } finally {
            fgAvailabilityChecked= true;
        }
    }

    return fgIsAvailable;
}
项目:DarwinSPL    文件:HyconstraintsBrowserInformationControl.java   
/**
 * <p>
 * Tells whether the SWT Browser widget and hence this information control is
 * available.
 * </p>
 * 
 * @param parent the parent component used for checking or <code>null</code> if
 * none
 * 
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailable(Composite parent) {
    if (!fgAvailabilityChecked) {
        try {
            Browser browser= new Browser(parent, SWT.NONE);
            browser.dispose();
            fgIsAvailable= true;

            Slider sliderV= new Slider(parent, SWT.VERTICAL);
            Slider sliderH= new Slider(parent, SWT.HORIZONTAL);
            int width= sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
            int height= sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
            fgScrollBarSize= new Point(width, height);
            sliderV.dispose();
            sliderH.dispose();
        } catch (SWTError er) {
            fgIsAvailable= false;
        } finally {
            fgAvailabilityChecked= true;
        }
    }

    return fgIsAvailable;
}
项目:DarwinSPL    文件:HymanifestBrowserInformationControl.java   
/**
 * <p>
 * Tells whether the SWT Browser widget and hence this information control is
 * available.
 * </p>
 * 
 * @param parent the parent component used for checking or <code>null</code> if
 * none
 * 
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailable(Composite parent) {
    if (!fgAvailabilityChecked) {
        try {
            Browser browser= new Browser(parent, SWT.NONE);
            browser.dispose();
            fgIsAvailable= true;

            Slider sliderV= new Slider(parent, SWT.VERTICAL);
            Slider sliderH= new Slider(parent, SWT.HORIZONTAL);
            int width= sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
            int height= sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
            fgScrollBarSize= new Point(width, height);
            sliderV.dispose();
            sliderH.dispose();
        } catch (SWTError er) {
            fgIsAvailable= false;
        } finally {
            fgAvailabilityChecked= true;
        }
    }

    return fgIsAvailable;
}
项目:PDFReporter-Studio    文件:UIUtils.java   
/**
 * Gets a valid {@link Display} instance trying the following steps:
 * <ol>
 * <li>get the current display from the UI thread if any;</li>
 * <li>get the display from the running workbench;</li>
 * <li>get a default display instance;</li>
 * </ol>
 * 
 * @return a valid {@link Display} instance
 */
public static Display getDisplay() {
    // If we are in the UI Thread use that
    Display d = Display.getCurrent();
    if (d != null)
        return d;
    if (PlatformUI.isWorkbenchRunning())
        return PlatformUI.getWorkbench().getDisplay();
    d = Display.getDefault();
    if (d != null)
        return d;

    // Invalid thread access if it is not the UI Thread
    // and the workbench is not created.
    throw new SWTError(SWT.ERROR_THREAD_INVALID_ACCESS);
}
项目:HMM    文件:AbstractConsole.java   
protected void createConsole() {
    Display.getDefault().syncExec(new Runnable() {
    public void run() {
        IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
        console = new MessageConsole(consoleName, null);
        manager.addConsoles(new IConsole[] { console });
        try {
            Font font = new Font(Display.getCurrent(), "simsun", 9, SWT.NORMAL);
            console.setFont(font);
        } catch (SWTError error) {
            error.printStackTrace();
        }
        mcs = console.newMessageStream();
        black = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
        red = Display.getCurrent().getSystemColor(SWT.COLOR_RED);
        mcs.setColor(black);
        manager.showConsoleView(console);
    }
});
  }
项目:mytourbook    文件:SearchView.java   
private void createUI_10_SearchInternal(final Composite parent) {

        try {

            _browser = new Browser(parent, SWT.NONE);
            GridDataFactory.fillDefaults().grab(true, true).applyTo(_browser);

        } catch (final SWTError e) {
            StatusUtil.showStatus("Could not instantiate Browser: " + e.getMessage(), e);//$NON-NLS-1$
            return;
        }

        _browser.addLocationListener(new LocationAdapter() {
            @Override
            public void changing(final LocationEvent event) {
                SearchMgr.onBrowserLocation(event);
            }
        });

    }
项目:OpenSPIFe    文件:TemporalNodeToolTipPolicy.java   
@Override
public void activate() {
    Control parent = getViewer().getControl();
    Display display = WidgetUtils.getDisplay();

    tip = new Shell(parent.getShell(), SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
    tip.setBackground(display.getSystemColor (SWT.COLOR_INFO_BACKGROUND));
    tip.setLayout (new FillLayout());

    try {
        browser = new Browser(tip, SWT.NONE);
    } catch (SWTError e) {
        System.out.println("Could not instantiate Browser: " + e.getMessage());
        display.dispose();
        return;
    }

    updateBrowserText();
    super.activate();
}
项目:OpenSPIFe    文件:HeatMapDataEditPartHoverEditPolicy.java   
private void initializeTip() {
    if(tooltipShell == null) {
        Control parent = getHost().getViewer().getControl();
        Display display = getDisplay(this.getHost());
        tooltipShell = new Shell(parent.getShell(), SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
        tooltipShell.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
        tooltipShell.setLayout(new FillLayout());
        try {
            mainComposite = getMainComposite();
            getTitleComposite();
            getTitleBodySeparatorLabel();
            getBodyComposite(getHost().getModel());
        } catch (SWTError e) {
            Logger logger = Logger.getLogger(HeatMapDataEditPartHoverEditPolicy.class);
            logger.error("Could not instantiate Browser", e);
            tooltipShell.dispose();
            tooltipShell = null;
        }
    }
}
项目:OpenSPIFe    文件:EditActionProvider.java   
/**
 * Set the clipboard contents. Prompt to retry if clipboard is busy.
 * 
 * @param resources
 *            the resources to copy to the clipboard
 * @param fileNames
 *            file names of the resources to copy to the clipboard
 * @param names
 *            string representation of all names
 */
private void setClipboard(IResource[] resources, String[] fileNames, String names) {
    try {
        // set the clipboard contents
        if (fileNames.length > 0) {
            clipboard.setContents(new Object[] { resources, fileNames, names }, new Transfer[] { ResourceTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance() });
        } else {
            clipboard.setContents(new Object[] { resources, names }, new Transfer[] { ResourceTransfer.getInstance(), TextTransfer.getInstance() });
        }
    } catch (SWTError e) {
        if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
            throw e;
        }
        if (MessageDialog.openQuestion(shell, "Problem Copying to Clipboard", "There was a problem when accessing the system clipboard. Retry?")) {
            setClipboard(resources, fileNames, names);
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:CopyToClipboardAction.java   
private void copyToClipboard(IResource[] resources, String[] fileNames, String names, IJavaElement[] javaElements, TypedSource[] typedSources, int repeat, Clipboard clipboard) {
    final int repeat_max_count= 10;
    try{
        clipboard.setContents(createDataArray(resources, javaElements, fileNames, names, typedSources),
                                createDataTypeArray(resources, javaElements, fileNames, typedSources));
    } catch (SWTError e) {
        if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD || repeat >= repeat_max_count)
            throw e;
        if (fAutoRepeatOnFailure) {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e1) {
                // do nothing.
            }
        }
        if (fAutoRepeatOnFailure || MessageDialog.openQuestion(fShell, ReorgMessages.CopyToClipboardAction_4, ReorgMessages.CopyToClipboardAction_5))
            copyToClipboard(resources, fileNames, names, javaElements, typedSources, repeat + 1, clipboard);
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:LocationCopyAction.java   
@Override
public void run() {
    IStructuredSelection selection= (IStructuredSelection) fLocationViewer.getSelection();
    StringBuffer buf= new StringBuffer();
    for (Iterator<?> iterator= selection.iterator(); iterator.hasNext();) {
        CallLocation location= (CallLocation) iterator.next();
        buf.append(location.getLineNumber()).append('\t').append(location.getCallText());
        buf.append('\n');
    }
    TextTransfer plainTextTransfer = TextTransfer.getInstance();
    try {
        fClipboard.setContents(
                new String[]{ CopyCallHierarchyAction.convertLineTerminators(buf.toString()) },
                new Transfer[]{ plainTextTransfer });
    } catch (SWTError e){
        if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD)
            throw e;
        if (MessageDialog.openQuestion(fViewSite.getShell(), CallHierarchyMessages.CopyCallHierarchyAction_problem, CallHierarchyMessages.CopyCallHierarchyAction_clipboard_busy))
            run();
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CopyToClipboardAction.java   
private void copyToClipboard(IResource[] resources, String[] fileNames, String names, IJavaElement[] javaElements, TypedSource[] typedSources, int repeat, Clipboard clipboard) {
    final int repeat_max_count= 10;
    try{
        clipboard.setContents(createDataArray(resources, javaElements, fileNames, names, typedSources),
                                createDataTypeArray(resources, javaElements, fileNames, typedSources));
    } catch (SWTError e) {
        if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD || repeat >= repeat_max_count)
            throw e;
        if (fAutoRepeatOnFailure) {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e1) {
                // do nothing.
            }
        }
        if (fAutoRepeatOnFailure || MessageDialog.openQuestion(fShell, ReorgMessages.CopyToClipboardAction_4, ReorgMessages.CopyToClipboardAction_5))
            copyToClipboard(resources, fileNames, names, javaElements, typedSources, repeat + 1, clipboard);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CopyCallHierarchyAction.java   
@Override
public void run() {
    StringBuffer buf= new StringBuffer();
    addCalls(fViewer.getTree().getSelection()[0], 0, buf);

    TextTransfer plainTextTransfer= TextTransfer.getInstance();
    try {
        fClipboard.setContents(
                new String[] { convertLineTerminators(buf.toString()) },
                new Transfer[] { plainTextTransfer });
    } catch (SWTError e) {
        if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD)
            throw e;
        if (MessageDialog.openQuestion(fView.getViewSite().getShell(), CallHierarchyMessages.CopyCallHierarchyAction_problem, CallHierarchyMessages.CopyCallHierarchyAction_clipboard_busy))
            run();
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:LocationCopyAction.java   
@Override
public void run() {
    IStructuredSelection selection= (IStructuredSelection) fLocationViewer.getSelection();
    StringBuffer buf= new StringBuffer();
    for (Iterator<?> iterator= selection.iterator(); iterator.hasNext();) {
        CallLocation location= (CallLocation) iterator.next();
        buf.append(location.getLineNumber()).append('\t').append(location.getCallText());
        buf.append('\n');
    }
    TextTransfer plainTextTransfer = TextTransfer.getInstance();
    try {
        fClipboard.setContents(
                new String[]{ CopyCallHierarchyAction.convertLineTerminators(buf.toString()) },
                new Transfer[]{ plainTextTransfer });
    } catch (SWTError e){
        if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD)
            throw e;
        if (MessageDialog.openQuestion(fViewSite.getShell(), CallHierarchyMessages.CopyCallHierarchyAction_problem, CallHierarchyMessages.CopyCallHierarchyAction_clipboard_busy))
            run();
    }
}
项目:Mailster    文件:MailBoxTableTreeItem.java   
void addItem(MailBoxTableTreeItem item, int index)
{
    if (item == null)
        throw new SWTError(SWT.ERROR_NULL_ARGUMENT);
    if (index < 0 || index > items.length)
        throw new SWTError(SWT.ERROR_INVALID_ARGUMENT, index + "");

    /* Put the item in the items list */
    MailBoxTableTreeItem[] newItems = new MailBoxTableTreeItem[items.length + 1];
    System.arraycopy(items, 0, newItems, 0, index);
    newItems[index] = item;
    System.arraycopy(items, index, newItems, index + 1, items.length - index);
    items = newItems;
    if (expanded)
        item.setVisible(true);
}
项目:Mailster    文件:MailBoxTableTree.java   
protected int addItem(MailBoxTableTreeItem item, int index)
{
    if (index < 0 || index > items.length)
        throw new SWTError(SWT.ERROR_INVALID_ARGUMENT);
    MailBoxTableTreeItem[] newItems = new MailBoxTableTreeItem[items.length + 1];
    System.arraycopy(items, 0, newItems, 0, index);
    newItems[index] = item;
    System.arraycopy(items, index, newItems, index + 1, items.length - index);
    items = newItems;

    /* Return the index in the table where this table should be inserted */
    if (index == items.length - 1)
        return table.getItemCount();
    else
        return table.indexOf(items[index + 1].tableItem);
}
项目:Mailster    文件:MailBoxTableTree.java   
public MailBoxTableTreeItem getByRealIndex(int index)
{
    int idx = 0;
    for (int i = 0; i < items.length; i++)
    {
        if (index == idx)
            return items[i];
        else
        {
            int count = items[i].getItemCount();

            if (count + idx >= index)
                return items[i].getItems()[index - idx - 1];
            idx += count + 1;
        }
    }

    throw new SWTError(SWT.ERROR_INVALID_ARGUMENT, "getByRealIndex(" + index + ")");
}
项目:Mailster    文件:GeneralConfigurationPage.java   
private void checkBrowser()
{
    // If OS is a Windows system and Xul is available, then give a chance to
    // use it.
    boolean xulAvailable = false;
    Shell testShell = new Shell();
    try
    {
        new Browser(testShell, SWT.BORDER | SWT.MOZILLA);            
        xulAvailable = true;
    }
    catch(SWTError e)
    {
    }
    finally
    {
        testShell.dispose();
    }

    isXulOptionnal = xulAvailable
            && System.getProperty("os.name").toLowerCase().startsWith("win");
}
项目:Pydev    文件:CopyAction.java   
/**
 * Set the clipboard contents. Prompt to retry if clipboard is busy.
 * 
 * @param resources the resources to copy to the clipboard
 * @param fileNames file names of the resources to copy to the clipboard
 * @param names string representation of all names
 */
private void setClipboard(IResource[] resources, String[] fileNames, String names) {
    try {
        // set the clipboard contents
        if (fileNames.length > 0) {
            clipboard.setContents(
                    new Object[] { resources, fileNames, names },
                    new Transfer[] { ResourceTransfer.getInstance(), FileTransfer.getInstance(),
                            TextTransfer.getInstance() });
        } else {
            clipboard.setContents(new Object[] { resources, names },
                    new Transfer[] { ResourceTransfer.getInstance(), TextTransfer.getInstance() });
        }
    } catch (SWTError e) {
        if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
            throw e;
        }
        if (MessageDialog.openQuestion(shell, "Problem with copy title", // TODO ResourceNavigatorMessages.CopyToClipboardProblemDialog_title,  //$NON-NLS-1$
                "Problem with copy.")) { //$NON-NLS-1$
            setClipboard(resources, fileNames, names);
        }
    }
}
项目:Pydev    文件:ClipboardHandler.java   
public void putIntoClipboard(int clipboardType, Display display, String plainText) throws SWTError {
    Clipboard clipboard = new Clipboard(display);
    try {
        TextTransfer plainTextTransfer = TextTransfer.getInstance();

        String[] data = new String[] { plainText };
        Transfer[] types = new Transfer[] { plainTextTransfer };

        try {
            clipboard.setContents(data, types, clipboardType);
        } catch (SWTError error) {
            // Copy to clipboard failed. This happens when another application
            // is accessing the clipboard while we copy. Ignore the error.
            // Fixes 1GDQAVN
            // Rethrow all other errors. Fixes bug 17578.
            if (error.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
                throw error;
            }
        }
    } finally {
        clipboard.dispose();
    }
}
项目:dLabPro-Plugin    文件:CommonDLabProManualView.java   
public void createPartControl(Composite parent)
{
  try
  {
    browser = new Browser(parent, SWT.NONE);
  }
  catch (SWTError e)
  {
    // This just creates an info text in the view area ->
    Label iLabel = new Label(parent,SWT.NONE);
    iLabel.setText("Cannot create browser widget\n\n"
        +"Here is the stack trace:\n"+e.toString());
    // <-- This would create an error message -->
    //throw new RuntimeException("Cannot create browser widget");
    // <--
  }
  showContent();
  //browser.addLocationListener(this);
}
项目:eclipse-bash-editor    文件:ReducedBrowserInformationControl.java   
/**
 * Tells whether this control is available for given parent composite
 * 
 * @param parent
 *            the parent component used for checking or <code>null</code> if
 *            none
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailableFor(Composite parent) {
    if (!browserAvailabilityChecked) {
        try {
            Browser browser = new Browser(parent, SWT.NONE);
            browser.dispose();
            swtBrowserCanBeUsed = true;

            /* compute scrollbar size */
            Slider sliderV = new Slider(parent, SWT.VERTICAL);
            Slider sliderH = new Slider(parent, SWT.HORIZONTAL);

            int width = sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
            int height = sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;

            cachedScrollBarSize = new Point(width, height);

            sliderV.dispose();
            sliderH.dispose();

        } catch (SWTError er) {
            swtBrowserCanBeUsed = false;
        } finally {
            browserAvailabilityChecked = true;
        }
    }

    return swtBrowserCanBeUsed;
}
项目:tap17-muggl-javaee    文件:LogComposite.java   
/**
 * Basic constructor for launching the composite of the LogWindow.
 * @param parent The windows this composite belongs to.
 * @param shell The current Shell.
 * @param display The current Display.
 * @param style The style for this composite.
 */
public LogComposite(LogWindow parent, Shell shell, Display display, int style) {
    // General initialization.
    super(shell, style);
    this.parent = parent;
    this.shell = shell;
    this.display = display;

    // Layout.
    this.setLayout(new FillLayout());

    // Components.
    try {
        Browser logBrowser = new Browser(this, SWT.BORDER);
        logBrowser.setSize(1000, 740);
        logBrowser.setUrl(Globals.getInst().currentLogfile);

        // Listener.
        this.addKeyListener(new EscKeyListener(parent));
        logBrowser.addKeyListener(new EscKeyListener(parent));

        // Finish setting up the composite.
        this.pack();
    } catch (SWTError e) {
        StaticGuiSupport.showMessageBox(shell, "Error",
                "Cannot show the log file. No browser is available.", SWT.OK | SWT.ICON_ERROR);
        parent.doExit();
    }
}
项目:BiglyBT    文件:BrowserWrapper.java   
public static BrowserWrapper
createBrowser(
    Composite       composite,
    int             style )
{
        // dump checking is async and might decide to disable the real browser to give it a chance to
        // complete in case there's a race

    AEDiagnostics.waitForDumpChecks( 10*1000 );

    boolean use_fake = COConfigurationManager.getBooleanParameter( "browser.internal.disable" );

    if ( use_fake ){

        return( new BrowserWrapperFake( composite, style, null ));

    }else{

        try{
            return( new BrowserWrapperSWT( composite, style ));

        }catch( SWTError error ){
            Control[] children = composite.getChildren();
            for (Control child : children) {
                if (child instanceof Browser) {
                    try {
                        child.dispose();
                    } catch (Throwable t) {

                    }
                }
            }

            return( new BrowserWrapperFake( composite, style, error ));
        }
    }
}
项目:egradle    文件:SimpleBrowserInformationControl.java   
/**
 * Tells whether this control is available for given parent composite
 * 
 * @param parent
 *            the parent component used for checking or <code>null</code> if
 *            none
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailableFor(Composite parent) {
    if (!browserAvailabilityChecked) {
        try {
            Browser browser = new Browser(parent, SWT.NONE);
            browser.dispose();
            swtBrowserCanBeUsed = true;

            /* compute scrollbar size */
            Slider sliderV = new Slider(parent, SWT.VERTICAL);
            Slider sliderH = new Slider(parent, SWT.HORIZONTAL);

            int width = sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
            int height = sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;

            cachedScrollBarSize = new Point(width, height);

            sliderV.dispose();
            sliderH.dispose();

        } catch (SWTError er) {
            swtBrowserCanBeUsed = false;
        } finally {
            browserAvailabilityChecked = true;
        }
    }

    return swtBrowserCanBeUsed;
}
项目:fluentmark    文件:CopyToClipboardAction.java   
private void copyToClipboard(Clipboard clipboard, String str, Shell shell) {
    try {
        clipboard.setContents(new String[] { str }, new Transfer[] { TextTransfer.getInstance() });
    } catch (SWTError ex) {
        if (ex.code != DND.ERROR_CANNOT_SET_CLIPBOARD) throw ex;
        String title = ActionMessages.CopyToClipboardAction_error_title;
        String message = ActionMessages.CopyToClipboardAction_error_message;
        if (MessageDialog.openQuestion(shell, title, message)) copyToClipboard(clipboard, str, shell);
    }
}
项目:PerformanceHat    文件:ControlFactoryImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public Browser createBrowser(final Composite parent, final Object layoutData) throws SWTError {
  final Browser browser = new Browser(parent, SWT.NONE);
  browser.setLayoutData(layoutData);
  return browser;
}
项目:PerformanceHat    文件:ControlFactoryImpl.java   
/**
 * {@inheritDoc}
 */
@Override
public Optional<Browser> createBrowserOrFallback(final Composite parent, final Object layoutData) {
  try {
    final Browser browser = createBrowser(parent, layoutData);
    return Optional.of(browser);
  }
  catch (final SWTError e) {
    final Label fallbackLabel = new Label(parent, SWT.NONE);
    fallbackLabel.setLayoutData(layoutData);
    fallbackLabel.setAlignment(SWT.CENTER);
    fallbackLabel.setText(BROWSER_FALLBACK_LABEL_MESSAGE);
    return Optional.absent();
  }
}
项目:APICloud-Studio    文件:ContentAssistant.java   
/**
 * showAssist
 * 
 * @param showStyle
 */
protected void showAssist(final int showStyle)
{
    final Display d = fContentAssistSubjectControlAdapter.getControl().getDisplay();
    if (d != null)
    {
        try
        {
            d.syncExec(new Runnable()
            {
                public void run()
                {
                    Control c = d.getFocusControl();
                    if (c == null)
                    {
                        return;
                    }

                    if (showStyle == SHOW_PROPOSALS)
                    {
                        fProposalPopup.showProposals(true);
                    }
                    else if (showStyle == SHOW_CONTEXT_INFO && fContextInfoPopup != null)
                    {
                        fContextInfoPopup.showContextProposals(true);
                    }
                    // }
                }
            });
        }
        catch (SWTError e)
        {
        }
    }
}
项目:APICloud-Studio    文件:CustomBrowserInformationControl.java   
/**
 * Tells whether the SWT Browser widget and hence this information control is available.
 * 
 * @param parent
 *            the parent component used for checking or <code>null</code> if none
 * @return <code>true</code> if this control is available
 */
public static boolean isAvailable(Composite parent)
{
    if (!fgAvailabilityChecked)
    {
        try
        {
            Browser browser = new Browser(parent, SWT.NONE);
            browser.dispose();
            fgIsAvailable = true;

            Slider sliderV = new Slider(parent, SWT.VERTICAL);
            Slider sliderH = new Slider(parent, SWT.HORIZONTAL);
            int width = sliderV.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
            int height = sliderH.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
            fgScrollBarSize = new Point(width, height);
            sliderV.dispose();
            sliderH.dispose();
        }
        catch (SWTError er)
        {
            fgIsAvailable = false;
        }
        finally
        {
            fgAvailabilityChecked = true;
        }
    }

    return fgIsAvailable;
}
项目:Eclipse-Postfix-Code-Completion    文件:CopyToClipboardAction.java   
private void copyToClipboard(ITextSelection selection, int repeatCount) {
    try{
        fClipboard.setContents(new String[] { selection.getText() }, new Transfer[] { TextTransfer.getInstance() });
    } catch (SWTError e) {
        if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD || repeatCount >= MAX_REPEAT_COUNT)
            throw e;

        if (MessageDialog.openQuestion(getShell(), InfoViewMessages.CopyToClipboard_error_title, InfoViewMessages.CopyToClipboard_error_message))
            copyToClipboard(selection, repeatCount + 1);
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:CopyCallHierarchyAction.java   
@Override
public void run() {
    StringBuffer buf= new StringBuffer();
    addCalls(fViewer.getTree().getSelection()[0], 0, buf);

    TextTransfer plainTextTransfer= TextTransfer.getInstance();
    try {
        fClipboard.setContents(
                new String[] { convertLineTerminators(buf.toString()) },
                new Transfer[] { plainTextTransfer });
    } catch (SWTError e) {
        if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD)
            throw e;
        if (MessageDialog.openQuestion(fView.getViewSite().getShell(), CallHierarchyMessages.CopyCallHierarchyAction_problem, CallHierarchyMessages.CopyCallHierarchyAction_clipboard_busy))
            run();
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:ClipboardOperationAction.java   
private void setClipboardContents(Clipboard clipboard, Object[] datas, Transfer[] transfers) {
    try {
        clipboard.setContents(datas, transfers);
    } catch (SWTError e) {
        if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
            throw e;
        }
        // silently fail.  see e.g. https://bugs.eclipse.org/bugs/show_bug.cgi?id=65975
    }
}