Search in sources :

Example 91 with ProgressMonitorDialog

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

the class I18nPreferencePage method runProgressMonitorDialog.

/**
     * 
     * DOC wzhang Comment method "runProgressMonitorDialog".
     * 
     * @param validated
     */
public void runProgressMonitorDialog(final String zipFileName) {
    updateCompleted = false;
    ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(getFieldEditorParent().getShell());
    IRunnableWithProgress runnable = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) {
            try {
                //$NON-NLS-1$
                monitor.beginTask(Messages.getString("I18nPreferencePage.wait_process"), IProgressMonitor.UNKNOWN);
                applyBabiliResource(zipFileName);
            } catch (Exception e1) {
                ExceptionHandler.process(e1);
            } finally {
                monitor.done();
            }
        }
    };
    try {
        progressDialog.run(true, true, runnable);
    } catch (InvocationTargetException e1) {
        ExceptionHandler.process(e1);
    } catch (InterruptedException e1) {
        ExceptionHandler.process(e1);
    }
    if (updateCompleted) {
    } else {
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 92 with ProgressMonitorDialog

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

the class StatLogsAndImplicitcontextTreeViewPage method save.

private void save() {
    if (viewer == null) {
        return;
    }
    final IRunnableWithProgress runnable = new IRunnableWithProgress() {

        @Override
        public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            monitor.beginTask(Messages.getString("StatLogsAndImplicitcontextTreeViewPage.SaveProjectSettings"), //$NON-NLS-1$                
            (addedObjects.size() + statAddedObjects.size()) * 100);
            addContext = false;
            statsLogAddContextModel = false;
            implicitAddContextModel = false;
            Map<String, Set<String>> implicitContextVars = null;
            Map<String, Set<String>> statsLogContextVars = null;
            // if add some object to use project setting ,check context model
            if (!addedObjects.isEmpty()) {
                if (pro != null) {
                    Element implicitContextLoad = (Element) pro.getInitialContextLoad();
                    implicitContextVars = DetectContextVarsUtils.detectByPropertyType(implicitContextLoad, true);
                }
            }
            if (!statAddedObjects.isEmpty()) {
                if (pro != null) {
                    Element statsAndLog = (Element) pro.getStatsAndLog();
                    statsLogContextVars = DetectContextVarsUtils.detectByPropertyType(statsAndLog, true);
                }
            }
            // if statslog and implicit use the same connection only show add context dialog one time
            if (implicitContextVars != null && statsLogContextVars != null && !implicitContextVars.isEmpty() && !statsLogContextVars.isEmpty() && implicitContextVars.keySet().toArray()[0].equals(statsLogContextVars.keySet().toArray()[0])) {
                showAddContextDialog(implicitContextVars);
                if (addContext) {
                    statsLogAddContextModel = true;
                    implicitAddContextModel = true;
                }
            } else {
                if (implicitContextVars != null && !implicitContextVars.isEmpty()) {
                    showAddContextDialog(implicitContextVars);
                    if (addContext) {
                        implicitAddContextModel = true;
                    }
                }
                if (statsLogContextVars != null && !statsLogContextVars.isEmpty()) {
                    showAddContextDialog(statsLogContextVars);
                    if (addContext) {
                        statsLogAddContextModel = true;
                    }
                }
            }
            saveChangedNode(EParameterName.IMPLICITCONTEXT_USE_PROJECT_SETTINGS.getName(), implicitAddContextModel, implicitContextVars, monitor);
            saveChangedNode(EParameterName.STATANDLOG_USE_PROJECT_SETTINGS.getName(), statsLogAddContextModel, statsLogContextVars, monitor);
            monitor.done();
        }
    };
    final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
    try {
        dialog.run(true, true, runnable);
    } catch (InvocationTargetException e) {
        ExceptionHandler.process(e);
    } catch (InterruptedException e) {
        ExceptionHandler.process(e);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Set(java.util.Set) Element(org.talend.core.model.process.Element) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 93 with ProgressMonitorDialog

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

the class RunContainerPreferencePage method initalizeRuntime.

private boolean initalizeRuntime(String location, String host) {
    boolean finished = true;
    performApply();
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
    try {
        dialog.run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                SubMonitor totalMonitor = SubMonitor.convert(monitor, 10);
                totalMonitor.beginTask("Initializing Runtime server", 10);
                // 1. try to stop first
                totalMonitor.setTaskName("Stoping Runtime server");
                new StopRuntimeProgress().run(totalMonitor);
                if (RuntimeServerController.getInstance().getRuntimeProcess() != null && RuntimeServerController.getInstance().getRuntimeProcess().isAlive()) {
                    RuntimeServerController.getInstance().getRuntimeProcess().waitFor(20, TimeUnit.SECONDS);
                }
                totalMonitor.worked(2);
                // 2. delete data(cannot use JMX to rebootCleanAll as a DLL delete failed)
                if (monitor.isCanceled()) {
                    throw new InterruptedException("Initalize is canceled by user");
                }
                totalMonitor.setTaskName("Deleting /data folder");
                try {
                    FileUtil.deleteFolder(location + "/data");
                } catch (IOException e) {
                    ExceptionHandler.process(e);
                    throw new InterruptedException(e.getMessage());
                }
                if (new File(location + "/data").exists()) {
                    throw new InterruptedException(RunContainerMessages.getString("RunContainerPreferencePage.InitailzeDialog7"));
                }
                totalMonitor.worked(1);
                // 3. start (again)
                if (monitor.isCanceled()) {
                    throw new InterruptedException("Initalize is canceled by user");
                }
                totalMonitor.setTaskName("Starting Runtime server");
                new StartRuntimeProgress(false).run(totalMonitor);
                totalMonitor.worked(2);
                // 4. command
                if (monitor.isCanceled()) {
                    throw new InterruptedException("Initalize is canceled by user");
                }
                File launcher;
                String os = System.getProperty("os.name");
                if (os != null && os.toLowerCase().contains("windows")) {
                    launcher = new File(location + "/bin/client.bat");
                } else {
                    launcher = new File(location + "/bin/client");
                }
                InputStream stream = RunContainerPreferencePage.class.getResourceAsStream("/resources/commands");
                File initFile = new File(location + "/scripts/initlocal.sh");
                if (!initFile.exists()) {
                    try {
                        Files.copy(stream, initFile.toPath());
                    } catch (IOException e) {
                        ExceptionHandler.process(e);
                        throw new InterruptedException(e.getMessage());
                    }
                }
                // without username and password is ok
                // fixed by KARAF-5019
                String command = launcher.getAbsolutePath() + " -h " + host + " -l 1 source file:scripts/initlocal.sh";
                RuntimeClientProgress clientProgress = new RuntimeClientProgress(command);
                clientProgress.run(totalMonitor);
                totalMonitor.done();
            }
        });
    } catch (Throwable e) {
        finished = false;
        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(getShell(), RunContainerMessages.getString("RunContainerPreferencePage.InitailzeDialog2"), RunContainerMessages.getString("RunContainerPreferencePage.InitailzeDialog4"), status);
    }
    return finished;
}
Also used : StartRuntimeProgress(org.talend.designer.esb.runcontainer.ui.progress.StartRuntimeProgress) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) StopRuntimeProgress(org.talend.designer.esb.runcontainer.ui.progress.StopRuntimeProgress) IStatus(org.eclipse.core.runtime.IStatus) InputStream(java.io.InputStream) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) SubMonitor(org.eclipse.core.runtime.SubMonitor) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RuntimeClientProgress(org.talend.designer.esb.runcontainer.ui.progress.RuntimeClientProgress) File(java.io.File)

Example 94 with ProgressMonitorDialog

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

the class LoginDialog method logIn.

/**
     * DOC smallet Comment method "logIn".
     * 
     * @param project
     * @throws Exception
     */
protected boolean logIn(final Project project) {
    final ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    ConnectionBean connBean = loginComposite.getConnection();
    final boolean needRestartForLocal = loginComposite.needRestartForLocal();
    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
    PreferenceManipulator prefManipulator = new PreferenceManipulator(CorePlugin.getDefault().getPreferenceStore());
    prefManipulator.setLastProject(project.getTechnicalLabel());
    saveLastConnBean(connBean);
    // check for Talendforge
    if (PluginChecker.isExchangeSystemLoaded() && !TalendPropertiesUtil.isHideExchange()) {
        IPreferenceStore prefStore = PlatformUI.getPreferenceStore();
        boolean checkTisVersion = prefStore.getBoolean(ITalendCorePrefConstants.EXCHANGE_CHECK_TIS_VERSION);
        IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
        if (!checkTisVersion && brandingService.isPoweredbyTalend()) {
            int count = prefStore.getInt(TalendForgeDialog.LOGINCOUNT);
            if (count < 0) {
                count = 1;
            }
            ExchangeUser exchangeUser = project.getExchangeUser();
            boolean isExchangeLogon = exchangeUser.getLogin() != null && !exchangeUser.getLogin().equals("");
            boolean isUserPassRight = true;
            if (isExchangeLogon) {
                IExchangeService service = (IExchangeService) GlobalServiceRegister.getDefault().getService(IExchangeService.class);
                if (service.checkUserAndPass(exchangeUser.getUsername(), exchangeUser.getPassword()) != null) {
                    isUserPassRight = false;
                }
            }
            if (!isExchangeLogon || !isUserPassRight) {
                if ((count + 1) % 4 == 0) {
                    // if (Platform.getOS().equals(Platform.OS_LINUX)) {
                    // TalendForgeDialog tfDialog = new TalendForgeDialog(this.getShell(), project);
                    // tfDialog.open();
                    // } else {
                    Display.getDefault().asyncExec(new Runnable() {

                        @Override
                        public void run() {
                            String userEmail = null;
                            if (project.getAuthor() != null) {
                                userEmail = project.getAuthor().getLogin();
                            }
                            TalendForgeDialog tfDialog = new TalendForgeDialog(getShell(), userEmail);
                            tfDialog.setBlockOnOpen(true);
                            tfDialog.open();
                        }
                    });
                }
                prefStore.setValue(TalendForgeDialog.LOGINCOUNT, count + 1);
            }
        }
    }
    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)) {
                    LoginComposite.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) {
        e.printStackTrace();
        loginComposite.populateProjectList();
        MessageDialog.openError(getShell(), getShell().getText(), e.getMessage());
        return false;
    }
    final Shell shell = this.getShell();
    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()) {
            loginComposite.populateProjectList();
            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(), getShell());
            }
        } else {
            loginComposite.populateTOSProjectList();
            MessageBoxExceptionHandler.process(e.getTargetException(), getShell());
        }
        return false;
    } catch (InterruptedException e) {
        if (PluginChecker.isSVNProviderPluginLoaded()) {
            loginComposite.populateProjectList();
        } else {
            loginComposite.populateTOSProjectList();
        }
        return false;
    }
    return true;
}
Also used : PreferenceManipulator(org.talend.core.prefs.PreferenceManipulator) OperationCancelException(org.talend.commons.exception.OperationCancelException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ICoreTisService(org.talend.core.services.ICoreTisService) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IExchangeService(org.talend.core.service.IExchangeService) Shell(org.eclipse.swt.widgets.Shell) IRepositoryFactory(org.talend.core.repository.model.IRepositoryFactory) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IBrandingService(org.talend.core.ui.branding.IBrandingService) ExchangeUser(org.talend.core.model.properties.ExchangeUser) Point(org.eclipse.swt.graphics.Point) InvocationTargetException(java.lang.reflect.InvocationTargetException) 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) ConnectionBean(org.talend.core.model.general.ConnectionBean) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) TalendForgeDialog(org.talend.registration.wizards.register.TalendForgeDialog)

Example 95 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)

Aggregations

ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)108 InvocationTargetException (java.lang.reflect.InvocationTargetException)99 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)85 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)83 ArrayList (java.util.ArrayList)31 Display (org.eclipse.swt.widgets.Display)24 CoreException (org.eclipse.core.runtime.CoreException)21 Shell (org.eclipse.swt.widgets.Shell)18 List (java.util.List)17 PersistenceException (org.talend.commons.exception.PersistenceException)17 IFile (org.eclipse.core.resources.IFile)14 PartInitException (org.eclipse.ui.PartInitException)14 IOException (java.io.IOException)13 IStatus (org.eclipse.core.runtime.IStatus)12 File (java.io.File)10 HashMap (java.util.HashMap)10 IProject (org.eclipse.core.resources.IProject)9 SocketTask (com.cubrid.cubridmanager.core.common.socket.SocketTask)8 SQLException (java.sql.SQLException)8 Status (org.eclipse.core.runtime.Status)8