Search in sources :

Example 86 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project tdi-studio-se by Talend.

the class ImportItemWizardPage method populateItems.

/**
     * DOC hcw Comment method "populateItems".
     */
private void populateItems() {
    selectedItems.clear();
    final Collection<ItemRecord> items = new ArrayList<ItemRecord>();
    IRunnableWithProgress op = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            repositoryUtil.clearAllData();
            items.addAll(totalItemRecords = repositoryUtil.populateItems(manager, overwrite, monitor));
        }
    };
    try {
        new ProgressMonitorDialog(getShell()).run(true, true, op);
    } catch (Exception e) {
    // ignore me
    }
    errors.clear();
    for (ItemRecord itemRecord : items) {
        // bug 21738
        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().equals(reObject.getLabel()) && itemRecord.getProperty().getVersion().equals(reObject.getVersion())) {
                    for (String error : itemRecord.getErrors()) {
                        //$NON-NLS-1$ //$NON-NLS-2$
                        errors.add("'" + itemRecord.getItemName() + "' " + error);
                    }
                } else if (itemRecord.getProperty().getId().equals(reObject.getId()) && itemRecord.getProperty().getLabel().equals(reObject.getLabel()) && !itemRecord.getProperty().getVersion().equals(reObject.getVersion())) {
                    for (String error : itemRecord.getErrors()) {
                        //$NON-NLS-1$ //$NON-NLS-2$
                        errors.add("'" + itemRecord.getItemName() + "' " + Messages.getString("ImportItemWizardPage.ErrorsMessage", reObject.getVersion()));
                    }
                } else {
                    // TDI-21399,TDI-21401
                    // if item is locked, cannot overwrite
                    ERepositoryStatus status = reObject.getRepositoryStatus();
                    if (status == ERepositoryStatus.LOCK_BY_OTHER || status == ERepositoryStatus.LOCK_BY_USER) {
                        for (String error : itemRecord.getErrors()) {
                            //$NON-NLS-1$ //$NON-NLS-2$
                            errors.add("'" + itemRecord.getItemName() + "' " + error);
                        }
                    }
                }
            }
        } else {
            if (itemRecord.getProperty() != null) {
                Item item = itemRecord.getProperty().getItem();
                if (item != null && (item instanceof JobDocumentationItem || item instanceof JobletDocumentationItem)) {
                    continue;
                }
                for (String error : itemRecord.getErrors()) {
                    //$NON-NLS-1$ //$NON-NLS-2$
                    errors.add("'" + itemRecord.getItemName() + "' " + error);
                }
            }
        }
    }
    if (errorsList != null) {
        errorsList.refresh();
    }
    selectedItems.addAll(items);
    checkTreeViewer.refresh(true);
    checkTreeViewer.expandAll();
    filteredCheckboxTree.resetCheckedElements();
    checkValidItems();
    updateFinishStatus();
// see feature 0004170: Unselect all items to import
// itemsList.setCheckedElements(checkValidItems());
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ArrayList(java.util.ArrayList) CoreException(org.eclipse.core.runtime.CoreException) ZipException(java.util.zip.ZipException) LoginException(org.talend.commons.exception.LoginException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TarException(org.eclipse.ui.internal.wizards.datatransfer.TarException) IOException(java.io.IOException) PersistenceException(org.talend.commons.exception.PersistenceException) 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) JobDocumentationItem(org.talend.core.model.properties.JobDocumentationItem) JobletDocumentationItem(org.talend.core.model.properties.JobletDocumentationItem) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 87 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project tdi-studio-se by Talend.

the class CustomComponentSettingPage method performApply.

@Override
protected void performApply() {
    final IRunnableWithProgress runnable = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            monitor.beginTask("Save custom component setting", (sharedAdded.size() + backAdded.size()) * 100);
            finish(monitor);
        }
    };
    final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
    try {
        if (!sharedAdded.isEmpty() || !backAdded.isEmpty()) {
            dialog.run(true, false, runnable);
        }
        init();
        sharedAdded.clear();
        backAdded.clear();
    } 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) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 88 with ProgressMonitorDialog

use of org.eclipse.jface.dialogs.ProgressMonitorDialog in project bndtools by bndtools.

the class GitHubRepoDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    setTitle(title);
    Composite area = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(area, SWT.NONE);
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    container.setLayout(new GridLayout(2, false));
    Label lblRepo = new Label(container, SWT.NONE);
    lblRepo.setText("Repository Name:");
    txtRepository = new Text(container, SWT.BORDER);
    txtRepository.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    txtRepository.setMessage("username/repository");
    if (repository != null)
        txtRepository.setText(repository);
    new Label(container, SWT.NONE).setText("Branch:");
    txtBranch = new Text(container, SWT.BORDER);
    txtBranch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    txtBranch.setMessage("default branch");
    if (branch != null)
        txtBranch.setText(branch);
    ControlDecoration branchDecor = new ControlDecoration(txtBranch, SWT.LEFT, container);
    branchDecor.setDescriptionText("Specify the branch, tag or commit ID you would like to clone from the\nrepository. We use the default branch specified in GitHub settings.");
    branchDecor.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
    branchDecor.setShowHover(true);
    final Button btnValidate = new Button(container, SWT.PUSH);
    btnValidate.setText("Validate");
    btnValidate.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 2, 1));
    ModifyListener modifyListener = new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent ev) {
            if (!txtRepository.getText().trim().equals(repository)) {
                isValidated = false;
                repository = txtRepository.getText().trim();
            }
            branch = txtBranch.getText().trim();
            updateButtons();
        }
    };
    txtRepository.addModifyListener(modifyListener);
    txtBranch.addModifyListener(modifyListener);
    btnValidate.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            setMessage(null, IMessageProvider.INFORMATION);
            try {
                if (repository == null || repository.isEmpty())
                    throw new GitHubValidationException("No repository name specified");
                if (repository.contains(":/"))
                    throw new GitHubValidationException("Specify GitHub repositories as username/repository");
                IRunnableWithProgress runnable = new IRunnableWithProgress() {

                    @Override
                    public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                        try {
                            final GithubRepoDetailsDTO dto = new GitHub(cache, executor).loadRepoDetails(repository).getValue();
                            final URI cloneUri = URI.create(dto.clone_url);
                            btnValidate.getDisplay().asyncExec(new Runnable() {

                                @Override
                                public void run() {
                                    setMessage(String.format("Validated! Clone URL is '%s'. Default branch 'origin/%s'", cloneUri, dto.default_branch), IMessageProvider.INFORMATION);
                                    isValidated = true;
                                    updateButtons();
                                }
                            });
                        } catch (InvocationTargetException e) {
                            throw e;
                        } catch (Exception e) {
                            throw new InvocationTargetException(e);
                        }
                    }
                };
                ProgressRunner.execute(false, runnable, new ProgressMonitorDialog(getParentShell()), btnValidate.getDisplay());
                setErrorMessage(null);
            } catch (InvocationTargetException ex) {
                Throwable t = ex.getCause();
                if (t instanceof FileNotFoundException)
                    setErrorMessage("Could not find the requested repository");
                else
                    setErrorMessage(t.getClass().getSimpleName() + ": " + t.getMessage());
            } catch (GitHubValidationException ex) {
                setErrorMessage(ex.getMessage());
            } catch (Exception ex) {
                setErrorMessage(ex.getClass().getSimpleName() + ": " + ex.getMessage());
            }
        }
    });
    return area;
}
Also used : GitHubValidationException(org.bndtools.templating.jgit.GitHubValidationException) ModifyListener(org.eclipse.swt.events.ModifyListener) GitHub(org.bndtools.templating.jgit.GitHub) Label(org.eclipse.swt.widgets.Label) FileNotFoundException(java.io.FileNotFoundException) URI(java.net.URI) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) Text(org.eclipse.swt.widgets.Text) InvocationTargetException(java.lang.reflect.InvocationTargetException) FileNotFoundException(java.io.FileNotFoundException) InvocationTargetException(java.lang.reflect.InvocationTargetException) GitHubValidationException(org.bndtools.templating.jgit.GitHubValidationException) GithubRepoDetailsDTO(org.bndtools.templating.jgit.GithubRepoDetailsDTO) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) GridData(org.eclipse.swt.layout.GridData)

Aggregations

ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)88 InvocationTargetException (java.lang.reflect.InvocationTargetException)81 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)74 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)74 ArrayList (java.util.ArrayList)27 Display (org.eclipse.swt.widgets.Display)22 CoreException (org.eclipse.core.runtime.CoreException)17 PersistenceException (org.talend.commons.exception.PersistenceException)17 List (java.util.List)15 Shell (org.eclipse.swt.widgets.Shell)12 PartInitException (org.eclipse.ui.PartInitException)12 IFile (org.eclipse.core.resources.IFile)11 SQLException (java.sql.SQLException)10 IOException (java.io.IOException)9 HashMap (java.util.HashMap)9 SocketTask (com.cubrid.cubridmanager.core.common.socket.SocketTask)8 File (java.io.File)8 Item (org.talend.core.model.properties.Item)8 IProject (org.eclipse.core.resources.IProject)7 TableItem (org.eclipse.swt.widgets.TableItem)7