public static void refresh() { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); try { ValidationView instance = (ValidationView) page.showView("views.problems"); List<ModelStatus> result = new ArrayList<>(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(UI.shell()); dialog.run(true, true, (monitor) -> { DatabaseValidation validation = DatabaseValidation.with(monitor); result.addAll(validation.evaluateAll()); }); StatusList[] model = createModel(result); instance.viewer.setInput(model); if (model.length == 0) Info.showBox(M.DatabaseValidationCompleteNoErrorsWereFound); } catch (Exception e) { log.error("Error validating database", e); } }
@Override public boolean performOk() { final MultiStatus multistatus = statusHelper .createMultiStatus("Status of importing target platform."); try { new ProgressMonitorDialog(getShell()).run(true, false, monitor -> { final IStatus status = store.save(monitor); if (!status.isOK()) { setMessage(status.getMessage(), ERROR); multistatus.merge(status); } else { updateInput(viewer, store.getLocations()); } }); } catch (final InvocationTargetException | InterruptedException exc) { multistatus.merge(statusHelper.createError("Error while building external libraries.", exc)); } if (multistatus.isOK()) return super.performOk(); else return false; }
/** * TODO merge monitor */ private void generateEMFCode(String genModelPath) throws InvocationTargetException, InterruptedException { /* * Generate model & edit */ List<URI> uris = new ArrayList<URI>(); uris.add(URI.createFileURI(genModelPath)); List<GenModel> genModels = GeneratorUIUtil.loadGenModels(new NullProgressMonitor(), uris, shell); GeneratorUIUtil.GeneratorOperation editOp = new GeneratorUIUtil.GeneratorOperation(shell); editOp.addGeneratorAndArguments(GenModelUtil.createGenerator(genModels.get(0)), genModels.get(0), "org.eclipse.emf.codegen.ecore.genmodel.generator.EditProject", "Edit"); editOp.addGeneratorAndArguments(GenModelUtil.createGenerator(genModels.get(0)), genModels.get(0), "org.eclipse.emf.codegen.ecore.genmodel.generator.ModelProject", "Model"); ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(shell); progressMonitorDialog.run(true, true, editOp); }
private IProject generateDesignProject(String occieLocation, String designName, String designProjectName, final IProgressMonitor monitor) throws CoreException, IOException { // Load the ecore file. String ecoreLocation = occieLocation.replace(".occie", ".ecore"); URI ecoreURI = URI.createFileURI(ecoreLocation); // Create a new resource set. ResourceSet resourceSet = new ResourceSetImpl(); // Load the OCCI resource. org.eclipse.emf.ecore.resource.Resource resource = resourceSet.getResource(ecoreURI, true); // Return the first element. EPackage ePackage = (EPackage) resource.getContents().get(0); String extensionScheme = Occi2Ecore.convertEcoreNamespace2OcciScheme(ePackage.getNsURI()); // Register the ePackage to avoid an error when trying to open the generated // .odesign file, EPackage.Registry.INSTANCE.put(ePackage.getNsURI(), ePackage); URI occieURI = URI.createFileURI(occieLocation); /* * Create design project */ IProject project = DesignerGeneratorUtils.genDesignProject(designProjectName, designName, extensionScheme, new ProgressMonitorDialog(shell)); /* * Create design model */ org.eclipse.cmf.occi.core.gen.design.main.Generate generator = new org.eclipse.cmf.occi.core.gen.design.main.Generate( occieURI, project.getFolder("description").getLocation().toFile(), new ArrayList<String>()); generator.doGenerate(BasicMonitor.toMonitor(monitor)); project.refreshLocal(IResource.DEPTH_INFINITE, monitor); return project; }
/** * this is called whenever a new repository location is added for example * or when user wants to refresh */ protected void refreshViewer(Object object, boolean refreshRepositoriesFolders) { if (treeViewer == null) return; if (refreshRepositoriesFolders) { IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { SVNProviderPlugin.getPlugin().getRepositories().refreshRepositoriesFolders(monitor); } }; try { new ProgressMonitorDialog(getShell()).run(true, false, runnable); } catch (Exception e) { SVNUIPlugin.openError(getShell(), null, null, e, SVNUIPlugin.LOG_TEAM_EXCEPTIONS); } } if (object == null) treeViewer.refresh(); else { if (object instanceof ISVNRemoteFolder) { ISVNRemoteFolder parent = ((ISVNRemoteFolder)object).getParent(); if (parent == null) { treeViewer.refresh(); return; } } treeViewer.refresh(object); } }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { Shell activeShell = HandlerUtil.getActiveShell(event); IRunnableWithProgress runner = ProjectSourceUtil.getRunner(); try { new ProgressMonitorDialog( activeShell ).run( true, false, runner ); } catch( InvocationTargetException | InterruptedException e ) { Throwable t = (e instanceof InvocationTargetException) ? e.getCause() : e; MessageDialog.openError( activeShell, "Error detaching sources", t.toString() ); } return null; }
/** * Attaches the sources. */ private void attachSources() { final File sourceArchive = page2.getSourceFile(); if (sourceArchive == null) { return; //nothing to do } IRunnableWithProgress runner = ProjectSourceUtil.getRunner(sourceArchive); try { new ProgressMonitorDialog( getContainer().getShell() ).run( true, false, runner ); } catch( InvocationTargetException | InterruptedException e ) { Throwable t = (e instanceof InvocationTargetException) ? e.getCause() : e; MessageDialog.openError( getShell(), "Error attaching sources", t.toString() ); } }
/** * @see org.eclipse.jface.action.Action#run() */ @Override public void run() { // 진행 모니터 다이얼로그 생성 ProgressMonitorDialog dialog = new ProgressMonitorDialog(parentShell); // 작업공간 변경 처리 생성 workspaceModifyOperation = new UMLWorkspaceModifyOperation(); try { // 진행 모니터 다이얼로그 실행 dialog.run(false, true, workspaceModifyOperation); } catch (InvocationTargetException ite) { ite.printStackTrace(); } catch (InterruptedException ie) { ie.printStackTrace(); } }
public void actionPerformed(final List<MObject> selectedElements, final IModule module) { ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getCurrent().getActiveShell()); try { progress.run(true, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor arg0) throws InvocationTargetException, InterruptedException { arg0.beginTask("Running...", IProgressMonitor.UNKNOWN); runScript(selectedElements, module); arg0.done(); } }); } catch (InvocationTargetException | InterruptedException e) { e.printStackTrace(); } }
@Override public void run() { Shell shell= JavaPlugin.getActiveWorkbenchShell(); SelectionDialog dialog= null; try { dialog= JavaUI.createTypeDialog(shell, new ProgressMonitorDialog(shell), SearchEngine.createWorkspaceScope(), IJavaElementSearchConstants.CONSIDER_ALL_TYPES, false); } catch (JavaModelException e) { String title= getDialogTitle(); String message= PackagesMessages.GotoType_error_message; ExceptionHandler.handle(e, title, message); return; } dialog.setTitle(getDialogTitle()); dialog.setMessage(PackagesMessages.GotoType_dialog_message); if (dialog.open() == IDialogConstants.CANCEL_ID) { return; } Object[] types= dialog.getResult(); if (types != null && types.length > 0) { gotoType((IType) types[0]); } }
@Override public void run() { ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); try { dialog.run(false, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { new StopRuntimeProgress().run(monitor); } }); } catch (Throwable e) { ExceptionHandler.process(e); IStatus status = new Status(IStatus.ERROR, ESBRunContainerPlugin.PLUGIN_ID, e.getMessage(), e); if (e.getCause() != null) { status = new Status(IStatus.ERROR, ESBRunContainerPlugin.PLUGIN_ID, e.getCause().getMessage(), e.getCause()); } RuntimeErrorDialog.openError(shell, RunContainerMessages.getString("RunContainerPreferencePage.InitailzeDialog6"), RunContainerMessages.getString("RunContainerPreferencePage.InitailzeDialog6"), status); } }
@Override public void run() { ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); try { dialog.run(false, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { new StartRuntimeProgress(true).run(monitor); } }); } catch (Throwable e) { ExceptionHandler.process(e); IStatus status = new Status(IStatus.ERROR, ESBRunContainerPlugin.PLUGIN_ID, e.getMessage(), e); if (e.getCause() != null) { status = new Status(IStatus.ERROR, ESBRunContainerPlugin.PLUGIN_ID, e.getCause().getMessage(), e.getCause()); } RuntimeErrorDialog.openError(shell, RunContainerMessages.getString("RunContainerPreferencePage.InitailzeDialog3"), RunContainerMessages.getString("RunContainerPreferencePage.InitailzeDialog3"), status); } }
/** * {@inheritDoc} */ @Override public void okPressed() { ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(getShell()); progressMonitorDialog.open(); progressMonitorDialog.getProgressMonitor().beginTask("connecting", IProgressMonitor.UNKNOWN); Properties serverProperties = new Properties(); serverProperties.put(Context.PROVIDER_URL, serverName.getText()); serverProperties.put(LdapImportSource.LDAP_BASE, ldapBase.getText()); this.ldapImport.setProperties(serverProperties); try { this.ldapImport.connect(); this.isInitFinished = true; progressMonitorDialog.close(); } catch (CorruptedSourceException e) { progressMonitorDialog.close(); this.isInitFinished = false; EMFStoreMessageDialog.showExceptionDialog("An exception occured", e); } this.isOkPressed = true; close(); }
/** * @see org.eclipse.jface.wizard.Wizard#performFinish() * @return a boolean which indicates, if there are items selected or not. */ @Override public boolean performFinish() { ArrayList<ImportItemWrapper> wrappedOrgUnits = ((AcUserImportPageTwo) this.getPages()[1]).getCheckedItems(); if (wrappedOrgUnits.size() > 0) { ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(getShell()); progressMonitorDialog.open(); progressMonitorDialog.getProgressMonitor().beginTask("Importing users", IProgressMonitor.UNKNOWN); importController.importOrgUnits(wrappedOrgUnits); progressMonitorDialog.close(); return true; } else { return false; } }
private void doFilter(final TmxEditorFilterBean filter) { TeActiveCellEditor.commit(); final String srcSearchStr = getSearchText(srcSearchText); final String tgtSearchStr = getSearchText(tgtSearchText); IRunnableWithProgress progress = new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { tmxDataAccess.loadDisplayTuIdentifierByFilter(monitor, filter, srcLangCode, tgtLangCode, srcSearchStr, tgtSearchStr); } }; try { new ProgressMonitorDialog(Display.getDefault().getActiveShell()).run(true, true, progress); } catch (Exception e) { e.printStackTrace(); } tmxEditorImpWithNattable.setSrcSearchStr(srcSearchStr); tmxEditorImpWithNattable.setTgtSearchStr(tgtSearchStr); tmxEditorImpWithNattable.getTable().setFocus(); tmxEditorImpWithNattable.refrush(); tmxEditorImpWithNattable.selectCell(getTgtColumnIndex(), 0); }
/** * Moves the specified source file to the specified target file. * * @param srcFile * the source file. * @param targetFile * the target file * @exception InvocationTargetException * if the run method must propagate a checked exception, it * should wrap it inside an * <code>InvocationTargetException</code>; runtime exceptions * and errors are automatically wrapped in an * <code>InvocationTargetException</code> by this method * @exception InterruptedException * if the operation detects a request to cancel, using * <code>IProgressMonitor.isCanceled()</code>, it should exit * by throwing <code>InterruptedException</code>; this method * propagates the exception */ private void moveFile( File srcFile, File targetFile ) throws InvocationTargetException, InterruptedException { if ( targetFile.exists( ) ) { if ( !MessageDialog.openQuestion( getShell( ), Messages.getString( "MoveResourceAction.Dialog.Title" ), //$NON-NLS-1$ Messages.getString( "MoveResourceAction.Dialog.Message" ) ) ) //$NON-NLS-1$ { return; } new ProgressMonitorDialog( getShell( ) ).run( true, true, createDeleteRunnable( Arrays.asList( new File[]{ targetFile } ) ) ); } new ProgressMonitorDialog( getShell( ) ).run( true, true, createRenameFileRunnable( srcFile, targetFile ) ); }
private void refreshReportProject( final IProject project ) { WorkspaceModifyOperation op = new WorkspaceModifyOperation( ) { protected void execute( IProgressMonitor monitor ) throws CoreException { project.refreshLocal( IResource.DEPTH_INFINITE, monitor ); } }; try { new ProgressMonitorDialog( composite.getShell( ) ).run( false, true, op ); } catch ( Exception e ) { ExceptionUtil.handle( e ); } }
/** * Test code below */ public static void main(String[] arg) { Shell shl = new Shell(); ProgressMonitorDialog dlg = new AsynchronousProgressMonitorDialog(shl); long l = System.currentTimeMillis(); try { dlg.run(true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Testing", 100000); for (long i = 0; i < 100000 && !monitor.isCanceled(); i++) { //monitor.worked(1); monitor.setTaskName("Task " + i); } } }); } catch (Exception e) { Log.log(e); } System.out.println("Took " + ((System.currentTimeMillis() - l))); }
private void jump() { Preconditions.checkArgument(currentRecord != null); long duration = currentRecord.getEnd() - currentRecord.getStart(); long relativeTime = scale.getSelection() * duration / scale.getMaximum(); final long time = currentRecord.getStart() + relativeTime; try { if (selectedHandler == null) { // run with progress monitor ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(scale.getShell()); progressMonitorDialog.run(false, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) { runJump(time, monitor); } }); } else { runJump(time, new NullProgressMonitor()); } } catch (Exception e) { MessageDialog.openError(scale.getShell(), "Exception", "Exception (" + e.getClass().getSimpleName() + ") during jumping in time: " + e.getMessage()); } }
@Execute public void execute( IEclipseContext context, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell, @Named(IServiceConstants.ACTIVE_PART) final MContribution contribution) throws InvocationTargetException, InterruptedException { final IEclipseContext pmContext = context.createChild(); ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell); dialog.open(); dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { pmContext.set(IProgressMonitor.class.getName(), monitor); if (contribution != null) { Object clientObject = contribution.getObject(); // ContextInjectionFactory.invoke(clientObject, Persist.class, //$NON-NLS-1$ // pmContext, null); } } }); pmContext.dispose(); }
@Execute public void execute(IProvisioningAgent agent, UISynchronize sync, IWorkbench workbench) { // update using a progress monitor final IRunnableWithProgress runnable = new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { update(agent, monitor, sync, workbench); } }; try { new ProgressMonitorDialog(null).run(true, true, runnable); } catch (InvocationTargetException | InterruptedException exc) { exc.printStackTrace(); } }
@Override public boolean performFinish() { String selectedProjectPath = wizardPage.getSelectedProjectPath(); String exampleCategory = wizardPage.getSelectedExampleCategory(); IProject project = wizardPage.getIProject(); AsposeExampleSupport asposeExampleSupport = new AsposeExampleSupport(selectedProjectPath, exampleCategory, project); try { new ProgressMonitorDialog(this.getShell()).run(true, false, asposeExampleSupport); } catch (InvocationTargetException | InterruptedException e) { e.printStackTrace(); } return true; }
private void downloadExamplesRepo() { // download code examples with status progress try { new ProgressMonitorDialog(this.getShell()).run(true, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Downloading latest example categories...", IProgressMonitor.UNKNOWN); AsposeMavenProjectManager.initialize(null); AsposeJavaAPI component = AsposeTasksJavaAPI.initialize(AsposeMavenProjectManager.getInstance()); component.checkAndUpdateRepo(); monitor.done(); } }); } catch (InvocationTargetException | InterruptedException e) { e.printStackTrace(); } }
public void run(){ System.out.println("Will add dialog:"); String filePath; String[] fileNames; FileShellFactory fileShellFactory=new FileShellFactory(); FileShell fileShell=fileShellFactory.getFileShell(FileShellFactory.ADD_FILE); if(fileShell.setFilePath(face.getShell())){ filePath=fileShell.getFilePath(); fileNames=fileShell.getFileNames(); }else{ return; } try { new ProgressMonitorDialog(null).run(false,false,new LoadMapfile(filePath,fileNames,face.getCescore().getMapControl())); face.setStatus("添加图层完成"); } catch (Exception e) { e.printStackTrace(); face.setStatus("添加图层失败"); } }
public void run() { String filePath; FileShellFactory fileShellFactory = new FileShellFactory(); FileShell fileShell = fileShellFactory .getFileShell(FileShellFactory.OPEN_FILE); if (fileShell.setFilePath(face.getShell())) { filePath = fileShell.getFilePath(); } else { return; } face.setStatus("正在加载地图..."); try { new ProgressMonitorDialog(null).run(false,false,new LoadMxdfile(filePath, face.getCescore())); face.setStatus("已加载:" + filePath); } catch (Exception e) { e.printStackTrace(); face.setStatus("加载地图失败"); } }
public void run(){ TreeItem[] selection = fftree.getSelection(); if (selection.length == 1) { TreeItem treeItem=selection[0]; FFItem ffitem=(FFItem)treeItem.getData(); { CMap map=ffitem.getCellValueCMap(); if(map!=null&&cescore!=null){ try { new ProgressMonitorDialog(null).run(false,false,new LoadGroupLayer(map,cescore)); } catch (Exception e) { MessageDialog.openError(shell,"获取单元格分值图","未能获取到分值图"); e.printStackTrace(); } } } } else { System.out.println("Multiselection"); } }
public void run(){ TreeItem[] selection = fftree.getSelection(); if (selection.length == 1) { TreeItem treeItem=selection[0]; FFItem ffitem=(FFItem)treeItem.getData(); if(ffitem instanceof BasicFactor){ // BasicFactor factor=(BasicFactor)ffitem; { // CMap map=factor.getIsolineCMap(); CMap map=ffitem.getRankMap(); if(map!=null&&cescore!=null){ try { new ProgressMonitorDialog(null).run(false,false,new LoadGroupLayer(map,cescore)); } catch (Exception e) { MessageDialog.openError(shell,"获取因素作用分值图","未能获取到分值图"); e.printStackTrace(); } } } } } else { System.out.println("Multiselection"); } }
@Override protected void okPressed(){ ProgressMonitorDialog progress = new ProgressMonitorDialog(getShell()); QueryProposalRunnable runnable = new QueryProposalRunnable(); try { progress.run(true, true, runnable); if (runnable.isCanceled()) { return; } else { proposal = runnable.getProposal(); } } catch (InvocationTargetException | InterruptedException e) { LoggerFactory.getLogger(BillingProposalWizardDialog.class) .error("Error running proposal query", e); MessageDialog.openError(getShell(), "Fehler", "Fehler beim Ausführen des Rechnungs-Vorschlags."); return; } super.okPressed(); }
public static void aquireAndRun(IPersistentObject lockPo, ILockHandler handler){ Display display = Display.getDefault(); display.syncExec(new Runnable() { @Override public void run(){ ProgressMonitorDialog progress = new ProgressMonitorDialog(display.getActiveShell()); try { progress.run(true, true, new AcquireLockRunnable(lockPo, handler)); } catch (InvocationTargetException | InterruptedException e) { logger.warn("Exception during acquire lock.", e); } } }); }
private void doCheckout(Commit commit) throws Exception { ProgressMonitorDialog dialog = new ProgressMonitorDialog(UI.shell()); dialog.run(true, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor m) throws InvocationTargetException, InterruptedException { try { FetchNotifierMonitor monitor = new FetchNotifierMonitor(m, M.CheckingOutCommit); RepositoryClient client = Database.getRepositoryClient(); client.checkout(commit.id, monitor); } catch (WebRequestException e) { throw new InvocationTargetException(e, e.getMessage()); } } }); }
@Override public boolean close() { ProgressMonitorDialog dialog = new ProgressMonitorDialog(this.getShell()); try { IRunnableWithProgress runnable = new ShutdownRunnable(); dialog.run(true, false, runnable); } catch (Throwable e) { this.error(e); return false; } return super.close(); }
@Override public void widgetSelected(final SelectionEvent e) { final MultiStatus multistatus = statusHelper.createMultiStatus("Status of installing npm dependencies."); InstallNpmDependencyDialog dialog = new InstallNpmDependencyDialog(getShell(), packageNameValidator.get(), packageVersionValidator.get()); dialog.open(); final String packageName = dialog.getPackageName(); if (!StringExtensions.isNullOrEmpty(packageName) && dialog.getReturnCode() == Window.OK) { try { final String packageVersion = dialog.getVersionConstraint(); new ProgressMonitorDialog(getShell()).run(true, false, monitor -> { multistatus .merge(installAction.apply(Collections.singletonMap(packageName, packageVersion), monitor)); }); } catch (final InvocationTargetException | InterruptedException exc) { multistatus.merge( statusHelper.createError("Error while installing npm dependency: '" + packageName + "'.", exc)); } finally { if (!multistatus.isOK()) { N4JSActivator.getInstance().getLog().log(multistatus); getDisplay().asyncExec(() -> openError( UIUtils.getShell(), "npm Install Failed", "Error while installing '" + packageName + "' npm package.\nPlease check your Error Log view for the detailed npm log about the failure.")); } } } }
@Override public void widgetSelected(final SelectionEvent e) { final MultiStatus multistatus = statusHelper.createMultiStatus("Status of uninstalling npm dependencies."); final InputDialog dialog = new InputDialog(UIUtils.getShell(), "npm Uninstall", "Specify an npm package name to uninstall:", initalValue.get(), validator.get()); dialog.open(); final String packageName = dialog.getValue(); if (!StringExtensions.isNullOrEmpty(packageName) && dialog.getReturnCode() == Window.OK) { try { new ProgressMonitorDialog(UIUtils.getShell()).run(true, false, monitor -> { multistatus.merge(uninstallAction.apply(Arrays.asList(packageName), monitor)); }); } catch (final InvocationTargetException | InterruptedException exc) { multistatus.merge( statusHelper.createError("Error while uninstalling npm dependency: '" + packageName + "'.", exc)); } finally { if (!multistatus.isOK()) { N4JSActivator.getInstance().getLog().log(multistatus); getDisplay().asyncExec(() -> openError( UIUtils.getShell(), "npm Uninstall Failed", "Error while uninstalling '" + packageName + "' npm package.\nPlease check your Error Log view for the detailed npm log about the failure.")); } } } }
/** * Creates a new default comparison of all API / implementation projects in the default workspace (i.e. the one * accessed via {@link IN4JSCore}) and shows this comparison in the widget. */ public void setComparison() { final ProgressMonitorDialog dlg = new ProgressMonitorDialog(getTree().getShell()); try { dlg.run(false, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { setComparison(monitor); } }); } catch (InvocationTargetException | InterruptedException e) { // ignore } }
private IProject generateDesignProject(String occieLocation, String designName, String designProjectName, final IProgressMonitor monitor) throws CoreException, IOException { // Load the ecore file. String ecoreLocation = occieLocation.replace(".occie", ".ecore"); URI ecoreURI = URI.createFileURI(ecoreLocation); // Create a new resource set. ResourceSet resourceSet = new ResourceSetImpl(); // Load the OCCI resource. org.eclipse.emf.ecore.resource.Resource resource = resourceSet.getResource(ecoreURI, true); // Return the first element. EPackage ePackage = (EPackage) resource.getContents().get(0); String extensionScheme = Occi2Ecore.convertEcoreNamespace2OcciScheme(ePackage.getNsURI()); // Register the ePackage to avoid an error when trying to open the generated // .odesign file, EPackage.Registry.INSTANCE.put(ePackage.getNsURI(), ePackage); URI occieURI = URI.createFileURI(occieLocation); /* * Create design project */ IProject project = DesignerGeneratorUtils.genDesignProject(designProjectName, designName, extensionScheme, new ProgressMonitorDialog(shell)); /* * Create design model */ org.eclipse.cmf.occi.core.gen.design.extended.main.Generate generator = new org.eclipse.cmf.occi.core.gen.design.extended.main.Generate( occieURI, project.getFolder("description").getLocation().toFile(), new ArrayList<String>()); generator.doGenerate(BasicMonitor.toMonitor(monitor)); project.refreshLocal(IResource.DEPTH_INFINITE, monitor); return project; }
@Override public void cancellableChanged(final boolean isCancellable) { if (runnableContext instanceof ProgressMonitorDialog) { ((ProgressMonitorDialog) runnableContext).setCancelable(isCancellable); } else if (runnableContext instanceof DeferredProgressMonitorDialogContext) { ((DeferredProgressMonitorDialogContext) runnableContext).setCancelable(isCancellable); } }
private void refreshRepositoriesFolders() { IRunnableWithProgress runnable = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { SVNProviderPlugin.getPlugin().getRepositories().refreshRepositoriesFolders(monitor); needsRefresh = false; } }; try { new ProgressMonitorDialog(getShell()).run(true, false, runnable); } catch (Exception e) { SVNUIPlugin.openError(getShell(), null, null, e, SVNUIPlugin.LOG_TEAM_EXCEPTIONS); } }