use of org.eclipse.wst.server.ui.editor.ServerEditorOverviewPageModifier in project webtools.servertools by eclipse.
the class OverviewEditorPart method createGeneralSection.
protected void createGeneralSection(Composite leftColumnComp, FormToolkit toolkit) {
Section section = toolkit.createSection(leftColumnComp, ExpandableComposite.TITLE_BAR | Section.DESCRIPTION);
section.setText(Messages.serverEditorOverviewGeneralSection);
section.setDescription(Messages.serverEditorOverviewGeneralDescription);
section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
Composite composite = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
layout.marginHeight = 5;
layout.marginWidth = 10;
layout.verticalSpacing = 5;
layout.horizontalSpacing = 5;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
IWorkbenchHelpSystem whs = PlatformUI.getWorkbench().getHelpSystem();
whs.setHelp(composite, ContextIds.EDITOR_OVERVIEW_PAGE);
toolkit.paintBordersFor(composite);
section.setClient(composite);
int decorationWidth = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth();
// server name
if (server != null) {
createLabel(toolkit, composite, Messages.serverEditorOverviewServerName);
serverName = toolkit.createText(composite, server.getName());
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
data.horizontalIndent = decorationWidth;
serverName.setLayoutData(data);
serverName.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (updating)
return;
updating = true;
execute(new SetServerNameCommand(getServer(), serverName.getText(), new SetServerNameCommand.Validator() {
public void validate() {
OverviewEditorPart.this.validate();
}
}));
updating = false;
}
});
whs.setHelp(serverName, ContextIds.EDITOR_SERVER);
// hostname
hostnameLabel = createLabel(toolkit, composite, Messages.serverEditorOverviewServerHostname);
hostname = toolkit.createText(composite, server.getHost());
hostnameDecoration = new ControlDecoration(hostname, SWT.TOP | SWT.LEAD);
data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
data.horizontalIndent = decorationWidth;
hostname.setLayoutData(data);
hostname.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (updating)
return;
updating = true;
execute(new SetServerHostnameCommand(getServer(), hostname.getText()));
updating = false;
}
});
whs.setHelp(hostname, ContextIds.EDITOR_HOSTNAME);
FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
FieldDecoration fd = registry.getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
hostnameDecoration.setImage(fd.getImage());
hostnameDecoration.setDescriptionText(fd.getDescription());
hostnameDecoration.hide();
hostname.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
hostnameDecoration.show();
}
public void focusLost(FocusEvent e) {
hostnameDecoration.hide();
}
});
// updateDecoration(hostnameDecoration, new Status(IStatus.INFO, ServerUIPlugin.PLUGIN_ID, "Press Ctrl-Space"));
List<String> hosts = ServerUIPlugin.getPreferences().getHostnames();
String[] hosts2 = hosts.toArray(new String[hosts.size()]);
new AutoCompleteField(hostname, new TextContentAdapter(), hosts2);
}
// runtime
if (server != null && server.getServerType() != null && server.getServerType().hasRuntime()) {
final Hyperlink link = toolkit.createHyperlink(composite, Messages.serverEditorOverviewRuntime, SWT.NONE);
final IServerWorkingCopy server2 = server;
link.addHyperlinkListener(new HyperlinkAdapter() {
public void linkActivated(HyperlinkEvent e) {
IRuntime runtime = server2.getRuntime();
if (runtime != null && ServerUIPlugin.hasWizardFragment(runtime.getRuntimeType().getId()))
editRuntime(runtime);
}
});
final IRuntime runtime = server.getRuntime();
if (runtime == null || !ServerUIPlugin.hasWizardFragment(runtime.getRuntimeType().getId()))
link.setEnabled(false);
IRuntimeType runtimeType = server.getServerType().getRuntimeType();
runtimes = ServerUIPlugin.getRuntimes(runtimeType);
runtimeCombo = new Combo(composite, SWT.READ_ONLY);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalIndent = decorationWidth;
data.horizontalSpan = 2;
runtimeCombo.setLayoutData(data);
updateRuntimeCombo();
int size = runtimes.length;
for (int i = 0; i < size; i++) {
if (runtimes[i].equals(runtime))
runtimeCombo.select(i);
}
runtimeCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
try {
if (updating)
return;
updating = true;
IRuntime newRuntime = runtimes[runtimeCombo.getSelectionIndex()];
execute(new SetServerRuntimeCommand(getServer(), newRuntime));
link.setEnabled(newRuntime != null && ServerUIPlugin.hasWizardFragment(newRuntime.getRuntimeType().getId()));
updating = false;
} catch (Exception ex) {
// ignore
}
}
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
});
whs.setHelp(runtimeCombo, ContextIds.EDITOR_RUNTIME);
// add runtime listener
runtimeListener = new IRuntimeLifecycleListener() {
public void runtimeChanged(final IRuntime runtime2) {
// may be name change of current runtime
Display.getDefault().syncExec(new Runnable() {
public void run() {
if (runtime2.equals(getServer().getRuntime())) {
try {
if (updating)
return;
updating = true;
execute(new SetServerRuntimeCommand(getServer(), runtime2));
updating = false;
} catch (Exception ex) {
// ignore
}
}
if (runtimeCombo != null && !runtimeCombo.isDisposed()) {
updateRuntimeCombo();
int size2 = runtimes.length;
for (int i = 0; i < size2; i++) {
if (runtimes[i].equals(runtime))
runtimeCombo.select(i);
}
}
}
});
}
public void runtimeAdded(final IRuntime runtime2) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
if (runtimeCombo != null && !runtimeCombo.isDisposed()) {
updateRuntimeCombo();
int size2 = runtimes.length;
for (int i = 0; i < size2; i++) {
if (runtimes[i].equals(runtime))
runtimeCombo.select(i);
}
}
}
});
}
public void runtimeRemoved(IRuntime runtime2) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
if (runtimeCombo != null && !runtimeCombo.isDisposed()) {
updateRuntimeCombo();
int size2 = runtimes.length;
for (int i = 0; i < size2; i++) {
if (runtimes[i].equals(runtime))
runtimeCombo.select(i);
}
}
}
});
}
};
ServerCore.addRuntimeLifecycleListener(runtimeListener);
}
// server configuration path
if (server != null && server.getServerType() != null && server.getServerType().hasServerConfiguration()) {
createLabel(toolkit, composite, Messages.serverEditorOverviewServerConfigurationPath);
IFolder folder = server.getServerConfiguration();
if (folder == null)
serverConfiguration = toolkit.createText(composite, Messages.elementUnknownName);
else
serverConfiguration = toolkit.createText(composite, "" + server.getServerConfiguration().getFullPath());
serverConfiguration.setEditable(false);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalIndent = decorationWidth;
data.widthHint = 75;
serverConfiguration.setLayoutData(data);
whs.setHelp(serverConfiguration, ContextIds.EDITOR_CONFIGURATION);
final IFolder currentFolder = server.getServerConfiguration();
browse = toolkit.createButton(composite, Messages.serverEditorOverviewServerConfigurationBrowse, SWT.PUSH);
browse.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ContainerSelectionDialog dialog = new ContainerSelectionDialog(serverConfiguration.getShell(), currentFolder, true, Messages.serverEditorOverviewServerConfigurationBrowseMessage);
dialog.showClosedProjects(false);
if (dialog.open() != Window.CANCEL) {
Object[] result = dialog.getResult();
if (result != null && result.length == 1) {
IPath path = (IPath) result[0];
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = root.findMember(path);
if (resource != null && resource instanceof IFolder) {
IFolder folder2 = (IFolder) resource;
if (updating)
return;
updating = true;
execute(new SetServerConfigurationFolderCommand(getServer(), folder2));
serverConfiguration.setText(folder2.getFullPath().toString());
updating = false;
}
}
}
}
});
browse.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
}
IServerType serverType = null;
if (server != null && server.getServerType() != null) {
serverType = server.getServerType();
if (serverType.supportsLaunchMode(ILaunchManager.RUN_MODE) || serverType.supportsLaunchMode(ILaunchManager.DEBUG_MODE) || serverType.supportsLaunchMode(ILaunchManager.PROFILE_MODE)) {
ILaunchConfigurationType launchType = ((ServerType) serverType).getLaunchConfigurationType();
if (launchType != null && launchType.isPublic()) {
final Hyperlink link = toolkit.createHyperlink(composite, Messages.serverEditorOverviewOpenLaunchConfiguration, SWT.NONE);
GridData data = new GridData();
data.horizontalSpan = 3;
link.setLayoutData(data);
link.addHyperlinkListener(new HyperlinkAdapter() {
public void linkActivated(HyperlinkEvent e) {
IEditorPart part = ((MultiPageEditorSite) getSite()).getMultiPageEditor();
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
page.saveEditor(part, true);
try {
ILaunchConfiguration launchConfig = ((Server) getServer()).getLaunchConfiguration(true, null);
// TODO: use correct launch group
DebugUITools.openLaunchConfigurationPropertiesDialog(link.getShell(), launchConfig, "org.eclipse.debug.ui.launchGroup.run");
} catch (CoreException ce) {
if (Trace.SEVERE) {
Trace.trace(Trace.STRING_SEVERE, "Could not create launch configuration", ce);
}
}
}
});
}
}
}
// Insertion of extension widgets. If the page modifier createControl is not implemented still
// add the modifier to the listeners list.
List<ServerEditorOverviewPageModifier> pageModifiersLst = getPageModifiers(serverType == null ? null : serverType.getId());
for (ServerEditorOverviewPageModifier curPageModifier : pageModifiersLst) {
if (server != null && server.getServerType() != null) {
curPageModifier.setServerWorkingCopy(server);
curPageModifier.setServerEditorPart(this);
curPageModifier.setFormToolkit(toolkit);
curPageModifier.createControl(ServerEditorOverviewPageModifier.UI_LOCATION.OVERVIEW, composite);
curPageModifier.setUIControlListener(this);
}
}
}
use of org.eclipse.wst.server.ui.editor.ServerEditorOverviewPageModifier in project webtools.servertools by eclipse.
the class ServerUIPlugin method loadServerEditorOverviewPageModifiers.
/**
* Load the Server editor page modifiers.
*/
private static synchronized void loadServerEditorOverviewPageModifiers() {
if (serverEditorOverviewPageModifierFactories != null)
return;
if (Trace.CONFIG) {
Trace.trace(Trace.STRING_CONFIG, "->- Loading .serverEditorOverviewPageModifier extension point ->-");
}
serverEditorOverviewPageModifierFactories = new ArrayList<OverviewPageModifierFactory>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IConfigurationElement[] cf = registry.getConfigurationElementsFor(ServerUIPlugin.PLUGIN_ID, "serverEditorOverviewPageModifier");
for (IConfigurationElement curConfigElement : cf) {
try {
ServerEditorOverviewPageModifier curExtension = (ServerEditorOverviewPageModifier) curConfigElement.createExecutableExtension("class");
if (Trace.CONFIG) {
Trace.trace(Trace.STRING_CONFIG, " Loaded .serverEditorOverviewPageModifier: " + cf[0].getAttribute("id") + ", loaded class=" + curExtension);
}
if (curExtension != null)
serverEditorOverviewPageModifierFactories.add(new OverviewPageModifierFactory(curConfigElement));
} catch (Throwable t) {
if (Trace.SEVERE) {
Trace.trace(Trace.STRING_SEVERE, " Could not load .serverEditorOverviewPageModifier: " + cf[0].getAttribute("id"), t);
}
}
}
Collections.sort(serverEditorOverviewPageModifierFactories);
if (Trace.CONFIG) {
Trace.trace(Trace.STRING_CONFIG, "-<- Done loading .serverEditorOverviewPageModifier extension point -<-");
}
}
use of org.eclipse.wst.server.ui.editor.ServerEditorOverviewPageModifier in project webtools.servertools by eclipse.
the class OverviewEditorPart method initialize.
/**
* Initialize the fields in this editor.
*/
protected void initialize() {
if (serverName == null)
return;
updating = true;
if (server != null) {
serverName.setText(server.getName());
if (readOnly)
serverName.setEditable(false);
else
serverName.setEditable(true);
hostname.setText(server.getHost());
if (readOnly)
hostname.setEditable(false);
else
hostname.setEditable(true);
if (runtimeCombo != null) {
updateRuntimeCombo();
IRuntime runtime = server.getRuntime();
int size2 = runtimes.length;
for (int i = 0; i < size2; i++) {
if (runtimes[i].equals(runtime))
runtimeCombo.select(i);
}
if (readOnly)
runtimeCombo.setEnabled(false);
else
runtimeCombo.setEnabled(true);
}
if (serverConfiguration != null) {
IFolder folder = server.getServerConfiguration();
if (folder == null)
serverConfiguration.setText(Messages.elementUnknownName);
else
serverConfiguration.setText("" + server.getServerConfiguration().getFullPath());
if (readOnly) {
serverConfiguration.setEditable(false);
browse.setEnabled(false);
} else {
serverConfiguration.setEditable(true);
browse.setEnabled(true);
}
}
Server svr = (Server) server;
int publishSetting = svr.getAutoPublishSetting();
autoPublishDisable.setSelection(publishSetting == Server.AUTO_PUBLISH_DISABLE);
autoPublishEnableResource.setSelection(publishSetting == Server.AUTO_PUBLISH_RESOURCE);
autoPublishEnableBuild.setSelection(publishSetting == Server.AUTO_PUBLISH_BUILD);
autoPublishTime.setSelection(svr.getAutoPublishTime());
if (readOnly) {
autoPublishDisable.setEnabled(false);
autoPublishEnableResource.setEnabled(false);
autoPublishEnableBuild.setEnabled(false);
autoPublishTime.setEnabled(false);
} else {
autoPublishDisable.setEnabled(true);
autoPublishEnableResource.setEnabled(true);
autoPublishEnableBuild.setEnabled(true);
autoPublishTime.setEnabled(publishSetting != Server.AUTO_PUBLISH_DISABLE);
}
List<ServerEditorOverviewPageModifier> pageModifiersLst = getPageModifiers(null);
for (ServerEditorOverviewPageModifier curPageModifier : pageModifiersLst) {
if (server != null && server.getServerType() != null)
curPageModifier.setServerWorkingCopy(server);
curPageModifier.handlePropertyChanged(new PropertyChangeEvent(this, AbstractUIControl.PROP_SERVER_TYPE, oldServerType, server.getServerType()));
}
}
updating = false;
validate();
}
Aggregations