Search in sources :

Example 76 with ProgressMonitorDialog

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

the class AbstractTalendEditor method doSaveAs.

@Override
public void doSaveAs() {
    SaveAsDialog dialog = new SaveAsDialog(getSite().getWorkbenchWindow().getShell());
    dialog.setOriginalFile(((IFileEditorInput) getEditorInput()).getFile());
    dialog.open();
    IPath path = dialog.getResult();
    if (path == null) {
        return;
    }
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    final IFile file = workspace.getRoot().getFile(path);
    WorkspaceModifyOperation op = new WorkspaceModifyOperation() {

        @Override
        public void execute(final IProgressMonitor monitor) throws CoreException {
            try {
                savePreviewPictures();
                getProcess().saveXmlFile();
            // file.refreshLocal(IResource.DEPTH_ONE, monitor);
            } catch (Exception e) {
                // e.printStackTrace();
                ExceptionHandler.process(e);
            }
        }
    };
    try {
        new ProgressMonitorDialog(getSite().getWorkbenchWindow().getShell()).run(false, true, op);
        // setInput(new FileEditorInput((IFile) file));
        getCommandStack().markSaveLocation();
        setDirty(false);
    } catch (Exception e) {
        // e.printStackTrace();
        ExceptionHandler.process(e);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) SaveAsDialog(org.eclipse.ui.dialogs.SaveAsDialog) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) IWorkspace(org.eclipse.core.resources.IWorkspace) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) CoreException(org.eclipse.core.runtime.CoreException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 77 with ProgressMonitorDialog

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

the class ComponentSearcher method run.

public void run() {
    final List<IRepositoryViewObject> found = new ArrayList<IRepositoryViewObject>();
    IRunnableWithProgress op = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            search(monitor, componentName, found);
        }
    };
    try {
        new ProgressMonitorDialog(shell).run(true, true, op);
    } catch (Exception e) {
    // ignore me
    }
    if (found.size() > 0) {
        Display.getDefault().syncExec(new Runnable() {

            @Override
            public void run() {
                final RepositoryReviewDialog dialog = new RepositoryReviewDialog(shell, new JobSearchResultProcessor(found), ERepositoryObjectType.PROCESS);
                if (dialog.open() == RepositoryReviewDialog.OK) {
                    RepositoryNode result = dialog.getResult();
                    openEditorOperation(result);
                }
            }
        });
    } else {
        MessageDialog.openInformation(shell, Messages.getString("ComponentSearcher.searchResult", componentName), //$NON-NLS-1$//$NON-NLS-2$
        Messages.getString("ComponentSearcher.noJobsFound"));
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) JobSearchResultProcessor(org.talend.repository.ui.dialog.JobSearchResultProcessor) RepositoryNode(org.talend.repository.model.RepositoryNode) RepositoryReviewDialog(org.talend.repository.ui.dialog.RepositoryReviewDialog) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) PersistenceException(org.talend.commons.exception.PersistenceException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 78 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 79 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 80 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)

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