List of usage examples for java.lang.reflect InvocationTargetException InvocationTargetException
public InvocationTargetException(Throwable target)
From source file:org.talend.camel.designer.ui.wizards.actions.JavaCamelJobScriptsExportWSAction.java
private void exportAllReferenceJobs(String routeName, ProcessItem routeProcess) throws InvocationTargetException, InterruptedException { Set<String> jobPackageNames = new HashSet<String>(); for (NodeType cTalendJob : EmfModelUtils.getComponentsByName(routeProcess, "cTalendJob")) { //$NON-NLS-1$ String jobId = null;/*w w w . ja v a 2 s . com*/ String jobVersion = null; String jobContext = null; for (Object o : cTalendJob.getElementParameter()) { if (!(o instanceof ElementParameterType)) { continue; } ElementParameterType ept = (ElementParameterType) o; String eptName = ept.getName(); if ("FROM_EXTERNAL_JAR".equals(eptName) && "true".equals(ept.getValue())) { //$NON-NLS-1$ break; } if ("SELECTED_JOB_NAME:PROCESS_TYPE_PROCESS".equals(eptName)) { //$NON-NLS-1$ jobId = ept.getValue(); } else if ("SELECTED_JOB_NAME:PROCESS_TYPE_VERSION".equals(eptName)) { //$NON-NLS-1$ jobVersion = ept.getValue(); } else if ("SELECTED_JOB_NAME:PROCESS_TYPE_CONTEXT".equals(eptName)) { //$NON-NLS-1$ jobContext = ept.getValue(); } } if (jobId == null || jobVersion == null) { continue; } IRepositoryViewObject repositoryObject; Project jobProject; try { repositoryObject = getJobRepositoryNode(jobId, ERepositoryObjectType.PROCESS); jobProject = getJobProject(jobId, ERepositoryObjectType.PROCESS); } catch (PersistenceException e) { throw new InvocationTargetException(e); } if (RelationshipItemBuilder.LATEST_VERSION.equals(jobVersion)) { jobVersion = repositoryObject.getVersion(); } String jobName = repositoryObject.getProperty().getDisplayName(); String jobBundleName = routeName + "_" + jobName; String jobBundleSymbolicName = jobBundleName; String jobPackageName = getJobPackageName(jobProject, jobName, jobVersion); if (!jobPackageNames.contains(jobPackageName)) { jobPackageNames.add(jobPackageName); } Project project = ProjectManager.getInstance().getCurrentProject(); if (project != null) { String projectName = project.getLabel(); if (projectName != null && projectName.length() > 0) { jobBundleSymbolicName = projectName.toLowerCase() + '.' + jobBundleSymbolicName; } } File jobFile; try { jobFile = File.createTempFile("job", FileConstants.JAR_FILE_SUFFIX, new File(getTempDir())); // $NON-NLS-1$ addBuildArtifact(repositoryObject, "jar", jobFile); } catch (IOException e) { throw new InvocationTargetException(e); } String jobArtifactVersion = buildArtifactVersionForReferencedJob(routeProcess, jobId); String jobBundleVersion = bundleVersion; BundleModel jobModel = new BundleModel(PomIdsHelper.getJobGroupId(repositoryObject.getProperty()), jobBundleName, jobArtifactVersion, jobFile); if (featuresModel.addBundle(jobModel)) { exportRouteUsedJobBundle(repositoryObject, jobFile, jobVersion, jobBundleName, jobBundleSymbolicName, jobBundleVersion, getArtifactId(), version, jobContext); } } addJobPackageToOsgiImport(routeProcess, jobPackageNames); }
From source file:org.talend.camel.designer.ui.wizards.actions.JavaCamelJobScriptsExportWSAction.java
@SuppressWarnings("unchecked") protected final void exportAllReferenceRoutelets(String routeName, ProcessItem routeProcess, Set<String> routelets) throws InvocationTargetException, InterruptedException { for (NodeType node : (Collection<NodeType>) routeProcess.getProcess().getNode()) { if (!EmfModelUtils.isComponentActive(node)) { continue; }/*from ww w. j a v a 2 s . co m*/ final ElementParameterType routeletId = EmfModelUtils.findElementParameterByName( EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_PROCESS.getName(), node); if (null != routeletId) { final IRepositoryViewObject referencedRouteletNode; try { referencedRouteletNode = getJobRepositoryNode(routeletId.getValue(), CamelRepositoryNodeType.repositoryRouteletType); // getRouteletRepositoryNode(routeletId); } catch (PersistenceException e) { throw new InvocationTargetException(e); } final ProcessItem routeletProcess = (ProcessItem) referencedRouteletNode.getProperty().getItem(); final String className = RouteJavaScriptOSGIForESBManager.getClassName(routeletProcess); String idSuffix = "-" + routeName; if (!routelets.add(className + idSuffix)) { continue; } String routeletVersion = EmfModelUtils.findElementParameterByName( EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_VERSION.getName(), node).getValue(); if (RelationshipItemBuilder.LATEST_VERSION.equals(routeletVersion)) { routeletVersion = referencedRouteletNode.getVersion(); } final File routeletFile; try { routeletFile = File.createTempFile("routelet", FileConstants.JAR_FILE_SUFFIX, new File(getTempDir())); // $NON-NLS-1$ addBuildArtifact(referencedRouteletNode, "jar", routeletFile); } catch (IOException e) { throw new InvocationTargetException(e); } String routeletName = referencedRouteletNode.getLabel(); String routeletBundleName = routeName + "_" + routeletName; String routeletBundleSymbolicName = routeletBundleName; Project project = ProjectManager.getInstance().getCurrentProject(); if (project != null) { String projectName = project.getLabel(); if (projectName != null && projectName.length() > 0) { routeletBundleSymbolicName = projectName.toLowerCase() + '.' + routeletBundleSymbolicName; } } String routeletModelVersion = PomIdsHelper.getJobVersion(referencedRouteletNode.getProperty()); String routeletModelGroupId = PomIdsHelper.getJobGroupId(referencedRouteletNode.getProperty()); List<ProjectReference> projectReferenceList = project.getProjectReferenceList(); if (projectReferenceList.size() == 0) { routeletModelVersion = getArtifactVersion(); routeletModelGroupId = getGroupId(); } BundleModel routeletModel = new BundleModel(routeletModelGroupId, routeletBundleName, routeletModelVersion, routeletFile); if (featuresModel.addBundle(routeletModel)) { exportRouteBundle(referencedRouteletNode, routeletFile, routeletVersion, routeletBundleName, routeletBundleSymbolicName, bundleVersion, idSuffix, null, EmfModelUtils.findElementParameterByName(EParameterName.PROCESS_TYPE.getName() + ':' + EParameterName.PROCESS_TYPE_CONTEXT.getName(), node).getValue()); CamelFeatureUtil.addFeatureAndBundles(routeletProcess, featuresModel); exportAllReferenceJobs(routeName, routeletProcess); exportAllReferenceRoutelets(routeName, routeletProcess, routelets); } } } }
From source file:org.talend.componentdesigner.manager.ComponentProjectManager.java
/** * Creates a new project resource with the selected name. * <p>/*from w w w . j a v a2 s. c o m*/ * In normal usage, this method is invoked after the user has pressed Finish on the wizard; the enablement of the * Finish button implies that all controls on the pages currently contain valid values. * </p> * <p> * Note that this wizard caches the new project once it has been successfully created; subsequent invocations of * this method will answer the same project resource without attempting to create it again. * </p> * * @return the created project resource, or <code>null</code> if the project was not created */ public IProject createNewProject(String directroy, String projectName, Shell shell) { if (projDir.equals(directroy)) { return project; } final Shell currentShell = shell; // get a project handle final IProject newProjectHandle = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); if (newProjectHandle.getRawLocation() != null) { if (newProjectHandle.getRawLocation().equals(directroy)) { return newProjectHandle; } else { try { newProjectHandle.delete(false, true, null); } catch (CoreException e) { // e.printStackTrace(); org.talend.componentdesigner.exception.ExceptionHandler.process(e); } } } // final IJavaProject javaProjHandle = JavaCore.create(newProjectHandle); // get a project descriptor URI location = null; if (directroy == null || directroy.equals(PluginConstant.EMPTY_STRING)) { return null; } else { location = new File(directroy).toURI(); } IWorkspace workspace = ResourcesPlugin.getWorkspace(); final IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName()); description.setLocationURI(location); // create the new project operation IRunnableWithProgress op = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { CreateProjectOperation op = new CreateProjectOperation(description, Messages.getString("ComponentProjectManager.NewProject")); //$NON-NLS-1$ try { PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().execute(op, monitor, WorkspaceUndoUtil.getUIInfoAdapter(currentShell)); } catch (ExecutionException e) { throw new InvocationTargetException(e); } } }; // run the new project creation o`peration try { ProgressUI.popProgressDialog(op, shell); } catch (InterruptedException e) { return null; } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof ExecutionException && t.getCause() instanceof CoreException) { CoreException cause = (CoreException) t.getCause(); StatusAdapter status; if (cause.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) { status = new StatusAdapter( new Status(IStatus.WARNING, ComponentDesigenerPlugin.PLUGIN_ID, IStatus.WARNING, Messages.getString("ComponentProjectManager.WarningMsg", //$NON-NLS-1$ newProjectHandle.getName()), cause)); } else { status = new StatusAdapter(new Status(cause.getStatus().getSeverity(), ComponentDesigenerPlugin.PLUGIN_ID, cause.getStatus().getSeverity(), Messages.getString("ComponentProjectManager.CreationProblems"), cause)); //$NON-NLS-1$ } status.setProperty(StatusAdapter.TITLE_PROPERTY, Messages.getString("ComponentProjectManager.CreationProblems")); //$NON-NLS-1$ StatusManager.getManager().handle(status, StatusManager.BLOCK); } else { StatusAdapter status = new StatusAdapter( new Status(IStatus.WARNING, ComponentDesigenerPlugin.PLUGIN_ID, 0, Messages.getString("ComponentProjectManager.InternalErrorMsg", t.getMessage()), t)); //$NON-NLS-1$ status.setProperty(StatusAdapter.TITLE_PROPERTY, Messages.getString("ComponentProjectManager.CreationProblems")); //$NON-NLS-1$ StatusManager.getManager().handle(status, StatusManager.LOG | StatusManager.BLOCK); } return null; } project = newProjectHandle; return project; }
From source file:org.talend.core.repository.ui.actions.DeleteAction.java
@Override protected void doRun() { final ISelection selection = getSelection(); final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance(); final DeleteActionCache deleteActionCache = DeleteActionCache.getInstance(); deleteActionCache.setGetAlways(false); deleteActionCache.setDocRefresh(false); deleteActionCache.createRecords();//w w w . j a va 2 s . c o m final Set<ERepositoryObjectType> types = new HashSet<ERepositoryObjectType>(); final List<RepositoryNode> deletedFolder = new ArrayList<RepositoryNode>(); final IWorkspaceRunnable op = new IWorkspaceRunnable() { @Override public void run(IProgressMonitor monitor) { monitor.beginTask("Delete Running", IProgressMonitor.UNKNOWN); //$NON-NLS-1$ Object[] selections = ((IStructuredSelection) selection).toArray(); List<RepositoryNode> selectNodes = new ArrayList<RepositoryNode>(); for (Object obj : selections) { if (obj instanceof RepositoryNode) { // TDI-28549:if selectNodes contains the obj's parent,no need to add obj again if (!isContainParentNode(selectNodes, (RepositoryNode) obj)) { selectNodes.add((RepositoryNode) obj); } } } final List<ItemReferenceBean> unDeleteItems = RepositoryNodeDeleteManager.getInstance() .getUnDeleteItems(selectNodes, deleteActionCache); List<RepositoryNode> accessNodes = new ArrayList<RepositoryNode>(); for (RepositoryNode node : selectNodes) { try { accessNodes.add(node); // ADD xqliu 2012-05-24 TDQ-4831 if (sourceFileOpening(node)) { continue; } // ~ TDQ-4831 if (containParent(node, (IStructuredSelection) selection)) { continue; } if (isForbidNode(node)) { continue; } if (node.getType() == ENodeType.REPOSITORY_ELEMENT) { if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) { IESBService service = (IESBService) GlobalServiceRegister.getDefault() .getService(IESBService.class); Item repoItem = node.getObject().getProperty().getItem(); if (service != null && !repoItem.getState().isDeleted()) { final StringBuffer jobNames = service.getAllTheJObNames(node); if (jobNames != null) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { String message = jobNames.toString() + Messages .getString("DeleteAction.deleteJobAssignedToOneService"); //$NON-NLS-1$ final Shell shell = getShell(); confirmAssignDialog = MessageDialog.openQuestion(shell, "", //$NON-NLS-1$ message); } }); if (!confirmAssignDialog) { continue; } } } } if (isInDeletedFolder(deletedFolder, node.getParent())) { continue; } // TDI-22550 if (GlobalServiceRegister.getDefault() .isServiceRegistered(IDesignerCoreService.class)) { IDesignerCoreService coreService = (IDesignerCoreService) GlobalServiceRegister .getDefault().getService(IDesignerCoreService.class); IRepositoryViewObject object = node.getObject(); if (coreService != null && object != null && object.getProperty() != null) { Item item = object.getProperty().getItem(); IProcess iProcess = coreService.getProcessFromItem(item); if (iProcess != null && iProcess instanceof IProcess2) { IProcess2 process = (IProcess2) iProcess; process.removeProblems4ProcessDeleted(); } } } boolean needReturn = deleteElements(factory, deleteActionCache, node); if (node.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.JOBLET) { needToUpdataPalette = true; } if (needReturn) { // TDI-31623: Access the rest nodes in select nodes if current node's delete has pb if (accessNodes.containsAll(selectNodes)) { return; } else { continue; } } types.add(node.getObjectType()); } else if (node.getType() == ENodeType.SIMPLE_FOLDER) { if (node.getChildren().size() > 0 && !node.getObject().isDeleted()) { if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) { IESBService service = (IESBService) GlobalServiceRegister.getDefault() .getService(IESBService.class); if (service != null) { final StringBuffer jobNames = service.getAllTheJObNames(node); if (jobNames != null) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { String message = null; if (jobNames.toString().contains(",")) { //$NON-NLS-1$ message = jobNames.toString() + Messages.getString( "DeleteAction.deleteSomeJobsAssignedToServices"); //$NON-NLS-1$ } else { message = jobNames.toString() + Messages.getString( "DeleteAction.deleteJobAssignedToOneService"); //$NON-NLS-1$ } final Shell shell = getShell(); confirmAssignDialog = MessageDialog.openQuestion(shell, "", //$NON-NLS-1$ message); } }); if (!confirmAssignDialog) { continue; } } } } } types.add(node.getContentType()); // fixed for the documentation deleted if (node.getContentType() == ERepositoryObjectType.PROCESS || node.getContentType() == ERepositoryObjectType.JOBLET) { types.add(ERepositoryObjectType.DOCUMENTATION); } deletedFolder.add(node); deleteFolder(node, factory, deleteActionCache); } } catch (PersistenceException e) { MessageBoxExceptionHandler.process(e); } catch (BusinessException e) { MessageBoxExceptionHandler.process(e); } } if (unDeleteItems.size() > 0) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { ItemReferenceDialog dialog = new ItemReferenceDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), unDeleteItems); dialog.open(); } }); } try { factory.saveProject(ProjectManager.getInstance().getCurrentProject()); } catch (PersistenceException e) { ExceptionHandler.process(e); } } /** * DOC xqliu Comment method "sourceFileOpening". * * @param node * @return */ private boolean sourceFileOpening(RepositoryNode node) { boolean result = false; if (node != null) { if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) { ITDQRepositoryService service = (ITDQRepositoryService) GlobalServiceRegister.getDefault() .getService(ITDQRepositoryService.class); if (service != null) { result = service.sourceFileOpening(node); } } } return result; } }; IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { IWorkspace workspace = ResourcesPlugin.getWorkspace(); try { ISchedulingRule schedulingRule = workspace.getRoot(); // the update the project files need to be done in the workspace runnable to avoid all // notification // of changes before the end of the modifications. workspace.run(op, schedulingRule, IWorkspace.AVOID_UPDATE, monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } } }; try { PlatformUI.getWorkbench().getProgressService().run(false, false, iRunnableWithProgress); // fix for TDI-22986 , force build the .java if routine is deleted physical if (forceBuild) { IRunProcessService service = (IRunProcessService) GlobalServiceRegister.getDefault() .getService(IRunProcessService.class); service.buildJavaProject(); } } catch (Exception e) { ExceptionHandler.process(e); } synchUI(deleteActionCache); }
From source file:org.talend.dataprofiler.core.ui.action.actions.DQDeleteAction.java
/** * physical delete generating report file. * /*from w w w. ja v a 2s . c om*/ * @param repFileNode * @throws PersistenceException */ private void deleteReportFile(final ReportFileRepNode repFileNode) throws PersistenceException { @SuppressWarnings("rawtypes") RepositoryWorkUnit repositoryWorkUnit = new RepositoryWorkUnit( ProjectManager.getInstance().getCurrentProject(), "deleteReportFile") { //$NON-NLS-1$ @Override protected void run() throws LoginException, PersistenceException { final IWorkspaceRunnable op = new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) { try { IPath location = Path .fromOSString(repFileNode.getResource().getProjectRelativePath().toOSString()); IFile latestRepIFile = ResourceManager.getRootProject().getFile(location); if (latestRepIFile.isLinked()) { File file = new File(latestRepIFile.getRawLocation().toOSString()); if (file.exists()) { file.delete(); } } latestRepIFile.delete(true, null); IContainer parent = latestRepIFile.getParent(); if (parent != null) { parent.refreshLocal(IResource.DEPTH_INFINITE, monitor); } } catch (CoreException e) { log.error(e, e); } } }; IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { IWorkspace workspace = ResourcesPlugin.getWorkspace(); try { ISchedulingRule schedulingRule = workspace.getRoot(); workspace.run(op, schedulingRule, IWorkspace.AVOID_UPDATE, monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } } }; try { PlatformUI.getWorkbench().getProgressService().run(false, false, iRunnableWithProgress); } catch (InterruptedException e) { ExceptionHandler.process(e); } catch (InvocationTargetException e) { ExceptionHandler.process(e); } } }; repositoryWorkUnit.setAvoidUnloadResources(true); ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(repositoryWorkUnit); repositoryWorkUnit.throwPersistenceExceptionIfAny(); // refresh the parent RepositoryNode parent = repFileNode.getParent(); if (parent != null) { CorePlugin.getDefault().refreshDQView(parent); } }
From source file:org.talend.repository.imports.ImportItemUtil.java
private void importItemRecord(ResourcesManager manager, ItemRecord itemRecord, boolean overwrite, IPath destinationPath, final Set<String> overwriteDeletedItems, final Set<String> idDeletedBeforeImport, String contentType, final IProgressMonitor monitor) { monitor.subTask(Messages.getString("ImportItemWizardPage.Importing") + itemRecord.getItemName()); //$NON-NLS-1$ resolveItem(manager, itemRecord);/*from www .j a v a 2 s.c o m*/ int num = 0; for (Object obj : itemRecord.getResourceSet().getResources()) { if (!(obj instanceof PropertiesProjectResourceImpl)) { if (obj instanceof XMIResourceImpl) { num++; if (num > 2) {// The is no explanation for this value and what is this loop for to I increased // it to // 2 so that metadata migration for 4.1 works try { throw new InvocationTargetException(new PersistenceException( "The source file of " + itemRecord.getLabel() + " has error,Please check it!")); } catch (InvocationTargetException e) { ExceptionHandler.process(e); } return; } } } } final Item item = itemRecord.getItem(); if (item != null) { ProxyRepositoryFactory repFactory = ProxyRepositoryFactory.getInstance(); ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(item); IPath path = new Path(item.getState().getPath()); if (destinationPath != null && itemType.name().equals(contentType)) { path = destinationPath.append(path); } try { repFactory.createParentFoldersRecursively(ProjectManager.getInstance().getCurrentProject(), itemType, path, true); } catch (Exception e) { logError(e); path = new Path(""); //$NON-NLS-1$ } try { Item tmpItem = item; // delete existing items before importing, this should be done // once for a different id String id = itemRecord.getProperty().getId(); IRepositoryViewObject lastVersion = itemRecord.getExistingItemWithSameId(); if (lastVersion != null && overwrite && !itemRecord.isLocked() && (itemRecord.getState() == State.ID_EXISTED || itemRecord.getState() == State.NAME_EXISTED || itemRecord.getState() == State.NAME_AND_ID_EXISTED) && !deletedItems.contains(id)) { if (!overwriteDeletedItems.contains(id)) { // bug 10520. ERepositoryStatus status = repFactory.getStatus(lastVersion); if (status == ERepositoryStatus.DELETED) { repFactory.restoreObject(lastVersion, path); // restore first. } overwriteDeletedItems.add(id); } /* only delete when name exsit rather than id exist */ if (itemRecord.getState().equals(ItemRecord.State.NAME_EXISTED) || itemRecord.getState().equals(ItemRecord.State.NAME_AND_ID_EXISTED)) { if (!idDeletedBeforeImport.contains(id)) { // TDI-19535 (check if exists, delete all items with same id) List<IRepositoryViewObject> allVersionToDelete = repFactory.getAllVersion( ProjectManager.getInstance().getCurrentProject(), lastVersion.getId(), false); for (IRepositoryViewObject currentVersion : allVersionToDelete) { repFactory.forceDeleteObjectPhysical(lastVersion, currentVersion.getVersion()); } idDeletedBeforeImport.add(id); } } lastVersion = null; // List<IRepositoryObject> list = cache.findObjectsByItem(itemRecord); // if (!list.isEmpty()) { // // this code will delete all version of item with same // // id // repFactory.forceDeleteObjectPhysical(list.get(0)); // deletedItems.add(id); // } } User author = itemRecord.getProperty().getAuthor(); if (author != null) { if (!repFactory.setAuthorByLogin(tmpItem, author.getLogin())) { tmpItem.getProperty().setAuthor(null); // author will be // the logged // user in // create method } } if (item instanceof JobletProcessItem) { hasJoblets = true; } if (tmpItem instanceof ProcessItem && !statAndLogsSettingsReloaded && !implicitSettingsReloaded) { ProcessItem processItem = (ProcessItem) tmpItem; ParametersType paType = processItem.getProcess().getParameters(); boolean statsPSettingRemoved = false; // for commanline import project setting if (itemRecord.isRemoveProjectStatslog()) { if (paType != null) { String paramName = "STATANDLOG_USE_PROJECT_SETTINGS"; EList listParamType = paType.getElementParameter(); for (int j = 0; j < listParamType.size(); j++) { ElementParameterType pType = (ElementParameterType) listParamType.get(j); if (pType != null && paramName.equals(pType.getName())) { pType.setValue(Boolean.FALSE.toString()); statsPSettingRemoved = true; break; } } } } // 14446: item apply project setting param if use project setting String statslogUsePSetting = null; String implicitUsePSetting = null; if (paType != null) { EList listParamType = paType.getElementParameter(); for (int j = 0; j < listParamType.size(); j++) { ElementParameterType pType = (ElementParameterType) listParamType.get(j); if (pType != null) { if (!statsPSettingRemoved && "STATANDLOG_USE_PROJECT_SETTINGS".equals(pType.getName())) { statslogUsePSetting = pType.getValue(); } if ("IMPLICITCONTEXT_USE_PROJECT_SETTINGS".equals(pType.getName())) { implicitUsePSetting = pType.getValue(); } if (statsPSettingRemoved && implicitUsePSetting != null || !statsPSettingRemoved && implicitUsePSetting != null && statslogUsePSetting != null) { break; } } } } if (statslogUsePSetting != null && Boolean.parseBoolean(statslogUsePSetting) && !statAndLogsSettingsReloaded) { CorePlugin.getDefault().getDesignerCoreService().reloadParamFromProjectSettings(paType, "STATANDLOG_USE_PROJECT_SETTINGS"); statAndLogsSettingsReloaded = true; } if (implicitUsePSetting != null && Boolean.parseBoolean(implicitUsePSetting) && !implicitSettingsReloaded) { CorePlugin.getDefault().getDesignerCoreService().reloadParamFromProjectSettings(paType, "IMPLICITCONTEXT_USE_PROJECT_SETTINGS"); implicitSettingsReloaded = true; } } if (lastVersion == null || itemRecord.getState().equals(ItemRecord.State.ID_EXISTED)) { // import has not been developed to cope with migration in mind // so some model may not be able to load like the ConnectionItems // in that case items needs to be copied before migration // here we check that the loading of the item failed before calling the create method boolean isConnectionEmptyBeforeMigration = tmpItem instanceof ConnectionItem && ((ConnectionItem) tmpItem).getConnection().eResource() == null && !itemRecord.getMigrationTasksToApply().isEmpty(); repFactory.create(tmpItem, path, true); if (isConnectionEmptyBeforeMigration) {// copy the file before migration, this is bad because it // should not refer to Filesytem // but this is a quick hack and anyway the migration task only works on files // IPath itemPath = itemRecord.getPath().removeFileExtension().addFileExtension( // FileConstants.ITEM_EXTENSION); InputStream is = manager.getStream(itemRecord.getPath().removeFileExtension() .addFileExtension(FileConstants.ITEM_EXTENSION)); try { URI propertyResourceURI = EcoreUtil.getURI(((ConnectionItem) tmpItem).getProperty()); URI relativePlateformDestUri = propertyResourceURI.trimFileExtension() .appendFileExtension(FileConstants.ITEM_EXTENSION); URL fileURL = FileLocator.toFileURL(new java.net.URL( "platform:/resource" + relativePlateformDestUri.toPlatformString(true))); //$NON-NLS-1$ OutputStream os = new FileOutputStream(fileURL.getFile()); try { FileCopyUtils.copyStreams(is, os); } finally { os.close(); } } finally { is.close(); } } else { // connections from migrations (from 4.0.x or previous version) doesn't support reference or // screenshots // so no need to call this code. // It's needed to avoid to call the save method mainly just before or after the copy of the old // connection since it will copyScreenshotFile(manager, itemRecord); boolean haveRef = copyReferenceFiles(manager, tmpItem, itemRecord.getPath()); if (haveRef) { repFactory.save(tmpItem, true); } } repFactory.unloadResources(tmpItem.getProperty()); itemRecord.setImportPath(path.toPortableString()); itemRecord.setRepositoryType(itemType); itemRecord.setItemId(itemRecord.getProperty().getId()); itemRecord.setItemVersion(itemRecord.getProperty().getVersion()); itemRecord.setImported(true); cache.addToCache(tmpItem); } else if (VersionUtils.compareTo(lastVersion.getProperty().getVersion(), tmpItem.getProperty().getVersion()) < 0) { repFactory.forceCreate(tmpItem, path); itemRecord.setImportPath(path.toPortableString()); itemRecord.setItemId(itemRecord.getProperty().getId()); itemRecord.setRepositoryType(itemType); itemRecord.setItemVersion(itemRecord.getProperty().getVersion()); itemRecord.setImported(true); cache.addToCache(tmpItem); } else { PersistenceException e = new PersistenceException( Messages.getString("ImportItemUtil.persistenceException", tmpItem.getProperty())); //$NON-NLS-1$ itemRecord.addError(e.getMessage()); logError(e); } if (tmpItem != null) { RelationshipItemBuilder.getInstance().addOrUpdateItem(tmpItem, true); if (tmpItem.getState() != null) { if (itemType != null) { final Set<String> folders = restoreFolder.getFolders(itemType); if (folders != null) { for (String folderPath : folders) { if (folderPath != null && folderPath.equals(path.toString())) { FolderItem folderItem = repFactory.getFolderItem( ProjectManager.getInstance().getCurrentProject(), itemType, path); if (folderItem != null) { folderItem.getState().setDeleted(false); while (!(folderItem.getParent() instanceof Project)) { folderItem = (FolderItem) folderItem.getParent(); if (folderItem.getType() == FolderType.SYSTEM_FOLDER_LITERAL) { break; } folderItem.getState().setDeleted(false); } } break; } } } } } } } catch (Exception e) { itemRecord.addError(e.getMessage()); logError(e); } } String label = itemRecord.getLabel(); for (Resource resource : itemRecord.getResourceSet().getResources()) { // Due to the system of lazy loading for db repository of ByteArray, // it can't be unloaded just after create the item. if (!(resource instanceof ByteArrayResource)) { resource.unload(); } } TimeMeasure.step("importItemRecords", "Import item: " + label); applyMigrationTasks(itemRecord, monitor); TimeMeasure.step("importItemRecords", "applyMigrationTasks: " + label); }
From source file:org.talend.repository.imports.ImportItemWizardPage.java
public boolean performFinish() { final List<ItemRecord> itemRecords = new ArrayList<ItemRecord>(); final List<ItemRecord> checkedItemRecords = getCheckedElements(); itemRecords.addAll(checkedItemRecords); itemRecords.addAll(getHadoopSubrecords(itemRecords)); for (ItemRecord itemRecord : itemRecords) { Item item = itemRecord.getProperty().getItem(); if (item instanceof JobletProcessItem) { needToRefreshPalette = true; }/*from w w w. j a v a 2s . c om*/ IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance(); if (item.getState().isLocked()) { try { factory.unlock(item); } catch (PersistenceException e) { ExceptionHandler.process(e); } catch (LoginException e) { ExceptionHandler.process(e); } } ERepositoryStatus status = factory.getStatus(item); if (status != null && status == ERepositoryStatus.LOCK_BY_USER) { try { factory.unlock(item); } catch (PersistenceException e) { ExceptionHandler.process(e); } catch (LoginException e) { ExceptionHandler.process(e); } } } try { IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { IPath destinationPath = null; String contentType = ""; if (rNode != null && rNode.getType().equals(ENodeType.SIMPLE_FOLDER)) { destinationPath = RepositoryNodeUtilities.getPath(rNode); contentType = rNode.getContentType().name(); } repositoryUtil.setErrors(false); repositoryUtil.clear(); repositoryUtil.importItemRecords(manager, itemRecords, monitor, overwrite, destinationPath, contentType); if (repositoryUtil.hasErrors()) { throw new InvocationTargetException(new CoreException(new Status(IStatus.ERROR, FrameworkUtil.getBundle(this.getClass()).getSymbolicName(), "Import errors"))); //$NON-NLS-1$ } } }; new ProgressMonitorDialog(getShell()).run(true, true, iRunnableWithProgress); } catch (InvocationTargetException e) { Throwable targetException = e.getTargetException(); if (repositoryUtil.getRoutineExtModulesMap().isEmpty()) { if (targetException instanceof CoreException) { MessageDialog.openWarning(getShell(), Messages.getString("ImportItemWizardPage.ImportSelectedItems"), //$NON-NLS-1$ Messages.getString("ImportItemWizardPage.ErrorsOccured")); //$NON-NLS-1$ } } } catch (InterruptedException e) { // } ResourcesManager curManager = this.manager; if (curManager instanceof ProviderManager) { curManager.closeResource(); } selectedItems = null; itemRecords.clear(); return true; }
From source file:org.talend.repository.ui.actions.DeleteAction.java
@Override protected void doRun() { final ISelection selection = getSelection(); final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance(); final DeleteActionCache deleteActionCache = DeleteActionCache.getInstance(); deleteActionCache.setGetAlways(false); deleteActionCache.setDocRefresh(false); deleteActionCache.createRecords();//from w w w. j av a 2s . co m final Set<ERepositoryObjectType> types = new HashSet<ERepositoryObjectType>(); final List<RepositoryNode> deletedFolder = new ArrayList<RepositoryNode>(); final IWorkspaceRunnable op = new IWorkspaceRunnable() { public void run(IProgressMonitor monitor) { monitor.beginTask("Delete Running", IProgressMonitor.UNKNOWN); //$NON-NLS-1$ Object[] selections = ((IStructuredSelection) selection).toArray(); List<RepositoryNode> selectNodes = new ArrayList<RepositoryNode>(); for (Object obj : selections) { if (obj instanceof RepositoryNode) { selectNodes.add((RepositoryNode) obj); } } final List<ItemReferenceBean> unDeleteItems = RepositoryNodeDeleteManager.getInstance() .getUnDeleteItems(selectNodes, deleteActionCache); for (RepositoryNode node : selectNodes) { try { // ADD xqliu 2012-05-24 TDQ-4831 if (sourceFileOpening(node)) { continue; } // ~ TDQ-4831 if (containParent(node, (IStructuredSelection) selection)) { continue; } if (isForbidNode(node)) { continue; } if (node.getType() == ENodeType.REPOSITORY_ELEMENT) { if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) { IESBService service = (IESBService) GlobalServiceRegister.getDefault() .getService(IESBService.class); Item repoItem = node.getObject().getProperty().getItem(); if (service != null && !repoItem.getState().isDeleted()) { final StringBuffer jobNames = service.getAllTheJObNames(node); if (jobNames != null) { Display.getDefault().syncExec(new Runnable() { public void run() { String message = jobNames.toString() + Messages .getString("DeleteAction.deleteJobAssignedToOneService"); //$NON-NLS-1$ final Shell shell = getShell(); confirmAssignDialog = MessageDialog.openQuestion(shell, "", //$NON-NLS-1$ message); } }); if (!confirmAssignDialog) { continue; } } } } if (isInDeletedFolder(deletedFolder, node.getParent())) { continue; } boolean needReturn = deleteElements(factory, deleteActionCache, node); if (node.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.JOBLET) { needToUpdataPalette = true; } if (needReturn) { return; } types.add(node.getObjectType()); } else if (node.getType() == ENodeType.SIMPLE_FOLDER) { FolderItem folderItem = (FolderItem) node.getObject().getProperty().getItem(); if (node.getChildren().size() > 0 && !folderItem.getState().isDeleted()) { if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) { IESBService service = (IESBService) GlobalServiceRegister.getDefault() .getService(IESBService.class); if (service != null) { final StringBuffer jobNames = service.getAllTheJObNames(node); if (jobNames != null) { Display.getDefault().syncExec(new Runnable() { public void run() { String message = null; if (jobNames.toString().contains(",")) { //$NON-NLS-1$ message = jobNames.toString() + Messages.getString( "DeleteAction.deleteSomeJobsAssignedToServices"); //$NON-NLS-1$ } else { message = jobNames.toString() + Messages.getString( "DeleteAction.deleteJobAssignedToOneService"); //$NON-NLS-1$ } final Shell shell = getShell(); confirmAssignDialog = MessageDialog.openQuestion(shell, "", //$NON-NLS-1$ message); } }); if (!confirmAssignDialog) { continue; } } } } } // bug 18158 boolean isSqlTemplate = false; if (node.getObject() instanceof Folder) { // isSqlTemplate = ((Folder) node.getObject()).getContentType().equals( // ERepositoryObjectType.SQLPATTERNS); Object label = node.getProperties(EProperties.LABEL); if (ENodeType.SIMPLE_FOLDER.equals(node.getType()) && ERepositoryObjectType.SQLPATTERNS.equals(node.getContentType()) && (label.equals("Generic") || label.equals("UserDefined") //$NON-NLS-1$//$NON-NLS-2$ || label.equals("MySQL") //$NON-NLS-1$ || label.equals("Netezza") || label.equals("Oracle") //$NON-NLS-1$ //$NON-NLS-2$ || label.equals("ParAccel") || label.equals("Teradata")) //$NON-NLS-1$ //$NON-NLS-2$ || label.equals("Hive")) { //$NON-NLS-1$ isSqlTemplate = true; } } if (!isSqlTemplate) { types.add(node.getContentType()); // fixed for the documentation deleted if (node.getContentType() == ERepositoryObjectType.PROCESS || node.getContentType() == ERepositoryObjectType.JOBLET) { types.add(ERepositoryObjectType.DOCUMENTATION); } deletedFolder.add(node); deleteFolder(node, factory, deleteActionCache); } } } catch (PersistenceException e) { MessageBoxExceptionHandler.process(e); } catch (BusinessException e) { MessageBoxExceptionHandler.process(e); } } if (unDeleteItems.size() > 0) { Display.getDefault().syncExec(new Runnable() { public void run() { ItemReferenceDialog dialog = new ItemReferenceDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), unDeleteItems); dialog.open(); } }); } try { factory.saveProject(ProjectManager.getInstance().getCurrentProject()); } catch (PersistenceException e) { ExceptionHandler.process(e); } } /** * DOC xqliu Comment method "sourceFileOpening". * * @param node * @return */ private boolean sourceFileOpening(RepositoryNode node) { boolean result = false; if (node != null) { if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) { ITDQRepositoryService service = (ITDQRepositoryService) GlobalServiceRegister.getDefault() .getService(ITDQRepositoryService.class); if (service != null) { result = service.sourceFileOpening(node); } } } return result; } }; IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { IWorkspace workspace = ResourcesPlugin.getWorkspace(); try { ISchedulingRule schedulingRule = workspace.getRoot(); // the update the project files need to be done in the workspace runnable to avoid all // notification // of changes before the end of the modifications. workspace.run(op, schedulingRule, IWorkspace.AVOID_UPDATE, monitor); } catch (CoreException e) { throw new InvocationTargetException(e); } } }; try { PlatformUI.getWorkbench().getProgressService().run(false, false, iRunnableWithProgress); } catch (Exception e) { ExceptionHandler.process(e); } final boolean updatePalette = needToUpdataPalette; Display.getCurrent().syncExec(new Runnable() { public void run() { // MOD qiongli 2011-1-24,avoid to refresh repositoryView for top if (!org.talend.commons.utils.platform.PluginChecker.isOnlyTopLoaded()) { if (updatePalette && GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) { ICoreService service = (ICoreService) GlobalServiceRegister.getDefault() .getService(ICoreService.class); service.updatePalette(); } IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); for (IEditorReference editors : page.getEditorReferences()) { if (GlobalServiceRegister.getDefault().isServiceRegistered(IDiagramModelService.class)) { IDiagramModelService service = (IDiagramModelService) GlobalServiceRegister.getDefault() .getService(IDiagramModelService.class); service.refreshBusinessModel(editors); } } } deleteActionCache.revertParameters(); } }); }
From source file:org.talend.repository.ui.actions.importproject.ImportProjectsUtilities.java
/** * DOC smallet Comment method "afterImportAs". * /*from w ww . ja v a 2 s. co m*/ * @param newName * @param technicalName * @throws InvocationTargetException */ private static Project afterImportAs(String newName, String technicalName) throws InvocationTargetException { // Rename in ".project" and "talendProject" or "talend.project" // TODO SML Optimize final IWorkspace workspace = org.eclipse.core.resources.ResourcesPlugin.getWorkspace(); IContainer containers = (IProject) workspace.getRoot().findMember(new Path(technicalName)); IResource file2 = containers.findMember(IProjectDescription.DESCRIPTION_FILE_NAME); try { FilesUtils.replaceInFile("<name>.*</name>", file2.getLocation().toOSString(), //$NON-NLS-1$ "<name>" + technicalName + "</name>"); //$NON-NLS-1$ //$NON-NLS-2$ // TDI-19269 final IProject project = workspace.getRoot().getProject(technicalName); XmiResourceManager xmiManager = new XmiResourceManager(); try { final Project loadProject = xmiManager.loadProject(project); loadProject.setTechnicalLabel(technicalName); loadProject.setLabel(newName); loadProject.setLocal(true); loadProject.setId(0); loadProject.setUrl(null); loadProject.setCreationDate(null); loadProject.setDescription(""); loadProject.setType(null); // ADD xqliu 2012-03-12 TDQ-4771 clear the list of Folders if (loadProject.getFolders() != null) { loadProject.getFolders().clear(); } // ~ TDQ-4771 xmiManager.saveResource(loadProject.eResource()); return loadProject; } catch (PersistenceException e) { // } } catch (IOException e) { throw new InvocationTargetException(e); } return null; }
From source file:org.talend.repository.ui.login.LoginComposite.java
private void createTosActionArea(Composite parent) { tosActionComposite = toolkit.createComposite(parent); tosActionComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); tosActionComposite.setLayout(new FormLayout()); tosActionComposite.setBackgroundMode(SWT.INHERIT_DEFAULT); repositoryComposite.setBackground(parent.getBackground()); // tosActionComposite.setBackground(GREY_COLOR); FormData data;/*ww w . ja va2s. co m*/ // go manageProjectsButton = toolkit.createButton(tosActionComposite, null, SWT.PUSH); manageProjectsButton.setBackground(tosActionComposite.getBackground()); manageProjectsButton.setText(Messages.getString("LoginComposite.manageProjectsButton")); //$NON-NLS-1$ manageProjectsButton.setVisible(false); manageViewer = new ComboViewer(tosActionComposite, SWT.BORDER | SWT.READ_ONLY); manageViewer.setContentProvider(ArrayContentProvider.getInstance()); manageViewer.setInput(getManageElements()); manageViewer.getCombo().setVisible(false); data = new FormData(); data.top = new FormAttachment(0, HORIZONTAL_THREE_SPACE); data.right = new FormAttachment(100, -HORIZONTAL_TWO_SPACE); data.bottom = new FormAttachment(100, -HORIZONTAL_FOUR_SPACE); manageProjectsButton.setLayoutData(data); manageProjectLabel1 = toolkit.createLabel(tosActionComposite, Messages.getString("LoginComposite.actionTitle")); //$NON-NLS-1$ manageProjectLabel1.setBackground(tosActionComposite.getBackground()); data = new FormData(); comfortColumnWidth(manageProjectLabel1, data); data.left = new FormAttachment(0, HORIZONTAL_TWO_SPACE); // data.right = new FormAttachment(0, LEFTSPACE); data.bottom = new FormAttachment(manageProjectsButton, HORIZONTAL_FOUR_SPACE, SWT.CENTER); manageProjectLabel1.setLayoutData(data); manageProjectLabel1.setVisible(false); // data for managerViewer data = new FormData(); data.left = new FormAttachment(manageProjectLabel1, HORIZONTAL_SPACE); data.bottom = new FormAttachment(manageProjectLabel1, HORIZONTAL_FOUR_SPACE, SWT.CENTER); Point pbtnPoint = manageProjectsButton.computeSize(SWT.DEFAULT, SWT.DEFAULT); data.right = new FormAttachment(100, -HORIZONTAL_THREE_SPACE - pbtnPoint.x); manageViewer.getControl().setLayoutData(data); // manageProjectsButtonTemp = toolkit.createButton(tosActionComposite, null, SWT.PUSH); manageProjectsButtonTemp.setBackground(tosActionComposite.getBackground()); manageProjectsButtonTemp.setText(Messages.getString("LoginComposite.NewImport")); //$NON-NLS-1$ manageProjectsButtonTemp.setFont(font); data = new FormData(); data.top = new FormAttachment(0, HORIZONTAL_THREE_SPACE); data.right = new FormAttachment(90, -HORIZONTAL_TWO_SPACE); data.bottom = new FormAttachment(100, -HORIZONTAL_FOUR_SPACE); manageProjectsButtonTemp.setLayoutData(data); manageProjectLabel1 = toolkit.createLabel(tosActionComposite, Messages.getString("LoginComposite.selectADemoProject")); //$NON-NLS-1$ manageProjectLabel1.setFont(font); manageProjectLabel1.setBackground(tosActionComposite.getBackground()); GC gc = new GC(manageProjectLabel1); Point labelSize = gc.stringExtent(Messages.getString("LoginComposite.selectADemoProject")); //$NON-NLS-1$ gc.dispose(); data = new FormData(); data.left = new FormAttachment(10, HORIZONTAL_SPACE); data.right = new FormAttachment(10, HORIZONTAL_TWO_SPACE + labelSize.x); data.bottom = new FormAttachment(manageProjectsButtonTemp, HORIZONTAL_FOUR_SPACE, SWT.CENTER); manageProjectLabel1.setLayoutData(data); // importText = toolkit.createText(tosActionComposite, "", SWT.BORDER | SWT.READ_ONLY); // data = new FormData(); // data.left = new FormAttachment(manageProjectLabel1, 5, SWT.RIGHT); // data.bottom = new FormAttachment(manageProjectLabel1, HORIZONTAL_FOUR_SPACE, SWT.CENTER); // Point btPoint = manageProjectsButtonTemp.computeSize(SWT.DEFAULT, SWT.DEFAULT); // data.right = new FormAttachment(100, -HORIZONTAL_THREE_SPACE - btPoint.x); // importText.setLayoutData(data); importCombo = new ComboViewer(tosActionComposite, SWT.BORDER | SWT.READ_ONLY); data = new FormData(); data.left = new FormAttachment(manageProjectLabel1, 10, SWT.RIGHT); data.bottom = new FormAttachment(manageProjectLabel1, HORIZONTAL_FOUR_SPACE, SWT.CENTER); Point btPoint = manageProjectsButtonTemp.computeSize(SWT.DEFAULT, SWT.DEFAULT); data.right = new FormAttachment(100, -HORIZONTAL_THREE_SPACE - btPoint.x - 50); importCombo.getCombo().setLayoutData(data); importCombo.setContentProvider(ArrayContentProvider.getInstance()); List<DemoProjectBean> demoProjectList = ImportProjectsUtilities.getAllDemoProjects(); for (int i = 0; i < demoProjectList.size(); i++) { DemoProjectBean bean = demoProjectList.get(i); importCombo.add(bean.getProjectName()); } importCombo.setSelection(new StructuredSelection(new Object[] { importCombo.getElementAt(0) })); manageProjectsButtonTemp.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // ImportDemoProjectAction.getInstance().setShell(getShell()); // ImportDemoProjectAction.getInstance().run(); // populateProjectList(); // String newProject = ImportDemoProjectAction.getInstance().getProjectName(); // if (newProject != null) { // importText.setText(newProject); // } NewImportProjectWizard newPrjWiz = new NewImportProjectWizard(); WizardDialog newProjectDialog = new WizardDialog(getShell(), newPrjWiz); newProjectDialog.setTitle(Messages.getString("NewImportProjectWizard.windowTitle")); //$NON-NLS-1$ if (newProjectDialog.open() == Window.OK) { final String projectName = newPrjWiz.getName().trim().replace(' ', '_'); final String demoProjName = importCombo.getCombo() .getItem(importCombo.getCombo().getSelectionIndex()); // ProgressDialog progressDialog = new ProgressDialog(getShell()) { private IProgressMonitor monitorWrap; @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitorWrap = new EventLoopProgressMonitor(monitor); try { final List<DemoProjectBean> demoProjectsList = ImportProjectsUtilities .getAllDemoProjects(); DemoProjectBean demoProjectBean = null; for (DemoProjectBean demoBean : demoProjectsList) { if (demoBean.getProjectName().equals(demoProjName)) { demoProjectBean = demoBean; break; } } if (null == demoProjectBean) { throw new IOException("cannot find selected demo project"); //$NON-NLS-1$ } ImportProjectsUtilities.importDemoProject(getShell(), projectName, demoProjectBean, monitor); } catch (Exception e1) { throw new InvocationTargetException(e1); } monitorWrap.done(); } }; try { progressDialog.executeProcess(); } catch (InvocationTargetException e1) { MessageBoxExceptionHandler.process(e1.getTargetException(), getShell()); } catch (InterruptedException e1) { // Nothing to do } dialog.advanced(); } } }); }