use of org.eclipse.ui.WorkbenchException in project polymap4-core by Polymap4.
the class CommonWizardDescriptor method init.
void init() throws WorkbenchException {
wizardId = configElement.getAttribute(ATT_WIZARD_ID);
type = configElement.getAttribute(ATT_TYPE);
menuGroupId = configElement.getAttribute(ATT_MENU_GROUP_ID);
if (menuGroupId == null) {
menuGroupId = DEFAULT_MENU_GROUP_ID;
}
/*
* The id defaults to the id of the enclosing navigatorContent extension, if any
* If not enclosed, this can be null initially, so it will default to the
* value of the associatedExtensionId
*
* Code elsewhere anticipates that this attribute may be null, so there is
* no need to set it to a default non-null value. Indeed, this will cause
* incorrect behavior.
* */
if (id == null) {
id = configElement.getAttribute(ATT_ASSOCIATED_EXTENSION_ID);
}
if (wizardId == null || wizardId.length() == 0) {
throw new WorkbenchException(// $NON-NLS-1$
"Missing attribute: " + ATT_WIZARD_ID + // $NON-NLS-1$
" in common wizard extension: " + configElement.getDeclaringExtension().getNamespaceIdentifier());
}
if (type == null || type.length() == 0) {
throw new WorkbenchException(// $NON-NLS-1$
"Missing attribute: " + ATT_TYPE + // $NON-NLS-1$
" in common wizard extension: " + configElement.getDeclaringExtension().getNamespaceIdentifier());
}
IConfigurationElement[] children = configElement.getChildren(TAG_ENABLEMENT);
if (children.length == 1) {
try {
enablement = ElementHandler.getDefault().create(ExpressionConverter.getDefault(), children[0]);
} catch (CoreException e) {
NavigatorPlugin.log(IStatus.ERROR, 0, e.getMessage(), e);
}
} else if (children.length > 1) {
throw new WorkbenchException(// $NON-NLS-1$
"More than one element: " + TAG_ENABLEMENT + // $NON-NLS-1$
" in common wizard extension: " + configElement.getDeclaringExtension().getUniqueIdentifier());
}
}
use of org.eclipse.ui.WorkbenchException in project polymap4-core by Polymap4.
the class NavigatorContentDescriptor method init.
/**
* Parses the configuration element.
*
* @throws WorkbenchException
* if the configuration element could not be parsed. Reasons
* include:
* <ul>
* <li>A required attribute is missing.</li>
* <li>More elements are define than is allowed.</li>
* </ul>
*/
private void init() throws WorkbenchException {
id = configElement.getAttribute(ATT_ID);
name = configElement.getAttribute(ATT_NAME);
String priorityString = configElement.getAttribute(ATT_PRIORITY);
icon = configElement.getAttribute(ATT_ICON);
String activeByDefaultString = configElement.getAttribute(ATT_ACTIVE_BY_DEFAULT);
activeByDefault = (activeByDefaultString != null && activeByDefaultString.length() > 0) ? Boolean.valueOf(activeByDefaultString).booleanValue() : true;
String providesSaveablesString = configElement.getAttribute(ATT_PROVIDES_SAVEABLES);
providesSaveables = (providesSaveablesString != null && providesSaveablesString.length() > 0) ? Boolean.valueOf(providesSaveablesString).booleanValue() : false;
appearsBeforeId = configElement.getAttribute(ATT_APPEARS_BEFORE);
if (priorityString != null) {
try {
Priority p = Priority.get(priorityString);
priority = p != null ? p.getValue() : Priority.NORMAL_PRIORITY_VALUE;
} catch (NumberFormatException exception) {
priority = Priority.NORMAL_PRIORITY_VALUE;
}
}
// We start with this because the sort ExtensionPriorityComparator works
// from the sequenceNumber
sequenceNumber = priority;
String sortOnlyString = configElement.getAttribute(ATT_SORT_ONLY);
sortOnly = (sortOnlyString != null && sortOnlyString.length() > 0) ? Boolean.valueOf(sortOnlyString).booleanValue() : false;
if (id == null) {
throw new WorkbenchException(NLS.bind(CommonNavigatorMessages.Attribute_Missing_Warning, new Object[] { ATT_ID, id, configElement.getDeclaringExtension().getNamespaceIdentifier() }));
}
contribution = new IPluginContribution() {
public String getLocalId() {
return getId();
}
public String getPluginId() {
return configElement.getDeclaringExtension().getNamespaceIdentifier();
}
};
IConfigurationElement[] children;
children = configElement.getChildren(TAG_INITIAL_ACTIVATION);
if (children.length > 0) {
if (children.length == 1) {
initialActivation = new CustomAndExpression(children[0]);
} else {
throw new WorkbenchException(NLS.bind(CommonNavigatorMessages.Attribute_Missing_Warning, new Object[] { TAG_INITIAL_ACTIVATION, id, configElement.getDeclaringExtension().getNamespaceIdentifier() }));
}
}
if (sortOnly)
return;
children = configElement.getChildren(TAG_ENABLEMENT);
if (children.length == 0) {
children = configElement.getChildren(TAG_TRIGGER_POINTS);
if (children.length == 1) {
enablement = new CustomAndExpression(children[0]);
} else {
throw new WorkbenchException(NLS.bind(CommonNavigatorMessages.Attribute_Missing_Warning, new Object[] { TAG_TRIGGER_POINTS, id, configElement.getDeclaringExtension().getNamespaceIdentifier() }));
}
children = configElement.getChildren(TAG_POSSIBLE_CHILDREN);
if (children.length == 1) {
possibleChildren = new CustomAndExpression(children[0]);
} else if (children.length > 1) {
throw new WorkbenchException(NLS.bind(CommonNavigatorMessages.Attribute_Missing_Warning, new Object[] { TAG_POSSIBLE_CHILDREN, id, configElement.getDeclaringExtension().getNamespaceIdentifier() }));
}
} else if (children.length == 1) {
try {
enablement = ElementHandler.getDefault().create(ExpressionConverter.getDefault(), children[0]);
} catch (CoreException e) {
NavigatorPlugin.log(IStatus.ERROR, 0, e.getMessage(), e);
}
} else if (children.length > 1) {
throw new WorkbenchException(NLS.bind(CommonNavigatorMessages.Attribute_Missing_Warning, new Object[] { TAG_ENABLEMENT, id, configElement.getDeclaringExtension().getNamespaceIdentifier() }));
}
children = configElement.getChildren(TAG_OVERRIDE);
if (children.length == 0) {
overridePolicy = OverridePolicy.get(OverridePolicy.InvokeAlwaysRegardlessOfSuppressedExt_LITERAL);
} else if (children.length == 1) {
suppressedExtensionId = children[0].getAttribute(ATT_SUPPRESSED_EXT_ID);
overridePolicy = OverridePolicy.get(children[0].getAttribute(ATT_POLICY));
} else if (children.length > 1) {
throw new WorkbenchException(NLS.bind(CommonNavigatorMessages.Too_many_elements_Warning, new Object[] { TAG_OVERRIDE, id, configElement.getDeclaringExtension().getNamespaceIdentifier() }));
}
}
use of org.eclipse.ui.WorkbenchException in project Palladio-Editors-Sirius by PalladioSimulator.
the class NewPalladioProjectWizard method openPalladioPerspective.
private void openPalladioPerspective() {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
try {
workbench.showPerspective(PERSPECTIVE_ID, window);
} catch (WorkbenchException e) {
MessageDialog.openError(getShell(), "Error", "Could not open Palladio Perspective");
e.printStackTrace();
}
}
use of org.eclipse.ui.WorkbenchException in project yamcs-studio by yamcs.
the class EditOPIAction method run.
@Override
public void run() {
var page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
var shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
IOPIRuntime opiRuntime = OPIShell.getOPIShellForShell(shell);
if (opiRuntime == null) {
// if the selected object isn't an OPIShell so grab the
// OPIView or OPIRunner currently selected
var part = page.getActivePart();
if (part instanceof IOPIRuntime) {
opiRuntime = (IOPIRuntime) part;
}
}
IWorkbenchWindow targetWindow = null;
for (var window : PlatformUI.getWorkbench().getWorkbenchWindows()) {
if (window.getActivePage().getPerspective().getId().equals(OPIEditorPerspective.ID)) {
targetWindow = window;
}
}
if (targetWindow == null) {
try {
targetWindow = PlatformUI.getWorkbench().openWorkbenchWindow(OPIEditorPerspective.ID, null);
} catch (WorkbenchException e) {
throw new RuntimeException(e);
}
}
targetWindow.getShell().setActive();
if (opiRuntime != null) {
var path = opiRuntime.getDisplayModel().getOpiFilePath();
page = targetWindow.getActivePage();
if (page != null) {
try {
var editorInput = ResourceUtil.editorInputFromPath(path);
page.openEditor(editorInput, OPI_EDITOR_ID, true, IWorkbenchPage.MATCH_ID | IWorkbenchPage.MATCH_INPUT);
} catch (PartInitException e) {
ErrorHandlerUtil.handleError("Failed to open current OPI in editor", e);
}
}
}
}
use of org.eclipse.ui.WorkbenchException in project tdi-studio-se by Talend.
the class OpenDiagramAction method getSelectedObject.
private ISelection getSelectedObject() {
if (params == null) {
return getSelection();
} else {
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (null == workbenchWindow) {
return null;
}
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
if (null == workbenchPage) {
return null;
}
IPerspectiveDescriptor currentPerspective = workbenchPage.getPerspective();
if (!IBrandingConfiguration.PERSPECTIVE_DI_ID.equals(currentPerspective.getId())) {
// show di perspective
try {
workbenchWindow.getWorkbench().showPerspective(IBrandingConfiguration.PERSPECTIVE_DI_ID, workbenchWindow);
workbenchPage = workbenchWindow.getActivePage();
} catch (WorkbenchException e) {
ExceptionHandler.process(e);
return null;
}
}
RepositoryNode repositoryNode = RepositoryNodeUtilities.getRepositoryNode(params.getProperty("nodeId"), false);
IRepositoryView viewPart = getViewPart();
if (repositoryNode != null && viewPart != null) {
RepositoryNodeUtilities.expandParentNode(viewPart, repositoryNode);
return new StructuredSelection(repositoryNode);
}
return null;
}
}
Aggregations