Search in sources :

Example 16 with Server

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

the class ServerDecorator method getServerStatusLabel.

public static String getServerStatusLabel(IServer server) {
    IStatus status = ((Server) server).getServerStatus();
    if (status != null)
        return status.getMessage();
    if (server.getServerType() == null)
        return "";
    if (server.getServerState() == IServer.STATE_UNKNOWN)
        return "";
    String serverId = server.getId();
    if (ServersView2.publishing.contains(serverId))
        return ServerDecorator.syncState[4];
    // republish
    int i = 0;
    if (server.shouldPublish()) {
        if (((Server) server).isPublishUnknown())
            return "";
        i += 2;
    }
    if (server.shouldRestart())
        i = 1;
    return syncState[i];
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IServer(org.eclipse.wst.server.core.IServer) Server(org.eclipse.wst.server.core.internal.Server) ModuleServer(org.eclipse.wst.server.ui.internal.view.servers.ModuleServer)

Example 17 with Server

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

the class ServersView2 method dispose.

@Override
public void dispose() {
    ServerCore.removeServerLifecycleListener(serverResourceListener);
    // remove listeners from servers
    IServer[] servers = ServerCore.getServers();
    if (servers != null) {
        int size = servers.length;
        for (int i = 0; i < size; i++) {
            servers[i].removeServerListener(serverListener);
            ((Server) servers[i]).removePublishListener(publishListener);
        }
    }
    super.dispose();
}
Also used : Server(org.eclipse.wst.server.core.internal.Server) Point(org.eclipse.swt.graphics.Point)

Example 18 with Server

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

the class ServersView2 method addListener.

protected void addListener() {
    // To enable the UI updating of servers and its childrens
    serverResourceListener = new IServerLifecycleListener() {

        public void serverAdded(IServer server) {
            addServer(server);
            server.addServerListener(serverListener);
            ((Server) server).addPublishListener(publishListener);
        }

        public void serverChanged(IServer server) {
            refreshServerContent(server);
        }

        public void serverRemoved(IServer server) {
            removeServer(server);
            server.removeServerListener(serverListener);
            ((Server) server).removePublishListener(publishListener);
        }
    };
    ServerCore.addServerLifecycleListener(serverResourceListener);
    // To enable the refresh of the State decorator
    publishListener = new PublishAdapter() {

        public void publishStarted(IServer server) {
            handlePublishChange(server, true);
        }

        public void publishFinished(IServer server, IStatus status) {
            handlePublishChange(server, false);
        }
    };
    serverListener = new IServerListener() {

        public void serverChanged(ServerEvent event) {
            if (event == null)
                return;
            int eventKind = event.getKind();
            IServer server = event.getServer();
            if ((eventKind & ServerEvent.SERVER_CHANGE) != 0) {
                // server change event
                if ((eventKind & ServerEvent.STATE_CHANGE) != 0) {
                    int state = event.getState();
                    String id = server.getId();
                    if (state == IServer.STATE_STARTING || state == IServer.STATE_STOPPING) {
                        boolean startThread = false;
                        synchronized (starting) {
                            if (!starting.contains(id)) {
                                if (starting.isEmpty())
                                    startThread = true;
                                starting.add(id);
                            }
                        }
                        if (startThread)
                            startThread();
                    } else {
                        boolean stopThread = false;
                        synchronized (starting) {
                            if (starting.contains(id)) {
                                starting.remove(id);
                                if (starting.isEmpty())
                                    stopThread = true;
                            }
                        }
                        if (stopThread)
                            stopThread();
                    }
                    refreshServerState(server);
                    refreshServerContent(server);
                } else if ((eventKind & ServerEvent.PUBLISH_STATE_CHANGE) != 0 || (eventKind & ServerEvent.STATUS_CHANGE) != 0) {
                    refreshServerState(server);
                }
            } else if ((eventKind & ServerEvent.MODULE_CHANGE) != 0) {
                // module change event
                if ((eventKind & ServerEvent.STATE_CHANGE) != 0 || (eventKind & ServerEvent.PUBLISH_STATE_CHANGE) != 0 || (eventKind & ServerEvent.STATUS_CHANGE) != 0) {
                    refreshServerContent(server);
                }
            }
        // TODO Angel Says: I don't think we need this
        // refreshServer(server);
        }
    };
    // add listeners to servers
    IServer[] servers = ServerCore.getServers();
    if (servers != null) {
        int size = servers.length;
        for (int i = 0; i < size; i++) {
            servers[i].addServerListener(serverListener);
            ((Server) servers[i]).addPublishListener(publishListener);
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Server(org.eclipse.wst.server.core.internal.Server) PublishAdapter(org.eclipse.wst.server.core.util.PublishAdapter) Point(org.eclipse.swt.graphics.Point)

Example 19 with Server

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

the class DefaultServerLabelDecorator method decorateImage.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ILabelDecorator#decorateImage(org.eclipse.swt.graphics.Image, java.lang.Object)
	 */
public Image decorateImage(Image image, Object element) {
    try {
        Image img = map.get(element);
        if (img != null)
            return img;
    } catch (Exception e) {
    // ignore
    }
    DefaultServerImageDescriptor dsid = null;
    if (element instanceof Server) {
        IStatus status = ((Server) element).getServerStatus();
        if (status != null) {
            ISharedImages sharedImages = ServerUIPlugin.getInstance().getWorkbench().getSharedImages();
            if (status.getSeverity() == IStatus.ERROR)
                dsid = new DefaultServerImageDescriptor(image, sharedImages.getImage(ISharedImages.IMG_OBJS_ERROR_TSK));
            else if (status.getSeverity() == IStatus.WARNING)
                dsid = new DefaultServerImageDescriptor(image, sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK));
            else if (status.getSeverity() == IStatus.INFO)
                dsid = new DefaultServerImageDescriptor(image, sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK));
        }
    }
    if (dsid == null)
        dsid = new DefaultServerImageDescriptor(image);
    Image image2 = dsid.createImage();
    map.put(element, image2);
    return image2;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Server(org.eclipse.wst.server.core.internal.Server) ISharedImages(org.eclipse.ui.ISharedImages) Image(org.eclipse.swt.graphics.Image)

Example 20 with Server

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

the class ServerPropertyPage method createContents.

/**
 * Create the body of the page.
 *
 * @param parent org.eclipse.swt.widgets.Composite
 * @return org.eclipse.swt.widgets.Control
 */
protected Control createContents(Composite parent) {
    try {
        IAdaptable element = getElement();
        server = (IServer) element.getAdapter(IServer.class);
        Composite composite = new Composite(parent, SWT.NONE);
        GridLayout layout = new GridLayout();
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        layout.numColumns = 3;
        composite.setLayout(layout);
        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
        IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem();
        whs.setHelp(composite, ContextIds.SERVER_PROPERTY_PAGE);
        // name
        Label label = new Label(composite, SWT.NONE);
        label.setText(Messages.propServerInfoName);
        label = new Label(composite, SWT.NONE);
        label.setText(server.getName());
        GridData data = new GridData(GridData.FILL_HORIZONTAL);
        data.horizontalSpan = 2;
        label.setLayoutData(data);
        // type
        label = new Label(composite, SWT.NONE);
        label.setText(Messages.propServerInfoType);
        IServerType serverType = server.getServerType();
        label = new Label(composite, SWT.NONE);
        if (serverType != null)
            label.setText(serverType.getName());
        else
            label.setText(Messages.elementUnknownName);
        data = new GridData(GridData.FILL_HORIZONTAL);
        data.horizontalSpan = 2;
        label.setLayoutData(data);
        // vendor
        label = new Label(composite, SWT.NONE);
        label.setText(Messages.propServerInfoVendor);
        IRuntimeType runtimeType = null;
        if (serverType != null)
            runtimeType = serverType.getRuntimeType();
        label = new Label(composite, SWT.NONE);
        if (runtimeType != null)
            label.setText(runtimeType.getVendor());
        else
            label.setText(Messages.elementUnknownName);
        data = new GridData(GridData.FILL_HORIZONTAL);
        data.horizontalSpan = 2;
        label.setLayoutData(data);
        // location
        label = new Label(composite, SWT.NONE);
        label.setText(Messages.switchServerLocation);
        label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING));
        final Label serverLocation = new Label(composite, SWT.NONE);
        final Server svr = (Server) server;
        if (svr.getFile() != null)
            serverLocation.setText(svr.getFile().getFullPath().toPortableString());
        else
            serverLocation.setText(Messages.switchServerLocationMetadata);
        serverLocation.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
        Button switchLocation = new Button(composite, SWT.PUSH);
        switchLocation.setText(Messages.actionSwitchServerLocation);
        switchLocation.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
        switchLocation.setEnabled(!server.isReadOnly());
        switchLocation.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                try {
                    Server.switchLocation(svr, null);
                } catch (CoreException ce) {
                    if (Trace.SEVERE) {
                        Trace.trace(Trace.STRING_SEVERE, "Error switching server location", ce);
                    }
                }
                if (svr.getFile() != null)
                    serverLocation.setText(svr.getFile().getFullPath().toPortableString());
                else
                    serverLocation.setText(Messages.switchServerLocationMetadata);
            }
        });
        Dialog.applyDialogFont(composite);
        return composite;
    } catch (Exception e) {
        if (Trace.SEVERE) {
            Trace.trace(Trace.STRING_SEVERE, "Error creating property page", e);
        }
        return null;
    }
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) Composite(org.eclipse.swt.widgets.Composite) IServer(org.eclipse.wst.server.core.IServer) Server(org.eclipse.wst.server.core.internal.Server) IRuntimeType(org.eclipse.wst.server.core.IRuntimeType) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) CoreException(org.eclipse.core.runtime.CoreException) GridLayout(org.eclipse.swt.layout.GridLayout) IWorkbenchHelpSystem(org.eclipse.ui.help.IWorkbenchHelpSystem) CoreException(org.eclipse.core.runtime.CoreException) IServerType(org.eclipse.wst.server.core.IServerType) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

Server (org.eclipse.wst.server.core.internal.Server)23 IServer (org.eclipse.wst.server.core.IServer)17 IStatus (org.eclipse.core.runtime.IStatus)11 CoreException (org.eclipse.core.runtime.CoreException)7 IOException (java.io.IOException)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 Job (org.eclipse.core.runtime.jobs.Job)4 ControllableServerBehavior (org.jboss.ide.eclipse.as.wtp.core.server.behavior.ControllableServerBehavior)4 File (java.io.File)3 IFile (org.eclipse.core.resources.IFile)3 Status (org.eclipse.core.runtime.Status)3 IServerType (org.eclipse.wst.server.core.IServerType)3 IMemento (org.eclipse.wst.server.core.internal.IMemento)3 IControllableServerBehavior (org.jboss.ide.eclipse.as.wtp.core.server.behavior.IControllableServerBehavior)3 CDKServer (org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)3 ArrayList (java.util.ArrayList)2 IProject (org.eclipse.core.resources.IProject)2 IDebugEventSetListener (org.eclipse.debug.core.IDebugEventSetListener)2 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)2