Search in sources :

Example 1 with IModuleType

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

the class IModuleTypeTestCase method testCreate.

public void testCreate() {
    type = new IModuleType() {

        public String getId() {
            return null;
        }

        public String getName() {
            return null;
        }

        public String getVersion() {
            return null;
        }
    };
    type.getId();
    type.getName();
    type.getVersion();
}
Also used : IModuleType(org.eclipse.wst.server.core.IModuleType)

Example 2 with IModuleType

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

the class ProjectPropertyPage 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();
        project = (IProject) element.getAdapter(IProject.class);
        // if (element instanceof IProject)
        // project = (IProject) element;
        Composite composite = new Composite(parent, SWT.NONE);
        GridLayout layout = new GridLayout();
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        layout.numColumns = 2;
        layout.verticalSpacing = 5;
        composite.setLayout(layout);
        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
        /*Label label = new Label(composite, SWT.WRAP);
			label.setText(Messages.prefProjectDescription);
			GridData data = new GridData(GridData.FILL_HORIZONTAL);
			data.horizontalSpan = 2;
			data.widthHint = 200;
			label.setLayoutData(data);*/
        module = ServerUtil.getModule(project);
        if (module == null) {
            Label label = new Label(composite, SWT.NONE);
            label.setText(Messages.prefProjectNotModule);
            GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
            data.horizontalSpan = 2;
            data.verticalIndent = 5;
            label.setLayoutData(data);
        } else {
            IModuleType mt = module.getModuleType();
            if (mt != null) {
                Label label = new Label(composite, SWT.NONE);
                label.setText(Messages.prefProject);
                GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
                data.verticalIndent = 5;
                label.setLayoutData(data);
                Label moduleKind = new Label(composite, SWT.NONE);
                data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
                data.verticalIndent = 5;
                moduleKind.setLayoutData(data);
                moduleKind.setText(module.getName() + " (" + mt.getName() + ")");
            }
            defaultServer = ServerCore.getDefaultServer(module);
            final IServer[] servers = getServersBySupportedModule(module);
            if (servers == null || servers.length == 0) {
                Label label = new Label(composite, SWT.WRAP);
                label.setText(Messages.prefProjectNotConfigured);
                GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
                data.horizontalSpan = 2;
                data.verticalIndent = 5;
                label.setLayoutData(data);
            } else {
                Label label = new Label(composite, SWT.NONE);
                label.setText(Messages.prefProjectDefaultServer);
                GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
                data.horizontalSpan = 2;
                data.verticalIndent = 5;
                label.setLayoutData(data);
                table = new Table(composite, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
                data = new GridData(GridData.FILL_HORIZONTAL);
                data.horizontalSpan = 2;
                data.horizontalIndent = 15;
                data.heightHint = 90;
                table.setLayoutData(data);
                // add none option
                TableItem item = new TableItem(table, SWT.NONE);
                item.setText(Messages.prefProjectNoServer);
                // item.setImage();
                int size2 = servers.length;
                count = 0;
                ILabelProvider labelProvider = ServerUICore.getLabelProvider();
                for (int j = 0; j < size2; j++) {
                    item = new TableItem(table, SWT.NONE);
                    item.setText(labelProvider.getText(servers[j]));
                    item.setImage(labelProvider.getImage(servers[j]));
                    item.setData(servers[j]);
                    if (servers[j].equals(defaultServer))
                        count = j + 1;
                }
                labelProvider.dispose();
                table.setSelection(count);
                table.addSelectionListener(new SelectionAdapter() {

                    public void widgetSelected(SelectionEvent event) {
                        int index = table.getSelectionIndex();
                        if (index == 0)
                            server = null;
                        else if (index > 0)
                            server = servers[index - 1];
                    }
                });
            }
        }
        Dialog.applyDialogFont(composite);
        return composite;
    } catch (Exception e) {
        if (Trace.SEVERE) {
            Trace.trace(Trace.STRING_SEVERE, "Error creating project property page", e);
        }
        return null;
    }
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) IServer(org.eclipse.wst.server.core.IServer) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) IModuleType(org.eclipse.wst.server.core.IModuleType) TableItem(org.eclipse.swt.widgets.TableItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) CoreException(org.eclipse.core.runtime.CoreException) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 3 with IModuleType

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

the class IModuleTestCase method testCreateModule.

public void testCreateModule() {
    module = new IModule() {

        public String getId() {
            return null;
        }

        public String getName() {
            return null;
        }

        public IModuleType getModuleType() {
            return null;
        }

        public IProject getProject() {
            return null;
        }

        public Object getAdapter(Class adapter) {
            return null;
        }

        public Object loadAdapter(Class adapter, IProgressMonitor monitor) {
            return null;
        }

        public boolean isExternal() {
            return false;
        }

        public boolean exists() {
            return true;
        }
    };
    module.getId();
    module.getName();
    module.getModuleType();
    module.getProject();
    module.getAdapter(null);
    module.loadAdapter(null, null);
    assertFalse(module.isExternal());
}
Also used : IModule(org.eclipse.wst.server.core.IModule) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IModuleType(org.eclipse.wst.server.core.IModuleType) IProject(org.eclipse.core.resources.IProject)

Example 4 with IModuleType

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

the class MatchesTestCase method testMatches.

public void testMatches() {
    IRuntimeType rt = ServerCore.getRuntimeTypes()[0];
    System.out.println("Runtime: " + rt.getName());
    IModuleType[] mt = rt.getModuleTypes();
    for (int i = 0; i < NUM; i++) {
        ServerUtil.isSupportedModule(mt, "jst.web", "2.4");
    }
    long time = System.currentTimeMillis();
    for (int i = 0; i < NUM; i++) {
        ServerUtil.isSupportedModule(mt, "jst.web", "2.4");
    }
    System.out.println("Time: " + (System.currentTimeMillis() - time));
    time = System.currentTimeMillis();
    for (int i = 0; i < NUM; i++) {
        ServerUtil.isSupportedModule(mt, "jst.*", "2.*");
    }
    System.out.println("Time2: " + (System.currentTimeMillis() - time));
    time = System.currentTimeMillis();
    for (int i = 0; i < NUM; i++) {
        ServerUtil.isSupportedModule(mt, "*", "2.4");
    }
    System.out.println("Time3: " + (System.currentTimeMillis() - time));
}
Also used : IModuleType(org.eclipse.wst.server.core.IModuleType) IRuntimeType(org.eclipse.wst.server.core.IRuntimeType)

Example 5 with IModuleType

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

the class NewServerComposite method isSupportedModule.

/**
 * Returns the status of whether the given module could be added to the server.
 *
 * @param server a server
 * @param module a module
 * @return an IStatus representing the error or warning, or null if there are no problems
 */
protected static IStatus isSupportedModule(IServerAttributes server, IModule module) {
    if (server != null && module != null) {
        IServerType serverType = server.getServerType();
        IModuleType mt = module.getModuleType();
        if (!ServerUtil.isSupportedModule(serverType.getRuntimeType().getModuleTypes(), mt)) {
            String type = mt.getName();
            return new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, NLS.bind(Messages.errorVersionLevel, new Object[] { type, mt.getVersion() }));
        }
        IModule[] rootModules = null;
        try {
            rootModules = server.getRootModules(module, null);
        } catch (CoreException ce) {
            return ce.getStatus();
        } catch (Exception e) {
            if (Trace.WARNING) {
                Trace.trace(Trace.STRING_WARNING, "Could not find root module", e);
            }
        }
        if (rootModules != null) {
            if (rootModules.length == 0)
                return new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, Messages.errorRootModule);
            int size = rootModules.length;
            IStatus status = null;
            boolean found = false;
            for (int i = 0; i < size; i++) {
                try {
                    if (server != null)
                        status = server.canModifyModules(new IModule[] { rootModules[i] }, null, null);
                    if (status != null && status.isOK())
                        found = true;
                } catch (Exception e) {
                    if (Trace.WARNING) {
                        Trace.trace(Trace.STRING_WARNING, "Could not find root module", e);
                    }
                }
            }
            if (!found && status != null)
                return status;
        }
    }
    return null;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IModule(org.eclipse.wst.server.core.IModule) IStatus(org.eclipse.core.runtime.IStatus) IModuleType(org.eclipse.wst.server.core.IModuleType) CoreException(org.eclipse.core.runtime.CoreException) IServerType(org.eclipse.wst.server.core.IServerType) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

IModuleType (org.eclipse.wst.server.core.IModuleType)6 CoreException (org.eclipse.core.runtime.CoreException)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 IModule (org.eclipse.wst.server.core.IModule)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IProject (org.eclipse.core.resources.IProject)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Label (org.eclipse.swt.widgets.Label)1 Table (org.eclipse.swt.widgets.Table)1 TableItem (org.eclipse.swt.widgets.TableItem)1 IRuntime (org.eclipse.wst.server.core.IRuntime)1