Search in sources :

Example 61 with IProgressMonitor

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

Example 62 with IProgressMonitor

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

the class FTPWizard method performFinish.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.wizard.IWizard#performFinish()
     */
@Override
public boolean performFinish() {
    final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    try {
        if (creation) {
            String nextId = factory.getNextId();
            connectionProperty.setId(nextId);
            factory.create(connectionItem, propertiesWizardPage.getDestinationPath());
        } else {
            RepositoryUpdateManager.updateFileConnection(connectionItem);
            boolean isModified = propertiesWizardPage.isNameModifiedByUser();
            if (isModified) {
                if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
                    IDesignerCoreService service = (IDesignerCoreService) GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
                    if (service != null) {
                        service.refreshComponentView(connectionItem);
                    }
                }
            }
            IWorkspace workspace = ResourcesPlugin.getWorkspace();
            IWorkspaceRunnable operation = new IWorkspaceRunnable() {

                public void run(IProgressMonitor monitor) throws CoreException {
                    try {
                        factory.save(connectionItem);
                        closeLockStrategy();
                    } catch (PersistenceException e) {
                        throw new CoreException(new Status(IStatus.ERROR, "", "", e));
                    }
                }
            };
            workspace.run(operation, null);
        }
    } catch (Exception e) {
        String detailError = e.toString();
        new //$NON-NLS-1$
        ErrorDialogWidthDetailArea(//$NON-NLS-1$
        getShell(), //$NON-NLS-1$
        PID, //$NON-NLS-1$
        "", detailError);
        return false;
    }
    return true;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IWorkspace(org.eclipse.core.resources.IWorkspace) PersistenceException(org.talend.commons.exception.PersistenceException) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) CoreException(org.eclipse.core.runtime.CoreException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 63 with IProgressMonitor

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

the class ImportDemoProjectItemsPage method populateExistItemRecords.

private String populateExistItemRecords(final List<ResourcesManager> manager) {
    //$NON-NLS-1$
    String messageInfo = "";
    final Collection<ImportItem> items = new ArrayList<ImportItem>();
    IRunnableWithProgress op = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            try {
                for (ResourcesManager rm : manager) {
                    items.addAll(importManager.populateImportingItems(rm, true, monitor));
                }
            } catch (Exception e) {
                ExceptionHandler.process(e);
            }
        }
    };
    try {
        new ProgressMonitorDialog(getShell()).run(true, true, op);
    } catch (Exception e) {
    // ignore me
    }
    for (ImportItem itemRecord : items) {
        if (itemRecord.getExistingItemWithSameId() != null && itemRecord.getExistingItemWithSameId() instanceof RepositoryViewObject) {
            RepositoryViewObject reObject = (RepositoryViewObject) itemRecord.getExistingItemWithSameId();
            if (itemRecord.getProperty() != null && reObject != null) {
                if (!itemRecord.getProperty().getId().equals(reObject.getId()) && itemRecord.getProperty().getLabel().equalsIgnoreCase(reObject.getLabel())) {
                    messageInfo = Messages.getString("ImportDemoProjectPage.loseItems", reObject.getLabel());
                }
                if (itemRecord.getProperty().getId().equals(reObject.getId()) && itemRecord.getProperty().getLabel().equals(reObject.getLabel())) {
                    messageInfo = Messages.getString("ImportDemoProjectPage.overwriteItems");
                }
            }
        }
    }
    return messageInfo;
}
Also used : ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ArrayList(java.util.ArrayList) ResourcesManager(org.talend.repository.items.importexport.manager.ResourcesManager) ZipException(java.util.zip.ZipException) FileNotFoundException(java.io.FileNotFoundException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TarException(org.eclipse.ui.internal.wizards.datatransfer.TarException) IOException(java.io.IOException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 64 with IProgressMonitor

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

the class LoginProjectPage method createFetchLicenseJob.

private Job createFetchLicenseJob(Project proj) {
    final String projLabel = proj.getLabel();
    Job fetchJob = new //$NON-NLS-1$
    Job(//$NON-NLS-1$
    Messages.getString("LoginProjectPage.fetchLicense.job", proj.getLabel())) {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            ConnectionBean cBean = loginHelper.getCurrentSelectedConnBean();
            try {
                String userId = cBean.getUser();
                String url = getAdminURL();
                JSONObject jsonObj = getRemoteService().getLicenseKey(userId, cBean.getPassword(), url, projLabel);
                //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                String fetchedLicense = jsonObj.getString("customerName") + "_" + jsonObj.getString("licenseKey");
                String key = loginHelper.getLicenseMapKey(url, projLabel, userId);
                loginHelper.putLicense(key, fetchedLicense);
            } catch (Exception e) {
                ExceptionHandler.process(e);
            }
            return Status.OK_STATUS;
        }

        @Override
        protected void canceling() {
            Thread thread = this.getThread();
            try {
                // to interrupt the slow network connection
                thread.interrupt();
            } catch (Exception e) {
                ExceptionHandler.process(e);
            }
        }
    };
    fetchLicenseJobMap.put(proj, fetchJob);
    return fetchJob;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) JSONObject(org.talend.utils.json.JSONObject) ConnectionBean(org.talend.core.model.general.ConnectionBean) Job(org.eclipse.core.runtime.jobs.Job) InvocationTargetException(java.lang.reflect.InvocationTargetException) SystemException(org.talend.commons.exception.SystemException) JSONException(org.talend.utils.json.JSONException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 65 with IProgressMonitor

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

the class BuildJobHandler method build.

@Override
public void build(IProgressMonitor monitor) throws Exception {
    final IWorkspaceRunnable runnable = new IWorkspaceRunnable() {

        @Override
        public void run(IProgressMonitor monitor) throws CoreException {
            try {
                buildDelegate(monitor);
            } catch (Exception e) {
                ExceptionHandler.process(e);
            }
        }
    };
    try {
        IWorkspace workspace = ResourcesPlugin.getWorkspace();
        workspace.run(runnable, workspace.getRoot(), IWorkspace.AVOID_UPDATE, monitor);
    } catch (CoreException e) {
        throw new InvocationTargetException(e);
    }
}
Also used : IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IWorkspace(org.eclipse.core.resources.IWorkspace) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

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