use of org.eclipse.ui.internal.dialogs.SavePerspectiveDialog in project eclipse.platform.ui by eclipse-platform.
the class SavePerspectiveHandler method saveNonSingleton.
/**
* Save a singleton over the user selection.
*/
private void saveNonSingleton(IWorkbenchPage page, PerspectiveDescriptor oldDesc) {
// Get reg.
PerspectiveRegistry reg = (PerspectiveRegistry) WorkbenchPlugin.getDefault().getPerspectiveRegistry();
// Get persp name.
SavePerspectiveDialog dlg = new SavePerspectiveDialog(page.getWorkbenchWindow().getShell(), reg);
// Look up the descriptor by id again to ensure it is still valid.
IPerspectiveDescriptor description = reg.findPerspectiveWithId(oldDesc.getId());
dlg.setInitialSelection(description);
if (dlg.open() != IDialogConstants.OK_ID) {
return;
}
// Create descriptor.
PerspectiveDescriptor newDesc = (PerspectiveDescriptor) dlg.getPersp();
if (newDesc == null) {
String name = dlg.getPerspName();
newDesc = reg.createPerspective(name, (PerspectiveDescriptor) description);
if (newDesc == null) {
MessageDialog.openError(dlg.getShell(), WorkbenchMessages.SavePerspective_errorTitle, WorkbenchMessages.SavePerspective_errorMessage);
return;
}
}
// Save state.
page.savePerspectiveAs(newDesc);
}
use of org.eclipse.ui.internal.dialogs.SavePerspectiveDialog in project eclipse.platform.ui by eclipse-platform.
the class UIDialogs method testSavePerspective.
@Test
public void testSavePerspective() {
PerspectiveRegistry reg = (PerspectiveRegistry) WorkbenchPlugin.getDefault().getPerspectiveRegistry();
// Get persp name.
SavePerspectiveDialog dialog = new SavePerspectiveDialog(getShell(), reg);
IPerspectiveDescriptor description = reg.findPerspectiveWithId(getWorkbench().getActiveWorkbenchWindow().getActivePage().getPerspective().getId());
dialog.setInitialSelection(description);
DialogCheck.assertDialog(dialog);
}
use of org.eclipse.ui.internal.dialogs.SavePerspectiveDialog in project eclipse.platform.ui by eclipse-platform.
the class UIDialogsAuto method testSavePerspective.
@Test
public void testSavePerspective() {
PerspectiveRegistry reg = (PerspectiveRegistry) WorkbenchPlugin.getDefault().getPerspectiveRegistry();
// Get persp name.
SavePerspectiveDialog dialog = new SavePerspectiveDialog(getShell(), reg);
IPerspectiveDescriptor description = reg.findPerspectiveWithId(getWorkbench().getActiveWorkbenchWindow().getActivePage().getPerspective().getId());
dialog.setInitialSelection(description);
DialogCheck.assertDialogTexts(dialog);
}
Aggregations