List of usage examples for org.eclipse.jface.dialogs MessageDialog openError
public static void openError(Shell parent, String title, String message)
From source file:ar.com.tadp.xml.rinzo.jdt.wizards.NewJAXBParserWizard.java
License:Open Source License
@Override public boolean performFinish() { try {/* w ww . j a va2 s . co m*/ Driver.run(this.createArgumentsList(), new XJCListenerExtension()); this.refreshSourceFolder(); this.createParser(); } catch (Exception e) { MessageDialog.openError(this.getShell(), "Generate JAXB Parser", e.getLocalizedMessage()); XMLEditorPlugin.log(e); return false; } return true; }
From source file:aspectminingtool.dialogs.Sinergia.SinergiaSettings.java
License:Open Source License
public void open() { try {//from w w w . ja va 2 s . c om Shell parent = getParent(); dialogShell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); { // Register as a resource user - SWTResourceManager will // handle the obtaining and disposing of resources // SWTResourceManager.registerResourceUser(dialogShell); } GridLayout dialogShellLayout = new GridLayout(); dialogShellLayout.makeColumnsEqualWidth = true; dialogShell.setLayout(dialogShellLayout); dialogShell.setText("Sinergia Settings"); dialogShell.setDragDetect(false); dialogShell.setSize(398, 355); { group1 = new Group(dialogShell, SWT.NONE); group1.setText("Fan-In Analysis"); GridLayout composite1Layout = new GridLayout(); composite1Layout.numColumns = 2; composite1Layout.marginLeft = 60; composite1Layout.makeColumnsEqualWidth = true; GridData composite1LData = new GridData(); composite1LData.horizontalAlignment = GridData.FILL; composite1LData.grabExcessHorizontalSpace = true; composite1LData.heightHint = 37; group1.setLayoutData(composite1LData); group1.setLayout(composite1Layout); { GridData compositeUmbralLData = new GridData(); compositeUmbralLData.horizontalAlignment = GridData.FILL; compositeUmbralLData.heightHint = 31; composite111 = new Composite(group1, SWT.NONE); GridLayout compositeUmbralLayout = new GridLayout(); compositeUmbralLayout.makeColumnsEqualWidth = true; compositeUmbralLayout.numColumns = 2; composite111.setLayout(compositeUmbralLayout); composite111.setLayoutData(compositeUmbralLData); { LabelUmbralFanIn = new CLabel(composite111, SWT.NONE); GridData labelUmbralLData = new GridData(); labelUmbralLData.horizontalIndent = -5; labelUmbralLData.widthHint = 65; labelUmbralLData.heightHint = 21; LabelUmbralFanIn.setLayoutData(labelUmbralLData); LabelUmbralFanIn.setText("Threshold"); } { TextUmbralFanIn = new Text(composite111, SWT.BORDER); GridData UmbralLData = new GridData(); UmbralLData.widthHint = 24; UmbralLData.heightHint = 15; TextUmbralFanIn.setLayoutData(UmbralLData); TextUmbralFanIn.setText("10"); } } { GridData compositeUmbral2LData = new GridData(); compositeUmbral2LData.horizontalAlignment = GridData.FILL; compositeUmbral2LData.heightHint = 31; composite112 = new Composite(group1, SWT.NONE); GridLayout compositeUmbral2Layout = new GridLayout(); compositeUmbral2Layout.makeColumnsEqualWidth = true; compositeUmbral2Layout.numColumns = 3; composite112.setLayout(compositeUmbral2Layout); composite112.setLayoutData(compositeUmbral2LData); { LabelConfianzaFanIn = new CLabel(composite112, SWT.NONE); GridData labelConfianzaLData = new GridData(); labelConfianzaLData.horizontalIndent = -5; labelConfianzaLData.widthHint = 40; labelConfianzaLData.heightHint = 21; LabelConfianzaFanIn.setLayoutData(labelConfianzaLData); LabelConfianzaFanIn.setText("Trust"); } { TextConfianzaFanIn = new Text(composite112, SWT.BORDER); GridData UmbralLData = new GridData(); UmbralLData.widthHint = 24; UmbralLData.heightHint = 15; TextConfianzaFanIn.setLayoutData(UmbralLData); TextConfianzaFanIn.setText("33"); } { PercentLabel = new Label(composite112, SWT.NONE); GridData PercentLabelLData = new GridData(); PercentLabel.setLayoutData(PercentLabelLData); PercentLabel.setText("%"); } } } group9 = new Group(dialogShell, SWT.NONE); group9.setText("Unique Methods Analysis"); GridLayout composite9Layout = new GridLayout(); composite9Layout.numColumns = 2; composite9Layout.marginLeft = 60; GridData composite9LData = new GridData(); composite9LData.horizontalAlignment = GridData.FILL; composite9LData.grabExcessHorizontalSpace = true; composite9LData.heightHint = 37; group9.setLayoutData(composite9LData); group9.setLayout(composite9Layout); { GridData composite2LData = new GridData(); composite991 = new Composite(group9, SWT.NONE); GridLayout composite2Layout = new GridLayout(); composite2Layout.makeColumnsEqualWidth = true; composite2Layout.numColumns = 2; composite991.setLayout(composite2Layout); composite991.setLayoutData(composite2LData); } { LabelUmbralUniqueM = new CLabel(composite991, SWT.NONE); GridData LabelUmbralUniqueMLData = new GridData(); LabelUmbralUniqueMLData.horizontalIndent = -5; LabelUmbralUniqueMLData.widthHint = 65; LabelUmbralUniqueMLData.heightHint = 21; LabelUmbralUniqueM.setLayoutData(LabelUmbralUniqueMLData); LabelUmbralUniqueM.setText("Threshold"); } { TextUmbralUniqueM = new Text(composite991, SWT.BORDER); GridData TextUmbralUniqueMLData = new GridData(); TextUmbralUniqueMLData.widthHint = 24; TextUmbralUniqueMLData.heightHint = 15; TextUmbralUniqueM.setLayoutData(TextUmbralUniqueMLData); TextUmbralUniqueM.setText("10"); } { GridData composite12LData = new GridData(); composite992 = new Composite(group9, SWT.NONE); GridLayout composite12Layout = new GridLayout(); composite12Layout.makeColumnsEqualWidth = true; composite12Layout.numColumns = 3; composite992.setLayout(composite12Layout); composite992.setLayoutData(composite12LData); } { LabelConfianzaUniqueM = new CLabel(composite992, SWT.NONE); GridData LabelConfianzaUniqueMLData = new GridData(); LabelConfianzaUniqueMLData.horizontalIndent = -5; LabelConfianzaUniqueMLData.widthHint = 40; LabelConfianzaUniqueMLData.heightHint = 21; LabelConfianzaUniqueM.setLayoutData(LabelConfianzaUniqueMLData); LabelConfianzaUniqueM.setText("Trust"); } { TextConfianzaUniqueM = new Text(composite992, SWT.BORDER); GridData TextConfianzaUniqueMLData = new GridData(); TextConfianzaUniqueMLData.widthHint = 24; TextConfianzaUniqueMLData.heightHint = 15; TextConfianzaUniqueM.setLayoutData(TextConfianzaUniqueMLData); TextConfianzaUniqueM.setText("33"); } { PercentLabelUnique = new Label(composite992, SWT.NONE); GridData PercentLabelUniqueLData = new GridData(); PercentLabelUnique.setLayoutData(PercentLabelUniqueLData); PercentLabelUnique.setText("%"); } { group6 = new Group(dialogShell, SWT.NONE); group6.setText("Execution Relations Analysis"); GridLayout composite6Layout = new GridLayout(); composite6Layout.makeColumnsEqualWidth = true; composite6Layout.marginLeft = 60; composite6Layout.numColumns = 2; GridData composite6LData = new GridData(); composite6LData.horizontalAlignment = GridData.FILL; composite6LData.grabExcessHorizontalSpace = true; group6.setLayoutData(composite6LData); group6.setLayout(composite6Layout); { GridData composite3LData = new GridData(); composite661 = new Composite(group6, SWT.NONE); GridLayout composite3Layout = new GridLayout(); composite3Layout.makeColumnsEqualWidth = true; composite3Layout.numColumns = 2; composite661.setLayout(composite3Layout); composite661.setLayoutData(composite3LData); } { LabelUmbralFlowGraph = new CLabel(composite661, SWT.NONE); GridData LabelUmbralFlowGraphLData = new GridData(); LabelUmbralFlowGraphLData.horizontalIndent = -5; LabelUmbralFlowGraphLData.widthHint = 65; LabelUmbralFlowGraphLData.heightHint = 21; LabelUmbralFlowGraph.setLayoutData(LabelUmbralFlowGraphLData); LabelUmbralFlowGraph.setText("Threshold"); } { TextUmbralFlowGraph = new Text(composite661, SWT.BORDER); GridData TextUmbralFlowGraphLData = new GridData(); TextUmbralFlowGraphLData.widthHint = 24; TextUmbralFlowGraphLData.heightHint = 15; TextUmbralFlowGraph.setLayoutData(TextUmbralFlowGraphLData); TextUmbralFlowGraph.setText("10"); } { GridData composite13LData = new GridData(); composite662 = new Composite(group6, SWT.NONE); GridLayout composite3Layout = new GridLayout(); composite3Layout.makeColumnsEqualWidth = true; composite3Layout.numColumns = 3; composite662.setLayout(composite3Layout); composite662.setLayoutData(composite13LData); } { LabelConfianzaFlowGraph = new CLabel(composite662, SWT.NONE); GridData LabelConfianzaFlowGraphLData = new GridData(); LabelConfianzaFlowGraphLData.horizontalIndent = -5; LabelConfianzaFlowGraphLData.widthHint = 40; LabelConfianzaFlowGraphLData.heightHint = 21; LabelConfianzaFlowGraph.setLayoutData(LabelConfianzaFlowGraphLData); LabelConfianzaFlowGraph.setText("Trust"); } { TextConfianzaFlowGraph = new Text(composite662, SWT.BORDER); GridData TextUmbralFlowGraphLData = new GridData(); TextUmbralFlowGraphLData.widthHint = 24; TextUmbralFlowGraphLData.heightHint = 15; TextConfianzaFlowGraph.setLayoutData(TextUmbralFlowGraphLData); TextConfianzaFlowGraph.setText("33"); } { PercentLabelFlow = new Label(composite662, SWT.NONE); GridData PercentLabelFlowLData = new GridData(); PercentLabelFlow.setLayoutData(PercentLabelFlowLData); PercentLabelFlow.setText("%"); } group0 = new Group(dialogShell, SWT.NONE); group0.setText("Sinergia Analysis"); GridLayout composite11Layout = new GridLayout(); composite11Layout.makeColumnsEqualWidth = true; composite11Layout.marginLeft = 60; composite11Layout.numColumns = 2; GridData composite11LData = new GridData(); composite11LData.horizontalAlignment = GridData.FILL; composite11LData.grabExcessHorizontalSpace = true; group0.setLayoutData(composite11LData); group0.setLayout(composite11Layout); { composite001 = new Composite(group0, SWT.NONE); GridLayout composite7Layout = new GridLayout(); GridData composite7LData = new GridData(); composite7LData.widthHint = 166; composite7LData.heightHint = 31; composite001.setLayoutData(composite7LData); composite001.setLayout(composite7Layout); composite7Layout.numColumns = 3; { LabelUmbralSinergia = new CLabel(composite001, SWT.NONE); GridData LabelUmbralSinergiaLData = new GridData(); LabelUmbralSinergiaLData.horizontalIndent = -5; LabelUmbralSinergiaLData.widthHint = 65; LabelUmbralSinergiaLData.heightHint = 21; LabelUmbralSinergia.setLayoutData(LabelUmbralSinergiaLData); LabelUmbralSinergia.setText("Threshold"); } { TextUmbralSinergia = new Text(composite001, SWT.BORDER); GridData TextUmbralSinergiaLData = new GridData(); TextUmbralSinergiaLData.widthHint = 24; TextUmbralSinergiaLData.heightHint = 15; TextUmbralSinergia.setLayoutData(TextUmbralSinergiaLData); TextUmbralSinergia.setText("50"); } { PercentLabelSinergia = new Label(composite001, SWT.NONE); GridData PercentLabelSinergiaLData = new GridData(); PercentLabelSinergia.setLayoutData(PercentLabelSinergiaLData); PercentLabelSinergia.setText("%"); } } } { composite5 = new Composite(dialogShell, SWT.NONE); GridLayout composite5Layout = new GridLayout(); composite5Layout.numColumns = 2; GridData composite5LData = new GridData(); composite5LData.horizontalAlignment = GridData.FILL; composite5LData.grabExcessHorizontalSpace = true; composite5.setLayoutData(composite5LData); composite5.setLayout(composite5Layout); { okButton = new Button(composite5, SWT.PUSH | SWT.CENTER); GridData okButtonLData = new GridData(); okButtonLData.horizontalAlignment = GridData.END; okButtonLData.grabExcessHorizontalSpace = true; okButtonLData.widthHint = 60; okButtonLData.heightHint = 33; okButton.setLayoutData(okButtonLData); okButton.setText("OK"); okButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { SinergiaAnalysis sA = new SinergiaAnalysis(javaProject); sA.assertRestricciones(getRestricciones()); // sA.calculateFacts(); // Shell shell = new Shell(); // // try { // new ProgressMonitorDialog(shell).run(true, true, // sA); // // } catch (InvocationTargetException e) { // MessageDialog.openError(shell, "Error", // e.getMessage()); // } catch (InterruptedException e) { // // TODO Auto-generated catch block // MessageDialog.openInformation(shell, "Cancelled", // e.getMessage()); // } Shell shell = new Shell(); try { sA.ejecutar(); } catch (InvocationTargetException e) { MessageDialog.openError(shell, "Error", e.getMessage()); } catch (InterruptedException e) { MessageDialog.openInformation(shell, "Cancelled", e.getMessage()); } // leer seleccion de rbol // leer los checkboxs // mandar a hacer filtrados dialogShell.dispose(); } }); } { CancelButton = new Button(composite5, SWT.PUSH | SWT.CENTER); GridData cancelButtonLData = new GridData(); cancelButtonLData.horizontalAlignment = GridData.END; cancelButtonLData.widthHint = 60; cancelButtonLData.heightHint = 33; CancelButton.setLayoutData(cancelButtonLData); CancelButton.setText("Cancelar"); CancelButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { System.out.println("okButton.widgetSelected, event=" + evt); dialogShell.dispose(); } }); } } dialogShell.layout(); dialogShell.pack(); // dialogShell.setLocation(getParent().toDisplay(100, 100)); dialogShell.open(); Display display = dialogShell.getDisplay(); while (!dialogShell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } catch (Exception e) { e.printStackTrace(); } }
From source file:astrecognition.views.ClassPickerDialog.java
License:Open Source License
private void addListeners() { Listener listener = new Listener() { public void handleEvent(Event event) { if (event.widget == ok || event.widget == table) { TableItem[] selection = table.getSelection(); if (selection == null || selection.length == 0) { MessageDialog.openError(dialog, "Invalid Package Selection", "There was no selection of package. Please select again"); return; }/*www. jav a 2 s . c om*/ if (selection[0] == null) { MessageDialog.openError(dialog, "Invalid Package Selection", "There was no selection of package. Please select again"); return; } classTree = (Tree) selection[0].getData(); } dialog.close(); } }; ok.addListener(SWT.Selection, listener); cancel.addListener(SWT.Selection, listener); table.addListener(SWT.MouseDoubleClick, listener); }
From source file:astrecognition.views.ProjectPickerDialog.java
License:Open Source License
private void addListeners() { Listener listener = new Listener() { public void handleEvent(Event event) { if (event.widget == ok || event.widget == table) { TableItem[] selection = table.getSelection(); if (selection == null || selection.length == 0) { MessageDialog.openError(dialog, "Invalid Project Selection", "There was no selection of project. Please select again"); return; }/*from www . ja va 2 s. c om*/ if (selection[0] == null) { MessageDialog.openError(dialog, "Invalid Project Selection", "There was no selection of project. Please select again"); return; } javaProject = (IJavaProject) selection[0].getData(); } dialog.close(); } }; ok.addListener(SWT.Selection, listener); cancel.addListener(SWT.Selection, listener); table.addListener(SWT.MouseDoubleClick, listener); }
From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.editors.JFXBuildConfigurationEditor.java
License:Open Source License
private String handleKeyStoreFilesystemSelection(Shell parent) { FileDialog dialog = new FileDialog(parent, SWT.OPEN); String keystore = dialog.open(); if (keystore != null) { IStatus s = validateKeyStore(new File(keystore)); if (s.isOK()) { return keystore; } else {//from w ww . ja v a2s . c om MessageDialog.openError(parent, "Not a keystore", "Looks like the selected file is not a keystore"); return handleKeyStoreFilesystemSelection(parent); } } return null; }
From source file:at.bestsolution.efxclipse.tooling.ui.handler.OpenWithFXMLHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IEvaluationContext context = (IEvaluationContext) event.getApplicationContext(); ISelection s = (ISelection) context.getVariable(ISources.ACTIVE_MENU_SELECTION_NAME); if (s instanceof IStructuredSelection) { Object o = ((IStructuredSelection) s).getFirstElement(); if (o instanceof IFile) { IFile f = (IFile) o;/*from w w w .j a v a 2 s . co m*/ String scenebuilder = InstanceScope.INSTANCE.getNode("at.bestsolution.efxclipse.tooling.ui") .get("scenebuilder.exe", null); if (scenebuilder != null) { try { String executable = scenebuilder; if (Util.isMac()) { executable += "/Contents/MacOS/scenebuilder-launcher.sh"; } Runtime.getRuntime() .exec(new String[] { executable, f.getLocation().toFile().getAbsolutePath() }); } catch (IOException e) { MessageDialog.openError(HandlerUtil.getActiveShell(event), "Launch failed", "Failed to launch SceneBuilder. The error message was: " + e.getMessage()); } } else { if (Program.findProgram(".fxml") != null) { if (!Program.launch(f.getLocation().toFile().getAbsolutePath())) { MessageDialog.openInformation(HandlerUtil.getActiveShell(event), "Unable to open file", "Opening the file with SceneBuilder failed. Try setting the absolute path to scenebuilder in your the preferences"); } } else { MessageDialog.openInformation(HandlerUtil.getActiveShell(event), "Unable to open file", "Opening the file with SceneBuilder failed. Try setting the absolute path to scenebuilder in your the preferences"); } } } } return null; }
From source file:at.bestsolution.persistence.emap.ecoregenerator.GenModelGenerateDoctrineActionDelegate.java
License:Open Source License
@Override public final void runWithEvent(final IAction action, final Event event) { if (action instanceof EditorPluginAction) { ISelection s = ((EditorPluginAction) action).getSelection(); if (s instanceof IStructuredSelection && !s.isEmpty() && ((IStructuredSelection) s).getFirstElement() instanceof GenModel) { try { GenModel genModel = (GenModel) ((IStructuredSelection) s).getFirstElement(); IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); List<IProject> emapProjects = new ArrayList<IProject>(); for (IProject p : allProjects) { if (p.isOpen() && p.getNature(Messages.GenModelGenerateDoctrineActionDelegate_5) != null && p.getNature("org.eclipse.xtext.ui.shared.xtextNature") != null) { emapProjects.add(p); }//from w ww . j ava 2 s. co m } if (emapProjects.isEmpty()) { MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.GenModelGenerateDoctrineActionDelegate_6, Messages.GenModelGenerateDoctrineActionDelegate_7); } else { GeneratorOptionsDialog dlg = new GeneratorOptionsDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), emapProjects); if (dlg.open() == IDialogConstants.OK_ID) { final IProject project = dlg.getSelectedProject(); if (!project.exists()) { project.create(new NullProgressMonitor()); } if (!project.isOpen()) { project.open(new NullProgressMonitor()); } final HashMap<EClass, EClassMetaInfo> metaInfo = new HashMap<EClass, EClassMetaInfo>(); try { IFolder srcFolder = dlg.getSelectedFolder(); for (GenPackage pack : genModel.getGenPackages()) { collectMetaPackageCode(metaInfo, project, srcFolder, srcFolder, pack); } for (GenPackage pack : genModel.getGenPackages()) { generatePackageCode(metaInfo, project, srcFolder, pack); } } finally { metaInfo.clear(); } } } } catch (CoreException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.GenModelGenerateDoctrineActionDelegate_8, Messages.GenModelGenerateDoctrineActionDelegate_9); } } else { MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.GenModelGenerateDoctrineActionDelegate_10, Messages.GenModelGenerateDoctrineActionDelegate_11); } }
From source file:at.bitandart.zoubek.mervin.handlers.SaveReview.java
License:Open Source License
@SuppressWarnings("restriction") @Execute/*from w w w. ja v a 2 s . c o m*/ public void execute(final Shell shell, final IReviewRepositoryService repoService, final @Named(IMervinContextConstants.ACTIVE_MODEL_REVIEW) ModelReview modelReview, final User reviewer) { ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(shell); try { progressMonitorDialog.run(true, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { repoService.saveReview(new URI(modelReview.getRepositoryURI()), modelReview, reviewer, monitor); } catch (RepositoryIOException e) { logger.error(e, MessageFormat.format( "IO Error while saving the review with id \"{0}\" to repository \"{1}\"", modelReview.getId(), modelReview.getRepositoryURI())); MessageDialog.openError(shell, "Repository IO Error", "An IO error occured while saving the review. Make sure the originating repository is available and writeable. See error log for details."); } catch (InvalidReviewRepositoryException e) { logger.error(e, MessageFormat.format( "Invalid review repository detected while saving the review with id \"{0}\" to repository \"{1}\"", modelReview.getId(), modelReview.getRepositoryURI())); MessageDialog.openError(shell, "Invalid Repository", "The repository URI points to an invalid repository. Make sure the originating repository is available and writeable. See error log for details."); } catch (InvalidReviewException e) { logger.error(e, MessageFormat.format( "Invalid review detected while saving the review with id \"{0}\" to repository \"{1}\"", modelReview.getId(), modelReview.getRepositoryURI())); MessageDialog.openError(shell, "Invalid Review", "The current review is invalid:\n" + e.getMessage()); } catch (URISyntaxException e) { logger.error(e, MessageFormat.format( "Invalid URI detected while saving the review with id \"{0}\" to repository \"{1}\"", modelReview.getId(), modelReview.getRepositoryURI())); MessageDialog.openError(shell, "Invalid URI", MessageFormat.format("The URI \"{0}\" is invalid. See error log for details.", modelReview.getRepositoryURI())); } } }); } catch (InvocationTargetException | InterruptedException e) { logger.error(e, MessageFormat.format("Error while saving the review with id \"{0}\" to repository \"{1}\"", modelReview.getId(), modelReview.getRepositoryURI())); MessageDialog.openError(shell, "Unexpected Error", "An unexpected error occured while saving the review. See error log for details."); } }
From source file:at.bitandart.zoubek.mervin.model.modelreview.presentation.ModelReviewModelWizard.java
License:Open Source License
/** * Do the work after everything is specified. <!-- begin-user-doc --> <!-- * end-user-doc -->//from w ww . ja v a 2s .c o m * * @generated */ @Override public boolean performFinish() { try { // Remember the file. // final IFile modelFile = getModelFile(); // Do the work within an operation. // WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { @Override protected void execute(IProgressMonitor progressMonitor) { try { // Create a resource set // ResourceSet resourceSet = new ResourceSetImpl(); // Get the URI of the model file. // URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true); // Create a resource for this file. // Resource resource = resourceSet.createResource(fileURI); // Add the initial model object to the contents. // EObject rootObject = createInitialModel(); if (rootObject != null) { resource.getContents().add(rootObject); } // Save the contents of the resource to the file system. // Map<Object, Object> options = new HashMap<Object, Object>(); options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding()); resource.save(options); } catch (Exception exception) { MervinModelReviewEditorPlugin.INSTANCE.log(exception); } finally { progressMonitor.done(); } } }; getContainer().run(false, false, operation); // Select the new file resource in the current view. // IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); IWorkbenchPage page = workbenchWindow.getActivePage(); final IWorkbenchPart activePart = page.getActivePart(); if (activePart instanceof ISetSelectionTarget) { final ISelection targetSelection = new StructuredSelection(modelFile); getShell().getDisplay().asyncExec(new Runnable() { public void run() { ((ISetSelectionTarget) activePart).selectReveal(targetSelection); } }); } // Open an editor on the new file. // try { page.openEditor(new FileEditorInput(modelFile), workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId()); } catch (PartInitException exception) { MessageDialog.openError(workbenchWindow.getShell(), MervinModelReviewEditorPlugin.INSTANCE.getString("_UI_OpenEditorError_label"), exception.getMessage()); return false; } return true; } catch (Exception exception) { MervinModelReviewEditorPlugin.INSTANCE.log(exception); return false; } }
From source file:at.bitandart.zoubek.mervin.review.wizards.LoadReviewWizard.java
License:Open Source License
@SuppressWarnings("restriction") @Override// w w w . j a v a 2s . co m public boolean performFinish() { String repositoryPath = selectRepositoryPage.getSelectedRepositoryPath(); final URI uri; final String id = gerritChangeSelectionPage.getReviewId(); try { uri = new URI(repositoryPath); } catch (URISyntaxException e) { // this should actually never happen, but to be sure: MessageDialog.openError(getShell(), "Invalid repository path", "Invalid repository path"); return false; } try { new ProgressMonitorDialog(getShell()).run(true, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { /* * TODO add reviewer selection page and let the user * choose the reviewer */ modelReview = repoService.loadReview(uri, id, reviewer, monitor); } catch (RepositoryIOException | InvalidReviewRepositoryException | InvalidReviewException e) { new InvocationTargetException(e); } } }); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); if (cause instanceof RepositoryIOException) { logger.error(cause, MessageFormat.format( "An IO error occurred while loading the review with id \"{0}\" from repository at \"{0}\".", id, uri)); MessageDialog.openError(getShell(), "IO Error", "An IO error occurred while loading the review. See the error log for details"); } else if (cause instanceof InvalidReviewRepositoryException) { MessageDialog.openError(getShell(), "Invalid repository", "The specified repository cannot be found or is not accessible. Make sure to select a valid accessible repository."); } else if (cause instanceof InvalidReviewException) { MessageDialog.openError(getShell(), "Invalid review.", "The specified review does not exist or is not accessible. Make sure to select a valid accessible review."); } else { logger.error(cause, MessageFormat .format("Unexpected error during loading the review with id {0} and uri {1}", id, uri)); MessageDialog.openError(getShell(), "Unexpected Error occured.", "Unexpected Error occured, see error log for details."); } return false; } catch (InterruptedException e) { logger.error(e, MessageFormat .format("Unexpected error during loading the review with id {0} and uri {1}", id, uri)); MessageDialog.openError(getShell(), "Unexpected Error occured.", "Unexpected Error occured, see error log for details."); return false; } return true; }