use of org.eclipse.wst.server.ui.internal.viewers.ServerTypeComposite in project webtools.servertools by eclipse.
the class NewManualServerComposite method createControl.
/**
* Returns this page's initial visual components.
*/
protected void createControl() {
// top level group
GridLayout layout = new GridLayout();
layout.numColumns = 3;
layout.horizontalSpacing = SWTUtil.convertHorizontalDLUsToPixels(this, 4);
layout.verticalSpacing = SWTUtil.convertVerticalDLUsToPixels(this, 4);
layout.marginWidth = 0;
layout.marginHeight = 0;
setLayout(layout);
this.setFont(getParent().getFont());
IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem();
whs.setHelp(this, ContextIds.NEW_SERVER_WIZARD);
List<ServerCreationWizardPageExtension> pageExtensionLst = ServerUIPlugin.getServerCreationWizardPageExtensions();
// Add the page modifier top section UI.
for (ServerCreationWizardPageExtension curPageExtension : pageExtensionLst) {
curPageExtension.createControl(ServerCreationWizardPageExtension.UI_POSITION.TOP, this);
curPageExtension.setUIControlListener(this);
}
serverTypeComposite = new ServerTypeComposite(this, moduleType, serverTypeId, new ServerTypeComposite.ServerTypeSelectionListener() {
public void serverTypeSelected(IServerType type2) {
handleTypeSelection(type2);
// WizardUtil.defaultSelect(parent, CreateServerWizardPage.this);
}
});
serverTypeComposite.setIncludeIncompatibleVersions(includeIncompatible);
GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
data.horizontalSpan = 3;
data.minimumHeight = 150;
serverTypeComposite.setLayoutData(data);
whs.setHelp(serverTypeComposite, ContextIds.NEW_SERVER_TYPE);
// Add the page modifier middle section UI.
for (ServerCreationWizardPageExtension curPageExtension : pageExtensionLst) {
curPageExtension.createControl(ServerCreationWizardPageExtension.UI_POSITION.MIDDLE, this);
}
hostnameListener = new IHostnameSelectionListener() {
public void hostnameSelected(String selectedHostname) {
setHost(selectedHostname);
}
};
hostnameLabel = new Label(this, SWT.NONE);
hostnameLabel.setText(Messages.hostname);
hostname = new Text(this, SWT.SINGLE | SWT.BORDER | SWT.CANCEL);
hostname.setText(HostnameComposite.LOCALHOST);
hostnameDecoration = new ControlDecoration(hostname, SWT.TOP | SWT.LEAD);
GridData data2 = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
hostname.setLayoutData(data2);
new Label(this, SWT.NONE);
hostname.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
setHostnameChangeTimer(hostname.getText());
}
});
FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
fd = registry.getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
hostnameDecoration.setImage(fd.getImage());
hostnameDecoration.setDescriptionText(fd.getDescription());
hostname.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
hostnameDecoration.show();
}
public void focusLost(FocusEvent e) {
hostnameDecoration.hide();
}
});
List<String> hosts = ServerUIPlugin.getPreferences().getHostnames();
String[] hosts2 = hosts.toArray(new String[hosts.size()]);
new AutoCompleteField(hostname, new TextContentAdapter(), hosts2);
serverNameLabel = new Label(this, SWT.NONE);
serverNameLabel.setText(Messages.serverName);
serverName = new Text(this, SWT.SINGLE | SWT.BORDER | SWT.CANCEL);
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
if ((serverName.getStyle() & SWT.CANCEL) != 0)
data.horizontalSpan = 2;
serverName.setLayoutData(data);
if (server != null)
serverName.setText(server.getName());
serverName.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (updatingServerName)
return;
String name = serverName.getText();
IServerType selectedServerType = serverTypeComposite.getSelectedServerType();
if (!validate(selectedServerType)) {
// Do not set the server name if it is invalid
return;
}
if (server != null) {
server.setName(name);
String base = serverName.getText().trim();
if (ServerPlugin.isIdInUse(server, base)) {
server.setAttribute("id", generateUniqueId(base));
}
IRuntime runtime2 = server.getRuntime();
if (runtime2 != null && runtime2 instanceof IRuntimeWorkingCopy) {
IRuntimeWorkingCopy rwc = (IRuntimeWorkingCopy) runtime2;
rwc.setName(name);
}
}
if (serverNameModified)
return;
serverNameModified = true;
if (serverNameToolBar != null)
serverNameToolBar.getControl().setVisible(true);
}
});
if ((serverName.getStyle() & SWT.CANCEL) == 0) {
serverNameToolBar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
serverNameToolBar.createControl(this);
IAction resetDefaultAction = new // $NON-NLS-1$
Action(// $NON-NLS-1$
"", // $NON-NLS-1$
IAction.AS_PUSH_BUTTON) {
public void run() {
((ServerWorkingCopy) server).setDefaults(null);
serverName.setText(server.getName());
serverNameModified = false;
if (serverNameToolBar != null)
serverNameToolBar.getControl().setVisible(false);
}
};
resetDefaultAction.setToolTipText(Messages.serverNameDefault);
resetDefaultAction.setImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_ETOOL_RESET_DEFAULT));
resetDefaultAction.setDisabledImageDescriptor(ImageResource.getImageDescriptor(ImageResource.IMG_DTOOL_RESET_DEFAULT));
serverNameToolBar.add(resetDefaultAction);
serverNameToolBar.update(false);
serverNameToolBar.getControl().setVisible(false);
}
runtimeLabel = new Label(this, SWT.NONE);
runtimeLabel.setText(Messages.wizNewServerRuntime);
runtimeCombo = new Combo(this, SWT.READ_ONLY);
runtimeCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
runtimeCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
try {
setRuntime(runtimes[runtimeCombo.getSelectionIndex()]);
} catch (Exception ex) {
// ignore
}
}
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
addRuntime = new Link(this, SWT.NONE);
addRuntime.setText("<a>" + Messages.addRuntime + "</a>");
addRuntime.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
addRuntime.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
IServerType serverType = serverTypeComposite.getSelectedServerType();
showRuntimeWizard(serverType);
}
});
configureRuntimes = new Link(this, SWT.NONE);
configureRuntimes.setText("<a>" + Messages.configureRuntimes + "</a>");
data = new GridData(GridData.HORIZONTAL_ALIGN_END);
data.horizontalSpan = 3;
configureRuntimes.setLayoutData(data);
configureRuntimes.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (showPreferencePage()) {
runtime = null;
IServerType serverType = serverTypeComposite.getSelectedServerType();
updateRuntimeCombo(serverType);
}
}
});
// Add the page modifier bottom section UI.
for (ServerCreationWizardPageExtension curPageExtension : pageExtensionLst) {
curPageExtension.createControl(ServerCreationWizardPageExtension.UI_POSITION.BOTTOM, this);
}
Dialog.applyDialogFont(this);
}
Aggregations