use of org.eclipse.wst.server.core.IServer in project sling by apache.
the class ServersActionModeFiddlerActionDelegate method selectionChanged.
@Override
public void selectionChanged(IAction action, ISelection selection) {
server = null;
modules = null;
if (selection != null && (selection instanceof IStructuredSelection)) {
IStructuredSelection iss = (IStructuredSelection) selection;
Object first = iss.getFirstElement();
if (first instanceof IServer) {
server = (IServer) first;
modules = null;
if (iss.size() > 1) {
// verify that all selected elements are of type IServer
Iterator<?> it = iss.iterator();
// skip the first, we have that above already
it.next();
while (it.hasNext()) {
Object next = it.next();
if (!(next instanceof IServer)) {
server = null;
modules = null;
break;
}
}
}
} else if (first instanceof IServerModule) {
modules = new LinkedList<>();
IServerModule module = (IServerModule) first;
modules.add(module.getModule());
server = module.getServer();
if (iss.size() > 1) {
// verify that all selected elements are of type IServerModule
// plus add the module[] to the modules list
Iterator<?> it = iss.iterator();
// skip the first, we have that above already
it.next();
while (it.hasNext()) {
Object next = it.next();
if (!(next instanceof IServerModule)) {
server = null;
module = null;
break;
} else {
module = (IServerModule) next;
modules.add(module.getModule());
}
}
}
}
}
if (server != null) {
if (server.getServerState() != IServer.STATE_STARTED) {
server = null;
modules = null;
}
}
cleanAction.setEnabled(server != null);
publishAction.setEnabled(server != null);
action.setEnabled(true);
final IAction serverRunAction = actionBars.getGlobalActionHandler("org.eclipse.wst.server.run");
final IAction serverDebugAction = actionBars.getGlobalActionHandler("org.eclipse.wst.server.debug");
IAction stopRunAction = actionBars.getGlobalActionHandler("org.eclipse.wst.server.stop");
if (serverRunAction == null || stopRunAction == null || serverDebugAction == null) {
return;
}
// serverRunAction.setHoverImageDescriptor(SharedImages.SLING_LOG);
serverRunAction.setHoverImageDescriptor(SharedImages.RUN_CONNECT);
serverDebugAction.setHoverImageDescriptor(SharedImages.DEBUG_CONNECT);
stopRunAction.setHoverImageDescriptor(SharedImages.DISCONNECT);
findWstPublishAction();
for (ActionContributionItem appendedAction : appendedToolbarActionContributionItems) {
if (!contributionAdded(appendedAction)) {
actionBars.getToolBarManager().add(appendedAction);
}
}
if (wstPublishAction != null) {
wstPublishAction.setVisible(false);
publishActionContributionItem.setVisible(true);
} else {
// otherwise hide it, as it is an unexpected situation
publishActionContributionItem.setVisible(false);
}
final String runText = "Connect to server in run mode";
if (runTooltipListener == null) {
runTooltipListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(IAction.TOOL_TIP_TEXT)) {
if (!event.getNewValue().equals(runText)) {
serverRunAction.setToolTipText(runText);
}
}
}
};
serverRunAction.addPropertyChangeListener(runTooltipListener);
}
final String debugText = "Connect to server in debug mode";
if (debugTooltipListener == null) {
debugTooltipListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(IAction.TOOL_TIP_TEXT)) {
if (!event.getNewValue().equals(debugText)) {
serverDebugAction.setToolTipText(debugText);
}
}
}
};
serverDebugAction.addPropertyChangeListener(debugTooltipListener);
}
final String disconnectText = "Disconnect from server";
if (disconnectTooltipListener == null) {
disconnectTooltipListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(IAction.TOOL_TIP_TEXT)) {
if (!event.getNewValue().equals(disconnectText)) {
serverRunAction.setToolTipText(disconnectText);
}
}
}
};
stopRunAction.addPropertyChangeListener(disconnectTooltipListener);
}
serverRunAction.setToolTipText(runText);
serverDebugAction.setToolTipText(debugText);
stopRunAction.setToolTipText(disconnectText);
}
use of org.eclipse.wst.server.core.IServer in project sling by apache.
the class SlingLaunchpadCombo method refreshRepositoryList.
public void refreshRepositoryList(IProgressMonitor monitor) {
repositoryCombo.removeAll();
List<IServer> servers = project != null ? SelectionUtils.getServersLinkedToProject(project, monitor) : Arrays.asList(ServerCore.getServers());
for (IServer server : servers) {
repositoryCombo.add(server.getId());
}
if (servers.size() > 0) {
repositoryCombo.select(0);
}
}
use of org.eclipse.wst.server.core.IServer in project sling by apache.
the class AbstractNewSlingApplicationWizard method publishModules.
protected void publishModules(final List<IProject> createdProjects, IProgressMonitor monitor) throws CoreException {
IServer server = setupServerWizardPage.getOrCreateServer(monitor);
if (server == null) {
return;
}
if (setupServerWizardPage.getStartServer()) {
server.start(ILaunchManager.RUN_MODE, monitor);
}
List<IModule[]> modules = new ArrayList<>();
for (IProject project : createdProjects) {
IModule module = ServerUtil.getModule(project);
if (module != null && shouldDeploy(module)) {
modules.add(new IModule[] { module });
}
}
if (modules.size() > 0) {
server.publish(IServer.PUBLISH_CLEAN, modules, null, null);
}
}
use of org.eclipse.wst.server.core.IServer in project sling by apache.
the class ImportWizard method performFinish.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
public boolean performFinish() {
if (!mainPage.isPageComplete()) {
return false;
}
final IServer server = mainPage.getServer();
IResource resource = mainPage.getResource();
final IProject project = resource.getProject();
final IPath projectRelativePath = resource.getProjectRelativePath();
try {
getContainer().run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
// following this change ( see org.apache.sling.ide.core.ResourceUtil )
try {
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
try {
new ImportRepositoryContentAction(server, projectRelativePath, project, serializationManager).run(monitor);
} catch (SerializationException e) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import failed", e));
} catch (InvocationTargetException e) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import failed", e.getCause()));
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} finally {
serializationManager.destroy();
}
}
}, project, IWorkspace.AVOID_UPDATE, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
}
});
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
mainPage.setErrorMessage("Import error : " + cause.getMessage() + " . Please see the error log for details.");
Activator.getDefault().getPluginLogger().error("Repository import failed", cause);
return false;
} catch (OperationCanceledException | InterruptedException e) {
Thread.currentThread().interrupt();
return false;
}
return true;
}
use of org.eclipse.wst.server.core.IServer in project sling by apache.
the class NewSlingContentProjectWizard method configureCreatedProjects.
@Override
protected Projects configureCreatedProjects(List<IProject> createdProjects, IProgressMonitor monitor) throws CoreException {
Projects projects = new Projects();
for (IProject project : createdProjects) {
ConfigurationHelper.convertToContentPackageProject(project, monitor, new Path("jcr_root"));
projects.getContentProjects().add(project);
}
IServer server = getSetupServerWizardPage().getOrCreateServer(monitor);
advance(monitor, 1);
finishConfiguration(createdProjects, server, monitor);
advance(monitor, 1);
return projects;
}
Aggregations