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();
}
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;
}
}
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());
}
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));
}
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;
}
Aggregations