/** * */ protected Image getImageImpl(Object element) { IRuntimeType runtimeType = (IRuntimeType) element; return ImageResource.getImage(runtimeType.getId()); }
protected boolean matchesRuntimeType(IRuntimeType rt) { String text = rt.getName(); if (wordMatches(text)) return true; text = rt.getDescription(); if (wordMatches(text)) return true; text = rt.getVendor(); if (wordMatches(text)) return true; text = rt.getVersion(); if (wordMatches(text)) return true; IModuleType[] mts = rt.getModuleTypes(); if (mts != null) { int size = mts.length; for (int i = 0; i < size; i++) { if (matchesModuleType(mts[i])) return true; } } return false; }
protected void handleSelection(IRuntimeType runtimeType) { if (runtimeType == null) runtime = null; else { try { runtime = null; runtime = (IRuntimeWorkingCopy) cache.get(runtimeType); } catch (Exception e) { // ignore } if (runtime == null) { try { runtime = runtimeType.createRuntime(null, null); ServerUtil.setRuntimeDefaultName(runtime); if (runtime != null) cache.put(runtimeType, runtime); } catch (Exception e) { // ignore } } } serverType = getCompatibleServerType(runtimeType); handleServer(); }
/** * Sort two runtime types. * * @param r1 the first runtime type * @param r2 the second runtime type * @return a negative number if the first element is less than the * second element; the value <code>0</code> if the first element is * equal to the second element; and a positive number if the first * element is greater than the second element */ protected int compareRuntimeTypes(IRuntimeType r1, IRuntimeType r2) { if (isSameFamily(r1.getName(), r1.getVersion(), r2.getName(), r2.getVersion())) return compareVersions(r1.getVersion(), r2.getVersion()); return r1.getName().compareToIgnoreCase(r2.getName()); }
public void fillTree() { clean(); List list = new ArrayList(); IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(type, version, runtimeTypeId); if (runtimeTypes != null) { int size = runtimeTypes.length; for (int i = 0; i < size; i++) { IRuntimeType runtimeType = runtimeTypes[i]; if (!creation || runtimeType.canCreate()) { TreeElement ele = getOrCreate(list, runtimeType.getVendor()); ele.contents.add(runtimeType); elementToParentMap.put(runtimeType, ele); } } } elements = list.toArray(); } }
/** * */ protected String getTextImpl(Object element) { IRuntimeType runtimeType = (IRuntimeType) element; return notNull(runtimeType.getName()); } }
/** * Returns true if the given server type can launch the module. */ protected boolean isValidServerType(IServerType type, IModule module) { try { IRuntimeType runtimeType = type.getRuntimeType(); ServerUtil.isSupportedModule(runtimeType.getModuleTypes(), module.getModuleType()); } catch (Exception e) { return false; } return true; } }
/** * Sort two server types. * * @param s1 the first server type * @param s2 the second server type * @return a negative number if the first element is less than the * second element; the value <code>0</code> if the first element is * equal to the second element; and a positive number if the first * element is greater than the second element */ protected int compareServerTypes(IServerType s1, IServerType s2) { IRuntimeType r1 = s1.getRuntimeType(); IRuntimeType r2 = s2.getRuntimeType(); if (r1 != null && r2 != null) { if (isSameFamily(s1.getName(), r1.getVersion(), s2.getName(), r2.getVersion())) return compareVersions(r1.getVersion(), r2.getVersion()); } return s1.getName().compareToIgnoreCase(s2.getName()); } }
public void selectionChanged(SelectionChangedEvent event) { Object obj = getSelection(event.getSelection()); if (obj instanceof IRuntimeType) { selection = (IRuntimeType) obj; setDescription(selection.getDescription()); } else { selection = null; setDescription(""); } listener.runtimeTypeSelected(selection); } });
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; }
protected boolean include(IServerType serverType) { if (serverTypeId != null && !serverType.getId().startsWith(serverTypeId)) return false; IRuntimeType runtimeType = serverType.getRuntimeType(); if (runtimeType == null) return false; String moduleTypeId = null; if (moduleType != null) moduleTypeId = moduleType.getId(); if (includeIncompatibleVersions) { if (!ServerUtil.isSupportedModule(runtimeType.getModuleTypes(), moduleTypeId, null)) return false; } else { String moduleVersion = null; if (moduleType != null) moduleVersion = moduleType.getVersion(); if (!ServerUtil.isSupportedModule(runtimeType.getModuleTypes(), moduleTypeId, moduleVersion)) return false; } if (localhost || serverType.supportsRemoteHosts()) return true; return false; }
if (serverTypeId.matches(serverId)) { String kieVersion = e.getAttribute("runtimeId"); String rid = server.getRuntime().getRuntimeType().getVersion();
public void selectionChanged(SelectionChangedEvent event) { Object obj = getSelection(event.getSelection()); if (obj instanceof IServer) { selection = (IServer) obj; setDescription(selection.getServerType().getRuntimeType().getDescription()); } else { selection = null; setDescription(""); } listener.serverSelected(selection); } });
public static ServerTargetComboHelper getValidServerTargetComboItems(String j2eeType, String selectedVersion) { IRuntime[] validServerTargets = ServerUtil.getRuntimes(j2eeType, selectedVersion); String[] serverTargetList = null; if (validServerTargets.length>0) { int serverTargetListSize = validServerTargets.length; serverTargetList = new String[serverTargetListSize]; for (int i = 0; i < validServerTargets.length; i++) { IRuntime runtime = validServerTargets[i]; serverTargetList[i] = runtime.getName() + " (" + runtime.getRuntimeType().getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ } } return new ServerTargetComboHelper(Arrays.asList(validServerTargets), serverTargetList); }
protected static IRuntimeWorkingCopy getRuntimeFromDir(File dir, IProgressMonitor monitor) { for (int i = 0; i < runtimeTypes.length; i++) { try { IRuntimeType runtimeType = ServerCore.findRuntimeType(runtimeTypes[i]); String absolutePath = dir.getAbsolutePath(); String id = absolutePath.replace(File.separatorChar,'_').replace(':','-'); IRuntimeWorkingCopy runtime = runtimeType.createRuntime(id, monitor); runtime.setName(dir.getName()); runtime.setLocation(new Path(absolutePath)); ITomcatRuntimeWorkingCopy wc = (ITomcatRuntimeWorkingCopy) runtime.loadAdapter(ITomcatRuntimeWorkingCopy.class, null); wc.setVMInstall(JavaRuntime.getDefaultVMInstall()); IStatus status = runtime.validate(monitor); if (status == null || status.getSeverity() != IStatus.ERROR) return runtime; Trace.trace(Trace.FINER, "False runtime found at " + dir.getAbsolutePath() + ": " + status.getMessage()); } catch (Exception e) { Trace.trace(Trace.SEVERE, "Could not find runtime", e); } } return null; } }
/** * Returns a list of all servers that this module is configured on. * * @param module org.eclipse.wst.server.core.IModule * @return java.util.List */ protected static IServer[] getServersBySupportedModule(IModule module) { if (module == null) return new IServer[0]; // do it the slow way - go through all servers and // see if this module is configured in it List list = new ArrayList(); IServer[] servers = ServerCore.getServers(); if (servers != null) { int size = servers.length; for (int i = 0; i < size; i++) { if (servers[i].getServerType() != null && servers[i].getServerType().getRuntimeType() != null && ServerUtil.isSupportedModule(servers[i].getServerType().getRuntimeType().getModuleTypes(), module.getModuleType())) list.add(servers[i]); } } IServer[] allServers = new IServer[list.size()]; list.toArray(allServers); return allServers; }
public void runtimeFound(IRuntimeWorkingCopy runtime) { String runtimeTypeId = runtime.getRuntimeType().getId(); String serverTypeId = runtimeTypeId.substring(0, runtimeTypeId.length() - 8); IServerType serverType = ServerCore.findServerType(serverTypeId); try { IServerWorkingCopy server = serverType.createServer(serverTypeId, null, runtime, monitor); listener.serverFound(server); } catch (Exception e) { Trace.trace(Trace.WARNING, "Could not create Tomcat server", e); } } };
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())); }
IRuntimeWorkingCopy runtimeWC = runtimeType.createRuntime(null, null); ServerUtil.setRuntimeDefaultName(runtimeWC); runtimes = new IRuntime[1];