Search in sources :

Example 51 with IProgressMonitor

use of org.eclipse.core.runtime.IProgressMonitor 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 52 with IProgressMonitor

use of org.eclipse.core.runtime.IProgressMonitor 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 53 with IProgressMonitor

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

the class ImportItemWizardPage method updateItemsList.

public void updateItemsList(final String path, boolean isneedUpdate) {
    if (!isneedUpdate) {
        if (path.equals(lastPath)) {
            return;
        }
    }
    lastPath = path;
    if (path == null || path.length() == 0) {
        selectedItems = new ArrayList<ItemRecord>();
        checkTreeViewer.refresh(true);
        // get the top item to check if tree is empty, if not then uncheck everything
        TreeItem topItem = checkTreeViewer.getTree().getTopItem();
        if (topItem != null) {
            checkTreeViewer.setSubtreeChecked(topItem.getData(), false);
        }
        // else not root element, tree is already empty
        checkValidItems();
        return;
    }
    final boolean dirSelected = this.itemFromDirectoryRadio.getSelection();
    try {
        getContainer().run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) {
                // monitor.beginTask(DataTransferMessages.WizardProjectsImportPage_SearchingMessage, 100);
                //$NON-NLS-1$
                monitor.beginTask(Messages.getString("DataTransferMessages.WizardProjectsImportPage_SearchingMessage"), 100);
                File directory = new File(path);
                monitor.worked(10);
                if (!dirSelected && ArchiveFileManipulations.isTarFile(path)) {
                    sourceTarFile = getSpecifiedTarSourceFile(path);
                    if (sourceTarFile == null) {
                        return;
                    }
                    TarLeveledStructureProvider provider = new TarLeveledStructureProvider(sourceTarFile);
                    manager = ResourcesManagerFactory.getInstance().createResourcesManager(provider);
                    if (!manager.collectPath2Object(provider.getRoot())) {
                        return;
                    }
                } else if (!dirSelected && ArchiveFileManipulations.isZipFile(path)) {
                    sourceFile = getSpecifiedZipSourceFile(path);
                    if (sourceFile == null) {
                        return;
                    }
                    ZipLeveledStructureProvider provider = new ZipLeveledStructureProvider(sourceFile);
                    manager = ResourcesManagerFactory.getInstance().createResourcesManager(provider);
                    if (!manager.collectPath2Object(provider.getRoot())) {
                        return;
                    }
                } else if (dirSelected && directory.isDirectory()) {
                    manager = ResourcesManagerFactory.getInstance().createResourcesManager();
                    if (!manager.collectPath2Object(directory)) {
                        return;
                    }
                } else {
                    monitor.worked(60);
                }
                monitor.done();
            }
        });
    } catch (InvocationTargetException e) {
        IDEWorkbenchPlugin.log(e.getMessage(), e);
    } catch (InterruptedException e) {
    // Nothing to do if the user interrupts.
    }
    populateItems();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TarLeveledStructureProvider(org.eclipse.ui.internal.wizards.datatransfer.TarLeveledStructureProvider) TreeItem(org.eclipse.swt.widgets.TreeItem) ZipLeveledStructureProvider(org.eclipse.ui.internal.wizards.datatransfer.ZipLeveledStructureProvider) ZipFile(java.util.zip.ZipFile) TarFile(org.eclipse.ui.internal.wizards.datatransfer.TarFile) File(java.io.File) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 54 with IProgressMonitor

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

the class ImportItemWizardPage method performFinish.

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;
        }
        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(), //$NON-NLS-1$
                    "Import errors")));
                }
            }
        };
        new ProgressMonitorDialog(getShell()).run(true, true, iRunnableWithProgress);
    } catch (InvocationTargetException e) {
        Throwable targetException = e.getTargetException();
        if (repositoryUtil.getRoutineExtModulesMap().isEmpty()) {
            if (targetException instanceof CoreException) {
                //$NON-NLS-1$
                MessageDialog.openWarning(//$NON-NLS-1$
                getShell(), //$NON-NLS-1$
                Messages.getString("ImportItemWizardPage.ImportSelectedItems"), //$NON-NLS-1$
                Messages.getString("ImportItemWizardPage.ErrorsOccured"));
            }
        }
    } catch (InterruptedException e) {
    //
    }
    ResourcesManager curManager = this.manager;
    if (curManager instanceof ProviderManager) {
        curManager.closeResource();
    }
    selectedItems = null;
    itemRecords.clear();
    return true;
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) IPath(org.eclipse.core.runtime.IPath) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ArrayList(java.util.ArrayList) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) JobletDocumentationItem(org.talend.core.model.properties.JobletDocumentationItem) JobDocumentationItem(org.talend.core.model.properties.JobDocumentationItem) Item(org.talend.core.model.properties.Item) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) TreeItem(org.eclipse.swt.widgets.TreeItem) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) CoreException(org.eclipse.core.runtime.CoreException) PersistenceException(org.talend.commons.exception.PersistenceException) LoginException(org.talend.commons.exception.LoginException) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 55 with IProgressMonitor

use of org.eclipse.core.runtime.IProgressMonitor 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)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)530 InvocationTargetException (java.lang.reflect.InvocationTargetException)181 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)162 CoreException (org.eclipse.core.runtime.CoreException)134 Job (org.eclipse.core.runtime.jobs.Job)133 IStatus (org.eclipse.core.runtime.IStatus)110 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)83 Status (org.eclipse.core.runtime.Status)81 ArrayList (java.util.ArrayList)80 IOException (java.io.IOException)69 IFile (org.eclipse.core.resources.IFile)60 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)58 File (java.io.File)56 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)54 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)50 ITask (com.cubrid.common.core.task.ITask)49 IProject (org.eclipse.core.resources.IProject)43 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)37 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)37 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)37