Java Code Examples for org.eclipse.core.runtime.Platform#getProduct()

The following examples show how to use org.eclipse.core.runtime.Platform#getProduct() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SplashHandler.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void init(Shell splash) {
    super.init(splash);

    String progressString = null;

    // Try to get the progress bar and message updater.
    IProduct product = Platform.getProduct();
    if (product != null) {
        progressString = product.getProperty(IProductConstants.STARTUP_PROGRESS_RECT);
    }
    Rectangle progressRect = StringConverter.asRectangle(progressString, PROCESS_BAR_RECTANGLE);
    setProgressRect(progressRect);

    // Set font color.
    setForeground(FOREGROUND_COLOR);

    // Set the software version.
    getContent().addPaintListener(e -> {
        e.gc.setForeground(getForeground());
        e.gc.drawText(
                NLS.bind(Messages.SplahScreen_VersionString,
                        TracingRcpPlugin.getDefault().getBundle().getVersion().toString()),
                VERSION_LOCATION.x, VERSION_LOCATION.y, true);
    });
}
 
Example 2
Source File: ExitDialog.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected static String exitMessage() {
    String productName = null;
    final IProduct product = Platform.getProduct();
    if (product != null) {
        productName = product.getName();
    }
    String message = null;
    if (productName == null) {
        message = IDEWorkbenchMessages.PromptOnExitDialog_message0;
    } else {
        message = NLS.bind(
                IDEWorkbenchMessages.PromptOnExitDialog_message1,
                productName);
    }
    return message;
}
 
Example 3
Source File: AboutDialog.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
   * Create an instance of the AboutDialog for the given window.
   * @param parentShell The parent of the dialog.
   */
  public AboutDialog(Shell parentShell) {
      super(parentShell);
      product = Platform.getProduct();
      if (product != null) {
	productName = product.getName();
}
      if (productName == null) {
	productName = WorkbenchMessages.AboutDialog_defaultProductName;
}

      // create a descriptive object for each BundleGroup
      IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();
      LinkedList groups = new LinkedList();
      if (providers != null) {
	for (int i = 0; i < providers.length; ++i) {
              IBundleGroup[] bundleGroups = providers[i].getBundleGroups();
              for (int j = 0; j < bundleGroups.length; ++j) {
			groups.add(new AboutBundleGroupData(bundleGroups[j]));
		}
          }
}
      bundleGroupInfos = (AboutBundleGroupData[]) groups
              .toArray(new AboutBundleGroupData[0]);
  }
 
Example 4
Source File: EmbeddedBrowser.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Obtains URLs to product image
 * 
 * @return String[] with URLs as Strings or null
 */
private static String[] getProductImageURLs( )
{
	IProduct product = Platform.getProduct( );

	if ( product != null )
	{
		String url = product.getProperty( "windowImages" ); //$NON-NLS-1$

		if ( url != null && url.length( ) > 0 )
		{
			return url.split( ",\\s*" ); //$NON-NLS-1$
		}

		url = product.getProperty( "windowImage" ); //$NON-NLS-1$

		if ( url != null && url.length( ) > 0 )
		{
			return new String[]{
				url
			};
		}
	}

	return null;
}
 
Example 5
Source File: EclipseUtil.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public synchronized static String getStudioPrefix()
{
	// Cache this value!
	if (fgPrefix == null)
	{
		fgPrefix = APTANA_STUDIO_PREFIX;
		IProduct product = Platform.getProduct();
		if (product != null)
		{
			String name = product.getProperty("studioPrefix"); //$NON-NLS-1$
			if (!StringUtil.isEmpty(name))
			{
				fgPrefix = name;
			}
		}
	}
	return fgPrefix;
}
 
Example 6
Source File: DesignerWorkbenchWindowAdvisor.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void preWindowOpen( )
{
	IWorkbenchWindowConfigurer configurer = getWindowConfigurer( );
	configurer.setShowCoolBar( true );
	configurer.setShowStatusLine( true );

	String title = null;
	IProduct product = Platform.getProduct( );
	if ( product != null )
	{
		title = product.getName( );
	}

	if ( title == null )
	{
		title = DesignerWorkbenchMessages.Workbench_title;
	}
	configurer.setTitle( title );
}
 
Example 7
Source File: Application.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public Object start(IApplicationContext context) throws Exception {
	OpenDocumentEventProcessor openDocProcessor = new OpenDocumentEventProcessor();

	Display display = PlatformUI.createDisplay();
	display.addListener(SWT.OpenDocument, openDocProcessor);

	try {
		IProduct product = Platform.getProduct();
		String id = product.getId();
		String hsVersion = "";
		if (id.equals("net.heartsome.cat.te.tmx_editor_product")) {
			hsVersion = "F";
		}
		System.getProperties().put("TSVersion", "88");
		System.getProperties().put("TSEdition", hsVersion);

		String versionDate = System.getProperty("date", "");
		String version = System.getProperty("version", "");
		System.getProperties().put("TSVersionDate", version + "." + versionDate);
		checkCleanValue();

		int returnCode = PlatformUI.createAndRunWorkbench(display,
				new ApplicationWorkbenchAdvisor(openDocProcessor));
		if (returnCode == PlatformUI.RETURN_RESTART)
			return IApplication.EXIT_RESTART;
		else
			return IApplication.EXIT_OK;
	} finally {
		display.dispose();
	}

}
 
Example 8
Source File: SelfBaseHelpSystem.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Obtains name of the Eclipse product
 * 
 * @return String
 */
public static String getProductName() {
	IProduct product = Platform.getProduct();
	if (product == null) {
		return ""; //$NON-NLS-1$
	}
	String name = product.getName();
	return name == null ? "" : name; //$NON-NLS-1$
}
 
Example 9
Source File: SelfBaseHelpSystem.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Obtains name of the Eclipse product
 * 
 * @return String
 */
public static String getProductName() {
	IProduct product = Platform.getProduct();
	if (product == null) {
		return ""; //$NON-NLS-1$
	}
	String name = product.getName();
	return name == null ? "" : name; //$NON-NLS-1$
}
 
Example 10
Source File: RenameTypeProcessor.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean canEnableSimilarDeclarationUpdating() {

	IProduct product = Platform.getProduct();
	if (product != null) {
		String property = product.getProperty("org.eclipse.jdt.ui.refactoring.handlesSimilarDeclarations"); //$NON-NLS-1$
		if ("false".equalsIgnoreCase(property)) {
			return false;
		}
	}

	return true;
}
 
Example 11
Source File: CordovaEngineProvider.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
public List<DownloadableCordovaEngine> getDownloadableEngines(String platformId) throws CoreException {
	AbstractEngineRepoProvider provider = new NpmBasedEngineRepoProvider();
	IProduct product = Platform.getProduct();
	if (product != null) {
		String productId = Platform.getProduct().getId();
		List<CordovaEngineRepoProvider> providerProxies = HybridCore.getCordovaEngineRepoProviders();
		for (CordovaEngineRepoProvider providerProxy : providerProxies) {
			if (productId.equals(providerProxy.getProductId())) {
				provider = providerProxy.createProvider();
			}
		}
	}
	return provider.getEngines(platformId);
}
 
Example 12
Source File: CordovaEngineProvider.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
public List<DownloadableCordovaEngine> getDownloadableEngines() throws CoreException {
	AbstractEngineRepoProvider provider = new NpmBasedEngineRepoProvider();
	IProduct product = Platform.getProduct();
	if (product != null) {
		String productId = Platform.getProduct().getId();
		List<CordovaEngineRepoProvider> providerProxies = HybridCore.getCordovaEngineRepoProviders();
		for (CordovaEngineRepoProvider providerProxy : providerProxies) {
			if (productId.equals(providerProxy.getProductId())) {
				provider = providerProxy.createProvider();
			}
		}
	}
	return provider.getEngines();
}
 
Example 13
Source File: SelfBaseHelpSystem.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Obtains name of the Eclipse product
 * 
 * @return String
 */
public static String getProductName() {
	IProduct product = Platform.getProduct();
	if (product == null) {
		return ""; //$NON-NLS-1$
	}
	String name = product.getName();
	return name == null ? "" : name; //$NON-NLS-1$
}
 
Example 14
Source File: RenameTypeProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public boolean canEnableSimilarDeclarationUpdating() {

		IProduct product= Platform.getProduct();
		if (product != null) {
			String property= product.getProperty("org.eclipse.jdt.ui.refactoring.handlesSimilarDeclarations"); //$NON-NLS-1$
			if ("false".equalsIgnoreCase(property)) //$NON-NLS-1$
				return false;
		}

		return true;
	}
 
Example 15
Source File: AnalyticsPingManager.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private static void sendPing(
    String pluginName, Action action, @Nullable String label, @Nullable Integer value,
    CustomDimensionAssignment... customDimensions) {
  Map<String, String> parametersMap = Maps.newHashMap(STANDARD_PARAMETERS);
  String anonymizedClientId = GdtPlugin.getInstallationId();
  parametersMap.put("cid", anonymizedClientId);
  parametersMap.put("ec", pluginName); // category
  parametersMap.put("ea", action.toString());
  if (label != null) {
    parametersMap.put("el", label);
  }
  if (value != null) {
    parametersMap.put("ev", value.toString());
  }
  setCustomDimension(parametersMap, CustomDimensionName.ANONYMIZED_CLIENT_ID, anonymizedClientId);
  @SuppressWarnings("deprecation") // PluginVersionIdentifier.toString()
  String gwtVersion =
      new VersionedIdentifier(
          GdtExtPlugin.FEATURE_ID, GdtExtPlugin.FEATURE_VERSION.toString()).toString();
  setCustomDimension(parametersMap, CustomDimensionName.GWT_VERSION, gwtVersion);
  setCustomDimension(
      parametersMap, CustomDimensionName.ECLIPSE_VERSION, GdtPlugin.getEclipseVersion());

  if (Platform.getProduct() != null) {
    setCustomDimension(
        parametersMap, CustomDimensionName.ECLIPSE_PRODUCT_ID, Platform.getProduct().getId());
  } else {
    setCustomDimension(
        parametersMap, CustomDimensionName.ECLIPSE_PRODUCT_ID, "null");
  }

  setCustomDimension(parametersMap, CustomDimensionName.SDK_VERSIONS, getSdkVersions());
  for (CustomDimensionAssignment nameValuePair : customDimensions) {
    setCustomDimension(parametersMap, nameValuePair.getName(), nameValuePair.getValue());
  }
  sendPostRequest(parametersMap);
}
 
Example 16
Source File: EclipseUtil.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Retrieves the product version from the Platform aboutText property
 * 
 * @return
 */
public static String getProductVersion()
{
	String version = null;
	try
	{
		IProduct product = Platform.getProduct();
		if (product != null)
		{
			String aboutText = product.getProperty("aboutText"); //$NON-NLS-1$
			if (!StringUtil.isEmpty(aboutText))
			{
				String pattern = "Version: (.*)\n"; //$NON-NLS-1$
				Pattern p = Pattern.compile(pattern);
				Matcher m = p.matcher(aboutText);
				boolean found = m.find();
				if (!found)
				{
					// fall back to trying to match build #
					p = Pattern.compile("build: (.*)\n"); //$NON-NLS-1$
					m = p.matcher(aboutText);
					found = m.find();
				}

				if (found)
				{
					version = m.group(1);
				}
			}
		}
	}
	catch (Exception e)
	{
		// ignore
	}
	if (StringUtil.isEmpty(version))
	{
		// falls back to the branding plugin version
		return getStudioVersion();
	}
	return version;
}
 
Example 17
Source File: BOSSplashHandler.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void init(final Shell splash) {
    super.init(splash);
    String progressRectString = null;
    String messageRectString = null;
    String foregroundColorString = null;
    final IProduct product = Platform.getProduct();
    if (product != null) {
        progressRectString = product.getProperty(IProductConstants.STARTUP_PROGRESS_RECT);
        messageRectString = product.getProperty(IProductConstants.STARTUP_MESSAGE_RECT);
        foregroundColorString = product.getProperty(IProductConstants.STARTUP_FOREGROUND_COLOR);
    }

    final Rectangle progressRect = StringConverter.asRectangle(progressRectString);
    setProgressRect(progressRect);

    final Rectangle messageRect = StringConverter.asRectangle(messageRectString);
    setMessageRect(messageRect);

    int foregroundColorInteger;
    try {
        foregroundColorInteger = Integer.parseInt(foregroundColorString, 16);
    } catch (final Exception ex) {
        foregroundColorInteger = 0xD2D7FF; // off white
    }

    setForeground(new RGB((foregroundColorInteger & 0xFF0000) >> 16,
            (foregroundColorInteger & 0xFF00) >> 8,
            foregroundColorInteger & 0xFF));

    setForeground(new RGB((foregroundColorInteger & 0xFF0000) >> 16,
            (foregroundColorInteger & 0xFF00) >> 8,
            foregroundColorInteger & 0xFF));

    // the following code will be removed for release time
    if (PrefUtil.getInternalPreferenceStore().getBoolean(
            "SHOW_BUILDID_ON_STARTUP")) { //$NON-NLS-1$
        final String buildId = System.getProperty(
                "eclipse.buildId", "Unknown Build"); //$NON-NLS-1$ //$NON-NLS-2$
        // find the specified location.  Not currently API
        // hardcoded to be sensible with our current splash Graphic
        final String buildIdLocString = product.getProperty("buildIdLocation"); //$NON-NLS-1$
        final Point buildIdPoint = StringConverter.asPoint(buildIdLocString,
                new Point(322, 190));
        getContent().addPaintListener(new PaintListener() {

            @Override
            public void paintControl(final PaintEvent e) {
                e.gc.setForeground(getForeground());
                e.gc.setBackground(getForeground()) ;
                e.gc
                .drawText(buildId, buildIdPoint.x, buildIdPoint.y,
                        true);
            }
        });
    }
    else {
        getContent(); // ensure creation of the progress
    }
}
 
Example 18
Source File: VersionDisplayingSplashHandler.java    From toolsuite-distribution with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void init(Shell splash) {
	super.init(splash);
	String progressRectString = null;
	String messageRectString = null;
	String foregroundColorString = null;
	String versionColorString = null;
	String buildIdLocationString = null;
	IProduct product = Platform.getProduct();
	if (product != null) {
		progressRectString = product.getProperty(IProductConstants.STARTUP_PROGRESS_RECT);
		messageRectString = product.getProperty(IProductConstants.STARTUP_MESSAGE_RECT);
		foregroundColorString = product.getProperty(IProductConstants.STARTUP_FOREGROUND_COLOR);
		versionColorString = product.getProperty("versionForegroundColor");
		buildIdLocationString = product.getProperty("versionRect");
	}
	Rectangle progressRect = StringConverter.asRectangle(progressRectString, new Rectangle(10, 10, 300, 15));
	setProgressRect(progressRect);

	Rectangle messageRect = StringConverter.asRectangle(messageRectString, new Rectangle(10, 35, 300, 15));
	setMessageRect(messageRect);

	int foregroundColorInteger;
	int versionColorInteger;
	try {
		foregroundColorInteger = Integer.parseInt(foregroundColorString, 16);
		versionColorInteger = Integer.parseInt(versionColorString, 16);
	}
	catch (Exception ex) {
		foregroundColorInteger = 0xD2D7FF; // off white
		versionColorInteger = 0xD2D7FF; // off white
	}

	setForeground(new RGB((foregroundColorInteger & 0xFF0000) >> 16, (foregroundColorInteger & 0xFF00) >> 8,
			foregroundColorInteger & 0xFF));
	final Color versionColor = new Color(getSplash().getShell().getDisplay(),
			new RGB((versionColorInteger & 0xFF0000) >> 16, (versionColorInteger & 0xFF00) >> 8,
					versionColorInteger & 0xFF));

	// add Version number at custom location
	final String version = getVersionString();
	final Point versionPoint = StringConverter.asPoint(buildIdLocationString, new Point(322, 190));
	getContent().addPaintListener(new PaintListener() {

		public void paintControl(PaintEvent e) {
			e.gc.setForeground(versionColor);

			// This is needed to right align the text to the given location
			Point p = e.gc.textExtent(version);
			e.gc.drawText(version, versionPoint.x - p.x, versionPoint.y, true);
		}
	});
}
 
Example 19
Source File: TomcatVmArgsBuilder.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public String getProductApplicationId() {
    return Platform.getProduct() != null ? Platform.getProduct().getApplication() : null;
}
 
Example 20
Source File: UIDesignerServerManager.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private String getProductApplicationId() {
    return Platform.getProduct() != null ? Platform.getProduct().getApplication() : null;
}