Search in sources :

Example 6 with EventLoopProgressMonitor

use of org.talend.commons.ui.swt.dialogs.EventLoopProgressMonitor in project tdi-studio-se by Talend.

the class SchemaXMLLinker method createLinks.

/**
     * amaumont Comment method "createLinks".
     */
public void createLinks() {
    removeAllLinks();
    getBackgroundRefresher().refreshBackground();
    ProgressDialog progressDialog = new ProgressDialog(getSource().getShell(), 1000) {

        private IProgressMonitor monitorWrap;

        @Override
        public void run(IProgressMonitor monitor) {
            TreeItem root = xmlViewer.getTree().getItem(0);
            //
            List<HL7TreeNode> mappableNodes = new ArrayList<HL7TreeNode>();
            if (getManager().getHl7Component().isHL7Output()) {
                if (getManager() instanceof HL7OutputManager) {
                    //$NON-NLS-1$
                    mappableNodes = ((HL7OutputManager) getManager()).getTreeData("");
                    createLoopLinks(mappableNodes);
                    xmlViewer.refresh();
                    getBackgroundRefresher().refreshBackground();
                }
            } else {
                List<TreeItem> allItems = TreeUtils.collectAllItems(root);
                monitorWrap = new EventLoopProgressMonitor(monitor);
                //$NON-NLS-1$
                String taskName = Messages.getString("XmlToXPathLinker.Loop");
                int totalWork = allItems.size();
                monitorWrap.beginTask(taskName, totalWork);
                for (int i = 0; i < totalWork; i++) {
                    if (monitorWrap.isCanceled()) {
                        return;
                    }
                    TreeItem treeItem = allItems.get(i);
                    HL7TreeNode node = (HL7TreeNode) treeItem.getData();
                    if (node.getColumn() == null) {
                        continue;
                    }
                    // add now parameter for bug 9279
                    createLoopLinks(node.getColumn().getLabel(), treeItem, monitorWrap, i == totalWork - 1);
                    monitorWrap.worked(1);
                }
                monitorWrap.done();
            }
        }
    };
    try {
        progressDialog.executeProcess();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
        ExceptionHandler.process(e);
    } catch (InterruptedException e) {
        // Nothing to do
        ExceptionHandler.process(e);
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) ArrayList(java.util.ArrayList) EventLoopProgressMonitor(org.talend.commons.ui.swt.dialogs.EventLoopProgressMonitor) ProgressDialog(org.talend.commons.ui.swt.dialogs.ProgressDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) HL7TreeNode(org.talend.designer.hl7.ui.data.HL7TreeNode) HL7OutputManager(org.talend.designer.hl7.managers.HL7OutputManager)

Example 7 with EventLoopProgressMonitor

use of org.talend.commons.ui.swt.dialogs.EventLoopProgressMonitor in project tdi-studio-se by Talend.

the class JSONToXPathLinker method handleListenableListAfterTableViewerRefreshedEvent.

public void handleListenableListAfterTableViewerRefreshedEvent(final ListenableListEvent<SchemaTarget> event) {
    if (event.type == ListenableListEvent.TYPE.ADDED) {
        ProgressDialog progressDialog = new ProgressDialog(getTree().getShell(), 1000) {

            private IProgressMonitor monitorWrap;

            @Override
            public void run(IProgressMonitor monitor) {
                monitorWrap = new EventLoopProgressMonitor(monitor);
                List<SchemaTarget> addedObjects = new ArrayList<SchemaTarget>(event.addedObjects);
                JSONToXPathLinker.this.createFieldsLinkWithProgressMonitor(monitorWrap, addedObjects.size(), addedObjects, event.index, addedObjects.size());
                monitorWrap.done();
            }
        };
        try {
            progressDialog.executeProcess();
        } catch (InvocationTargetException e) {
            ExceptionHandler.process(e);
        } catch (InterruptedException e) {
        // Nothing to do
        }
        getBackgroundRefresher().refreshBackground();
    } else if (event.type == ListenableListEvent.TYPE.SWAPED) {
        getBackgroundRefresher().refreshBackground();
    } else if (event.type == TYPE.REMOVED) {
        getBackgroundRefresher().refreshBackground();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ArrayList(java.util.ArrayList) EventLoopProgressMonitor(org.talend.commons.ui.swt.dialogs.EventLoopProgressMonitor) ProgressDialog(org.talend.commons.ui.swt.dialogs.ProgressDialog) SchemaTarget(org.talend.repository.model.json.SchemaTarget) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 8 with EventLoopProgressMonitor

use of org.talend.commons.ui.swt.dialogs.EventLoopProgressMonitor in project tdi-studio-se by Talend.

the class ImportDemoProjectItemsPage method performFinish.

public boolean performFinish() {
    List<DemoProjectBean> checkedElements = getCheckedElements();
    final List<ResourcesManager> finalCheckManagers = getResourceManagers(checkedElements);
    String warnMessage = populateExistItemRecords(finalCheckManagers);
    if (!warnMessage.equals("")) {
        MessageDialog dialog = new MessageDialog(getShell(), Messages.getString("ImportDemoProjectPage.overwrite"), null, warnMessage, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
        dialog.open();
        int result = dialog.getReturnCode();
        if (result != MessageDialog.OK) {
            return false;
        }
    }
    ProgressDialog progressDialog = new ProgressDialog(getShell()) {

        private IProgressMonitor monitorWrap;

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            monitorWrap = new EventLoopProgressMonitor(monitor);
            try {
                for (ResourcesManager resManager : finalCheckManagers) {
                    List<ImportItem> projectRecords = importManager.populateImportingItems(resManager, true, monitorWrap);
                    // clearOverWriteErrorMessages(projectRecords, overwrite);
                    importManager.importItemRecords(monitorWrap, resManager, projectRecords, true, projectRecords.toArray(new ImportItem[0]), null);
                }
            } catch (Exception e) {
                ExceptionHandler.process(e);
            }
            monitorWrap.done();
            if (monitor.isCanceled()) {
                MessageDialog.openInformation(getShell(), Messages.getString("ImportDemoProjectAction.messageDialogTitle.demoProjectCancel"), Messages.getString("ImportDemoProjectAction.messageDialogContent.demoProjectImportedIncompletely"));
                return;
            } else {
                MessageDialog.openInformation(getShell(), //$NON-NLS-1$
                Messages.getString("ImportDemoProjectAction.messageDialogTitle.demoProject"), //$NON-NLS-1$
                Messages.getString("ImportDemoProjectAction.messageDialogContent.demoProjectImportedSuccessfully"));
            }
        }
    };
    try {
        progressDialog.executeProcess();
    } catch (InvocationTargetException e) {
        MessageBoxExceptionHandler.process(e.getTargetException(), getShell());
    } catch (InterruptedException e) {
    // Nothing to do
    }
    return true;
}
Also used : ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) EventLoopProgressMonitor(org.talend.commons.ui.swt.dialogs.EventLoopProgressMonitor) ProgressDialog(org.talend.commons.ui.swt.dialogs.ProgressDialog) 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) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ResourcesManager(org.talend.repository.items.importexport.manager.ResourcesManager) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 9 with EventLoopProgressMonitor

use of org.talend.commons.ui.swt.dialogs.EventLoopProgressMonitor in project tdi-studio-se by Talend.

the class ImportDemoProjectPage method prefromFinish.

public boolean prefromFinish() {
    final DemoProjectBean selectPro = this.demoProjectList.get(selectedDemoProjectIndex);
    NewImportProjectWizard newPrjWiz = new NewImportProjectWizard();
    WizardDialog newProjectDialog = new WizardDialog(getShell(), newPrjWiz);
    //$NON-NLS-1$
    newProjectDialog.setTitle(Messages.getString("NewImportProjectWizard.windowTitle"));
    if (newProjectDialog.open() == Window.OK) {
        projectName = newPrjWiz.getName().trim().replace(' ', '_');
        // final String demoProjName = selectPro.getProjectName();
        //
        ProgressDialog progressDialog = new ProgressDialog(getShell()) {

            private IProgressMonitor monitorWrap;

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitorWrap = new EventLoopProgressMonitor(monitor);
                try {
                    // }
                    if (null == selectPro) {
                        //$NON-NLS-1$
                        throw new IOException("cannot find selected demo project");
                    }
                    ImportProjectsUtilities.importDemoProject(getShell(), projectName, selectPro, monitor);
                } catch (Exception e1) {
                    projectName = null;
                    throw new InvocationTargetException(e1);
                }
                monitorWrap.done();
            }
        };
        try {
            progressDialog.executeProcess();
        } catch (InvocationTargetException e1) {
            projectName = null;
            MessageBoxExceptionHandler.process(e1.getTargetException(), getShell());
        } catch (InterruptedException e1) {
            projectName = null;
        }
    }
    return true;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) NewImportProjectWizard(org.talend.repository.ui.login.NewImportProjectWizard) EventLoopProgressMonitor(org.talend.commons.ui.swt.dialogs.EventLoopProgressMonitor) IOException(java.io.IOException) ProgressDialog(org.talend.commons.ui.swt.dialogs.ProgressDialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)9 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)9 EventLoopProgressMonitor (org.talend.commons.ui.swt.dialogs.EventLoopProgressMonitor)9 ProgressDialog (org.talend.commons.ui.swt.dialogs.ProgressDialog)8 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)2 TreeItem (org.eclipse.swt.widgets.TreeItem)2 TarException (org.eclipse.ui.internal.wizards.datatransfer.TarException)2 SchemaTarget (org.talend.repository.model.json.SchemaTarget)2 FileNotFoundException (java.io.FileNotFoundException)1 MessageFormat (java.text.MessageFormat)1 Date (java.util.Date)1 ZipException (java.util.zip.ZipException)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 Display (org.eclipse.swt.widgets.Display)1