Search in sources :

Example 11 with IServer

use of org.eclipse.wst.server.core.IServer in project liferay-ide by liferay.

the class WorkflowDefinitionsCustomContentProvider method getPipelinedChildren.

@SuppressWarnings({ "rawtypes", "unchecked" })
public void getPipelinedChildren(Object parent, Set currentChildren) {
    if (parent instanceof IServer) {
        IServer server = (IServer) parent;
        /*
			 * IServerListener listener = new IServerListener() {

			 *
			 *
			 * @Override public void serverChanged( ServerEvent event ) { try {
			 * WorkflowDefinitionsCustomContentProvider.checkApiStatuses.
			 * remove( server.getId() ); refreshUI( (NavigatorContentService)
			 * getConfig().getService(), server ); } catch( Exception e) {} } };
			 * server.addServerListener( listener );
			 */
        if (server.getServerState() == IServer.STATE_STARTED) {
            WorkflowDefinitionsFolder definitionsNode = _workflowDefinitionFolders.get(server.getId());
            if (definitionsNode == null) {
                IStatus checkApiStatus = _checkApiStatuses.get(server.getId());
                if (checkApiStatus == null) {
                    Job checkJob = new Job("Checking for Kaleo Designer API...") {

                        @Override
                        protected IStatus run(IProgressMonitor monitor) {
                            try {
                                IKaleoConnection kaleoConnection = KaleoCore.getKaleoConnection(server);
                                KaleoCore.updateKaleoConnectionSettings(KaleoUtil.getLiferayServer(server, monitor), kaleoConnection);
                                kaleoConnection.getKaleoDefinitions();
                                kaleoConnection.getKaleoDraftWorkflowDefinitions();
                                WorkflowDefinitionsCustomContentProvider.this._checkApiStatuses.put(server.getId(), Status.OK_STATUS);
                                refreshUI((NavigatorContentService) getConfig().getService(), server);
                            } catch (Exception e) {
                                WorkflowDefinitionsCustomContentProvider.this._checkApiStatuses.put(server.getId(), KaleoUI.createErrorStatus(e));
                            }
                            return Status.OK_STATUS;
                        }
                    };
                    checkJob.schedule();
                } else {
                    if (checkApiStatus.isOK()) {
                        _insertDefinitionsNode(server, currentChildren);
                        WorkflowDefinitionsCustomContentProvider.this._checkApiStatuses.put(server.getId(), null);
                    } else {
                        KaleoUI.logInfo("Kaleo Workflow API unavailable.", checkApiStatus);
                    }
                }
            } else {
                if (!currentChildren.contains(definitionsNode)) {
                    currentChildren.add(definitionsNode);
                    // make sure children are cached.
                    definitionsNode.getChildren();
                }
            }
        } else {
            _workflowDefinitionFolders.put(server.getId(), null);
            _checkApiStatuses.put(server.getId(), null);
        }
    }
}
Also used : IServer(org.eclipse.wst.server.core.IServer) IStatus(org.eclipse.core.runtime.IStatus) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IKaleoConnection(com.liferay.ide.kaleo.core.IKaleoConnection) Job(org.eclipse.core.runtime.jobs.Job)

Example 12 with IServer

use of org.eclipse.wst.server.core.IServer in project liferay-ide by liferay.

the class WorkflowDefinitionsCustomContentProvider method hasChildren.

public boolean hasChildren(Object element, boolean currentHasChildren) {
    if (element instanceof IServer) {
        /*
			 * higher priority extension should consider Properties File
			 * extension's result
			 */
        if (currentHasChildren) {
            return true;
        }
        IServer server = (IServer) element;
        WorkflowDefinitionsFolder definitionsNode = _workflowDefinitionFolders.get(server.getId());
        if (definitionsNode != null) {
            return true;
        }
        if (ServerUtil.isLiferayRuntime(server)) {
            if (server.getServerState() == IServer.STATE_STARTED) {
                return true;
            }
        }
    }
    return currentHasChildren;
}
Also used : IServer(org.eclipse.wst.server.core.IServer)

Example 13 with IServer

use of org.eclipse.wst.server.core.IServer in project liferay-ide by liferay.

the class WorkflowProjectAdapterService method convert.

@Override
public <A> A convert(Object object, Class<A> adapterType) {
    A retval = null;
    if (IProject.class.equals(adapterType)) {
        ISapphirePart sapphirePart = context().find(ISapphirePart.class);
        WorkflowDefinition workflowDefinition = sapphirePart.getLocalModelElement().nearest(WorkflowDefinition.class);
        IFile file = workflowDefinition.adapt(IFile.class);
        if (file != null) {
            retval = adapterType.cast(file.getProject());
        } else {
            // create support project
            WorkflowSupportManager workflowSupportManager = KaleoCore.getDefault().getWorkflowSupportManager();
            IEditorInput editorInput = workflowDefinition.adapt(IEditorInput.class);
            if (editorInput instanceof WorkflowDefinitionEditorInput) {
                WorkflowDefinitionEditorInput workflowInput = (WorkflowDefinitionEditorInput) editorInput;
                WorkflowDefinitionEntry workflowEntry = workflowInput.getWorkflowDefinitionEntry();
                IServer server = workflowEntry.getParent().getParent();
                workflowSupportManager.setCurrentServer(server);
            }
            IJavaProject supportProject = workflowSupportManager.getSupportProject();
            retval = adapterType.cast(supportProject.getProject());
        }
    }
    return retval;
}
Also used : WorkflowDefinitionEditorInput(com.liferay.ide.kaleo.ui.editor.WorkflowDefinitionEditorInput) WorkflowDefinitionEntry(com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionEntry) IServer(org.eclipse.wst.server.core.IServer) IFile(org.eclipse.core.resources.IFile) IJavaProject(org.eclipse.jdt.core.IJavaProject) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) ISapphirePart(org.eclipse.sapphire.ui.ISapphirePart) WorkflowSupportManager(com.liferay.ide.kaleo.core.WorkflowSupportManager) IEditorInput(org.eclipse.ui.IEditorInput)

Example 14 with IServer

use of org.eclipse.wst.server.core.IServer in project liferay-ide by liferay.

the class DebugPortalLaunchParticipant method provideVMArgs.

public String provideVMArgs(ILaunchConfiguration configuration) {
    String retval = null;
    try {
        String stopServer = configuration.getAttribute(STOP_SERVER, "false");
        if (ILaunchManager.DEBUG_MODE.equals(saveLaunchMode) && "false".equals(stopServer)) {
            final IServer server = org.eclipse.wst.server.core.ServerUtil.getServer(configuration);
            final ILiferayRuntime liferayRuntime = (ILiferayRuntime) server.getRuntime().loadAdapter(ILiferayRuntime.class, null);
            final Version version = new Version(liferayRuntime.getPortalVersion());
            if (CoreUtil.compareVersions(version, ILiferayConstants.V620) >= 0) {
                if (this.fmDebugPort != null) {
                    retval = NLS.bind(FM_PARAMS, PortalCore.getPreference(PortalCore.PREF_FM_DEBUG_PASSWORD), this.fmDebugPort);
                } else {
                    // $NON-NLS-1$
                    PortalCore.logError("The freemarker debug port is invalid.");
                }
            }
        }
    } catch (CoreException e) {
    }
    return retval;
}
Also used : IServer(org.eclipse.wst.server.core.IServer) CoreException(org.eclipse.core.runtime.CoreException) Version(org.osgi.framework.Version) ILiferayRuntime(com.liferay.ide.server.core.ILiferayRuntime)

Example 15 with IServer

use of org.eclipse.wst.server.core.IServer in project liferay-ide by liferay.

the class DebugPortalLaunchParticipant method portalPostLaunch.

public void portalPostLaunch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
    final IServer server = org.eclipse.wst.server.core.ServerUtil.getServer(configuration);
    final IServerManagerConnection connection = ServerUtil.getServerManagerConnection(server, monitor);
    if (connection != null) {
        try {
            final String fmDebugPassword = connection.getFMDebugPassword();
            final int fmDebugPort = connection.getFMDebugPort();
            if (fmDebugPassword != null && fmDebugPort != -1) {
                launch.setAttribute(PortalCore.PREF_FM_DEBUG_PASSWORD, fmDebugPassword);
                launch.setAttribute(PortalCore.PREF_FM_DEBUG_PORT, Integer.toString(fmDebugPort));
                final IDebugTarget target = new FMDebugTarget(server.getHost(), launch, launch.getProcesses()[0]);
                launch.addDebugTarget(target);
            }
        } catch (APIException e) {
            LiferayServerCore.logError("Unable to determine remote freemarker debugger connection info.", e);
        }
    }
    this.saveLaunchMode = null;
    final String stopServer = configuration.getAttribute(STOP_SERVER, "false");
    if (ILaunchManager.DEBUG_MODE.equals(mode) && "false".equals(stopServer)) {
        if (this.fmDebugPort != null) {
            launch.setAttribute(PortalCore.PREF_FM_DEBUG_PORT, this.fmDebugPort);
            this.fmDebugPort = null;
            final IDebugTarget target = new FMDebugTarget(server.getHost(), launch, launch.getProcesses()[0]);
            launch.addDebugTarget(target);
        } else {
            // $NON-NLS-1$
            PortalCore.logError("Launch freemarker port is invalid.");
        }
    }
}
Also used : FMDebugTarget(com.liferay.ide.portal.core.debug.fm.FMDebugTarget) IServer(org.eclipse.wst.server.core.IServer) APIException(com.liferay.ide.core.remote.APIException) IServerManagerConnection(com.liferay.ide.server.remote.IServerManagerConnection) IDebugTarget(org.eclipse.debug.core.model.IDebugTarget)

Aggregations

IServer (org.eclipse.wst.server.core.IServer)183 CoreException (org.eclipse.core.runtime.CoreException)39 IModule (org.eclipse.wst.server.core.IModule)32 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)30 Test (org.junit.Test)30 IProject (org.eclipse.core.resources.IProject)25 IStatus (org.eclipse.core.runtime.IStatus)25 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)23 ArrayList (java.util.ArrayList)20 File (java.io.File)17 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)13 Status (org.eclipse.core.runtime.Status)12 Iterator (java.util.Iterator)11 IPath (org.eclipse.core.runtime.IPath)11 IServerType (org.eclipse.wst.server.core.IServerType)11 CDKServer (org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)11 IOException (java.io.IOException)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)10 Server (org.eclipse.wst.server.core.internal.Server)10 IFolder (org.eclipse.core.resources.IFolder)8