本文整理汇总了Java中org.eclipse.jface.util.Util.isGtk方法的典型用法代码示例。如果您正苦于以下问题:Java Util.isGtk方法的具体用法?Java Util.isGtk怎么用?Java Util.isGtk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.util.Util
的用法示例。
在下文中一共展示了Util.isGtk方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showDialogMenu
import org.eclipse.jface.util.Util; //导入方法依赖的package包/类
/**
* Show the dialog's menu. This message has no effect if the receiver was
* not configured to show a menu. Clients may call this method in order to
* trigger the menu via keystrokes or other gestures. Subclasses typically
* do not override method.
*/
protected void showDialogMenu() {
if (!showDialogMenu) {
return;
}
if (menuManager == null) {
menuManager = new MenuManager();
fillDialogMenu(menuManager);
}
// Setting this flag works around a problem that remains on X only,
// whereby activating the menu deactivates our shell.
listenToDeactivate = !Util.isGtk();
Menu menu = menuManager.createContextMenu(getShell());
Rectangle bounds = toolBar.getBounds();
Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
topLeft = getShell().toDisplay(topLeft);
menu.setLocation(topLeft.x, topLeft.y);
menu.setVisible(true);
}
示例2: getChange
import org.eclipse.jface.util.Util; //导入方法依赖的package包/类
/**
* Returns the change that will be executed when the proposal is applied.
* This method calls {@link #createChange()} to compute the change.
*
* @return the change for this proposal, can be <code>null</code> in rare cases if creation of
* the change failed
* @throws CoreException when the change could not be created
*/
public final Change getChange() throws CoreException {
if (Util.isGtk()) {
// workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=293995 :
// [Widgets] Deadlock while UI thread displaying/computing a change proposal and non-UI thread creating image
// Solution is to create the change outside a 'synchronized' block.
// Synchronization is achieved by polling fChange, using "fChange == COMPUTING_CHANGE" as barrier.
// Timeout of 10s for safety reasons (should not be reached).
long end= System.currentTimeMillis() + 10000;
do {
boolean computing;
synchronized (this) {
computing= fChange == COMPUTING_CHANGE;
}
if (computing) {
try {
Display display= Display.getCurrent();
if (display != null) {
while (! display.isDisposed() && display.readAndDispatch()) {
// empty the display loop
}
display.sleep();
} else {
Thread.sleep(100);
}
} catch (InterruptedException e) {
//continue
}
} else {
synchronized (this) {
if (fChange == COMPUTING_CHANGE) {
continue;
} else if (fChange != null) {
return fChange;
} else {
fChange= COMPUTING_CHANGE;
}
}
Change change= createChange();
synchronized (this) {
fChange= change;
}
return change;
}
} while (System.currentTimeMillis() < end);
synchronized (this) {
if (fChange == COMPUTING_CHANGE) {
return null; //failed
}
}
} else {
synchronized (this) {
if (fChange == null) {
fChange= createChange();
}
}
}
return fChange;
}
示例3: sortModifierKeys
import org.eclipse.jface.util.Util; //导入方法依赖的package包/类
protected int[] sortModifierKeys(final int modifierKeys) {
final IKeyLookup lookup = KeyLookupFactory.getDefault();
final int[] sortedKeys = new int[4];
int index = 0;
if (Util.isWindows()) {
if ((modifierKeys & lookup.getCtrl()) != 0) {
sortedKeys[index++] = lookup.getCtrl();
}
if ((modifierKeys & lookup.getAlt()) != 0) {
sortedKeys[index++] = lookup.getAlt();
}
if ((modifierKeys & lookup.getShift()) != 0) {
sortedKeys[index++] = lookup.getShift();
}
} else if (Util.isGtk() || Util.isMotif()) {
if ((modifierKeys & lookup.getShift()) != 0) {
sortedKeys[index++] = lookup.getShift();
}
if ((modifierKeys & lookup.getCtrl()) != 0) {
sortedKeys[index++] = lookup.getCtrl();
}
if ((modifierKeys & lookup.getAlt()) != 0) {
sortedKeys[index++] = lookup.getAlt();
}
} else if (Util.isMac()) {
if ((modifierKeys & lookup.getShift()) != 0) {
sortedKeys[index++] = lookup.getShift();
}
if ((modifierKeys & lookup.getCtrl()) != 0) {
sortedKeys[index++] = lookup.getCtrl();
}
if ((modifierKeys & lookup.getAlt()) != 0) {
sortedKeys[index++] = lookup.getAlt();
}
if ((modifierKeys & lookup.getCommand()) != 0) {
sortedKeys[index++] = lookup.getCommand();
}
}
return sortedKeys;
}
示例4: createLoadingShell
import org.eclipse.jface.util.Util; //导入方法依赖的package包/类
private Shell createLoadingShell() {
final Shell shell = new Shell(SWT.NO_TRIM);
shell.setLayout(new FormLayout());
shell.setMinimumSize(backgroundWidth, backgroundHeight);
shell.setSize(backgroundWidth, backgroundHeight);
Image background = IconLoader.loadIconNormal("loading");
Label lblTitle = new Label(shell, SWT.TRANSPARENT);
lblTitle.setFont(FontSize.getThisFontInNewSize(lblTitle.getFont(), 24, SWT.BOLD));
FormData fd_lblTitle = new FormData();
fd_lblTitle.top = new FormAttachment(0, 0);
fd_lblTitle.left = new FormAttachment(0, 10);
fd_lblTitle.right = new FormAttachment(100, -10);
lblTitle.setLayoutData(fd_lblTitle);
lblTitle.setText("Loading");
progressBar = new ProgressBar(shell, SWT.NONE);
progressBar.setMaximum(expectedMessageCount);
progressBar.setMinimum(0);
progressBar.setSelection(0);
FormData fd_progressBar = new FormData();
fd_progressBar.bottom = new FormAttachment(100, -10);
fd_progressBar.left = new FormAttachment(0, 10);
fd_progressBar.right = new FormAttachment(100, -10);
progressBar.setLayoutData(fd_progressBar);
lblAction = new Text(shell, SWT.WRAP | SWT.TRANSPARENT);
lblAction.setEditable(false);
FormData fd_lblAction = new FormData();
fd_lblAction.top = new FormAttachment(progressBar, -60);
fd_lblAction.bottom = new FormAttachment(progressBar, -10);
fd_lblAction.left = new FormAttachment(0, 10);
fd_lblAction.right = new FormAttachment(100, -200);
lblAction.setLayoutData(fd_lblAction);
lblAction.setText("Starting...");
if (!Util.isGtk()) {
shell.setBackgroundImage(background);
shell.setBackgroundMode(SWT.INHERIT_FORCE);
lblTitle.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
lblAction.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
}
shell.setSize(background.getBounds().x, background.getBounds().y);
shell.setLocation(getMonitorCenter(shell));
return shell;
}