Search in sources :

Example 81 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project tdi-studio-se by Talend.

the class LoginHelper method logIn.

public boolean logIn(ConnectionBean connBean, final Project project) {
    final ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    final boolean needRestartForLocal = needRestartForLocal(connBean);
    if (connBean == null || project == null || project.getLabel() == null) {
        return false;
    }
    try {
        if (!project.getEmfProject().isLocal() && factory.isLocalConnectionProvider()) {
            List<IRepositoryFactory> rfList = RepositoryFactoryProvider.getAvailableRepositories();
            IRepositoryFactory remoteFactory = null;
            for (IRepositoryFactory rf : rfList) {
                if (!rf.isLocalConnectionProvider()) {
                    remoteFactory = rf;
                    break;
                }
            }
            if (remoteFactory != null) {
                factory.setRepositoryFactoryFromProvider(remoteFactory);
                factory.getRepositoryContext().setOffline(true);
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    // Save last used parameters
    prefManipulator.setLastProject(project.getTechnicalLabel());
    saveLastConnBean(connBean);
    try {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreTisService.class)) {
            final ICoreTisService service = (ICoreTisService) GlobalServiceRegister.getDefault().getService(ICoreTisService.class);
            if (service != null) {
                // if in TIS then update the bundle status according to the project type
                if (!service.validProject(project, needRestartForLocal)) {
                    isRestart = true;
                    return true;
                }
            }
        // else not in TIS so ignor caus we may not have a licence so we do not know which bundles belong to
        // DI, DQ or MDM
        }
    } catch (PersistenceException e) {
        CommonExceptionHandler.process(e);
        MessageDialog.openError(getUsableShell(), getUsableShell().getText(), e.getMessage());
        return false;
    }
    final Shell shell = getUsableShell();
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
    IRunnableWithProgress runnable = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            // monitorWrap = new EventLoopProgressMonitor(monitor);
            try {
                factory.logOnProject(project, monitor);
            } catch (LoginException e) {
                throw new InvocationTargetException(e);
            } catch (PersistenceException e) {
                throw new InvocationTargetException(e);
            } catch (OperationCanceledException e) {
                throw new InterruptedException(e.getLocalizedMessage());
            }
            monitor.done();
        }
    };
    try {
        dialog.run(true, true, runnable);
    } catch (final InvocationTargetException e) {
        // if (PluginChecker.isSVNProviderPluginLoaded()) {
        if (e.getTargetException() instanceof OperationCancelException) {
            Display.getDefault().syncExec(new Runnable() {

                @Override
                public void run() {
                    MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.getString("LoginDialog.logonCanceled"), e.getTargetException().getLocalizedMessage());
                }
            });
        } else {
            MessageBoxExceptionHandler.process(e.getTargetException(), getUsableShell());
        }
        factory.getRepositoryContext().setProject(null);
        // }
        return false;
    } catch (InterruptedException e) {
        // }
        return false;
    }
    return true;
}
Also used : IRepositoryFactory(org.talend.core.repository.model.IRepositoryFactory) OperationCancelException(org.talend.commons.exception.OperationCancelException) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ICoreTisService(org.talend.core.services.ICoreTisService) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) PersistenceException(org.talend.commons.exception.PersistenceException) LoginException(org.talend.commons.exception.LoginException)

Example 82 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project tdi-studio-se by Talend.

the class LoginProjectPage method refreshLicenseIfNeeded.

/**
     * 
     * @return if false: user cancel login
     */
private boolean refreshLicenseIfNeeded() {
    ConnectionBean conn = loginHelper.getCurrentSelectedConnBean();
    Project proj = getProject();
    if (LoginHelper.isRemoteConnection(conn)) {
        String url = getAdminURL();
        String projLabel = proj.getLabel();
        String userId = conn.getUser();
        try {
            String key = loginHelper.getLicenseMapKey(url, projLabel, userId);
            String license = loginHelper.getLicense(key);
            if (license == null || license.isEmpty()) {
                Job fetchJob = fetchLicenseJobMap.get(proj);
                if (fetchJob == null || fetchJob.getResult() != null) {
                    // if result is not null, means fetchJob has already finished but no license fetched
                    fetchJob = fetchLicense(proj);
                }
                final Job fJob = fetchJob;
                if (fJob != null) {
                    final AtomicBoolean isInterupted = new AtomicBoolean(false);
                    ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
                    dialog.run(true, true, new IRunnableWithProgress() {

                        @Override
                        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                            monitor.setTaskName(fJob.getName());
                            while (true) {
                                if (monitor.isCanceled()) {
                                    /**
                                         * If network is slow, maybe just wait the fetch job finish, but still can click
                                         * the Refresh button to cancel all fetch jobs
                                         */
                                    // fJob.cancel();
                                    isInterupted.set(true);
                                    break;
                                }
                                IStatus result = fJob.getResult();
                                if (result != null) {
                                    break;
                                }
                                try {
                                    Thread.sleep(250);
                                } catch (Exception e) {
                                // nothing to do
                                }
                            }
                        }
                    });
                    if (isInterupted.get()) {
                        return false;
                    }
                }
                license = loginHelper.getLicense(key);
            }
            if (license == null || license.isEmpty()) {
                //$NON-NLS-1$
                throw new Exception(Messages.getString("LoginProjectPage.fetchLicense.error.failed"));
            }
        // will do save in CoreTisService if needed
        // ICoreTisService tisService = (ICoreTisService) GlobalServiceRegister.getDefault()
        // .getService(ICoreTisService.class);
        // File remoteLicense = tisService.getRemoteLicenseFile();
        // tisService.storeLicenseFile(remoteLicense, license);
        } catch (Exception e) {
            //$NON-NLS-1$
            ExceptionMessageDialog.openError(//$NON-NLS-1$
            getShell(), //$NON-NLS-1$
            Messages.getString("LoginProjectPage.fetchLicense.error.title"), Messages.getString("LoginProjectPage.fetchLicense.error.msg"), //$NON-NLS-1$
            e);
            return false;
        }
    }
    return true;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SystemException(org.talend.commons.exception.SystemException) JSONException(org.talend.utils.json.JSONException) PersistenceException(org.talend.commons.exception.PersistenceException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) Project(org.talend.core.model.general.Project) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ConnectionBean(org.talend.core.model.general.ConnectionBean) Job(org.eclipse.core.runtime.jobs.Job)

Example 83 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project tdi-studio-se by Talend.

the class CreateSandboxProjectDialog method okPressed.

@Override
protected void okPressed() {
    //        boolean confirm = MessageDialog.openConfirm(getShell(), Messages.getString("CreateSandboxProjectDialog.ConfirmTitle"), //$NON-NLS-1$
    //                Messages.getString("CreateSandboxProjectDialog.ConfirmMessages")); //$NON-NLS-1$ 
    // if (!confirm) {
    // super.okPressed();
    // return;
    // }
    //
    final String url = urlText.getText();
    final String projectName = projectLabelText.getText();
    final String projectLanguage = languageCombo.getText();
    final String projectAuthor = userLoginText.getText();
    final String projectAuthorPass = userPassText.getText();
    final String projectAuthorFirstname = userFirstNameText.getText();
    final String projectAuthorLastname = userLastNameText.getText();
    // final boolean needCreateNewConn = !existedBeforeConn() || !url.trim().equals(getExistedBeforeConnURL());
    bean = new ConnectionBean();
    bean.setRepositoryId(RepositoryConstants.REPOSITORY_REMOTE_ID);
    bean.setUser(projectAuthor);
    bean.setPassword(projectAuthorPass);
    bean.setName(generateConnectionName(projectAuthor));
    bean.setDescription(bean.getName());
    bean.setWorkSpace(new Path(Platform.getInstanceLocation().getURL().getPath()).toFile().getPath());
    bean.getDynamicFields().put(RepositoryConstants.REPOSITORY_URL, url);
    bean.setComplete(true);
    // set context for url and in order to create project later.
    RepositoryContext repositoryContext = new RepositoryContext();
    // if (existedBeforeConn()) {
    // Context ctx = CorePlugin.getContext();
    // RepositoryContext oldContext = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
    // repositoryContext.setUser(oldContext.getUser());
    // repositoryContext.setClearPassword(oldContext.getClearPassword());
    // } else {
    User user = ProjectHelper.createUser(projectAuthor, projectAuthorPass, projectAuthorFirstname, projectAuthorLastname, false);
    repositoryContext.setUser(user);
    repositoryContext.setClearPassword(projectAuthorPass);
    // }
    repositoryContext.setFields(bean.getDynamicFields());
    Context ctx = CorePlugin.getContext();
    ctx.putProperty(Context.REPOSITORY_CONTEXT_KEY, repositoryContext);
    // set provider
    // if (!existedBeforeConn()) { // no connection
    ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
    repositoryFactory.setRepositoryFactoryFromProvider(RepositoryFactoryProvider.getRepositoriyById(bean.getRepositoryId()));
    // }
    //
    IRunnableWithProgress runnable = new IRunnableWithProgress() {

        @Override
        public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            Display disp = Display.getCurrent();
            if (disp == null) {
                disp = Display.getDefault();
            }
            disp.syncExec(new Runnable() {

                @Override
                public void run() {
                    //$NON-NLS-1$
                    monitor.beginTask("Creating...", IProgressMonitor.UNKNOWN);
                    Project projectInfor = ProjectHelper.createProject(projectName, projectName, projectLanguage, projectAuthor, projectAuthorPass, projectAuthorFirstname, projectAuthorLastname, false);
                    projectInfor.setSandboxProject(true);
                    boolean ok = false;
                    try {
                        User authUser = originRepCtx.getUser();
                        String authPassword = originRepCtx.getClearPassword();
                        Project createProject = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().createProject(authUser, authPassword, projectInfor);
                        ok = (createProject != null);
                    } catch (PersistenceException e) {
                        ExceptionHandler.process(e);
                        //$NON-NLS-1$
                        MessageDialog.openError(//$NON-NLS-1$
                        getShell(), //$NON-NLS-1$
                        Messages.getString("CreateSandboxProjectDialog.Failure"), //$NON-NLS-1$
                        Messages.getString("CreateSandboxProjectDialog.failureMessage") + "\n\n" + //$NON-NLS-1$
                        e.getMessage());
                    }
                    if (ok) {
                        // if not created, will don't close the dialog
                        //$NON-NLS-1$
                        String messages = Messages.getString("CreateSandboxProjectDialog.successMessage");
                        // if (needCreateNewConn) {
                        messages += //$NON-NLS-1$ 
                        "\n\n" + //$NON-NLS-1$
                        Messages.getString("CreateSandboxProjectDialog.creatingConnectionMessages", bean.getName());
                        // }
                        MessageDialog.openInformation(getShell(), Messages.getString("CreateSandboxProjectDialog.successTitile"), //$NON-NLS-1$
                        messages);
                        // if (needCreateNewConn) {
                        // save connection
                        ConnectionUserPerReader instance = ConnectionUserPerReader.getInstance();
                        List<ConnectionBean> connections = instance.forceReadConnections();
                        connections.add(bean);
                        instance.saveConnections(connections);
                        // }
                        CreateSandboxProjectDialog.super.okPressed();
                    }
                    monitor.done();
                }
            });
        }
    };
    try {
        // final ProgressMonitorJobsDialog dialog = new ProgressMonitorJobsDialog(getShell());
        final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
        dialog.run(true, false, runnable);
    } catch (InvocationTargetException e) {
        ExceptionHandler.process(e);
    } catch (InterruptedException e) {
        ExceptionHandler.process(e);
    }
}
Also used : Path(org.eclipse.core.runtime.Path) Context(org.talend.core.context.Context) RepositoryContext(org.talend.core.context.RepositoryContext) RepositoryContext(org.talend.core.context.RepositoryContext) User(org.talend.core.model.properties.User) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) Project(org.talend.core.model.general.Project) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) ConnectionUserPerReader(org.talend.repository.ui.login.connections.ConnectionUserPerReader) PersistenceException(org.talend.commons.exception.PersistenceException) ConnectionBean(org.talend.core.model.general.ConnectionBean) List(java.util.List) Display(org.eclipse.swt.widgets.Display)

Example 84 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project tdi-studio-se by Talend.

the class TOSLoginComposite method addListener.

private void addListener() {
    createButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Project project = null;
            ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
            NewProjectWizard newPrjWiz = new NewProjectWizard(null);
            WizardDialog newProjectDialog = new WizardDialog(getShell(), newPrjWiz);
            //$NON-NLS-1$
            newProjectDialog.setTitle(Messages.getString("LoginDialog.newProjectTitle"));
            if (newProjectDialog.open() == Window.OK) {
                project = newPrjWiz.getProject();
                refresh();
                ArrayList<String> allProjects = (ArrayList<String>) projectListViewer.getInput();
                int index = 0;
                Collections.sort(allProjects);
                for (int i = 0; i < allProjects.size(); i++) {
                    String projectName = allProjects.get(i);
                    if (project.getLabel().equals(projectName)) {
                        index = i;
                        break;
                    }
                }
                projectListViewer.getList().select(index);
                projectListViewer.refresh();
            }
        }
    });
    deleteButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Shell activeShell = Display.getCurrent().getActiveShell();
            SelectDeleteProjectDialog dialog = new SelectDeleteProjectDialog(activeShell, true);
            if (dialog.open() == Dialog.OK) {
                CorePlugin.getDefault().getRepositoryLocalProviderService().resetXmiResourceSet();
                java.util.List<Object> delList = dialog.getDelList();
                if (delList.size() != 0) {
                    for (Object obj : delList) {
                        if (obj instanceof IProject) {
                            IProject p = (IProject) obj;
                            if (projectsMap.containsKey(p.getName())) {
                                projectsMap.remove(p.getName());
                                String name = convertorMapper.get(p.getName());
                                if (name != null) {
                                    convertorMapper.remove(p.getName());
                                    TOSLoginComposite.this.projectListViewer.getList().remove(name);
                                }
                                if (TOSLoginComposite.this.projectListViewer.getList().getItemCount() == 0) {
                                    enableOpenAndDelete(false);
                                } else if (TOSLoginComposite.this.projectListViewer.getSelection().isEmpty()) {
                                    TOSLoginComposite.this.projectListViewer.getList().select(0);
                                }
                                try {
                                    setStatusArea();
                                } catch (PersistenceException e1) {
                                    ExceptionHandler.process(e1);
                                }
                            }
                        }
                    }
                }
            }
            refresh();
        }
    });
    importButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ImportDemoProjectAction.getInstance().setShell(getShell());
            ImportProjectAsAction.getInstance().run();
            String newProject = ImportProjectAsAction.getInstance().getProjectName();
            if (newProject != null) {
                ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
                Project[] projects = null;
                try {
                    projects = repositoryFactory.readProject();
                } catch (PersistenceException e1) {
                    e1.printStackTrace();
                } catch (BusinessException e1) {
                    e1.printStackTrace();
                }
                if (!projectsMap.containsKey(newProject.toUpperCase())) {
                    for (Project project : projects) {
                        if (project.getLabel().toUpperCase().equals(newProject.toUpperCase())) {
                            projectsMap.put(newProject.toUpperCase(), project);
                            convertorMapper.put(newProject.toUpperCase(), newProject);
                            enableOpenAndDelete(true);
                            try {
                                setStatusArea();
                            } catch (PersistenceException e1) {
                                ExceptionHandler.process(e1);
                            }
                        }
                    }
                    TOSLoginComposite.this.projectListViewer.setInput(new ArrayList(convertorMapper.values()));
                }
            }
            try {
                IRunnableWithProgress op = new IRunnableWithProgress() {

                    @Override
                    public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                        try {
                            ProxyRepositoryFactory.getInstance().initialize();
                        } catch (PersistenceException e) {
                            throw new InvocationTargetException(e);
                        }
                    }
                };
                new ProgressMonitorDialog(getShell()).run(true, false, op);
                refresh();
            } catch (InvocationTargetException e1) {
                e1.getTargetException();
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
    });
    changeButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dirDialog = new DirectoryDialog(dialog.getShell());
            String path = dirDialog.open();
            if (path == null || "".equals(path)) {
                //$NON-NLS-1$
                workspaceText.setText(getRecentWorkSpace());
                loginComposite.getConnection().setWorkSpace(getRecentWorkSpace());
            } else {
                workspaceText.setText(path);
                loginComposite.getConnection().setWorkSpace(path);
                if (!path.equals(oldPath)) {
                    oldPath = path;
                    restartBut.setVisible(true);
                    openButton.setEnabled(false);
                    deleteButton.setEnabled(false);
                    createButton.setEnabled(false);
                    importButton.setEnabled(false);
                    demoProjectButton.setEnabled(false);
                    changeButton.setEnabled(false);
                }
            }
            java.util.List<ConnectionBean> list = new ArrayList<ConnectionBean>();
            list.add(loginComposite.getConnection());
            loginComposite.storedConnections = list;
            perReader.saveConnections(loginComposite.storedConnections);
            if (!loginComposite.isWorkSpaceSame()) {
                try {
                    setStatusArea();
                } catch (PersistenceException e1) {
                    ExceptionHandler.process(e1);
                }
            }
        }
    });
    restartBut.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            LoginComposite.isRestart = true;
            ConnectionBean connection = loginComposite.getConnection();
            perReader.saveLastConnectionBean(connection);
            // update the restart command line to specify the workspace to launch
            // if relaunch, should delete the "disableLoginDialog" argument in eclipse data for bug TDI-19214
            //$NON-NLS-1$
            EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand("-data", connection.getWorkSpace(), false);
            // store the workspace in the eclipse history so that it is rememebered on next studio launch
            //$NON-NLS-1$
            ChooseWorkspaceData workspaceData = new ChooseWorkspaceData("");
            workspaceData.workspaceSelected(connection.getWorkSpace());
            workspaceData.writePersistedData();
            dialog.okPressed();
        }
    });
    openButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            loginComposite.setRepositoryContextInContext();
            if (!TOSLoginComposite.this.projectListViewer.getSelection().isEmpty()) {
                String selection = TOSLoginComposite.this.projectListViewer.getList().getSelection()[0];
                if (selection != null && !selection.equals("")) {
                    Project project = (Project) projectsMap.get(selection.toUpperCase());
                    boolean flag = dialog.logIn(project);
                    if (flag) {
                        dialog.okPressed();
                    }
                }
            }
        }
    });
    demoProjectButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ImportDemoProjectAction action = ImportDemoProjectAction.getInstance();
            action.setShell(getShell());
            action.run();
            refresh();
        }
    });
}
Also used : ImportDemoProjectAction(org.talend.repository.ui.actions.importproject.ImportDemoProjectAction) ArrayList(java.util.ArrayList) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) Shell(org.eclipse.swt.widgets.Shell) BusinessException(org.talend.commons.exception.BusinessException) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) NewProjectWizard(org.talend.repository.ui.wizards.newproject.NewProjectWizard) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) ChooseWorkspaceData(org.talend.core.ui.workspace.ChooseWorkspaceData) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IProject(org.eclipse.core.resources.IProject) InvocationTargetException(java.lang.reflect.InvocationTargetException) SelectDeleteProjectDialog(org.talend.repository.ui.actions.importproject.SelectDeleteProjectDialog) Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) PersistenceException(org.talend.commons.exception.PersistenceException) ConnectionBean(org.talend.core.model.general.ConnectionBean) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 85 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project tdi-studio-se by Talend.

the class ExportItemWizardPage method exportDependenciesSelected.

/**
     * DOC qwei Comment method "exportDependenciesSelected".
     */
private void exportDependenciesSelected() {
    final Collection<Item> selectedItems = getSelectedItems();
    // addTreeCheckedSelection();
    IRunnableWithProgress runnable = new IRunnableWithProgress() {

        @Override
        public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            //$NON-NLS-1$
            monitor.beginTask("Dependencies", 100);
            //
            final List<IRepositoryViewObject> repositoryObjects = new ArrayList<IRepositoryViewObject>();
            ProcessUtils.clearFakeProcesses();
            RepositoryNodeUtilities.checkItemDependencies(selectedItems, repositoryObjects, false, true);
            monitor.worked(60);
            for (IRepositoryViewObject repositoryObject : repositoryObjects) {
                RepositoryNode repositoryNode = RepositoryNodeUtilities.getRepositoryNode(repositoryObject, monitor);
                if (repositoryNode != null) {
                    checkedDependency.add(repositoryNode);
                } else {
                    implicitDependences.add(repositoryObject);
                }
                // check relateion ship for job -->map -->structure
                for (IExtendedRepositoryNodeHandler nodeHandler : RepositoryContentManager.getExtendedNodeHandler()) {
                    List nodesAndDependencies = nodeHandler.getRepositoryNodeAndDependencies(repositoryObject);
                    if (!nodesAndDependencies.isEmpty()) {
                        checkedDependency.addAll(nodesAndDependencies);
                    }
                }
            }
            // check relateion ship for map -->structure
            for (Item item : selectedItems) {
                for (IExtendedRepositoryNodeHandler nodeHandler : RepositoryContentManager.getExtendedNodeHandler()) {
                    List nodesAndDependencies = nodeHandler.getRepositoryNodeAndDependencies(new RepositoryObject(item.getProperty()));
                    if (!nodesAndDependencies.isEmpty()) {
                        checkedDependency.addAll(nodesAndDependencies);
                    }
                }
            }
            monitor.worked(90);
            ProcessUtils.clearFakeProcesses();
            monitor.done();
        }
    };
    // final ProgressMonitorJobsDialog dialog = new ProgressMonitorJobsDialog(getShell());
    final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
    try {
        dialog.run(true, true, runnable);
    } catch (InvocationTargetException e) {
    //
    } catch (InterruptedException e) {
    //
    }
}
Also used : MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ArrayList(java.util.ArrayList) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) Item(org.talend.core.model.properties.Item) TreeItem(org.eclipse.swt.widgets.TreeItem) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IExtendedRepositoryNodeHandler(org.talend.core.model.repository.IExtendedRepositoryNodeHandler) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)88 InvocationTargetException (java.lang.reflect.InvocationTargetException)81 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)74 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)74 ArrayList (java.util.ArrayList)27 Display (org.eclipse.swt.widgets.Display)22 CoreException (org.eclipse.core.runtime.CoreException)17 PersistenceException (org.talend.commons.exception.PersistenceException)17 List (java.util.List)15 Shell (org.eclipse.swt.widgets.Shell)12 PartInitException (org.eclipse.ui.PartInitException)12 IFile (org.eclipse.core.resources.IFile)11 SQLException (java.sql.SQLException)10 IOException (java.io.IOException)9 HashMap (java.util.HashMap)9 SocketTask (com.cubrid.cubridmanager.core.common.socket.SocketTask)8 File (java.io.File)8 Item (org.talend.core.model.properties.Item)8 IProject (org.eclipse.core.resources.IProject)7 TableItem (org.eclipse.swt.widgets.TableItem)7