/** * Returns an array of all known runtime instances of * the given runtime type. This convenience method filters the list of known * runtime ({@link ServerCore#getRuntimes()}) for ones with a matching * runtime type ({@link IRuntime#getRuntimeType()}). The array will not * contain any working copies. * <p> * A new array is returned on each call, so clients may store or modify the result. * </p> * * @param runtimeType the runtime type * @return a possibly-empty list of runtime instances {@link IRuntime} * of the given runtime type */ public static IRuntime[] getRuntimes(IRuntimeType runtimeType) { List list = new ArrayList(); IRuntime[] runtimes = ServerCore.getRuntimes(); if (runtimes != null) { int size = runtimes.length; for (int i = 0; i < size; i++) { if (runtimes[i].getRuntimeType() != null && runtimes[i].getRuntimeType().equals(runtimeType)) list.add(runtimes[i]); } } IRuntime[] r = new IRuntime[list.size()]; list.toArray(r); return r; }
private DataModelPropertyDescriptor[] getValidServerTargetDescriptors() { List targets = getValidServerTargets(); DataModelPropertyDescriptor[] descriptors = null; if (!targets.isEmpty()) { int serverTargetListSize = targets.size(); descriptors = new DataModelPropertyDescriptor[serverTargetListSize]; for (int i = 0; i < targets.size(); i++) { IRuntime runtime = (IRuntime) targets.get(i); descriptors[i] = new DataModelPropertyDescriptor(runtime.getId(), runtime.getName()); } } else { descriptors = new DataModelPropertyDescriptor[0]; } return descriptors; }
protected boolean matchesRuntime(IRuntime r) { String text = r.getName(); if (wordMatches(text)) return true; if (r.getLocation() != null) { text = r.getLocation().toPortableString(); if (wordMatches(text)) return true; text = r.getLocation().toOSString(); if (wordMatches(text)) return true; } if (r.getRuntimeType() != null && matchesRuntimeType(r.getRuntimeType())) return true; return false; }
public int getServerTargetIndexFromItems(IRuntime serverTarget) { if (items != null && items.length > 0) { String serverTargetLabel = serverTarget.getName() + " (" + serverTarget.getRuntimeType().getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ for (int i = 0; i < items.length; i++) { String label = items[i]; if (label.equals(serverTargetLabel)) { return i; } } } return -1; }
public void runtimeSelected(IRuntime runtime) { if (runtime == null) { edit.setEnabled(false); remove.setEnabled(false); pathLabel.setText(""); } else if (runtime.isReadOnly()) { edit.setEnabled(false); remove.setEnabled(false); pathLabel.setText(runtime.getLocation() + ""); } else { edit.setEnabled(true); remove.setEnabled(true); pathLabel.setText(runtime.getLocation() + ""); } } });
/** * @see RuntimeClasspathProviderDelegate#resolveClasspathContainer(IProject, IRuntime) */ public IClasspathEntry[] resolveClasspathContainer(IProject project, IRuntime runtime) { IPath installPath = runtime.getLocation(); if (installPath == null) return new IClasspathEntry[0]; List list = new ArrayList(); String runtimeId = runtime.getRuntimeType().getId(); if (runtimeId.indexOf("32") > 0) { IPath path = installPath.append("lib"); addLibraryEntries(list, path.toFile(), true); } else if (runtimeId.indexOf("60") > 0) { // TODO May need some flexibility in case the installation has been configured differently // This lib "simplification" may cause issues for some. // Not known yet whether packaged Linux installs will go along. IPath path = installPath.append("lib"); addLibraryEntries(list, path.toFile(), true); } else { IPath path = installPath.append("common"); addLibraryEntries(list, path.append("lib").toFile(), true); addLibraryEntries(list, path.append("endorsed").toFile(), true); } return (IClasspathEntry[])list.toArray(new IClasspathEntry[list.size()]); } }
/** * @return */ private Object getDefaultServerTargetID() { List targets = getValidServerTargets(); if (!targets.isEmpty()) { IRuntime target = null; for (int i = targets.size() - 1; i < targets.size() && i >= 0; i--) { target = (IRuntime) targets.get(i); if (DEFAULT_TARGET_ID.equals(target.getId())) return target.getId(); } if (target != null) return target.getId(); } return null; }
/** * */ protected String getTextImpl(Object element) { IRuntime runtime = (IRuntime) element; return notNull(runtime.getName()); }
/** * Verifies the Tomcat installation directory. If it is * correct, true is returned. Otherwise, the user is notified * and false is returned. * @return boolean */ public IStatus verifyLocation() { return getVersionHandler().verifyInstallPath(getRuntime().getLocation()); }
protected void updateRuntimeCombo() { IRuntimeType runtimeType = server.getServerType().getRuntimeType(); runtimes = ServerUIPlugin.getRuntimes(runtimeType); if (SocketUtil.isLocalhost(server.getHost()) && runtimes != null) { List runtimes2 = new ArrayList(); int size = runtimes.length; for (int i = 0; i < size; i++) { IRuntime runtime2 = runtimes[i]; if (!runtime2.isStub()) runtimes2.add(runtime2); } runtimes = new IRuntime[runtimes2.size()]; runtimes2.toArray(runtimes); } int size = runtimes.length; String[] items = new String[size]; for (int i = 0; i < size; i++) items[i] = runtimes[i].getName(); runtimeCombo.setItems(items); }
public CloudFoundryServerRuntime getRuntime() { return (CloudFoundryServerRuntime) getServer().getRuntime().loadAdapter(CloudFoundryServerRuntime.class, null); }
public void keyPressed(KeyEvent e) { if (e.character == 'l') { try { IRuntime runtime = getSelectedRuntime(); IRuntimeWorkingCopy wc = runtime.createWorkingCopy(); wc.setReadOnly(!runtime.isReadOnly()); wc.save(false, null); refresh(runtime); } catch (Exception ex) { // ignore } } }
protected void editRuntime(IRuntime runtime) { IRuntimeWorkingCopy runtimeWorkingCopy = runtime.createWorkingCopy(); if (showWizard(runtimeWorkingCopy) != Window.CANCEL) { try { runtimeWorkingCopy.save(false, null); } catch (Exception ex) { // ignore } } }
public int compare(Viewer viewer, Object e1, Object e2) { IRuntime r1 = (IRuntime) e1; IRuntime r2 = (IRuntime) e2; if (sortByName) return getComparator().compare(notNull(r1.getName()), notNull(r2.getName())); if (r1.getRuntimeType() == null) return -1; if (r2.getRuntimeType() == null) return 1; return getComparator().compare(notNull(r1.getRuntimeType().getName()), notNull(r2.getRuntimeType().getName())); }
if (getRuntime().getLocation().hasTrailingSeparator()) return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, Messages.errorInstallDirTrailingSlash, null); if (getVMInstall() == null) String id = getRuntime().getRuntimeType().getId(); if (!found) { if (id != null && (id.indexOf("55") > 0 || id.indexOf("60") > 0)) return new Status(IStatus.WARNING, TomcatPlugin.PLUGIN_ID, 0, Messages.warningJRE, null); File f = getRuntime().getLocation().append("conf").toFile(); File[] conf = f.listFiles(); if (conf != null) {
private IRuntime getServerTargetByID(String id) { List targets = getValidServerTargets(); IRuntime target; for (int i = 0; i < targets.size(); i++) { target = (IRuntime) targets.get(i); if (id.equals(target.getId())) return target; } return null; }
runtimeLabel.setText(runtime.getName()); else runtimeLabel.setText("");
public List getRuntimeClasspath() { return getVersionHandler().getRuntimeClasspath(getRuntime().getLocation()); }
public TomcatRuntime getTomcatRuntime() { if (getServer().getRuntime() == null) return null; return (TomcatRuntime) getServer().getRuntime().loadAdapter(TomcatRuntime.class, null); }
public void widgetSelected(SelectionEvent e) { IRuntime runtime = runtimeComp.getSelectedRuntime(); if (runtime != null) { IRuntimeWorkingCopy runtimeWorkingCopy = runtime.createWorkingCopy(); if (showWizard(runtimeWorkingCopy) != Window.CANCEL) { try { runtimeComp.refresh(runtime); } catch (Exception ex) { // ignore } } } } });