public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { try { server.modifyModules(null, new IModule[] { module }, monitor); } catch (Exception e) { // ignore } return Status.OK_STATUS; }
protected static int getTimestamp(CommandManagerInfo info) { IServer server = info.wc.getOriginal(); if (server != null) return ((Server)server).getTimestamp(); return -1; }
public static void addModule(IModule module, TaskModel taskModel, IProgressMonitor monitor) throws CoreException { if (module == null) return; IServer server = (IServer) taskModel.getObject(TaskModel.TASK_SERVER); IModule parentModule = null; try { IModule[] parents = server.getRootModules(module, monitor); if (parents != null && parents.length > 0) parentModule = parents[0]; } catch (Exception e) { Trace.trace(Trace.WARNING, "Could not find parent module", e); } if (parentModule == null) { // use the original module since no parent module is available parentModule = module; } IModule[] modules = server.getModules(); int size = modules.length; for (int i = 0; i < size; i++) { if (parentModule.equals(modules[i])) return; } IServerWorkingCopy workingCopy = server.createWorkingCopy(); workingCopy.modifyModules(new IModule[] { parentModule }, new IModule[0], monitor); taskModel.putObject(TaskModel.TASK_SERVER, workingCopy.save(false, monitor)); }
try { IServerWorkingCopy wc = server.createWorkingCopy(); IModule[] parents = wc.getRootModules(modules[0], null); if (parents == null || parents.length == 0) return false; if (wc.canModifyModules(add, null, null).getSeverity() != IStatus.ERROR) { wc.modifyModules(modules, null, null); wc.save(false, null); return true;
protected static void tempSaveServer(TaskModel taskModel, IProgressMonitor monitor) throws CoreException { IServer server = (IServer) taskModel.getObject(TaskModel.TASK_SERVER); if (server != null && server instanceof IServerWorkingCopy) { IServerWorkingCopy workingCopy = (IServerWorkingCopy) server; if (!workingCopy.isDirty()) return; IFile file = ((Server)workingCopy).getFile(); if (file != null) { IProject project = file.getProject(); if (!file.getProject().exists()) EclipseUtil.createNewServerProject(null, project.getName(), null, monitor); ProjectProperties pp = ServerPlugin.getProjectProperties(project); if (!pp.isServerProject()) pp.setServerProject(true, monitor); } IRuntime runtime = workingCopy.getRuntime(); server = workingCopy.save(false, monitor); workingCopy = server.createWorkingCopy(); workingCopy.setRuntime(runtime); if (workingCopy.getServerType().hasServerConfiguration()) ((ServerWorkingCopy)workingCopy).importRuntimeConfiguration(runtime, null); taskModel.putObject(TaskModel.TASK_SERVER, workingCopy); } }
@Override public void performFinish(IProgressMonitor monitor) throws CoreException { IServer server = (IServer) getTaskModel().getObject(TaskModel.TASK_SERVER); if (server instanceof IServerWorkingCopy) { IServerWorkingCopy wc = (IServerWorkingCopy) server; wc.setAttribute(ISlingLaunchpadServer.PROP_PORT, DefaultCQLaunchpadConfiguration.INSTANCE.getPort()); wc.save(true, monitor); } } }
@Override public void setDefaults(IProgressMonitor monitor) { super.setDefaults(monitor); String typeName = CloudFoundryBrandingExtensionPoint.getServerDisplayName(serverTypeId); if (typeName == null || typeName.trim().length() == 0) { typeName = getServer().getServerType().getName(); } String name = typeName; int i = 2; while (ServerPlugin.isNameInUse(getServerWorkingCopy().getOriginal(), name)) { name = NLS.bind("{0} ({1})", new String[] { typeName, String.valueOf(i) }); //$NON-NLS-1$ i++; } getServerWorkingCopy().setName(name); getServerWorkingCopy().setHost("Cloud"); //$NON-NLS-1$ setAttribute("auto-publish-setting", 1); //$NON-NLS-1$ }
public IServer getServer(IModule module, IModuleArtifact moduleArtifact, IProgressMonitor monitor) throws CoreException { if (!ServerUIPlugin.isCompatibleWithLaunchMode(finalServer, launchMode)) return null; if (!ServerUtil.containsModule(finalServer, module, monitor)) { IServerWorkingCopy wc = finalServer.createWorkingCopy(); try { ServerUtil.modifyModules(wc, new IModule[] { module }, new IModule[0], monitor); wc.save(false, monitor); } catch (CoreException ce) { throw ce; } } return finalServer; } };
/** * Execute the command. * * @param monitor a progress monitor * @param info * @throws CoreException */ public void execute(IProgressMonitor monitor, IAdaptable info) throws CoreException { IServerWorkingCopy wc = null; IServer server2 = (IServer) getTaskModel().getObject(TaskModel.TASK_SERVER); if (server2 instanceof IServerWorkingCopy) wc = (IServerWorkingCopy) server2; else wc = server2.createWorkingCopy(); TomcatServer server = (TomcatServer) wc.loadAdapter(TomcatServer.class, monitor); TomcatConfiguration configuration = server.getTomcatConfiguration(); if (configuration.getWebModules().size() <= index) return; module = (WebModule) configuration.getWebModules().get(index); if (contextRoot != null && !contextRoot.startsWith("/") && contextRoot.length() > 0) contextRoot = "/" + contextRoot; if (!contextRoot.equals(module.getPath())) { configuration.modifyWebModule(index, module.getDocumentBase(), contextRoot, module.isReloadable()); wc.save(true, monitor); } }
String name = ""; if (server != null) name = server.getName(); monitor.beginTask(NLS.bind(Messages.savingTask, name), ticks); if (server != null) server.save(false, ProgressUtil.getSubMonitorFor(monitor, ticks)); getCommandManager().resourceSaved(serverId); commandManager.updateTimestamps(serverId);
protected static void saveServer(TaskModel taskModel, IProgressMonitor monitor) throws CoreException { IServer server = (IServer) taskModel.getObject(TaskModel.TASK_SERVER); if (server != null && server instanceof IServerWorkingCopy) { IServerWorkingCopy workingCopy = (IServerWorkingCopy) server; if (workingCopy.isDirty()) { IFile file = ((Server)workingCopy).getFile(); if (file != null) { IProject project = file.getProject(); if (!file.getProject().exists()) EclipseUtil.createNewServerProject(null, project.getName(), null, monitor); ProjectProperties pp = ServerPlugin.getProjectProperties(project); if (!pp.isServerProject()) pp.setServerProject(true, monitor); } taskModel.putObject(TaskModel.TASK_SERVER, workingCopy.save(false, monitor)); } } }
server.setHost(host); ServerUtil.setServerDefaultName(server); runtime = server.getRuntime(); listener.runtimeSelected(runtime); return; server = cache.getServer(serverType, isLocalhost, null); if (server != null) { server.setHost(host); ServerUtil.setServerDefaultName(server); if (serverType.hasRuntime() && server.getRuntime() == null) { runtime = null; updateRuntimes(serverType); setRuntime(getDefaultRuntime()); if (server.getServerType() != null && server.getServerType().hasServerConfiguration() && !runtime.getLocation().isEmpty()) ((ServerWorkingCopy)server).importRuntimeConfiguration(runtime, null);
/** * Undo the command. */ public void undo() { server.setHost(oldName); } }
public void setPassword(String password) { this.secureStoreDirty = true; this.password = password; // remove password in case an earlier version stored it in server // properties if (getServerWorkingCopy() != null) { getServerWorkingCopy().setAttribute(PROP_PASSWORD_ID, (String) null); } // in case setUrl() or setPassword() were never called, e.g. for legacy // servers updateServerId(); if (getData() != null) { getData().setPassword(password); } }
/** * Undo the command. */ public void undo() { server.setName(oldName); } }
server.addPropertyChangeListener(listener);
/** * Invoked when an action occurs. */ public void run() { if (MessageDialog.openConfirm(shell, Messages.defaultDialogTitle, Messages.dialogRemoveModuleConfirm)) { try { IServerWorkingCopy wc = server.createWorkingCopy(); wc.modifyModules(null, new IModule[] { module }, null); server = wc.save(true, null); if (server.getServerState() != IServer.STATE_STOPPED && ((Server)server).getAutoPublishSetting() != Server.AUTO_PUBLISH_DISABLE) { PublishServerJob publishJob = new PublishServerJob(server); publishJob.schedule(); } } catch (Exception e) { Trace.trace(Trace.WARNING, "Could not remove module", e); } } } }