private boolean hasFacet(IProject project, String facet) { try { return FacetedProjectFramework.hasProjectFacet(project, facet); } catch (CoreException e) { ProjectUIPlugin.logError(e); return false; } }
protected void createInfoGroup(Composite parent) { new Label(parent, SWT.LEFT).setText(Msgs.liferayPluginTypeLabel); final Text pluginTypeLabel = new Text(parent, SWT.READ_ONLY | SWT.BORDER); pluginTypeLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); final IProjectFacet liferayFacet = ProjectUtil.getLiferayFacet(getFacetedProject()); if (liferayFacet != null) { pluginTypeLabel.setText(liferayFacet.getLabel()); } new Label(parent, SWT.LEFT).setText(Msgs.liferayRuntimeLabel); this.runtimeCombo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY); this.runtimeCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1)); String currentRuntimeName = null; try { ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(getProject()); currentRuntimeName = liferayRuntime.getRuntime().getName(); } catch (Exception e) { ProjectUIPlugin.logError("Could not determine liferay runtime", e); // $NON-NLS-1$ } final List<String> runtimeNames = new ArrayList<String>(); int selectionIndex = -1; for (IRuntime runtime : ServerCore.getRuntimes()) { if (ServerUtil.isLiferayRuntime(runtime)) { runtimeNames.add(runtime.getName()); if (runtime.getName().equals(currentRuntimeName)) { selectionIndex = runtimeNames.size() - 1; } } } if (runtimeNames.size() == 0) { runtimeNames.add("No Liferay runtimes available."); // $NON-NLS-1$ } this.runtimeCombo.setItems(runtimeNames.toArray(new String[0])); if (selectionIndex > -1) { this.runtimeCombo.select(selectionIndex); } }