Search in sources :

Example 1 with Job

use of org.eclipse.core.runtime.jobs.Job in project tdi-studio-se by Talend.

the class ThreadDumpEditor method parseDumpFile.

/**
     * Parses the dump file.
     * 
     * @param filePath The file path
     */
private void parseDumpFile(final String filePath) {
    Job job = new Job(Messages.parseThreadDumpFileJobLabel) {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            final ThreadDumpParser parser = new ThreadDumpParser(new File(filePath), threadListElements, monitor);
            try {
                parser.parse();
            } catch (ParserConfigurationException e) {
                //$NON-NLS-1$
                return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not load thread dump file.", e);
            } catch (SAXException e) {
                //$NON-NLS-1$
                return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not load thread dump file.", e);
            } catch (IOException e) {
                //$NON-NLS-1$
                return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not load thread dump file.", e);
            }
            setProfileInfo(parser.getProfileInfo());
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    if (threadSashForm != null) {
                        threadSashForm.refresh();
                    }
                }
            });
            return Status.OK_STATUS;
        }
    };
    job.schedule();
}
Also used : ThreadDumpParser(org.talend.designer.runtime.visualization.core.dump.ThreadDumpParser) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) Job(org.eclipse.core.runtime.jobs.Job) File(java.io.File) SAXException(org.xml.sax.SAXException)

Example 2 with Job

use of org.eclipse.core.runtime.jobs.Job in project tdi-studio-se by Talend.

the class HeapDumpEditor method parseDumpFile.

/**
     * Parses the dump file.
     * 
     * @param filePath The file path
     */
private void parseDumpFile(final String filePath) {
    Job job = new Job(Messages.parseHeapDumpFileJobLabel) {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            HeapDumpParser parser = new HeapDumpParser(new File(filePath), heapListElements, monitor);
            try {
                parser.parse();
            } catch (ParserConfigurationException e) {
                //$NON-NLS-1$
                return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not load heap dump file.", e);
            } catch (SAXException e) {
                //$NON-NLS-1$
                return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not load heap dump file.", e);
            } catch (IOException e) {
                //$NON-NLS-1$
                return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not load heap dump file.", e);
            }
            setProfileInfo(parser.getProfileInfo());
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    if (heapHistogramPage != null) {
                        heapHistogramPage.refresh();
                    }
                }
            });
            return Status.OK_STATUS;
        }
    };
    job.schedule();
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) Job(org.eclipse.core.runtime.jobs.Job) HeapDumpParser(org.talend.designer.runtime.visualization.core.dump.HeapDumpParser) File(java.io.File) SAXException(org.xml.sax.SAXException)

Example 3 with Job

use of org.eclipse.core.runtime.jobs.Job in project tdi-studio-se by Talend.

the class GenericConnWizardPage method setVisible.

@Override
public void setVisible(boolean visible) {
    super.setVisible(visible);
    if (visible) {
        dynamicComposite.resetParameters();
        dynamicComposite.refresh();
        dynamicComposite.setMinHeight(dynamicComposite.getMinHeight());
        updateContextFields();
        if (getNameParameter() != null) {
            Job job = new //$NON-NLS-1$
            Job(//$NON-NLS-1$
            "") {

                @Override
                protected IStatus run(IProgressMonitor monitor) {
                    try {
                        listExistingObjects = loadRepositoryViewObjectList();
                    } catch (PersistenceException e) {
                        return new org.eclipse.core.runtime.Status(IStatus.ERROR, "org.talend.metadata.management.ui", 1, "", //$NON-NLS-1$ //$NON-NLS-2$
                        e);
                    }
                    retrieveNameFinished = true;
                    // force the refresh of the text field, no matter successfull retrieve of not.
                    Display d = DisplayUtils.getDisplay();
                    if (d != null) {
                        d.syncExec(new Runnable() {

                            @Override
                            public void run() {
                                evaluateTextField();
                            }
                        });
                    }
                    return Status.OK_STATUS;
                }
            };
            job.setUser(false);
            job.setPriority(Job.BUILD);
            // start as soon as possible
            job.schedule();
        }
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) PersistenceException(org.talend.commons.exception.PersistenceException) Status(org.eclipse.core.runtime.Status) Job(org.eclipse.core.runtime.jobs.Job) Display(org.eclipse.swt.widgets.Display)

Example 4 with Job

use of org.eclipse.core.runtime.jobs.Job in project tdi-studio-se by Talend.

the class PaletteSettingPage method okPressed.

protected void okPressed() {
    ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayUtils.getDefaultShell());
    IRunnableWithProgress rwp = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            IProxyRepositoryFactory prf = CorePlugin.getDefault().getProxyRepositoryFactory();
            try {
                prf.saveProject(project);
                ShowStandardAction.getInstance().doRun();
                if (needCodeGen) {
                    Job refreshTemplates = CorePlugin.getDefault().getCodeGeneratorService().refreshTemplates();
                    refreshTemplates.addJobChangeListener(new JobChangeAdapter() {

                        @Override
                        public void done(IJobChangeEvent event) {
                            CorePlugin.getDefault().getLibrariesService().resetModulesNeeded();
                        }
                    });
                }
            // ComponentUtilities.updatePalette();
            } catch (Exception ex) {
                ExceptionHandler.process(ex);
            }
        }
    };
    try {
        pmd.run(true, false, rwp);
    } catch (InvocationTargetException e) {
        ExceptionHandler.process(e);
    } catch (InterruptedException e) {
        ExceptionHandler.process(e);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) Job(org.eclipse.core.runtime.jobs.Job) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) InvocationTargetException(java.lang.reflect.InvocationTargetException) PersistenceException(org.talend.commons.exception.PersistenceException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 5 with Job

use of org.eclipse.core.runtime.jobs.Job in project tdi-studio-se by Talend.

the class MemoryRuntimeComposite method disconnectJVM.

private void disconnectJVM() {
    final Job disconnectJVM = new //$NON-NLS-1$
    Job(//$NON-NLS-1$
    "disconnect JVM") {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            if (isRemoteMonitoring) {
                if (currentJvm != null && currentJvm.isConnected()) {
                    currentJvm.disconnect();
                }
            }
            return Status.OK_STATUS;
        }
    };
    disconnectJVM.schedule();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Job(org.eclipse.core.runtime.jobs.Job)

Aggregations

Job (org.eclipse.core.runtime.jobs.Job)529 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)372 IStatus (org.eclipse.core.runtime.IStatus)126 CoreException (org.eclipse.core.runtime.CoreException)99 IOException (java.io.IOException)66 Status (org.eclipse.core.runtime.Status)57 File (java.io.File)50 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)45 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)44 JobChangeAdapter (org.eclipse.core.runtime.jobs.JobChangeAdapter)43 ArrayList (java.util.ArrayList)39 IFile (org.eclipse.core.resources.IFile)38 InvocationTargetException (java.lang.reflect.InvocationTargetException)35 Repository (org.eclipse.jgit.lib.Repository)30 IProject (org.eclipse.core.resources.IProject)25 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)25 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)24 Shell (org.eclipse.swt.widgets.Shell)23 UIJob (org.eclipse.ui.progress.UIJob)20 List (java.util.List)19