use of org.eclipse.jface.wizard.IWizardContainer in project hale by halestudio.
the class FeatureChainingConfigurationPage method createContent.
/**
* @see eu.esdihumboldt.hale.ui.HaleWizardPage#createContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createContent(Composite page) {
IWizardContainer container = getContainer();
if (container instanceof WizardDialog) {
changeListener = new IPageChangingListener() {
@Override
public void handlePageChanging(PageChangingEvent event) {
Object currentPage = event.getCurrentPage();
Object targetPage = event.getTargetPage();
if ((currentPage instanceof ChainPage || currentPage instanceof WorkspaceConfigurationPage) && targetPage instanceof FeatureChainingConfigurationPage) {
goingBack = true;
} else if (currentPage instanceof IncludeSchemaConfigurationPage && targetPage instanceof FeatureChainingConfigurationPage) {
goingBack = false;
}
}
};
WizardDialog dialog = (WizardDialog) container;
dialog.addPageChangingListener(changeListener);
} else {
changeListener = null;
}
}
use of org.eclipse.jface.wizard.IWizardContainer in project hale by halestudio.
the class IncludeSchemaConfigurationPage method createContent.
/**
* @see eu.esdihumboldt.hale.ui.HaleWizardPage#createContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createContent(Composite page) {
GridLayoutFactory.swtDefaults().numColumns(1).applyTo(page);
Group includeGroup = new Group(page, SWT.NONE);
includeGroup.setText("Include schema");
GridLayoutFactory.swtDefaults().numColumns(2).applyTo(includeGroup);
GridDataFactory.fillDefaults().grab(true, false).applyTo(includeGroup);
checkInclude = new Button(includeGroup, SWT.CHECK);
checkInclude.setText("Include target schema in the archive");
GridDataFactory.swtDefaults().span(2, 1).applyTo(checkInclude);
IWizardContainer container = getContainer();
if (container instanceof WizardDialog) {
changeListener = new IPageChangingListener() {
@Override
public void handlePageChanging(PageChangingEvent event) {
Object currentPage = event.getCurrentPage();
Object targetPage = event.getTargetPage();
if (currentPage instanceof FeatureChainingConfigurationPage && targetPage instanceof IncludeSchemaConfigurationPage) {
goingBack = true;
} else if (currentPage instanceof ExportSelectTargetPage && targetPage instanceof IncludeSchemaConfigurationPage) {
goingBack = false;
}
}
};
WizardDialog dialog = (WizardDialog) container;
dialog.addPageChangingListener(changeListener);
} else {
changeListener = null;
}
}
use of org.eclipse.jface.wizard.IWizardContainer in project xtext-eclipse by eclipse.
the class RefactoringWizardOpenOperation_NonForking method run.
/**
* That one exists since
* see RefactoringWizardOpenOperation#run(Shell, String, IRunnableContext)
* - not a JavaDoc link since this breaks the build on Galileo :-)
*/
public int run(final Shell parent, final String dialogTitle, final IRunnableContext context) throws InterruptedException {
Assert.isNotNull(dialogTitle);
final Refactoring refactoring = fWizard.getRefactoring();
final IJobManager manager = Job.getJobManager();
final int[] result = new int[1];
final InterruptedException[] canceled = new InterruptedException[1];
Runnable r = new Runnable() {
@Override
public void run() {
try {
// we are getting the block dialog for free if we pass in null
manager.beginRule(ResourcesPlugin.getWorkspace().getRoot(), null);
refactoring.setValidationContext(parent);
fInitialConditions = checkInitialConditions(refactoring, parent, dialogTitle, context);
if (fInitialConditions.hasFatalError()) {
String message = fInitialConditions.getMessageMatchingSeverity(RefactoringStatus.FATAL);
MessageDialog.openError(parent, dialogTitle, message);
result[0] = INITIAL_CONDITION_CHECKING_FAILED;
} else {
fWizard.setInitialConditionCheckingStatus(fInitialConditions);
/* CHANGE: don't use package private RefactoringUI */
Dialog dialog = createRefactoringWizardDialog(fWizard, parent);
dialog.create();
IWizardContainer wizardContainer = (IWizardContainer) dialog;
if (wizardContainer.getCurrentPage() == null)
/*
* Don't show the dialog at all if there are no user
* input pages and change creation was cancelled.
*/
result[0] = Window.CANCEL;
else
result[0] = dialog.open();
}
} catch (InterruptedException e) {
canceled[0] = e;
} catch (OperationCanceledException e) {
canceled[0] = new InterruptedException(e.getMessage());
} finally {
manager.endRule(ResourcesPlugin.getWorkspace().getRoot());
refactoring.setValidationContext(null);
disposeRefactoringContext(fWizard);
}
}
};
BusyIndicator.showWhile(parent != null ? parent.getDisplay() : null, r);
if (canceled[0] != null)
throw canceled[0];
return result[0];
}
use of org.eclipse.jface.wizard.IWizardContainer in project jbosstools-openshift by jbosstools.
the class ListDockerImagesWizardPage method doCreateControls.
@SuppressWarnings("unchecked")
@Override
protected void doCreateControls(final Composite parent, final DataBindingContext dbc) {
GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(2).applyTo(parent);
// filter image by name
final Label filterByNameLabel = new Label(parent, SWT.SEARCH);
filterByNameLabel.setText("Filter:");
filterByNameLabel.setToolTipText("Filter images by their name");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(filterByNameLabel);
final Text filterByNameText = new Text(parent, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(filterByNameText);
// table with all images
final Table dockerImagesTable = new Table(parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
final TableViewer dockerImagesTableViewer = new TableViewer(dockerImagesTable);
dockerImagesTable.setHeaderVisible(true);
dockerImagesTable.setLinesVisible(true);
addTableViewerColum(dockerImagesTableViewer, "Name", SWT.NONE, SWT.LEFT, 200, new ColumnLabelProvider() {
@Override
public String getText(final Object element) {
return ((DockerImageTag) element).getRepoName();
}
});
addTableViewerColum(dockerImagesTableViewer, "Tag", SWT.NONE, SWT.LEFT, 100, new ColumnLabelProvider() {
@Override
public String getText(final Object element) {
return ((DockerImageTag) element).getTag();
}
});
addTableViewerColum(dockerImagesTableViewer, "Image ID", SWT.NONE, SWT.LEFT, 150, new ColumnLabelProvider() {
@Override
public String getText(final Object element) {
return ((DockerImageTag) element).getId();
}
});
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(2, 1).hint(200, 100).applyTo(dockerImagesTable);
// observe the viewer content
dockerImagesTableViewer.setContentProvider(new ObservableListContentProvider());
// observe the viewer content
dockerImagesTableViewer.setInput(BeanProperties.list(ListDockerImagesWizardModel.class, ListDockerImagesWizardModel.DOCKER_IMAGES).observe(model));
// filter by name
final ViewerFilter imageNameFilter = new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return ((DockerImageTag) element).getRepoName().contains(filterByNameText.getText());
}
};
dockerImagesTableViewer.addFilter(imageNameFilter);
filterByNameText.addModifyListener(onFilterImages(dockerImagesTableViewer));
// bind selection
dbc.bindValue(ViewerProperties.singleSelection().observe(dockerImagesTableViewer), BeanProperties.value(ListDockerImagesWizardModel.SELECTED_DOCKER_IMAGE).observe(model));
dockerImagesTableViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
IWizardContainer container = getWizard().getContainer();
if (container instanceof OkCancelButtonWizardDialog) {
((OkCancelButtonWizardDialog) container).autoFinish();
}
}
});
// load the Docker images
try {
getContainer().run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
model.setDockerImages(model.getDockerConnection().getImages(true));
}
});
} catch (InvocationTargetException | InterruptedException e) {
OpenShiftUIActivator.getDefault().getLogger().logError(e);
}
}
use of org.eclipse.jface.wizard.IWizardContainer in project egit by eclipse.
the class FetchGerritChangePage method getRefsForContentAssist.
private Collection<Change> getRefsForContentAssist(String originalRefText) throws InvocationTargetException, InterruptedException {
String uriText = uriCombo.getText();
if (!changeRefs.containsKey(uriText)) {
changeRefs.put(uriText, new ChangeList(repository, uriText));
}
ChangeList list = changeRefs.get(uriText);
if (!list.isFinished()) {
IWizardContainer container = getContainer();
IRunnableWithProgress operation = monitor -> {
monitor.beginTask(MessageFormat.format(UIText.AsynchronousRefProposalProvider_FetchingRemoteRefsMessage, uriText), IProgressMonitor.UNKNOWN);
Collection<Change> result = list.get();
if (monitor.isCanceled()) {
return;
}
// If we get here, the ChangeList future is done.
if (result == null || result.isEmpty() || fetching) {
// Don't bother if we didn't get any results
return;
}
// If we do have results now, open the proposals.
Job showProposals = new WorkbenchJob(UIText.AsynchronousRefProposalProvider_ShowingProposalsJobName) {
@Override
public boolean shouldRun() {
return super.shouldRun() && !fetching;
}
@Override
public IStatus runInUIThread(IProgressMonitor uiMonitor) {
// the same
try {
if (container instanceof NonBlockingWizardDialog) {
// focus will be restored
if (fetching) {
return Status.CANCEL_STATUS;
}
String uriNow = uriCombo.getText();
if (!uriNow.equals(uriText)) {
return Status.CANCEL_STATUS;
}
if (refText != refText.getDisplay().getFocusControl()) {
fillInPatchSet(result, null);
return Status.CANCEL_STATUS;
}
// Try not to interfere with the user's typing.
// Only fill in the patch set number if the text
// is still the same.
fillInPatchSet(result, originalRefText);
doAutoFill = false;
} else {
// Dialog was blocked
fillInPatchSet(result, null);
doAutoFill = false;
}
contentProposer.openProposalPopup();
} catch (SWTException e) {
// Disposed already
return Status.CANCEL_STATUS;
} finally {
doAutoFill = true;
uiMonitor.done();
}
return Status.OK_STATUS;
}
};
showProposals.schedule();
};
if (container instanceof NonBlockingWizardDialog) {
NonBlockingWizardDialog dialog = (NonBlockingWizardDialog) container;
dialog.run(operation, () -> {
if (!fetching) {
list.cancel(ChangeList.CancelMode.ABANDON);
}
});
} else {
container.run(true, true, operation);
}
return null;
}
// ChangeList is already here, so get() won't block
Collection<Change> changes = list.get();
if (doAutoFill) {
fillInPatchSet(changes, originalRefText);
}
return changes;
}
Aggregations