use of org.eclipse.ui.forms.IManagedForm in project webtools.servertools by eclipse.
the class OverviewEditorPart method validate.
protected void validate() {
IManagedForm mForm = getManagedForm();
if (mForm == null)
return;
MultiStatus ms = new MultiStatus(ServerUIPlugin.PLUGIN_ID, 0, "Validating Overview Part", null);
mForm.getMessageManager().removeMessage("name", serverName);
if (server != null && serverName != null) {
if (ServerPlugin.isNameOnlyInUse(server, serverName.getText().trim())) {
mForm.getMessageManager().addMessage("name", Messages.errorDuplicateName, null, IMessageProvider.ERROR, serverName);
ms.add(new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, Messages.errorDuplicateName));
}
}
if (serverConfiguration != null) {
mForm.getMessageManager().removeMessage("config", serverConfiguration);
if (server != null && server.getServerType() != null && server.getServerType().hasServerConfiguration()) {
IFolder folder = getServer().getServerConfiguration();
if (folder == null || !folder.exists()) {
IProject project = null;
if (folder != null)
project = folder.getProject();
if (project != null && project.exists() && !project.isOpen()) {
mForm.getMessageManager().addMessage("config", NLS.bind(Messages.errorConfigurationNotAccessible, project.getName()), null, IMessageProvider.ERROR, serverConfiguration);
ms.add(new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, NLS.bind(Messages.errorConfigurationNotAccessible, project.getName())));
} else {
mForm.getMessageManager().addMessage("config", Messages.errorMissingConfiguration, null, IMessageProvider.ERROR, serverConfiguration);
ms.add(new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, Messages.errorMissingConfiguration));
}
}
}
}
validationStatus = (ms.isOK() ? Status.OK_STATUS : ms);
mForm.getMessageManager().update();
}
use of org.eclipse.ui.forms.IManagedForm in project bndtools by bndtools.
the class BndEditor method resolveRunBundles.
public Promise<IStatus> resolveRunBundles(IProgressMonitor monitor, boolean onSave) {
final Shell shell = getEditorSite().getShell();
final IFile file = ResourceUtil.getFile(getEditorInput());
if (file == null) {
MessageDialog.openError(shell, "Resolution Error", "Unable to run resolution because the file is not in the workspace.");
reallySave(monitor);
return Central.promiseFactory().resolved(Status.CANCEL_STATUS);
}
Job loadWorkspaceJob = new Job("Loading workspace...") {
@Override
protected IStatus run(IProgressMonitor monitor) {
if (monitor == null)
monitor = new NullProgressMonitor();
monitor.beginTask("Loading workspace", 2);
try {
Central.getWorkspace();
monitor.worked(1);
modelReady.getValue();
return Status.OK_STATUS;
} catch (Exception e) {
return new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Failed to initialize workspace.", e);
} finally {
monitor.done();
}
}
};
final UIJob runResolveInUIJob = new UIJob("Resolve") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
// dirty state to the model
for (Object pageObj : pages) {
if (pageObj instanceof IFormPage) {
IFormPage formPage = (IFormPage) pageObj;
IManagedForm form = formPage.getManagedForm();
if (form != null) {
IFormPart[] formParts = form.getParts();
for (IFormPart formPart : formParts) {
if (formPart.isDirty())
formPart.commit(false);
}
}
}
}
if (sourcePage.isActive() && sourcePage.isDirty()) {
sourcePage.commit(false);
}
// Create resolver job and pre-validate
final ResolveJob job = new ResolveJob(model);
IStatus validation = job.validateBeforeRun();
if (!validation.isOK()) {
if (onSave)
reallySave(monitor);
return validation;
}
// Add operation to perform at the end of resolution (i.e. display
// results and actually save the file)
final UIJob completionJob = new UIJob(shell.getDisplay(), "Display Resolution Results") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
ResolutionResult result = job.getResolutionResult();
ResolutionWizard wizard = new ResolutionWizard(model, file, result);
if (onSave) {
// We are in auto-resolve-on-save, only show the dialog if there is a problem
wizard.setAllowFinishUnresolved(true);
wizard.setPreserveRunBundlesUnresolved(true);
if (result.getOutcome() != ResolutionResult.Outcome.Resolved) {
WizardDialog dialog = new DuringSaveWizardDialog(shell, wizard);
dialog.create();
dialog.setErrorMessage("Resolve Failed! Saving now will not update the Run Bundles.");
if (dialog.open() == Window.OK)
reallySave(monitor);
} else {
wizard.performFinish();
reallySave(monitor);
}
} else {
// This is an interactive resolve, always show the dialog
boolean dirtyBeforeResolve = isDirty();
WizardDialog dialog = new WizardDialog(shell, wizard);
if (dialog.open() == Window.OK && !dirtyBeforeResolve) {
// save changes immediately if there were no unsaved changes before the resolve
reallySave(monitor);
}
}
return Status.OK_STATUS;
}
};
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
completionJob.schedule();
}
});
// Start job
job.setUser(true);
job.schedule();
return Status.OK_STATUS;
}
};
runResolveInUIJob.setUser(true);
return JobUtil.chainJobs(loadWorkspaceJob, runResolveInUIJob);
}
use of org.eclipse.ui.forms.IManagedForm in project bndtools by bndtools.
the class BundleContentPage method createFormContent.
@Override
protected void createFormContent(IManagedForm managedForm) {
FormToolkit toolkit = managedForm.getToolkit();
managedForm.setInput(model);
ScrolledForm scrolledForm = managedForm.getForm();
scrolledForm.setText("Bundle Content");
Form form = scrolledForm.getForm();
toolkit.decorateFormHeading(form);
form.addMessageHyperlinkListener(new MessageHyperlinkAdapter(getEditor()));
Composite body = form.getBody();
// Create controls
MDSashForm sashForm = new MDSashForm(body, SWT.HORIZONTAL, managedForm);
sashForm.setSashWidth(6);
toolkit.adapt(sashForm, false, false);
Composite leftPanel = toolkit.createComposite(sashForm);
createLeftPanel(managedForm, leftPanel);
Composite rightPanel = toolkit.createComposite(sashForm);
createRightPanel(managedForm, rightPanel);
sashForm.setWeights(new int[] { 1, 1 });
sashForm.hookResizeListener();
// Layout
body.setLayout(new FillLayout());
}
use of org.eclipse.ui.forms.IManagedForm in project bndtools by bndtools.
the class FormPartJavaSearchContext method getFormPage.
private IFormPage getFormPage() {
IManagedForm managedForm = formPart.getManagedForm();
if (managedForm == null)
return null;
Object container = managedForm.getContainer();
if (!(container instanceof IFormPage))
return null;
return (IFormPage) container;
}
use of org.eclipse.ui.forms.IManagedForm in project bndtools by bndtools.
the class WorkspaceMainPart method initialize.
@Override
public void initialize(final IManagedForm form) {
super.initialize(form);
final Composite container = (Composite) getSection().getClient();
// create a layout stack and the first visible component will be an empty component with "waiting" message
// this will be replaced by real composite once workspace completes
final StackLayout stackLayout = new StackLayout();
container.setLayout(stackLayout);
Composite labelParent = new Composite(container, SWT.NONE);
FillLayout fillLayout = new FillLayout();
fillLayout.marginHeight = fillLayout.marginWidth = 10;
labelParent.setLayout(fillLayout);
if (!Central.isWorkspaceInited()) {
Label label = new Label(labelParent, SWT.NONE);
label.setText("Workspace is loading, please wait...");
label.setBackground(container.getBackground());
label.setForeground(container.getForeground());
}
stackLayout.topControl = labelParent;
container.layout();
Central.onWorkspaceAsync(workspace -> {
IFile buildFile = Central.getWorkspaceBuildFile();
if (buildFile == null)
return;
Composite contents = new Composite(container, SWT.NONE);
if (!mainFile) {
ImageHyperlink link = form.getToolkit().createImageHyperlink(contents, SWT.CENTER);
link.setText("Open main build.bnd file.");
link.setImage(bndFileImg);
link.addHyperlinkListener(new FileOpenLinkListener(buildFile.getFullPath()));
} else {
IResource[] extFiles;
IContainer cnfDir = buildFile.getParent();
IFolder extDir = cnfDir.getFolder(new Path("ext"));
if (extDir.exists())
extFiles = extDir.members();
else
extFiles = new IResource[0];
if (extFiles.length > 0) {
for (IResource extFile : extFiles) {
if (extFile.getType() == IResource.FILE && "bnd".equalsIgnoreCase(extFile.getFileExtension())) {
ImageHyperlink link = form.getToolkit().createImageHyperlink(contents, SWT.CENTER);
link.setText("Open " + extFile.getName());
link.setImage(extFileImg);
link.addHyperlinkListener(new FileOpenLinkListener(extFile.getFullPath()));
}
}
} else {
createMissingExtsWarningPanel(contents, form.getToolkit(), extDir.getFullPath());
}
}
stackLayout.topControl = contents;
container.layout();
}).onFailure(e -> Plugin.error(Collections.singletonList(e.getMessage())));
}
Aggregations