Search in sources :

Example 16 with ModuleServer

use of org.eclipse.wst.server.ui.internal.view.servers.ModuleServer in project webtools.servertools by eclipse.

the class ModifyModulesComposite method createControl.

/**
 * Creates the UI of the page.
 */
protected void createControl() {
    GridLayout layout = new GridLayout();
    layout.horizontalSpacing = SWTUtil.convertHorizontalDLUsToPixels(this, 4);
    layout.verticalSpacing = SWTUtil.convertVerticalDLUsToPixels(this, 4);
    layout.numColumns = 3;
    setBackground(getParent().getBackground());
    setLayout(layout);
    setFont(getParent().getFont());
    PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ContextIds.MODIFY_MODULES_COMPOSITE);
    Display display = getDisplay();
    color = display.getSystemColor(SWT.COLOR_DARK_GRAY);
    FontData[] fd = getFont().getFontData();
    int size2 = fd.length;
    for (int i = 0; i < size2; i++) fd[i].setStyle(SWT.ITALIC);
    font = new Font(display, fd);
    addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            font.dispose();
        }
    });
    Label label = new Label(this, SWT.NONE);
    GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
    data.horizontalSpan = 3;
    label.setLayoutData(data);
    label.setText(Messages.wizModuleMessage);
    label = new Label(this, SWT.NONE);
    label.setText(Messages.wizModuleAvailableList);
    label = new Label(this, SWT.NONE);
    label.setText("");
    label = new Label(this, SWT.NONE);
    label.setText(Messages.wizModuleDeployedList);
    Tree availableTree = new Tree(this, SWT.BORDER | SWT.MULTI);
    data = new GridData(GridData.FILL_BOTH);
    data.heightHint = 200;
    data.widthHint = 150;
    availableTree.setLayoutData(data);
    availableTreeViewer = new TreeViewer(availableTree);
    ILabelProvider labelProvider = ServerUICore.getLabelProvider();
    labelProvider.addListener(new ILabelProviderListener() {

        public void labelProviderChanged(LabelProviderChangedEvent event) {
            Object[] obj = event.getElements();
            if (obj == null)
                availableTreeViewer.refresh(true);
            else {
                obj = ServerUIPlugin.adaptLabelChangeObjects(obj);
                int size = obj.length;
                for (int i = 0; i < size; i++) availableTreeViewer.refresh(obj[i], true);
            }
        }
    });
    availableTreeViewer.setLabelProvider(labelProvider);
    availableTreeViewer.setContentProvider(new AvailableContentProvider());
    availableTreeViewer.setComparator(new ViewerComparator() {

        public int compare(Viewer viewer, Object e1, Object e2) {
            if (e1 instanceof ModuleServer && e2 instanceof ModuleServer) {
                ModuleServer s1 = (ModuleServer) e1;
                ModuleServer s2 = (ModuleServer) e2;
                return (s1.getModuleDisplayName().compareToIgnoreCase(s2.getModuleDisplayName()));
            }
            return super.compare(viewer, e1, e2);
        }
    });
    availableTreeViewer.setInput(ROOT);
    availableTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            setEnablement();
        }
    });
    availableTreeViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            setEnablement();
            if (add.isEnabled())
                add(false);
        }
    });
    // slosh buttons
    Composite comp = new Composite(this, SWT.NONE);
    data = new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL);
    comp.setLayoutData(data);
    layout = new GridLayout();
    layout.marginWidth = 5;
    layout.marginHeight = 25;
    layout.verticalSpacing = 20;
    comp.setLayout(layout);
    add = new Button(comp, SWT.PUSH);
    add.setText(Messages.wizModuleAdd);
    add.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    add.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            add(false);
        }
    });
    remove = new Button(comp, SWT.PUSH);
    remove.setText(Messages.wizModuleRemove);
    remove.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    remove.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            remove(false);
        }
    });
    label = new Label(comp, SWT.NONE);
    label.setText("");
    addAll = new Button(comp, SWT.PUSH);
    addAll.setText(Messages.wizModuleAddAll);
    addAll.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    addAll.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            add(true);
        }
    });
    removeAll = new Button(comp, SWT.PUSH);
    removeAll.setText(Messages.wizModuleRemoveAll);
    removeAll.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    removeAll.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            remove(true);
        }
    });
    Tree deployedTree = new Tree(this, SWT.BORDER | SWT.MULTI);
    data = new GridData(GridData.FILL_BOTH);
    data.widthHint = 150;
    deployedTree.setLayoutData(data);
    deployedTreeViewer = new TreeViewer(deployedTree) {

        public void doUpdateItem(Widget widget, Object element, boolean fullMap) {
            if (widget instanceof TreeItem && color != null) {
                TreeItem item = (TreeItem) widget;
                if (element instanceof ModuleServer) {
                    ModuleServer ms = (ModuleServer) element;
                    IModule m = ms.module[ms.module.length - 1];
                    if (m.isExternal())
                        item.setForeground(color);
                    else
                        item.setForeground(null);
                    if (!(server instanceof IServer) || ((IServer) server).getModulePublishState(ms.module) != IServer.PUBLISH_STATE_NONE)
                        item.setFont(font);
                    else
                        item.setFont(null);
                }
            }
            super.doUpdateItem(widget, element, fullMap);
        }
    };
    labelProvider = ServerUICore.getLabelProvider();
    labelProvider.addListener(new ILabelProviderListener() {

        public void labelProviderChanged(LabelProviderChangedEvent event) {
            Object[] obj = event.getElements();
            if (obj == null)
                deployedTreeViewer.refresh(true);
            else {
                int size = obj.length;
                for (int i = 0; i < size; i++) deployedTreeViewer.refresh(obj[i], true);
            }
        }
    });
    deployedTreeViewer.setLabelProvider(labelProvider);
    deployedTreeViewer.setContentProvider(new DeployedContentProvider());
    deployedTreeViewer.setComparator(new ViewerComparator() {

        public int compare(Viewer viewer, Object e1, Object e2) {
            if (e1 instanceof ModuleServer && e2 instanceof ModuleServer) {
                ModuleServer s1 = (ModuleServer) e1;
                ModuleServer s2 = (ModuleServer) e2;
                return (s1.module[s1.module.length - 1].getName().compareToIgnoreCase(s2.module[s2.module.length - 1].getName()));
            }
            return super.compare(viewer, e1, e2);
        }
    });
    deployedTreeViewer.setInput(ROOT);
    deployedTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            setEnablement();
        }
    });
    deployedTreeViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            setEnablement();
            if (remove.isEnabled())
                remove(false);
        }
    });
    if (showPublishOption) {
        final Button publish = new Button(this, SWT.CHECK);
        publish.setText(Messages.wizModulePublishImmediately);
        data = new GridData(GridData.FILL_HORIZONTAL);
        data.horizontalSpan = 3;
        publish.setLayoutData(data);
        publishImmediately = ServerUIPlugin.getPreferences().getPublishOnAddRemoveModule();
        publish.setSelection(publishImmediately);
        publish.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                publishImmediately = publish.getSelection();
            }
        });
    }
    setEnablement();
    availableTree.setFocus();
    Dialog.applyDialogFont(this);
}
Also used : Font(org.eclipse.swt.graphics.Font) GridLayout(org.eclipse.swt.layout.GridLayout) ModuleServer(org.eclipse.wst.server.ui.internal.view.servers.ModuleServer) FontData(org.eclipse.swt.graphics.FontData) GridData(org.eclipse.swt.layout.GridData)

Example 17 with ModuleServer

use of org.eclipse.wst.server.ui.internal.view.servers.ModuleServer in project liferay-ide by liferay.

the class PluginsCustomContentProvider method getPipelinedChildren.

public void getPipelinedChildren(Object aParent, Set theCurrentChildren) {
    List<ModuleServer> redirectedModules = new ArrayList<ModuleServer>();
    // if a portlet module is going to be displayed, don't show it
    for (Object pipelinedChild : theCurrentChildren) {
        if (pipelinedChild instanceof ModuleServer) {
            ModuleServer module = (ModuleServer) pipelinedChild;
            if (ProjectUtil.isLiferayFacetedProject(module.getModule()[0].getProject())) {
                redirectedModules.add(module);
            }
        }
    }
    for (ModuleServer redirectedModule : redirectedModules) {
        theCurrentChildren.remove(redirectedModule);
    }
    // add portlet contents if there are any liferay plugins
    if (redirectedModules.size() > 0) {
        this.pluginsContentNode = new PluginsContent(redirectedModules, aParent);
        theCurrentChildren.add(this.pluginsContentNode);
    }
}
Also used : ModuleServer(org.eclipse.wst.server.ui.internal.view.servers.ModuleServer) ArrayList(java.util.ArrayList)

Example 18 with ModuleServer

use of org.eclipse.wst.server.ui.internal.view.servers.ModuleServer in project liferay-ide by liferay.

the class PluginsCustomContentProvider method interceptRefresh.

public boolean interceptRefresh(PipelinedViewerUpdate aRefreshSynchronization) {
    boolean needToExpandPluginsNode = false;
    Object obj = aRefreshSynchronization.getRefreshTargets().toArray()[0];
    if (obj instanceof ModuleServer) {
        ModuleServer module = (ModuleServer) obj;
        IModule[] modules = module.getServer().getModules();
        for (IModule m : modules) {
            if (module.getModule()[0].equals(m)) {
                needToExpandPluginsNode = true;
            }
        }
    }
    return false;
}
Also used : IModule(org.eclipse.wst.server.core.IModule) ModuleServer(org.eclipse.wst.server.ui.internal.view.servers.ModuleServer)

Example 19 with ModuleServer

use of org.eclipse.wst.server.ui.internal.view.servers.ModuleServer in project liferay-ide by liferay.

the class RedeployHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    final List<ModuleServer> modules = new ArrayList<ModuleServer>();
    final ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (!selection.isEmpty()) {
        if (selection instanceof IStructuredSelection) {
            List selectedObj = ((IStructuredSelection) selection).toList();
            for (Object object : selectedObj) {
                if (object instanceof ModuleServer) {
                    ModuleServer moduleServer = (ModuleServer) object;
                    modules.add(moduleServer);
                }
            }
        }
    }
    for (ModuleServer moduleServer : modules) {
        final ILiferayServerBehavior liferayServerBehavior = (ILiferayServerBehavior) moduleServer.getServer().loadAdapter(ILiferayServerBehavior.class, null);
        if (liferayServerBehavior != null) {
            try {
                liferayServerBehavior.redeployModule(moduleServer.getModule());
            } catch (CoreException e) {
                throw new ExecutionException(e.getMessage(), e.getCause());
            }
        }
    }
    return null;
}
Also used : ILiferayServerBehavior(com.liferay.ide.server.core.ILiferayServerBehavior) CoreException(org.eclipse.core.runtime.CoreException) ModuleServer(org.eclipse.wst.server.ui.internal.view.servers.ModuleServer) ArrayList(java.util.ArrayList) ISelection(org.eclipse.jface.viewers.ISelection) List(java.util.List) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 20 with ModuleServer

use of org.eclipse.wst.server.ui.internal.view.servers.ModuleServer in project liferay-ide by liferay.

the class RedeployAction method run.

public void run(IAction action) {
    if (selectedModules == null) {
        // can't do anything if server has not been selected
        return;
    }
    if (selectedModules != null) {
        for (ModuleServer moduleServer : selectedModules) {
            final ILiferayServerBehavior liferayServerBehavior = (ILiferayServerBehavior) moduleServer.getServer().loadAdapter(ILiferayServerBehavior.class, null);
            if (liferayServerBehavior != null) {
                Job redeployJob = new Job("Redeploying " + moduleServer.getModuleDisplayName()) {

                    @Override
                    protected IStatus run(IProgressMonitor monitor) {
                        try {
                            liferayServerBehavior.redeployModule(moduleServer.getModule());
                        } catch (CoreException e) {
                            LiferayServerCore.logError("Error redeploying " + moduleServer.getModuleDisplayName(), e);
                        }
                        return Status.OK_STATUS;
                    }
                };
                redeployJob.setUser(true);
                redeployJob.schedule();
            }
        }
    }
}
Also used : ILiferayServerBehavior(com.liferay.ide.server.core.ILiferayServerBehavior) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) ModuleServer(org.eclipse.wst.server.ui.internal.view.servers.ModuleServer) Job(org.eclipse.core.runtime.jobs.Job)

Aggregations

ModuleServer (org.eclipse.wst.server.ui.internal.view.servers.ModuleServer)21 IModule (org.eclipse.wst.server.core.IModule)8 IServer (org.eclipse.wst.server.core.IServer)7 IProject (org.eclipse.core.resources.IProject)5 ILiferayServerBehavior (com.liferay.ide.server.core.ILiferayServerBehavior)3 ArrayList (java.util.ArrayList)3 CoreException (org.eclipse.core.runtime.CoreException)3 IStatus (org.eclipse.core.runtime.IStatus)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 Image (org.eclipse.swt.graphics.Image)2 Iterator (java.util.Iterator)1 List (java.util.List)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IFile (org.eclipse.core.resources.IFile)1 IMarker (org.eclipse.core.resources.IMarker)1 IPath (org.eclipse.core.runtime.IPath)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)1 ISelection (org.eclipse.jface.viewers.ISelection)1