org.eclipse.jface.util.Util类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(166)

本文整理了Java中org.eclipse.jface.util.Util类的一些代码示例,展示了Util类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util类的具体详情如下:
包路径:org.eclipse.jface.util.Util
类名称:Util

Util介绍

[英]A static class providing utility methods to all of JFace.
[中]为所有JFace提供实用方法的静态类。

代码示例

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

/**
 * Returns whether to show a top separator line between the menu bar
 * and the rest of the window contents.  On some platforms such as the Mac,
 * the menu is separated from the main window already, so a separator line
 * is not desired.
 *
 * @return <code>true</code> to show the top separator, <code>false</code>
 *   to not show it
 * @since 3.0
 */
protected boolean showTopSeperator() {
  return !Util.isMac();
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

/**
 * The default command for launching the system explorer on this platform.
 *
 * @return The default command which launches the system explorer on this system, or an empty
 *         string if no default exists
 * @see ShowInSystemExplorerHandler#getDefaultCommand()
 */
public static String getShowInSystemExplorerCommand() {
  // See https://bugs.eclipse.org/419940 why it is implemented in here and not in ShowInSystemExplorerHandler#getDefaultCommand()
  if (Util.isGtk()) {
    return "dbus-send --print-reply --dest=org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItems array:string:\"${selected_resource_uri}\" string:\"\""; //$NON-NLS-1$
  } else if (Util.isWindows()) {
    return "explorer /E,/select=${selected_resource_loc}"; //$NON-NLS-1$
  } else if (Util.isMac()) {
    return "open -R \"${selected_resource_loc}\""; //$NON-NLS-1$
  }
  // if all else fails, return empty default
  return ""; //$NON-NLS-1$
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

/**
 * Trims sequences of '*' characters
 *
 * @param pattern
 *            string to be trimmed
 * @return trimmed pattern
 */
private String trimWildcardCharacters(String pattern) {
  return Util.replaceAll(pattern, "\\*+", "\\*"); //$NON-NLS-1$ //$NON-NLS-2$		}
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

@Override
protected String getKeyStrokeDelimiter() {
  // We must do the look up every time, as our locale might change.
  if (Util.isWindows()) {
    return Util.translateString(RESOURCE_BUNDLE,
        WIN32_KEY_STROKE_DELIMITER_KEY,
        KeySequence.KEY_STROKE_DELIMITER);
  }
  return Util.translateString(RESOURCE_BUNDLE, KEY_STROKE_DELIMITER_KEY,
      KeySequence.KEY_STROKE_DELIMITER);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

@Override
protected String getKeyDelimiter() {
  // We must do the look up every time, as our locale might change.
  if (Util.isMac()) {
    return Util.translateString(RESOURCE_BUNDLE,
        CARBON_KEY_DELIMITER_KEY, Util.ZERO_LENGTH_STRING);
  }
  return Util.translateString(RESOURCE_BUNDLE, KEY_DELIMITER_KEY,
      KeyStroke.KEY_DELIMITER);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

private String quotePath(String path) {
  if (Util.isLinux() || Util.isMac()) {
    // Quote for usage inside "", man sh, topic QUOTING:
    path = path.replaceAll("[\"$`]", "\\\\$0"); //$NON-NLS-1$ //$NON-NLS-2$
  }
  // Windows: Can't quote, since explorer.exe has a very special command line parsing strategy.
  return path;
}

代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.jface

if (Util.isWindows() || SWT.getPlatform().equals(RAP_PLATFORM)) {
  if ((modifierKeys & lookup.getCtrl()) != 0) {
    sortedKeys[index++] = lookup.getCtrl();
} else if (Util.isGtk() || Util.isMotif()) {
  if ((modifierKeys & lookup.getShift()) != 0) {
    sortedKeys[index++] = lookup.getShift();
} else if (Util.isMac()) {
  if ((modifierKeys & lookup.getShift()) != 0) {
    sortedKeys[index++] = lookup.getShift();

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

private List<ITheme> getCSSThemes(boolean highContrastMode) {
  ArrayList<ITheme> themes = new ArrayList<>();
  for (ITheme theme : engine.getThemes()) {
    /*
     * When we have Win32 OS - when the high contrast mode is enabled on
     * the platform, we display the 'high-contrast' special theme only.
     * If not, we don't want to mess the themes combo with the theme
     * since it is the special variation of the 'classic' one
     *
     * When we have GTK - we have to display the entire list of the
     * themes since we are not able to figure out if the high contrast
     * mode is enabled on the platform. The user has to manually select
     * the theme if they need it
     */
    if (!highContrastMode && !Util.isGtk()
        && theme.getId().equals(E4Application.HIGH_CONTRAST_THEME_ID)) {
      continue;
    }
    themes.add(theme);
  }
  themes.sort((ITheme t1, ITheme t2) -> t1.getLabel().compareTo(t2.getLabel()));
  return themes;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

if (!Util.isGtk()) {
    asyncClose();
  listenToParentDeactivate = !Util.isMac();
} else if (Util.isGtk()) {

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

if (Util.isLinux() || Util.isMac()) {
  p = Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", launchCmd }, null, dir); //$NON-NLS-1$ //$NON-NLS-2$
} else {
if (retCode != 0 && !Util.isWindows()) {
  return statusReporter.newStatus(IStatus.ERROR, "Execution of '" + launchCmd //$NON-NLS-1$
      + "' failed with return code: " + retCode, null); //$NON-NLS-1$

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

if (Util.isWindows()) {
  Program.launch(localHref);
} else if (Util.isMac()) {
  try {
    Runtime.getRuntime().exec("/usr/bin/open " + localHref); //$NON-NLS-1$

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

/**
 * Creates and returns the Window menu.
 */
private MenuManager createWindowMenu() {
  MenuManager menu = new MenuManager(
      IDEWorkbenchMessages.Workbench_window, IWorkbenchActionConstants.M_WINDOW);
  addMacWindowMenuItems(menu);
  menu.add(newWindowAction);
  menu.add(new Separator());
  menu.add(addShowView());
  menu.add(addPerspectiveActions());
  menu.add(new Separator());
  addKeyboardShortcuts(menu);
  Separator sep = new Separator(IWorkbenchActionConstants.MB_ADDITIONS);
  sep.setVisible(!Util.isMac());
  menu.add(sep);
  if(Util.isCocoa())
    menu.add(arrangeWindowsItem);
  // See the comment for quit in createFileMenu
  ActionContributionItem openPreferencesItem = new ActionContributionItem(openPreferencesAction);
  openPreferencesItem.setVisible(!Util.isMac());
  menu.add(openPreferencesItem);
  menu.add(ContributionItemFactory.OPEN_WINDOWS.create(getWindow()));
  return menu;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

/**
 * This method was copy/pasted from JFace.
 */
private Rectangle getConstrainedShellBounds(Display display, Rectangle preferredSize) {
  Rectangle result = new Rectangle(preferredSize.x, preferredSize.y, preferredSize.width,
      preferredSize.height);
  Point topLeft = new Point(preferredSize.x, preferredSize.y);
  Monitor mon = Util.getClosestMonitor(display, topLeft);
  Rectangle bounds = mon.getClientArea();
  if (result.height > bounds.height) {
    result.height = bounds.height;
  }
  if (result.width > bounds.width) {
    result.width = bounds.width;
  }
  result.x = Math.max(bounds.x, Math.min(result.x, bounds.x + bounds.width - result.width));
  result.y = Math.max(bounds.y, Math.min(result.y, bounds.y + bounds.height - result.height));
  return result;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

@Override
protected String getKeyStrokeDelimiter() {
  // We must do the look up every time, as our locale might change.
  if (org.eclipse.jface.util.Util.isWindows()) {
    return Util.translateString(RESOURCE_BUNDLE,
        WIN32_KEY_STROKE_DELIMITER_KEY,
        KeySequence.KEY_STROKE_DELIMITER, false, false);
  }
  return Util.translateString(RESOURCE_BUNDLE, KEY_STROKE_DELIMITER_KEY, KeySequence.KEY_STROKE_DELIMITER, false,
      false);
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench

private void updateQuickAccessText() {
  if (txtQuickAccess == null || txtQuickAccess.isDisposed()) {
    return;
  }
  updateQuickAccessTriggerSequence();
  if (triggerSequence != null) {
    txtQuickAccess.setToolTipText(
        NLS.bind(QuickAccessMessages.QuickAccess_TooltipDescription, triggerSequence.format()));
  } else {
    txtQuickAccess.setToolTipText(QuickAccessMessages.QuickAccess_TooltipDescription_Empty);
  }
  GC gc = new GC(txtQuickAccess);
  // workaround for Bug 491317
  if (Util.isWin32() || Util.isGtk()) {
    FontMetrics fm = gc.getFontMetrics();
    int wHint = QuickAccessMessages.QuickAccess_EnterSearch.length() * fm.getAverageCharWidth();
    int hHint = fm.getHeight();
    gc.dispose();
    txtQuickAccess.setSize(txtQuickAccess.computeSize(wHint, hHint));
  } else {
    Point p = gc.textExtent(QuickAccessMessages.QuickAccess_EnterSearch);
    Rectangle r = txtQuickAccess.computeTrim(0, 0, p.x, p.y);
    gc.dispose();
    // computeTrim() may result in r.x < 0
    GridDataFactory.fillDefaults().hint(r.width - r.x, SWT.DEFAULT).applyTo(txtQuickAccess);
  }
  txtQuickAccess.requestLayout();
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

if (count > MAX_RESOURCES_TO_TRANSFER) {
  String message = "Transfer aborted, too many resources: " + count + "."; //$NON-NLS-1$ //$NON-NLS-2$
  if (Util.isLinux()) {
    message += "\nIf you are running in x11vnc environment please consider to switch to vncserver " + //$NON-NLS-1$
        "+ vncviewer or to run x11vnc without clipboard support " + //$NON-NLS-1$

代码示例来源:origin: org.eclipse.platform/org.eclipse.jface

/**
 * Verifies that the given object is an instance of the given class.
 *
 * @param object
 *            The object to check; may be <code>null</code>.
 * @param c
 *            The class which the object should be; must not be
 *            <code>null</code>.
 */
public static void assertInstance(final Object object, final Class<?> c) {
  assertInstance(object, c, false);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

int index = 0;
if (Util.isWindows()) {
  if ((modifierKeys & lookup.getCtrl()) != 0) {
    sortedKeys[index++] = lookup.getCtrl();
} else if (Util.isGtk() || Util.isMotif()) {
  if ((modifierKeys & lookup.getShift()) != 0) {
    sortedKeys[index++] = lookup.getShift();
} else if (Util.isMac()) {

代码示例来源:origin: org.eclipse.platform/org.eclipse.compare

public void repaint() {
  if (!isDisposed()) {
    GC gc= new GC(this);
    doubleBufferPaint(gc);
    gc.dispose();
    if (Util.isGtk()) {
      redraw();
    }
  }
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface

if (!Util.isGtk()) {
    asyncClose();
  listenToParentDeactivate = !Util.isMac();
} else if (Util.isGtk()) {

相关文章