本文整理匯總了Java中org.eclipse.swt.SWTError類的典型用法代碼示例。如果您正苦於以下問題:Java SWTError類的具體用法?Java SWTError怎麽用?Java SWTError使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SWTError類屬於org.eclipse.swt包,在下文中一共展示了SWTError類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: AudibleBrowser
import org.eclipse.swt.SWTError; //導入依賴的package包/類
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);
}
示例2: setClipboard
import org.eclipse.swt.SWTError; //導入依賴的package包/類
/**
* 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);
}
}
}
示例3: configureShell
import org.eclipse.swt.SWTError; //導入依賴的package包/類
@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);
}
}
示例4: isAvailable
import org.eclipse.swt.SWTError; //導入依賴的package包/類
/**
* <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;
}
示例5: getDisplay
import org.eclipse.swt.SWTError; //導入依賴的package包/類
/**
* 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);
}
示例6: createConsole
import org.eclipse.swt.SWTError; //導入依賴的package包/類
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);
}
});
}
示例7: createUI_10_SearchInternal
import org.eclipse.swt.SWTError; //導入依賴的package包/類
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);
}
});
}
示例8: activate
import org.eclipse.swt.SWTError; //導入依賴的package包/類
@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();
}
示例9: initializeTip
import org.eclipse.swt.SWTError; //導入依賴的package包/類
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;
}
}
}
示例10: setClipboard
import org.eclipse.swt.SWTError; //導入依賴的package包/類
/**
* 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);
}
}
}
示例11: copyToClipboard
import org.eclipse.swt.SWTError; //導入依賴的package包/類
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);
}
}
示例12: run
import org.eclipse.swt.SWTError; //導入依賴的package包/類
@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();
}
}
示例13: run
import org.eclipse.swt.SWTError; //導入依賴的package包/類
@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();
}
}
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion-Juno38,代碼行數:18,代碼來源:CopyCallHierarchyAction.java
示例14: addItem
import org.eclipse.swt.SWTError; //導入依賴的package包/類
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);
}
示例15: addItem
import org.eclipse.swt.SWTError; //導入依賴的package包/類
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);
}