use of org.eclipse.ui.internal.dialogs.SelectPerspectiveDialog in project netxms by netxms.
the class ApplicationActionBarAdvisor method exportPerspective.
/**
* Export perspective
* @param window
*/
private void exportPerspective(IWorkbenchWindow window) {
try {
SelectPerspectiveDialog dlg = new SelectPerspectiveDialog(window.getShell(), window.getWorkbench().getPerspectiveRegistry());
if (dlg.open() == Window.OK) {
WorkbenchPage page = (WorkbenchPage) window.getActivePage();
Perspective p = page.findPerspective(dlg.getSelection());
// $NON-NLS-1$
final XMLMemento memento = XMLMemento.createWriteRoot("perspective");
p.saveState(memento);
FileDialog fd = new FileDialog(window.getShell());
// $NON-NLS-1$ //$NON-NLS-2$
fd.setFilterExtensions(new String[] { "*.xml", "*.*" });
fd.setFilterNames(new String[] { Messages.get().ApplicationActionBarAdvisor_XMLFiles, Messages.get().ApplicationActionBarAdvisor_AllFiles });
fd.setOverwrite(true);
fd.setText(Messages.get().ApplicationActionBarAdvisor_ExportPerspective);
final String fileName = fd.open();
if (fileName != null) {
new ConsoleJob(Messages.get().ApplicationActionBarAdvisor_ExportPerspective, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
FileWriter writer = null;
try {
writer = new FileWriter(fileName);
memento.save(writer);
} finally {
if (writer != null)
writer.close();
}
}
@Override
protected String getErrorMessage() {
return Messages.get().ApplicationActionBarAdvisor_PerspectiveExportFailed;
}
}.start();
}
}
} catch (Exception e) {
// $NON-NLS-1$
Activator.logError("Exception in exportPerspective", e);
MessageDialogHelper.openError(window.getShell(), Messages.get().ApplicationActionBarAdvisor_Error, Messages.get().ApplicationActionBarAdvisor_PerspectiveExportFailed);
}
}
Aggregations