use of org.eclipse.jface.wizard.WizardDialog in project bndtools by bndtools.
the class RunRequirementsPart method doResolve.
private void doResolve() {
// Make sure all the parts of this editor page have committed their
// dirty state to the model
IFormPart[] parts = getManagedForm().getParts();
for (IFormPart part : parts) {
if (part.isDirty())
part.commit(false);
}
final IFormPage page = (IFormPage) getManagedForm().getContainer();
final IEditorInput input = page.getEditorInput();
final IEditorPart editor = page.getEditor();
final IFile file = ResourceUtil.getFile(input);
final Shell parentShell = page.getEditor().getSite().getShell();
// Create the wizard and pre-validate
final ResolveJob job = new ResolveJob(model);
IStatus validation = job.validateBeforeRun();
if (!validation.isOK()) {
ErrorDialog errorDialog = new ErrorDialog(parentShell, "Validation Problem", null, validation, IStatus.ERROR | IStatus.WARNING) {
@Override
protected void createButtonsForButtonBar(Composite parent) {
// create OK, Cancel and Details buttons
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, false);
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true);
createDetailsButton(parent);
}
};
int response = errorDialog.open();
if (Window.CANCEL == response || validation.getSeverity() >= IStatus.ERROR) {
btnResolveNow.setEnabled(true);
return;
}
}
// Add the operation to perform at the end of the resolution job (i.e.,
// showing the result)
final Runnable showResult = new Runnable() {
@Override
public void run() {
ResolutionWizard wizard = new ResolutionWizard(model, file, job.getResolutionResult());
WizardDialog dialog = new WizardDialog(parentShell, wizard);
boolean dirtyBeforeResolve = editor.isDirty();
if (dialog.open() == Dialog.OK && !dirtyBeforeResolve) {
// only save the editor, when no unsaved changes happened before resolution
editor.getEditorSite().getPage().saveEditor(editor, false);
}
btnResolveNow.setEnabled(true);
}
};
job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
Outcome outcome = job.getResolutionResult().getOutcome();
if (outcome != Outcome.Cancelled)
parentShell.getDisplay().asyncExec(showResult);
}
});
job.setUser(true);
job.schedule();
}
use of org.eclipse.jface.wizard.WizardDialog in project bndtools by bndtools.
the class RunRequirementsPart method doAddBundle.
private void doAddBundle() {
try {
RepoBundleSelectionWizard wizard = new RepoBundleSelectionWizard(new ArrayList<VersionedClause>(), DependencyPhase.Run);
wizard.setSelectionPageTitle("Add Bundle Requirement");
WizardDialog dialog = new WizardDialog(getSection().getShell(), wizard);
if (Window.OK == dialog.open()) {
List<VersionedClause> result = wizard.getSelectedBundles();
Set<Requirement> adding = new LinkedHashSet<Requirement>(result.size());
for (VersionedClause bundle : result) {
Filter filter = new SimpleFilter(IdentityNamespace.IDENTITY_NAMESPACE, bundle.getName());
String versionRange = bundle.getVersionRange();
if (versionRange != null && !"latest".equals(versionRange)) {
filter = new AndFilter().addChild(filter).addChild(new LiteralFilter(Filters.fromVersionRange(versionRange)));
}
Requirement req = new CapReqBuilder(IdentityNamespace.IDENTITY_NAMESPACE).addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter.toString()).buildSyntheticRequirement();
adding.add(req);
}
updateViewerWithNewRequirements(adding);
}
} catch (Exception e) {
ErrorDialog.openError(getSection().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error selecting bundles.", e));
}
}
use of org.eclipse.jface.wizard.WizardDialog in project bndtools by bndtools.
the class RunBlacklistPart method doAddBundle.
private void doAddBundle() {
try {
RepoBundleSelectionWizard wizard = new RepoBundleSelectionWizard(new ArrayList<VersionedClause>(), DependencyPhase.Run);
wizard.setSelectionPageTitle("Add Bundle Blacklist");
WizardDialog dialog = new WizardDialog(getSection().getShell(), wizard);
if (Window.OK == dialog.open()) {
List<VersionedClause> result = wizard.getSelectedBundles();
Set<Requirement> adding = new LinkedHashSet<Requirement>(result.size());
for (VersionedClause bundle : result) {
Filter filter = new SimpleFilter(IdentityNamespace.IDENTITY_NAMESPACE, bundle.getName());
String versionRange = bundle.getVersionRange();
if (versionRange != null && !"latest".equals(versionRange)) {
filter = new AndFilter().addChild(filter).addChild(new LiteralFilter(Filters.fromVersionRange(versionRange)));
}
Requirement req = new CapReqBuilder(IdentityNamespace.IDENTITY_NAMESPACE).addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter.toString()).buildSyntheticRequirement();
adding.add(req);
}
updateViewerWithNewBlacklist(adding);
}
} catch (Exception e) {
ErrorDialog.openError(getSection().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error selecting bundles for blacklist.", e));
}
}
use of org.eclipse.jface.wizard.WizardDialog in project bndtools by bndtools.
the class MissingWorkspaceMarkerResolutionGenerator method getResolutions.
@Override
public IMarkerResolution[] getResolutions(IMarker marker) {
return new IMarkerResolution[] { new IMarkerResolution() {
@Override
public void run(IMarker marker) {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
WorkspaceSetupWizard wizard = new WorkspaceSetupWizard();
wizard.init(workbench, StructuredSelection.EMPTY);
WizardDialog dialog = new WizardDialog(window.getShell(), wizard);
dialog.open();
}
@Override
public String getLabel() {
return "Open 'New Bnd OSGi Workspace' Wizard";
}
} };
}
use of org.eclipse.jface.wizard.WizardDialog in project bndtools by bndtools.
the class ProjectTemplateSelectionWizardPage method createHeaderControl.
@Override
protected Control createHeaderControl(Composite parent) {
Composite composite;
Workspace workspace = Central.getWorkspaceIfPresent();
if (workspace == null || workspace.isDefaultWorkspace()) {
composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.marginWidth = 0;
layout.marginHeight = 0;
layout.marginBottom = 15;
layout.verticalSpacing = 15;
composite.setLayout(layout);
Label lblWarning = new Label(composite, SWT.NONE);
warningImg = Icons.desc("warning.big").createImage(parent.getDisplay());
lblWarning.setImage(warningImg);
Link link = new Link(composite, SWT.NONE);
link.setText("WARNING! The bnd workspace has not been configured. <a href=\"#workspace\">Create a workspace first</a> \n or configure a <a href=\"#prefs\">Template Repository</a> in Bndtools Preferences.");
link.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent ev) {
WizardDialog dialog = (WizardDialog) getContainer();
dialog.close();
if ("#workspace".equals(ev.text)) {
// We are going to open the New Workspace wizard in a new dialog.
// If that wizard completes successfully then we can reopen the New Project wizard.
WorkspaceSetupWizard workspaceWizard = new WorkspaceSetupWizard();
workspaceWizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY);
dialog = new WizardDialog(dialog.getShell(), workspaceWizard);
if (Window.OK == dialog.open()) {
try {
NewBndProjectWizard projectWizard = new NewBndProjectWizardFactory().create();
projectWizard.init(PlatformUI.getWorkbench(), StructuredSelection.EMPTY);
new WizardDialog(dialog.getShell(), projectWizard).open();
} catch (CoreException e) {
Plugin.getDefault().getLog().log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Unable to open New Bnd Project wizard", e));
}
}
} else if ("#prefs".equals(ev.text)) {
// Open the preference dialog with the template repositories page open.
// We can't reopen the New Project wizard after because we don't know that the user changed anything.
PreferenceDialog prefsDialog = PreferencesUtil.createPreferenceDialogOn(getShell(), "bndtools.prefPages.repos", null, null);
prefsDialog.open();
}
}
});
GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
link.setLayoutData(gd);
// ControlDecoration decor = new ControlDecoration(link, SWT.LEFT, composite);
// decor.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_WARNING).getImage());
Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
separator.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
} else {
// There is a workspace, just return null (no controls will be inserted into the panel).
composite = null;
}
return composite;
}
Aggregations