use of org.eclipse.jface.wizard.IWizard in project translationstudio8 by heartsome.
the class TSWizardDialog method hardClose.
/**
* Closes this window.
*
* @return <code>true</code> if the window is (or was already) closed, and
* <code>false</code> if it is still open
*/
private boolean hardClose() {
// inform wizards
for (int i = 0; i < createdWizards.size(); i++) {
IWizard createdWizard = (IWizard) createdWizards.get(i);
try {
createdWizard.dispose();
} catch (Exception e) {
Status status = new Status(IStatus.ERROR, Policy.JFACE, IStatus.ERROR, e.getMessage(), e);
Policy.getLog().log(status);
}
// Remove this dialog as a parent from the managed wizard.
// Note that we do this after calling dispose as the wizard or
// its pages may need access to the container during
// dispose code
createdWizard.setContainer(null);
}
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=202534
// disposing the wizards could cause the image currently set in
// this dialog to be disposed. A subsequent repaint event during
// close would then fail. To prevent this case, we null out the image.
setTitleImage(null);
return super.close();
}
use of org.eclipse.jface.wizard.IWizard in project meclipse by flaper87.
the class MeclipsePlugin method openWizard.
/**
* Stolen from
* http://torkildr.blogspot.com/2010/07/invoking-eclipse-wizard.html
*
* @param id
*/
public void openWizard(String id) {
// First see if this is a "new wizard".
IWizardDescriptor descriptor = PlatformUI.getWorkbench().getNewWizardRegistry().findWizard(id);
// If not check if it is an "import wizard".
if (descriptor == null) {
descriptor = PlatformUI.getWorkbench().getImportWizardRegistry().findWizard(id);
}
// Or maybe an export wizard
if (descriptor == null) {
descriptor = PlatformUI.getWorkbench().getExportWizardRegistry().findWizard(id);
}
try {
// Then if we have a wizard, open it.
if (descriptor != null) {
IWizard wizard = descriptor.createWizard();
WizardDialog wd = new WizardDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), wizard);
wd.setTitle(wizard.getWindowTitle());
wd.open();
}
} catch (CoreException e) {
e.printStackTrace();
}
}
use of org.eclipse.jface.wizard.IWizard in project translationstudio8 by heartsome.
the class ConversionHandler method execute.
/**
* the command has been executed, so extract extract the needed information from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
String commandId = event.getCommand().getId();
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
if (currentSelection.isEmpty()) {
return null;
}
if (currentSelection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) currentSelection;
Object object = structuredSelection.getFirstElement();
// 通过 adapter manager 获得 conversion item
Object adapter = Platform.getAdapterManager().getAdapter(object, IConversionItem.class);
if (adapter instanceof IConversionItem) {
// open the config conversion dialog
ConverterViewModel converterViewModel = null;
IConversionItem sourceItem = (IConversionItem) adapter;
if (commandId.equals("net.heartsome.cat.convert.ui.commands.convertCommand")) {
converterViewModel = new ConverterViewModel(Activator.getContext(), Converter.DIRECTION_POSITIVE);
// 记住所选择的文件
converterViewModel.setConversionItem(sourceItem);
IWizard wizard = new ConversionWizard(Arrays.asList(converterViewModel), null);
TSWizardDialog dialog = new ConversionWizardDialog(window.getShell(), wizard);
int result = dialog.open();
if (result == IDialogConstants.OK_ID) {
converterViewModel.convert();
}
} else {
converterViewModel = new ConverterViewModel(Activator.getContext(), Converter.DIRECTION_REVERSE);
converterViewModel.setConversionItem(sourceItem);
IWizard wizard = new ReverseConversionWizard(Arrays.asList(converterViewModel), null);
TSWizardDialog dialog = new ConversionWizardDialog(window.getShell(), wizard);
int result = dialog.open();
if (result == IDialogConstants.OK_ID) {
converterViewModel.convert();
}
}
}
}
return null;
}
use of org.eclipse.jface.wizard.IWizard in project translationstudio8 by heartsome.
the class TSWizardDialog method finishPressed.
/**
* The Finish button has been pressed.
*/
protected void finishPressed() {
// list (to save state).
if (wizard.performFinish()) {
// (to allow them to save state for example)
for (int i = 0; i < nestedWizards.size() - 1; i++) {
((IWizard) nestedWizards.get(i)).performFinish();
}
// Hard close the dialog.
setReturnCode(OK);
hardClose();
}
}
use of org.eclipse.jface.wizard.IWizard in project tdi-studio-se by Talend.
the class CreateGenericConnectionAction method doRun.
@Override
protected void doRun() {
IWizard wizard = new GenericConnWizard(PlatformUI.getWorkbench(), creation, repositoryNode, getExistingNames());
WizardDialog wizardDialog = new GenericWizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard, new GenericWizardInternalService().getComponentService());
if (Platform.getOS().equals(Platform.OS_LINUX)) {
wizardDialog.setPageSize(getWizardWidth(), getWizardHeight() + 80);
}
wizardDialog.create();
wizardDialog.open();
}
Aggregations