org.eclipse.core.runtime.Platform.getWS()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(12.5k)|赞(0)|评价(0)|浏览(148)

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

Platform.getWS介绍

[英]Returns the string name of the current window system for use in finding files whose path starts with $ws$. null is returned if the window system cannot be determined.

Clients are also able to acquire the EnvironmentInfo service and query it for the windowing system.
[中]返回当前窗口系统的字符串名称,用于查找路径以$ws$开头的文件。如果无法确定窗口系统,则返回null
客户还可以获取EnvironmentInfo服务,并为窗口系统查询该服务。

代码示例

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

static public boolean isLinuxGTK() {
  String ws = Platform.getWS();
  return ws.equals(Platform.WS_GTK);
}

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

private boolean filterByWS(String ws) {
  return !ws.equals(Platform.getWS());
}

代码示例来源:origin: org.eclipse/org.eclipse.pde.core

public String getDisplayWS() {
  if (fWS == null || fWS.trim().length() == 0)
    return Platform.getWS();
  return fWS.trim();
}

代码示例来源:origin: org.eclipse/org.eclipse.pde.core

/**
 * Returns the target windowing system as specified on the <b>Environment</b>
 * tab of the <b>Plug-in Development > Target Platform</b> preference page.
 *  
 * @return the target windowing system
 */
public static String getWS() {
  return getProperty(ICoreConstants.WS, Platform.getWS());
}

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

public static ArrayList<String> getPathPrefix(String locale) {
  ArrayList<String> pathPrefix = new ArrayList<>(5);
  // TODO add override for ws and os similar to how it's done with locale
  // now
  String ws = Platform.getWS();
  String os = Platform.getOS();
  if (locale == null)
    locale = Platform.getNL();
  if (ws != null)
    pathPrefix.add("ws/" + ws + '/'); //$NON-NLS-1$
  if (os != null && !os.equals("OS_UNKNOWN")) //$NON-NLS-1$
    pathPrefix.add("os/" + os + '/'); //$NON-NLS-1$
  if (locale != null && locale.length() >= 5)
    pathPrefix.add("nl/" + locale.substring(0, 2) + '/' + locale.substring(3, 5) + '/'); //$NON-NLS-1$
  if (locale != null && locale.length() >= 2)
    pathPrefix.add("nl/" + locale.substring(0, 2) + '/'); //$NON-NLS-1$
  // the plugin root
  pathPrefix.add(""); //$NON-NLS-1$
  return pathPrefix;
}

代码示例来源:origin: org.eclipse.platform/org.eclipse.e4.ui.css.swt.theme

private String getVarientThemeLabel(String label, String os, String ws) {
  String currentOS = Platform.getOS();
  String currentWS = Platform.getWS();
  if (os != null && !os.equals(currentOS)) {
    String osName;
    switch (os) {
    case Platform.OS_LINUX:		osName="Linux";break;
    case Platform.OS_MACOSX:	osName="Mac OS X";break;
    case Platform.OS_WIN32:		osName="Windows";break;
    default:					osName=os;break;
    }
    label += " [" + osName;
  }
  if (ws != null && !ws.equals(currentWS)) {
    String wsName;
    switch (ws) {
    case Platform.WS_COCOA:		wsName="Cocoa";break;
    case Platform.WS_GTK:		wsName="GTK";break;
    case Platform.WS_WPF:		wsName="WPF";break;
    default:					wsName=ws;break;
    }
    label += " - " + wsName;
  }
  if (os != null && !os.equals(currentOS)) {
    label += "]";
  }
  return label;
}

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

/**
 * Get the element that has os/ws attributes that best match the current
 * platform.
 *
 * @param elements the elements to check
 * @return the best match, if any
 */
private IConfigurationElement getBestPlatformMatch(
    IConfigurationElement[] elements) {
  IConfigurationElement match = null;
  String osname = Platform.getOS();
  String wsname = Platform.getWS();
  for (IConfigurationElement element : elements) {
    String elementOs = element.getAttribute(IWorkbenchRegistryConstants.ATT_OS);
    String elementWs = element.getAttribute(IWorkbenchRegistryConstants.ATT_WS);
    if (osname.equalsIgnoreCase(elementOs)) {
      if (wsname.equalsIgnoreCase(elementWs)) {
        // best possible match.  Return
        return element;
      }
      match = element;
    } else if (wsname.equalsIgnoreCase(elementWs)) {
      match = element;
    }
  }
  return match;
}

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

private void initializeText() {
  Bundle bundle = Platform.getBundle("org.eclipse.ui.views"); //$NON-NLS-1$
  if (bundle != null) {
    StringBuffer buff = new StringBuffer();
    buff.append("<form>"); //$NON-NLS-1$
    buff.append("<p><a href=\""); //$NON-NLS-1$
    buff.append(HREF_PROGRESS);
    buff.append("\""); //$NON-NLS-1$
    if (!Platform.getWS().equals(Platform.WS_GTK)) {
      buff.append(" alt=\""); //$NON-NLS-1$
      buff.append(Messages.EngineResultSection_progressTooltip);
      buff.append("\""); //$NON-NLS-1$
    }
    buff.append(">"); //$NON-NLS-1$
    buff.append(Messages.EngineResultSection_searchInProgress);
    buff.append("</a></p></form>"); //$NON-NLS-1$
    searchResults.setText(buff.toString(), true, false);
  } else {
    searchResults.setText(Messages.EngineResultSection_progress2, false, false);
  }
}

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

public static List readLines(BufferedReader reader) {
  List lines;
  LineReader lr= new LineReader(reader);
  if (!Platform.WS_CARBON.equals(Platform.getWS()))
    lr.ignoreSingleCR(); // Don't treat single CRs as line feeds to be consistent with command line patch
  lines= lr.readLines();
  return lines;
}

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

/**
 * Generates the environment properties string for this target definition's p2 profile.
 *
 * @return environment properties
 */
private String generateEnvironmentProperties(ITargetDefinition target) {
  // TODO: are there constants for these keys?
  StringBuffer env = new StringBuffer();
  String ws = target.getWS();
  if (ws == null) {
    ws = Platform.getWS();
  }
  env.append("osgi.ws="); //$NON-NLS-1$
  env.append(ws);
  env.append(","); //$NON-NLS-1$
  String os = target.getOS();
  if (os == null) {
    os = Platform.getOS();
  }
  env.append("osgi.os="); //$NON-NLS-1$
  env.append(os);
  env.append(","); //$NON-NLS-1$
  String arch = target.getArch();
  if (arch == null) {
    arch = Platform.getOSArch();
  }
  env.append("osgi.arch="); //$NON-NLS-1$
  env.append(arch);
  return env.toString();
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.debug.core

@Override
public String resolveValue(IDynamicVariable variable, String argument) throws CoreException {
  if ("ARCH".equals(argument)) { //$NON-NLS-1$
    return Platform.getOSArch();
  } else if ("ECLIPSE_HOME".equals(argument)) { //$NON-NLS-1$
    URL installURL = Platform.getInstallLocation().getURL();
    IPath ppath = new Path(installURL.getFile()).removeTrailingSeparator();
    return getCorrectPath(ppath.toOSString());
  } else if ("NL".equals(argument)) { //$NON-NLS-1$
    return Platform.getNL();
  } else if ("OS".equals(argument)) { //$NON-NLS-1$
    return Platform.getOS();
  } else if ("WS".equals(argument)) { //$NON-NLS-1$
    return Platform.getWS();
  }
  return null;
}

代码示例来源:origin: org.eclipse.mylyn.wikitext/ui

private void updateSourceTabLabel() {
  if (sourceTab != null) {
    // bug 270215 carbon shows tooltip in source editing area.
    boolean isCarbon = Platform.WS_CARBON.equals(Platform.getWS());
    MarkupLanguage markupLanguage = getMarkupLanguage();
    if (markupLanguage == null) {
      sourceTab.setText(Messages.MarkupEditor_markupSource);
      if (!isCarbon) {
        sourceTab.setToolTipText(Messages.MarkupEditor_markupSource_tooltip);
      }
    } else {
      sourceTab.setText(NLS.bind(Messages.MarkupEditor_markupSource_named,
          new Object[] { markupLanguage.getName() }));
      if (!isCarbon) {
        sourceTab.setToolTipText(NLS.bind(Messages.MarkupEditor_markupSource_tooltip_named,
            new Object[] { markupLanguage.getName() }));
      }
    }
  }
}

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

private static URL findWS(Bundle b, IPath path, Map<String, String> override, List<URL> multiple) {
  String ws = null;
  if (override != null)
    // check for override
    ws = override.get("$ws$"); //$NON-NLS-1$
  if (ws == null)
    // use default
    ws = Platform.getWS();
  IPath filePath = new Path("ws").append(ws).append(path); //$NON-NLS-1$
  // We know that there is only one segment to the ws path
  // e.g. ws/win32
  URL result = findInPlugin(b, filePath, multiple);
  if (result != null && multiple == null)
    return result;
  result = findInFragments(b, filePath, multiple);
  if (result != null && multiple == null)
    return result;
  // If we get to this point, we haven't found it yet.
  // Look in the plugin and fragment root directories
  result = findInPlugin(b, path, multiple);
  if (result != null && multiple == null)
    return result;
  return findInFragments(b, path, multiple);
}

代码示例来源:origin: org.eclipse.equinox.p2.ui.sdk/scheduler

private ConfigurationDescriptor getConfigdataFromProductFile(File installFolder) {
  Object[] productFileInfo = loadEclipseProductFile(installFolder);
  //Contrarily  to the runtime, when the .eclipseproduct can't be found, we don't fallback to org.eclipse.platform. 
  if (productFileInfo.length == 0)
    return null;
  return new ConfigurationDescriptor((String) productFileInfo[0], (Identifier) productFileInfo[1], getInstallDirHash(installFolder), Platform.getOS() + '_' + Platform.getWS() + '_' + Platform.getOSArch(), null);
}

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

/**
 * Returns the target windowing system as specified on the <b>Environment</b>
 * tab of the <b>Plug-in Development > Target Platform</b> preference page.
 *
 * @return the target windowing system
 */
public static String getWS() {
  try {
    ITargetDefinition target = TargetPlatformService.getDefault().getWorkspaceTargetDefinition();
    String result = target.getWS();
    if (result != null) {
      return result;
    }
  } catch (CoreException e) {
    PDECore.log(e);
  }
  return Platform.getWS();
}

代码示例来源:origin: org.eclipse.mylyn.commons/screenshots

@Override
public void clickMenu(int x, int y) {
  if (Platform.getWS().equalsIgnoreCase(Platform.WS_WIN32)
      || Platform.getWS().equalsIgnoreCase(Platform.WS_WPF)) {
    invokeFontDialog();
  } else {
    Menu rightClickMenu = new Menu(parent.getShell(), SWT.POP_UP);
    MenuItem menuItem = new MenuItem(rightClickMenu, SWT.PUSH);
    menuItem.setText(Messages.SelectToolAction_Font_);
    menuItem.addListener(SWT.Selection, new Listener() {
      public void handleEvent(final Event event) {
        invokeFontDialog();
      }
    });
    menuItem = new MenuItem(rightClickMenu, SWT.PUSH);
    menuItem.setText(Messages.SelectToolAction_Color_);
    menuItem.addListener(SWT.Selection, new Listener() {
      public void handleEvent(final Event event) {
        invokeColorDialog();
      }
    });
    Point p = parent.toDisplay(x, y);
    rightClickMenu.setLocation(p.x, p.y);
    rightClickMenu.setVisible(true);
  }
}

代码示例来源:origin: org.eclipse/org.eclipse.wst.server.ui

if (matches(featureRefs[i].getOS(), Platform.getOS()) &&
    matches(featureRefs[i].getOSArch(), Platform.getOSArch()) &&
    matches(featureRefs[i].getWS(), Platform.getWS())) {
  IFeature feature2 = featureRefs[i].getFeature(ProgressUtil.getSubMonitorFor(monitor, 5));
  if (feature2 != null)

代码示例来源:origin: org.eclipse/org.eclipse.pde.core

public void initializeDefaultPreferences() {
  Preferences preferences = PDECore.getDefault().getPluginPreferences();
  preferences.setDefault(
      ICoreConstants.TARGET_MODE,
      ICoreConstants.VALUE_USE_THIS);
  preferences.setDefault(
      ICoreConstants.CHECKED_PLUGINS,
      ICoreConstants.VALUE_SAVED_ALL);
  if (preferences.getString(ICoreConstants.TARGET_MODE).equals(ICoreConstants.VALUE_USE_THIS))
    preferences.setValue(
        ICoreConstants.PLATFORM_PATH,
        TargetPlatform.getDefaultLocation());
  else
    preferences.setDefault(
        ICoreConstants.PLATFORM_PATH,
        TargetPlatform.getDefaultLocation());
  // set defaults for the target environment variables.
  preferences.setDefault(ICoreConstants.OS, Platform.getOS());
  preferences.setDefault(ICoreConstants.WS, Platform.getWS());
  preferences.setDefault(ICoreConstants.NL, Locale.getDefault().toString());
  preferences.setDefault(ICoreConstants.ARCH, Platform.getOSArch());
}

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

public void run() {
    Shell windowShell=null;
    if (!narrow) {
      Shell[] shells = display.getShells();
      for (int i=0; i<shells.length; i++) {
        Object data = shells[i].getData();
        if (data!=null && data instanceof IWorkbenchWindow) {
          windowShell=shells[i];
          break;
        }
      }
    }
    if (windowShell!=null) {
      windowShell.forceActive();
      if (Platform.getWS().equals(Platform.WS_WIN32)) {
        // feature in Windows. Without this code,
        // the window will only flash in the launch bar.
        windowShell.setVisible(false);
        windowShell.setMinimized(true);
        windowShell.setVisible(true);
        windowShell.setMinimized(false);
      }
    }
    PreferenceDialog dialog = PreferencesUtil
        .createPreferenceDialogOn(windowShell, getCapabilityPageId(),
            null, null);
    dialog.open();
  }
});

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

/**
 * This was introduced to work around the behavior described in
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=130206
 */
private void forceDialogsOnTop() {
  IWorkbench workbench = PlatformUI.getWorkbench();
  Display display = workbench.getDisplay();
  /*
   * If the active shell is not in this display (e.g. help window),
   * bring the active workbench window up.
   */
  if (display.getActiveShell() == null) {
    IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    if (window != null) {
      Shell windowShell = window.getShell();
      windowShell.forceActive();
      if (Platform.getWS().equals(Platform.WS_WIN32)) {
        // feature in Windows. Without this code,
        // the window will only flash in the launch bar.
        windowShell.setVisible(false);
        windowShell.setMinimized(true);
        windowShell.setVisible(true);
        windowShell.setMinimized(false);
      }
    }
  }
}

相关文章