public static KeyProviderFactory findFactory ( final String id ) { for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_KEY_PROVIDER_FACTORY ) ) { if ( !ELE_FACTORY.equals ( ele.getName () ) ) { continue; } try { return (KeyProviderFactory)ele.createExecutableExtension ( ATTR_CLASS ); } catch ( final CoreException e ) { StatusManager.getManager ().handle ( e, Activator.PLUGIN_ID ); } } return null; }
public static Collection<KeyProviderFactory> createFactories () { final Collection<KeyProviderFactory> result = new LinkedList<KeyProviderFactory> (); for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_KEY_PROVIDER_FACTORY ) ) { if ( !ELE_FACTORY.equals ( ele.getName () ) ) { continue; } try { result.add ( (KeyProviderFactory)ele.createExecutableExtension ( ATTR_CLASS ) ); } catch ( final CoreException e ) { StatusManager.getManager ().handle ( e, Activator.PLUGIN_ID ); } } return result; }
@Override public void setVisible ( final boolean visible ) { super.setVisible ( visible ); if ( visible ) { try { getContainer ().run ( false, false, new IRunnableWithProgress () { @Override public void run ( final IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException { setMergeResult ( PreviewPage.this.mergeController.merge ( wrap ( monitor ) ) ); } } ); } catch ( final Exception e ) { final Status status = new Status ( IStatus.ERROR, Activator.PLUGIN_ID, Messages.PreviewPage_StatusErrorFailedToMerge, e ); StatusManager.getManager ().handle ( status ); ErrorDialog.openError ( getShell (), Messages.PreviewPage_TitleErrorFailedToMerge, Messages.PreviewPage_MessageErrorFailedToMerge, status ); } } }
@Override public void run () { try { final IViewPart viewPart = getViewSite ().getWorkbenchWindow ().getActivePage ().showView ( ChartConfiguratorView.VIEW_ID ); if ( viewPart instanceof ChartConfiguratorView ) { ( (ChartConfiguratorView)viewPart ).setChartConfiguration ( getConfiguration () ); } } catch ( final PartInitException e ) { StatusManager.getManager ().handle ( e.getStatus (), StatusManager.BLOCK ); } }
private StyleGenerator create ( final IConfigurationElement ele ) { if ( ele == null ) { return null; } try { final Object o = ele.createExecutableExtension ( Messages.PreferenceSelectorStyleGenerator_2 ); if ( o instanceof StyleGenerator ) { return (StyleGenerator)o; } logger.warn ( "Class referenced in 'generatorClass' did not implement {}", StyleGenerator.class ); //$NON-NLS-1$ return null; } catch ( final CoreException e ) { StatusManager.getManager ().handle ( e, Activator.PLUGIN_ID ); return null; } }
private void createButton ( final Composite parent ) { this.wrapper = new Composite ( parent, SWT.NONE ); final GridLayout layout = new GridLayout ( 1, true ); layout.marginHeight = layout.marginWidth = 0; this.wrapper.setLayout ( layout ); this.startButton = new Button ( this.wrapper, SWT.PUSH ); this.startButton.setLayoutData ( new GridData ( SWT.CENTER, SWT.CENTER, true, true ) ); this.startButton.setText ( Messages.DetailsPart_startButton_label ); this.startButton.addSelectionListener ( new SelectionAdapter () { @Override public void widgetSelected ( final SelectionEvent e ) { try { start (); } catch ( final Exception ex ) { logger.error ( "Failed to start chart", ex ); //$NON-NLS-1$ StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, ex ), StatusManager.BLOCK ); } } } ); }
protected List<FilterTab> getFilterTabs () { final List<FilterTab> result = new LinkedList<FilterTab> (); result.add ( new QueryByExampleTab () ); result.add ( new FreeFormTab () ); for ( final IConfigurationElement ele : Platform.getExtensionRegistry ().getConfigurationElementsFor ( EXTP_FILTER_TAB ) ) { if ( !"filterTab".equals ( ele.getName () ) ) { continue; } try { result.add ( (FilterTab)ele.createExecutableExtension ( "class" ) ); } catch ( final CoreException e ) { StatusManager.getManager ().handle ( e.getStatus () ); } } return result; }
public FactoryImpl () { this.prefs = Preferences.userNodeForPackage ( FactoryImpl.class ).node ( "files" ); try { for ( final String child : this.prefs.childrenNames () ) { final Preferences childNode = this.prefs.node ( child ); final String fileName = childNode.get ( "file", null ); if ( fileName != null ) { this.files.add ( fileName ); } } } catch ( final BackingStoreException e ) { StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ) ); } }
@Override public void init ( final Realm realm ) { this.realm = realm; this.list = new WritableList (); for ( final String name : this.names ) { try { this.list.add ( new SunMSCAPIProvider ( this.realm, name ) ); } catch ( final Exception e ) { StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ) ); } } }
@Override public boolean performFinish () { try { getContainer ().run ( true, true, new IRunnableWithProgress () { public void run ( final IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException { doExport ( monitor ); } } ); return true; } catch ( final Exception e ) { StatusManager.getManager ().handle ( new Status ( IStatus.ERROR, Activator.PLUGIN_ID, Messages.ExportWizard_ErrorMessage, e ) ); return false; } }
/** * Trigger the controller to update the data from the registration manager * <p> * This method can be called from any thread and must synchronized to the UI * </p> */ @Override public void triggerDataUpdate () { try { Display.getDefault ().asyncExec ( new Runnable () { @Override public void run () { handleDataUpdate (); }; } ); } catch ( final Exception e ) { StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ) ); } }
private void runUpdate ( final boolean ignoreParents ) { logger.debug ( "Running update: {}", this.nameHierarchy ); try { if ( this.onUpdate != null ) { this.onUpdate.execute ( this.scriptContext ); } } catch ( final Exception e ) { StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ), StatusManager.LOG ); errorLog ( "Failed to run update", e ); } notifySummaryListeners (); // propagate update if ( !ignoreParents && this.parentController != null ) { this.parentController.runUpdate ( false ); } }
public void execute ( final ScriptExecutor scriptExecutor, final Map<String, Object> scriptObjects ) throws Exception { if ( scriptExecutor == null ) { return; } try { scriptExecutor.execute ( this.scriptContext, scriptObjects ); } catch ( final Exception e ) { StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ), StatusManager.LOG ); throw new InvocationTargetException ( e ); } }
private void fireScriptEvent ( final ScriptExecutor script, final Object event, final String eventName ) { this.controller.debugLog ( String.format ( "%s: %s", eventName, event ) ); //$NON-NLS-1$ final Map<String, Object> scriptObjects = new LinkedHashMap<String, Object> ( 1 ); scriptObjects.put ( "event", event ); //$NON-NLS-1$ try { this.controller.execute ( script, scriptObjects ); } catch ( final Exception e ) { this.controller.errorLog ( "Failed to handle event: " + eventName, e ); //$NON-NLS-1$ if ( !Boolean.getBoolean ( "org.eclipse.scada.vi.ui.draw2d.suppressErrors" ) ) //$NON-NLS-1$ { StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, "Failed to handle event", e ), StatusManager.SHOW ); } } }
@SuppressWarnings ( "unchecked" ) @Override public Object execute ( final ExecutionEvent event ) throws ExecutionException { final String detailViewId = event.getParameter ( "org.eclipse.scada.vi.details.showDetailDialog.id" ); final Map<String, String> parameters = (Map<String, String>)event.getObjectParameterForExecution ( "org.eclipse.scada.vi.details.showDetailDialog.parameters" ); try { if ( this.useWaitShell ) { openWithWaitShell ( getShell (), detailViewId, parameters ); } else { open ( getShell (), detailViewId, parameters ); } } catch ( final Exception e ) { StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, "Failed to open detail view", e ), StatusManager.SHOW ); } return null; }
protected void validateAll ( final IProject project, final ComposedAdapterFactory adapterFactory, final Set<String> extensions, final IProgressMonitor monitor ) { logger.debug ( "Validating all resources of {}", project ); try { project.accept ( new IResourceVisitor () { @Override public boolean visit ( final IResource resource ) throws CoreException { return handleResource ( null, resource, adapterFactory, extensions, monitor ); } } ); } catch ( final CoreException e ) { StatusManager.getManager ().handle ( e.getStatus () ); } }
@Override public Object execute ( final ExecutionEvent event ) throws ExecutionException { final MultiStatus ms = new MultiStatus ( HivesPlugin.PLUGIN_ID, 0, getLabel (), null ); for ( final ServerLifecycle server : SelectionHelper.iterable ( getSelection (), ServerLifecycle.class ) ) { try { process ( server ); } catch ( final CoreException e ) { ms.add ( e.getStatus () ); } } if ( !ms.isOK () ) { StatusManager.getManager ().handle ( ms, StatusManager.SHOW ); } return null; }
public void dispose () { try { stop (); } catch ( final CoreException e ) { StatusManager.getManager ().handle ( e.getStatus () ); } for ( final ServerEndpointImpl endpoint : this.endpointImpls ) { endpoint.dispose (); } this.endpointImpls.clear (); if ( !this.endpoints.isDisposed () ) { this.endpoints.clear (); this.endpoints.dispose (); } }
@Override public Object execute ( final ExecutionEvent event ) throws ExecutionException { for ( final IFile file : SelectionHelper.iterable ( getSelection (), IFile.class ) ) { try { HivesPlugin.getDefault ().getServerHost ().startServer ( file ); getActivePage ().showView ( "org.eclipse.scada.da.server.ui.ServersView" ); //$NON-NLS-1$ } catch ( final Exception e ) { logger.warn ( "Failed to start file: " + file, e ); //$NON-NLS-1$ StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ), StatusManager.BLOCK ); } } return null; }
@Override public Object execute ( final ExecutionEvent event ) throws ExecutionException { final Component component = SelectionHelper.first ( getSelection (), Component.class ); if ( component == null ) { return null; } try { final IObservableSet input = Helper.createObversableInput ( DisplayRealm.getRealm ( getShell ().getDisplay () ), component ); new ComponentOutputDialog ( getShell (), input ).open (); } catch ( final Exception e ) { StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, "Failed to generate component output", e ), StatusManager.BLOCK ); throw new ExecutionException ( "Failed to generate component output", e ); } return null; }
private void openInbuiltOperationClass(String operationName, PropertyDialogButtonBar propertyDialogButtonBar) { String operationClassName = null; Operations operations = XMLConfigUtil.INSTANCE.getComponent(FilterOperationClassUtility.INSTANCE.getComponentName()) .getOperations(); List<TypeInfo> typeInfos = operations.getStdOperation(); for (int i = 0; i < typeInfos.size(); i++) { if (typeInfos.get(i).getName().equalsIgnoreCase(operationName)) { operationClassName = typeInfos.get(i).getClazz(); break; } } propertyDialogButtonBar.enableApplyButton(true); javaProject = FilterOperationClassUtility.getIJavaProject(); if (javaProject != null) { try { IType findType = javaProject.findType(operationClassName); JavaUI.openInEditor(findType); } catch (JavaModelException | PartInitException e) { Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,Messages.CLASS_NOT_EXIST,null); StatusManager.getManager().handle(status, StatusManager.BLOCK); logger.error(e.getMessage(), e); } } else { WidgetUtility.errorMessage(Messages.SAVE_JOB_MESSAGE); } }
private void generateTargetXMLInWorkspace(IFile ifile, Container container) { IFile outPutFile = ResourcesPlugin.getWorkspace().getRoot().getFile(ifile.getFullPath().removeFileExtension().addFileExtension("xml")); try { if(container!=null) ConverterUtil.INSTANCE.convertToXML(container, false, outPutFile,null); else ConverterUtil.INSTANCE.convertToXML(this.container, false, outPutFile,null); } catch (EngineException eexception) { logger.warn("Failed to create the engine xml", eexception); MessageDialog.openError(Display.getDefault().getActiveShell(), "Failed to create the engine xml", eexception.getMessage()); // }catch (InstantiationException|IllegalAccessException| InvocationTargetException| NoSuchMethodException exception) { logger.error("Failed to create the engine xml", exception); Status status = new Status(IStatus.ERROR, "hydrograph.ui.graph", "Failed to create Engine XML " + exception.getMessage()); StatusManager.getManager().handle(status, StatusManager.SHOW); } }
private void generateTargetXMLInLocalFileSystem(IFileStore fileStore, Container container) { try { if(container!=null) ConverterUtil.INSTANCE.convertToXML(container, false, null,fileStore); else ConverterUtil.INSTANCE.convertToXML(this.container, false,null,fileStore); } catch (EngineException eexception) { logger.warn("Failed to create the engine xml", eexception); MessageDialog.openError(Display.getDefault().getActiveShell(), "Failed to create the engine xml", eexception.getMessage()); }catch (InstantiationException| IllegalAccessException| InvocationTargetException| NoSuchMethodException exception) { logger.error("Failed to create the engine xml", exception); Status status = new Status(IStatus.ERROR, "hydrograph.ui.graph", "Failed to create Engine XML " + exception.getMessage()); StatusManager.getManager().handle(status, StatusManager.SHOW); } }
/** * Stores dialog settings. * * @param settings * settings used to store dialog */ protected void storeDialog(IDialogSettings settings) { settings.put(SHOW_STATUS_LINE, toggleStatusLineAction.isChecked()); XMLMemento memento = XMLMemento.createWriteRoot(HISTORY_SETTINGS); this.contentProvider.saveHistory(memento); StringWriter writer = new StringWriter(); try { memento.save(writer); settings.put(HISTORY_SETTINGS, writer.getBuffer().toString()); } catch (IOException e) { // Simply don't store the settings StatusManager .getManager() .handle( new Status( IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.ERROR, WorkbenchMessages.FilteredItemsSelectionDialog_storeError, e)); } }
/** * Deletes the given entity from the given library. * * @param library * @param entity */ public void deleteEntityFromLibrary(final EntityLibrary library, final Entity<?> entity) { // Check whether there is already something existing in the // library with this name. if (library.getEntity(entity.getName()) == null) { StatusManager.getManager().handle( new Status(IStatus.WARNING, TriqEditorPlugin.getID(), "Delete from Library failed: An object with name " + entity.getName() + " does not exist in the library " + library.getName()), StatusManager.SHOW); return; } ChangeRequest request = new MoMLChangeRequest(this, library, "<deleteEntity name=\"" + entity.getName() + "\"/>\n") { @Override public NamedObj getLocality() { return userLibraryMap.get(USER_LIBRARY_NAME); } }; request.addChangeListener(new EntityLibraryChangedListener(this)); library.requestChange(request); }
public void launch(IEditorPart editor, String mode) { try { IEditorInput editorInput = editor.getEditorInput(); if (editorInput instanceof IFileEditorInput) { IFile file = ((IFileEditorInput) editorInput).getFile(); runSpecs(file, mode); } else { GaugeUtil.displayWarningMessage( "Cannot run specs for the selection.", StatusManager.LOG, null); } } catch (CoreException e) { GaugeUtil.displayErrorMessage("Unable to run specs", StatusManager.LOG, e); } }
public static void migratePreferences() { Preferences pref = new ProfileScope(getDefaultAgentLocation(), IProfileRegistry.SELF).getNode(P2_Activator.PLUGIN_ID); try { if (pref.keys().length == 0) { // migrate preferences from instance scope to profile scope Preferences oldPref = new InstanceScope().getNode(P2_Activator.PLUGIN_ID); // don't migrate everything. Some of the preferences moved to // another bundle. pref.put(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, oldPref.get(PreferenceConstants.PREF_OPEN_WIZARD_ON_ERROR_PLAN, MessageDialogWithToggle.PROMPT)); pref.putBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION, oldPref.getBoolean(PreferenceConstants.PREF_SHOW_LATEST_VERSION, true)); pref.flush(); } } catch (BackingStoreException e) { StatusManager.getManager().handle(new Status(IStatus.ERROR, P2_Activator.PLUGIN_ID, 0, ProvSDKMessages.PreferenceInitializer_Error, e), StatusManager.LOG); } }
public void savePreferences() { if (preferenceStore != null) { try { preferenceStore.save(); } catch (final IOException e) { final Status status = new Status( IStatus.ERROR, PLUGIN_ID, 0, ProvSDKMessages.ProvSDKUIActivator_ErrorSavingPrefs, e); StatusManager.getManager().handle(status, StatusManager.LOG | StatusManager.SHOW); } } }
@Override public synchronized AbstractStatusHandler getWorkbenchErrorHandler() { return new WorkbenchErrorHandler() { @Override public void handle(StatusAdapter statusAdapter, int style) { if (isClosing) { // we are shutting down, so just log WorkbenchPlugin.log(statusAdapter.getStatus()); return; } if ((style & StatusManager.SHOW) != 0) { style = style | StatusManager.BLOCK; } super.handle(statusAdapter, style); } }; }
private static BindingManager loadModelBackend(IServiceLocator locator) { IBindingService bindingService = (IBindingService) locator.getService(IBindingService.class); BindingManager bindingManager = new BindingManager(new ContextManager(), new CommandManager()); final Scheme[] definedSchemes = bindingService.getDefinedSchemes(); try { Scheme modelActiveScheme = null; for (int i = 0; i < definedSchemes.length; i++) { final Scheme scheme = definedSchemes[i]; final Scheme copy = bindingManager.getScheme(scheme.getId()); copy.define(scheme.getName(), scheme.getDescription(), scheme.getParentId()); if (definedSchemes[i] == bindingService.getActiveScheme()) { modelActiveScheme = copy; } } bindingManager.setActiveScheme(modelActiveScheme); } catch (final NotDefinedException e) { StatusManager.getManager() .handle(new Status(IStatus.WARNING, WorkbenchPlugin.PI_WORKBENCH, "Keys page found an undefined scheme", e)); //$NON-NLS-1$ } bindingManager.setLocale(bindingService.getLocale()); bindingManager.setPlatform(bindingService.getPlatform()); bindingManager.setBindings(bindingService.getBindings()); return bindingManager; }
@Override public boolean continueWorkingWithOperation(ProfileChangeOperation operation, Shell shell) { Assert.isTrue(operation.getResolutionResult() != null); IStatus status = operation.getResolutionResult(); // user cancelled if (status.getSeverity() == IStatus.CANCEL) return false; // Special case those statuses where we would never want to open a wizard if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) { MessageDialog.openInformation(shell, P2UpdateUtil.CHECK_UPDATE_JOB_NAME, P2UpdateUtil.UPDATE_PROMPT_INFO_NO_UPDATE); return false; } // there is no plan, so we can't continue. Report any reason found if (operation.getProvisioningPlan() == null && !status.isOK()) { StatusManager.getManager().handle(status, StatusManager.LOG | StatusManager.SHOW); return false; } // Allow the wizard to open otherwise. return true; }
/** * Displays a non blocking nested error mesage. * @param errors A map of errors. * @return Status.CANCEL_STATUS. */ IStatus nonblockError(Map<String, List<String>> errors) { MultiStatus err = new MultiStatus(Activator.PLUGIN_ID, Status.ERROR, "Error during project compilation", null); for (Entry<String, List<String>> entry : errors.entrySet()) { MultiStatus lab = new MultiStatus(Activator.PLUGIN_ID, Status.ERROR, entry.getKey(), null); for (String s : entry.getValue()) { lab.add(new Status(Status.ERROR, Activator.PLUGIN_ID, Status.ERROR, s, null)); } err.add(lab); } StatusManager.getManager().handle(err, StatusManager.SHOW); return Status.CANCEL_STATUS; }
public KNode transform(final IVariable variable) { DebuKVizDialog.resetShown(); // Generate a top-level KNode and set some layout options KNode graph = KGraphUtil.createInitializedNode(); graph.setProperty(CoreOptions.DIRECTION, Direction.DOWN); graph.setProperty(LayeredOptions.NODE_PLACEMENT_STRATEGY, NodePlacementStrategy.LINEAR_SEGMENTS); // Generate a transformation context VariableTransformationContext context = new VariableTransformationContext(); // Start the mighty transformation! try { VariableTransformation.invokeFor(variable, graph, context); } catch (DebugException e) { StatusManager.getManager().handle(new Status( Status.ERROR, DebuKVizPlugin.PLUGIN_ID, "Error accessing the Eclipse debug framework.", e)); } return graph; }
/** * Save the given class model at the given URI. * * @param classModel * the classmodel to save. * @param fileUri * the URI to save the model to. */ private void saveclassModel(KClassModel classModel, URI fileUri) { if (classModel == null || fileUri == null) { return; } // Create a resource set. ResourceSet resourceSet = new ResourceSetImpl(); // ResourceSet testResourceSet = new ResourceSetImpl(); // Create a resource for this file. Resource resource = resourceSet.createResource(fileUri); // Resource testResource = testResourceSet.createResource(URI.createFileURI("asdf/model.xmi")); // Add the model object to the contents. resource.getContents().add(classModel); // testResource.getContents().add(classModel); // Save the contents of the resource to the file system. try { resource.save(Collections.EMPTY_MAP); // testResource.save(Collections.EMPTY_MAP); } catch (IOException exception) { IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, "Could not save selection to project meta data.", exception); StatusManager.getManager().handle(status); } }
@Override protected void storeDialog(IDialogSettings settings) { super.storeDialog(settings); XMLMemento memento = XMLMemento.createWriteRoot("workingSet"); //$NON-NLS-1$ workingSetFilterActionGroup.saveState(memento); workingSetFilterActionGroup.dispose(); StringWriter writer = new StringWriter(); try { memento.save(writer); settings.put(WORKINGS_SET_SETTINGS, writer.getBuffer().toString()); } catch (IOException e) { StatusManager.getManager().handle( new Status(IStatus.ERROR, AnalysisPlugin.getPluginID(), IStatus.ERROR, "", e)); //$NON-NLS-1$ // don't do anything. Simply don't store the settings } }
@Override protected void restoreDialog(IDialogSettings settings) { super.restoreDialog(settings); String setting = settings.get(WORKINGS_SET_SETTINGS); if (setting != null) { try { IMemento memento = XMLMemento.createReadRoot(new StringReader(setting)); workingSetFilterActionGroup.restoreState(memento); } catch (WorkbenchException e) { StatusManager.getManager().handle( new Status(IStatus.ERROR, AnalysisPlugin.getPluginID(), IStatus.ERROR, "", e)); //$NON-NLS-1$ // don't do anything. Simply don't restore the settings } } addListFilter(workingSetFilter); applyFilter(); }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { File commandFile = extractAbsolutePathFromSelection(getCurrentSelection(event)); if (commandFile != null && hasUserConfirmed(commandFile, getActiveShell(event))) { ConsoleLogger logger = new ConsoleLogger(); executeCommandsFile(commandFile, logger); try { logger.close(); } catch (Exception e) { StatusManager.getManager().handle(new Status(Status.ERROR, VersioningUIPlugin.PLUGIN_ID, "Was not able to show console with results.", e), StatusManager.SHOW); } } return null; }