Search in sources :

Example 21 with IRunnableWithProgress

use of org.eclipse.jface.operation.IRunnableWithProgress in project tdi-studio-se by Talend.

the class StatusManagerSettingPage method updateItemsVersion.

private void updateItemsVersion() {
    IRunnableWithProgress runnable = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            //$NON-NLS-1$
            monitor.beginTask("", getModifiedVersionItems().size() * 100);
            Set<ERepositoryObjectType> types = new HashSet<ERepositoryObjectType>();
            for (RepositoryObject object : getModifiedVersionItems()) {
                // IRepositoryViewObject repositoryObject = object.getRepositoryNode().getObject();
                if (object != null && object.getProperty() != null) {
                    if (object.getStatusCode().equals(object.getProperty().getStatusCode())) {
                        final Item item = object.getProperty().getItem();
                        item.getProperty().setOldStatusCode(object.getStatusCode());
                        // types.add(object.getRepositoryNode().getObjectType());
                        try {
                            // }
                            if (object != null) {
                                // obj.setVersion(object.getNewVersion());
                                FACTORY.save(project, object.getProperty());
                            } else {
                            // FACTORY.save(project, item.getProperty());
                            }
                        } catch (PersistenceException e) {
                            ExceptionHandler.process(e);
                        }
                    }
                }
                monitor.worked(100);
            }
            // RepositoryManager.refresh(types);
            monitor.done();
        }
    };
    // final ProgressMonitorJobsDialog dialog = new ProgressMonitorJobsDialog(null);
    final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
    try {
        dialog.run(false, false, runnable);
    } catch (InvocationTargetException e) {
        ExceptionHandler.process(e);
    } catch (InterruptedException e) {
        ExceptionHandler.process(e);
    }
}
Also used : Item(org.talend.core.model.properties.Item) TableItem(org.eclipse.swt.widgets.TableItem) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RepositoryObject(org.talend.core.model.repository.RepositoryObject) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) PersistenceException(org.talend.commons.exception.PersistenceException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) HashSet(java.util.HashSet)

Example 22 with IRunnableWithProgress

use of org.eclipse.jface.operation.IRunnableWithProgress 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 23 with IRunnableWithProgress

use of org.eclipse.jface.operation.IRunnableWithProgress in project tdi-studio-se by Talend.

the class ErDiagramComposite method createErDiagram.

/**
     * admin Comment method "createErDiagram".
     * 
     * @return
     */
private ErDiagram createErDiagram(boolean isShowDesignerPage) {
    erDiagram = new ErDiagram();
    erDiagram.setErDiagramComposite(this);
    if (isShowDesignerPage) {
        IRunnableWithProgress progress = new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                //$NON-NLS-1$
                monitor.beginTask("", IProgressMonitor.UNKNOWN);
                try {
                    List<MetadataColumn> selectedColumns = new ArrayList<MetadataColumn>();
                    List<MetadataTable> tables = EMFRepositoryNodeManager.getInstance().getTables(getNodes(), selectedColumns);
                    erDiagram.setMetadataTables(tables);
                    List<String[]> fks = EMFRepositoryNodeManager.getInstance().getPKFromTables(tables, erDiagram.getErDiagramComposite().getDialog().getSelectedContext());
                    for (MetadataTable metadataTable : tables) {
                        Table table = new Table();
                        table.setMetadataTable(metadataTable, selectedColumns);
                        table.setErDiagram(erDiagram);
                        erDiagram.addTable(table);
                    }
                    erDiagram.setRelations(fks);
                } finally {
                    monitor.done();
                }
            }
        };
        UIUtils.runWithProgress(progress, true, dialog.getProgressMonitor(), dialog.getShell());
    } else {
        erDiagram.setMetadataTables(new ArrayList<MetadataTable>());
        erDiagram.setRelations(new ArrayList<String[]>());
    }
    return erDiagram;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) Table(org.talend.sqlbuilder.erdiagram.ui.nodes.Table) ErDiagram(org.talend.sqlbuilder.erdiagram.ui.nodes.ErDiagram) ArrayList(java.util.ArrayList) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 24 with IRunnableWithProgress

use of org.eclipse.jface.operation.IRunnableWithProgress in project tdi-studio-se by Talend.

the class CreateTableCommand method execute.

@Override
public void execute() {
    for (MetadataTable metadataTable : metaTables) {
        if (!tableNames.contains(metadataTable.getSourceName())) {
            Table table = new Table();
            table.setMetadataTable(metadataTable, null);
            table.setErDiagram(erDiagram);
            erDiagram.addTable(table);
            erDiagram.getMetadataTables().add(metadataTable);
        }
    }
    IRunnableWithProgress progress = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            //$NON-NLS-1$
            monitor.beginTask("", IProgressMonitor.UNKNOWN);
            try {
                fks = EMFRepositoryNodeManager.getInstance().getPKFromTables(erDiagram.getMetadataTables(), erDiagram.getErDiagramComposite().getDialog().getSelectedContext());
            } finally {
                monitor.done();
            }
        }
    };
    ISQLBuilderDialog dialog = erDiagram.getErDiagramComposite().getDialog();
    UIUtils.runWithProgress(progress, true, dialog.getProgressMonitor(), dialog.getShell());
    erDiagram.setRelations(fks);
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Table(org.talend.sqlbuilder.erdiagram.ui.nodes.Table) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) ISQLBuilderDialog(org.talend.sqlbuilder.ui.ISQLBuilderDialog) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 25 with IRunnableWithProgress

use of org.eclipse.jface.operation.IRunnableWithProgress in project tesb-studio-se by Talend.

the class WebServiceUIPresenter method refreshPageByWsdl.

@Override
public void refreshPageByWsdl(final String wsdlLocation) {
    webServiceUI.setErrorMessage(null);
    portTableModel.removeAll();
    functionTableModel.removeAll();
    IRunnableWithProgress retrieveData = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            monitor.beginTask("Retrieve WSDL parameter from net.", IProgressMonitor.UNKNOWN);
            try {
                retrieveData(wsdlLocation);
            } catch (Exception e) {
                throw new InvocationTargetException(e);
            } finally {
                monitor.done();
            }
        }
    };
    try {
        webServiceUI.runWithProgress(retrieveData);
        if (currentSetting.hasRpcOperation()) {
            webServiceUI.setErrorMessage(Messages.getString("WebServiceUI.NotSupportRpc"));
        }
        final List<String> ports = new ArrayList<String>(portFunctionsMap.keySet());
        portTableModel.addAll(ports);
        if (!ports.isEmpty()) {
            functionTableModel.addAll(portFunctionsMap.get(ports.get(0)));
            webServiceUI.selectFirstFunction();
        }
    } catch (InvocationTargetException e) {
        webServiceUI.setErrorMessage("Error getting service description: " + e.getCause().getMessage());
        webServiceUI.setPageComplete(false);
    } catch (InterruptedException e) {
    // ignore e.
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ArrayList(java.util.ArrayList) InvocationTargetException(java.lang.reflect.InvocationTargetException) WSDLException(javax.wsdl.WSDLException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Aggregations

IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)177 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)167 InvocationTargetException (java.lang.reflect.InvocationTargetException)160 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)83 CoreException (org.eclipse.core.runtime.CoreException)56 ArrayList (java.util.ArrayList)42 IStatus (org.eclipse.core.runtime.IStatus)39 Status (org.eclipse.core.runtime.Status)36 IFile (org.eclipse.core.resources.IFile)27 File (java.io.File)24 IOException (java.io.IOException)24 PartInitException (org.eclipse.ui.PartInitException)24 List (java.util.List)19 IProject (org.eclipse.core.resources.IProject)19 PersistenceException (org.talend.commons.exception.PersistenceException)19 Shell (org.eclipse.swt.widgets.Shell)18 Display (org.eclipse.swt.widgets.Display)17 IResource (org.eclipse.core.resources.IResource)16 IPath (org.eclipse.core.runtime.IPath)15 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)12