Search in sources :

Example 1 with IServerLifecycleListener

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

the class RemoteServerWizardFragment method performFinish.

@Override
public void performFinish(IProgressMonitor monitor) throws CoreException {
    try {
        this.wizard.run(false, false, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                if (lastServerStatus == null || (!lastServerStatus.isOK())) {
                    lastServerStatus = getRemoteServerWC().validate(monitor);
                    if (!lastServerStatus.isOK()) {
                        throw new InterruptedException(lastServerStatus.getMessage());
                    }
                }
            }
        });
    } catch (Exception e) {
    }
    ServerCore.addServerLifecycleListener(new IServerLifecycleListener() {

        String id = getServerWorkingCopy().getId();

        public void serverAdded(final IServer server) {
            if (server.getId().equals(id)) {
                UIUtil.async(new Runnable() {

                    public void run() {
                        // $NON-NLS-1$
                        IViewPart serversView = UIUtil.showView("org.eclipse.wst.server.ui.ServersView");
                        CommonViewer viewer = (CommonViewer) serversView.getAdapter(CommonViewer.class);
                        viewer.setSelection(new StructuredSelection(server));
                    }
                });
                ServerCore.removeServerLifecycleListener(this);
                server.addServerListener(new IServerListener() {

                    public void serverChanged(ServerEvent event) {
                        if (event.getServer().getServerState() == IServer.STATE_STARTED) {
                            server.publish(IServer.PUBLISH_INCREMENTAL, null, null, null);
                            server.removeServerListener(this);
                        }
                    }
                });
            }
        }

        public void serverChanged(IServer server) {
        }

        public void serverRemoved(IServer server) {
        }
    });
}
Also used : IServer(org.eclipse.wst.server.core.IServer) IViewPart(org.eclipse.ui.IViewPart) CommonViewer(org.eclipse.ui.navigator.CommonViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) InvocationTargetException(java.lang.reflect.InvocationTargetException) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IServerLifecycleListener(org.eclipse.wst.server.core.IServerLifecycleListener) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ServerEvent(org.eclipse.wst.server.core.ServerEvent) IServerListener(org.eclipse.wst.server.core.IServerListener)

Example 2 with IServerLifecycleListener

use of org.eclipse.wst.server.core.IServerLifecycleListener in project webtools.servertools by eclipse.

the class ServerLifecycleListenerTestCase method testListener.

public void testListener() {
    IServerLifecycleListener listener = new IServerLifecycleListener() {

        public void serverAdded(IServer server) {
        // ignore
        }

        public void serverChanged(IServer server) {
        // ignore
        }

        public void serverRemoved(IServer server) {
        // ignore
        }
    };
    listener.serverAdded(null);
    listener.serverChanged(null);
    listener.serverRemoved(null);
}
Also used : IServerLifecycleListener(org.eclipse.wst.server.core.IServerLifecycleListener) IServer(org.eclipse.wst.server.core.IServer)

Example 3 with IServerLifecycleListener

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

the class LiferayServerCore method start.

/*
     * (non-Javadoc)
     * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext )
     */
@Override
public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;
    this.runtimeLifecycleListener = new IRuntimeLifecycleListener() {

        @Override
        public void runtimeAdded(IRuntime runtime) {
            saveGlobalRuntimeSettings(runtime);
        }

        @Override
        public void runtimeChanged(IRuntime runtime) {
            saveGlobalRuntimeSettings(runtime);
        }

        @Override
        public void runtimeRemoved(IRuntime runtime) {
            saveGlobalRuntimeSettings(runtime);
        }
    };
    this.serverLifecycleListener = new IServerLifecycleListener() {

        @Override
        public void serverAdded(IServer server) {
            saveGlobalServerSettings(server);
        }

        @Override
        public void serverChanged(IServer server) {
            saveGlobalServerSettings(server);
        }

        @Override
        public void serverRemoved(IServer server) {
            saveGlobalServerSettings(server);
            if (connections.get(server.getId()) != null) {
                connections.put(server.getId(), null);
            }
        }
    };
    ServerCore.addRuntimeLifecycleListener(this.runtimeLifecycleListener);
    ServerCore.addServerLifecycleListener(this.serverLifecycleListener);
}
Also used : IServerLifecycleListener(org.eclipse.wst.server.core.IServerLifecycleListener) IServer(org.eclipse.wst.server.core.IServer) IRuntimeLifecycleListener(org.eclipse.wst.server.core.IRuntimeLifecycleListener) IRuntime(org.eclipse.wst.server.core.IRuntime)

Example 4 with IServerLifecycleListener

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

the class KaleoCore method getKaleoConnection.

public static IKaleoConnection getKaleoConnection(ILiferayServer liferayServer) {
    if (_kaleoConnections == null) {
        _kaleoConnections = new HashMap<>();
        IServerLifecycleListener serverLifecycleListener = new IServerLifecycleListener() {

            public void serverAdded(IServer server) {
            }

            public void serverChanged(IServer server) {
            }

            public void serverRemoved(IServer s) {
                ILiferayServer server = (ILiferayServer) s.loadAdapter(ILiferayServer.class, new NullProgressMonitor());
                if (liferayServer.equals(server)) {
                    IKaleoConnection service = _kaleoConnections.get(liferayServer.getId());
                    if (service != null) {
                        service = null;
                        _kaleoConnections.put(liferayServer.getId(), null);
                    }
                }
            }
        };
        ServerCore.addServerLifecycleListener(serverLifecycleListener);
    }
    IKaleoConnection service = _kaleoConnections.get(liferayServer.getId());
    if (service == null) {
        service = new KaleoConnection();
        updateKaleoConnectionSettings(liferayServer, service);
        _kaleoConnections.put(liferayServer.getId(), service);
    }
    return service;
}
Also used : IServerLifecycleListener(org.eclipse.wst.server.core.IServerLifecycleListener) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) ILiferayServer(com.liferay.ide.server.core.ILiferayServer)

Aggregations

IServer (org.eclipse.wst.server.core.IServer)4 IServerLifecycleListener (org.eclipse.wst.server.core.IServerLifecycleListener)4 ILiferayServer (com.liferay.ide.server.core.ILiferayServer)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 IViewPart (org.eclipse.ui.IViewPart)1 CommonViewer (org.eclipse.ui.navigator.CommonViewer)1 IRuntime (org.eclipse.wst.server.core.IRuntime)1 IRuntimeLifecycleListener (org.eclipse.wst.server.core.IRuntimeLifecycleListener)1 IServerListener (org.eclipse.wst.server.core.IServerListener)1 ServerEvent (org.eclipse.wst.server.core.ServerEvent)1