Example usage for org.eclipse.jface.operation IRunnableWithProgress IRunnableWithProgress

List of usage examples for org.eclipse.jface.operation IRunnableWithProgress IRunnableWithProgress

Introduction

In this page you can find the example usage for org.eclipse.jface.operation IRunnableWithProgress IRunnableWithProgress.

Prototype

IRunnableWithProgress

Source Link

Usage

From source file:com.muratools.eclipse.wizard.newInstall.NewInstallWizard.java

License:Apache License

private void downloadMura() {
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
    try {/*from ww w.j  a v  a  2 s. c  o  m*/
        dialog.run(true, true, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                //monitor.beginTask("Downloading Mura...", 100);

                try {
                    URL url = new URL("http://www.getmura.com/currentversion/?source=muratools");
                    int contentLength = url.openConnection().getContentLength();
                    monitor.beginTask("Downloading Mura...", contentLength);

                    InputStream reader = url.openStream();

                    FileOutputStream writer = new FileOutputStream(zipLocation);
                    byte[] buffer = new byte[44640];
                    int bytesRead = 0;

                    int tp = 0;
                    while ((bytesRead = reader.read(buffer)) > 0) {
                        writer.write(buffer, 0, bytesRead);
                        buffer = new byte[44640];

                        tp++;
                        System.err.println(tp + " / "
                                + Integer.toString((int) Math.ceil((double) contentLength / (double) 44640))
                                + "[" + bytesRead + "]");

                        monitor.worked(bytesRead);
                    }

                    writer.close();
                    reader.close();
                } catch (MalformedURLException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }

                monitor.done();
            }
        });
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:com.muratools.eclipse.wizard.newInstall.NewInstallWizard.java

License:Apache License

private void deployMuraZip() {
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
    try {/*from  w  w w  .  j a  v a 2 s . c  om*/
        dialog.run(true, true, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                //monitor.beginTask("Unzipping Mura...", IProgressMonitor.UNKNOWN);

                try {
                    String tempDir = System.getProperty("java.io.tmpdir") + "/latest-mura-"
                            + Long.toString(new Date().getTime());
                    // make the tempDir
                    new File(tempDir).mkdir();

                    Enumeration entries;
                    ZipFile zipFile;

                    zipFile = new ZipFile(zipLocation);

                    entries = zipFile.entries();

                    monitor.beginTask("Unzipping Mura...", zipFile.size() * 2);

                    // unzip the zip file to the temp directory
                    while (entries.hasMoreElements()) {
                        ZipEntry entry = (ZipEntry) entries.nextElement();
                        String fullEntryPath = tempDir + "/" + entry.getName();

                        if (entry.isDirectory()) {
                            (new File(fullEntryPath)).mkdir();
                            continue;
                        }

                        copyInputStream(zipFile.getInputStream(entry),
                                new BufferedOutputStream(new FileOutputStream(fullEntryPath)));

                        monitor.worked(1);
                    }
                    zipFile.close();

                    // copy the files to the target directory
                    String sourceDir = tempDir;
                    File testDir = new File(tempDir + "/www");
                    if (testDir.exists() && testDir.isDirectory()) {
                        sourceDir += "/www";
                    }

                    copyDirectory(new File(sourceDir), new File(getTargetDirectory()), monitor);

                } catch (IOException e) {
                    e.printStackTrace();
                }

                monitor.done();
            }
        });
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:com.netxforge.editing.base.impl.EMFEditingService.java

License:Open Source License

public IRunnableWithProgress doGetSaveOperation(IProgressMonitor monitor) {
    final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
    saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);

    // Do the work within an operation because this is a long running
    // activity that modifies the workbench.
    ///*from   w w  w . ja v  a  2s. com*/
    IRunnableWithProgress operation = new IRunnableWithProgress() {

        // This is the method that gets invoked when the operation runs.
        //
        public void run(IProgressMonitor monitor) {
            // Save the resources to the file system.
            //
            boolean first = true;
            for (Resource resource : getEditingDomain().getResourceSet().getResources()) {
                if ((first || !resource.getContents().isEmpty()) && !getEditingDomain().isReadOnly(resource)) {
                    try {

                        resource.save(saveOptions);
                        // Save a copy of the objects of certain resources.

                    } catch (Exception exception) {
                        exception.printStackTrace();

                        // Various reasons why save would fail...
                        // At least warn the user.
                        // The DIRTY objects will still appear in the UI, so
                        // the editing
                        // should be undone, or DIRTY objects rolled back.

                        // MessageDialog.openError(Display.getDefault()
                        // .getActiveShell(), "Error saving",
                        // exception.getMessage());

                        // TODO, give user feedback, and undo of domain.
                        // Command cmd;
                        // while( ( cmd =
                        // domain.getCommandStack().getUndoCommand()) !=
                        // null){
                        // cmd.undo();
                        // }
                    }
                    first = false;
                }
            }
        }
    };

    return operation;
}

From source file:com.netxforge.netxstudio.delta16042013.generics.presentation.GenericsEditor.java

License:Open Source License

/**
 * This is for implementing {@link IEditorPart} and simply saves the model file.
 * <!-- begin-user-doc -->//from  www  .j  a  v a  2s  . c  o  m
 * <!-- end-user-doc -->
 * @generated NOT
 */
@Override
public void doSave(IProgressMonitor progressMonitor) {
    // Save only resources that have actually changed.
    //
    final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
    saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);

    // Do the work within an operation because this is a long running activity that modifies the workbench.
    //
    IRunnableWithProgress operation = new IRunnableWithProgress() {
        // This is the method that gets invoked when the operation runs.
        //
        public void run(IProgressMonitor monitor) {
            // Save the resources to the file system.
            //
            boolean first = true;
            for (Resource resource : editingDomain.getResourceSet().getResources()) {
                if ((first || !resource.getContents().isEmpty() || isPersisted(resource))
                        && !editingDomain.isReadOnly(resource)) {
                    try {
                        long timeStamp = resource.getTimeStamp();
                        resource.save(saveOptions);
                        if (resource.getTimeStamp() != timeStamp) {
                            savedResources.add(resource);
                        }
                    } catch (Exception exception) {
                        resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
                    }
                    first = false;
                }
            }
        }
    };

    updateProblemIndication = false;
    try {
        // This runs the options, and shows progress.
        //
        new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);

        // Refresh the necessary state.
        //
        ((BasicCommandStack) editingDomain.getCommandStack()).saveIsDone();
        firePropertyChange(IEditorPart.PROP_DIRTY);
    } catch (Exception exception) {
        // Something went wrong that shouldn't.
        //
        NetxstudioEditorPlugin.INSTANCE.log(exception);
    }
    updateProblemIndication = true;
    updateProblemIndication();
}

From source file:com.netxforge.netxstudio.delta16042013.generics.presentation.GenericsModelWizard.java

License:Open Source License

/**
 * Do the work after everything is specified.
 * <!-- begin-user-doc -->//from   w w w . j  av  a  2  s . c  om
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public boolean performFinish() {
    try {
        // Get the URI of the model file.
        //
        final URI fileURI = getModelURI();
        if (new File(fileURI.toFileString()).exists()) {
            if (!MessageDialog.openQuestion(getShell(),
                    NetxstudioEditorPlugin.INSTANCE.getString("_UI_Question_title"),
                    NetxstudioEditorPlugin.INSTANCE.getString("_WARN_FileConflict",
                            new String[] { fileURI.toFileString() }))) {
                initialObjectCreationPage.selectFileField();
                return false;
            }
        }

        // Do the work within an operation.
        //
        IRunnableWithProgress operation = new IRunnableWithProgress() {
            public void run(IProgressMonitor progressMonitor) {
                try {
                    // Create a resource set
                    //
                    ResourceSet resourceSet = new ResourceSetImpl();

                    // Create a resource for this file.
                    //
                    Resource resource = resourceSet.createResource(fileURI);

                    // Add the initial model object to the contents.
                    //
                    EObject rootObject = createInitialModel();
                    if (rootObject != null) {
                        resource.getContents().add(rootObject);
                    }

                    // Save the contents of the resource to the file system.
                    //
                    Map<Object, Object> options = new HashMap<Object, Object>();
                    options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding());
                    resource.save(options);
                } catch (Exception exception) {
                    NetxstudioEditorPlugin.INSTANCE.log(exception);
                } finally {
                    progressMonitor.done();
                }
            }
        };

        getContainer().run(false, false, operation);

        return NetxstudioEditorAdvisor.openEditor(workbench, fileURI);
    } catch (Exception exception) {
        NetxstudioEditorPlugin.INSTANCE.log(exception);
        return false;
    }
}

From source file:com.netxforge.netxstudio.screens.editing.CDOEditingService.java

License:Open Source License

public IRunnableWithProgress doGetSaveOperation(IProgressMonitor monitor) {
    final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
    saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);

    // Do the work within an operation because this is a long running
    // activity that modifies the workbench.
    IRunnableWithProgress operation = new IRunnableWithProgress() {
        // This is the method that gets invoked when the operation runs.
        public void run(IProgressMonitor monitor) {
            // Save the resources to the file system.
            try {
                monitor.beginTask("Saving all Objects", 100);

                // FIXME, REVISION HANDLING WITH NEW STORE.
                // monitor.subTask("Copy history");
                // saveHistory();
                monitor.worked(50);//from w w  w  . j av a 2 s  . c om
                monitor.subTask("Committing transaction from regular view");
                CDOTransaction transaction = getView() instanceof CDOTransaction ? (CDOTransaction) getView()
                        : null;
                if (transaction != null) {
                    commitRegular(monitor, transaction);
                }
                monitor.subTask("Committing transaction from regular view");
                transaction = getCDOData().getTransaction();
                if (transaction != null) {
                    commitRegular(monitor, transaction);
                }

                monitor.done();
            } catch (Exception e) {
                e.printStackTrace();
                // List of possible exceptions.

                // MessageDialog.openError(Display.getDefault()
                // .getActiveShell(), "Error saving object",
                // "Error saving, rolling back. ");
                if (EditingActivator.DEBUG) {
                    System.out.println("Can't save, rolling back");
                }

                ((IDawnEditor) CDOEditingService.this).getDawnEditorSupport().rollback();
            }
        }
    };

    return operation;
}

From source file:com.nextep.datadesigner.vcs.gui.dialog.MergeResultGUI.java

License:Open Source License

private void createMergeNavigators() {
    // Sorting results by source name / target name
    final List<IComparisonItem> sortedResult = Arrays.asList(result);
    // Sorting items unless told not to do so
    if (!noSort) {
        Collections.sort(sortedResult, new Comparator<IComparisonItem>() {

            @Override//  w  w  w.j  av  a2 s  .  c o  m
            public int compare(IComparisonItem o1, IComparisonItem o2) {
                IReferenceable src = o1.getSource() == null ? o1.getTarget() : o1.getSource();
                IReferenceable tgt = o2.getSource() == null ? o2.getTarget() : o2.getSource();
                return ((INamedObject) src).getName().compareTo(((INamedObject) tgt).getName());
            }

        });
    }
    // Creating merge lines items
    ProgressMonitorDialog pd = new ProgressMonitorDialog(this.getShell());
    try {
        pd.run(false, false, new IRunnableWithProgress() {
            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.setTaskName("Initializing...");
                monitor.beginTask("Preparing preview for user validation...", result.length);
                for (IComparisonItem content : sortedResult) {
                    //                  if(!hideUnchanged || content.getDifferenceType()!=DifferenceType.EQUALS) {
                    int type = UPDATES;
                    switch (content.getDifferenceType()) {
                    case EQUALS:
                        if (hideUnchanged) {
                            continue;
                        }
                        type = UNCHANGED;
                        break;
                    case DIFFER:
                        type = UPDATES;
                        break;
                    case MISSING_SOURCE:
                        type = DELETIONS;
                        break;
                    case MISSING_TARGET:
                        type = ADDITIONS;
                        break;
                    }
                    sourceConn = new MergeNavigator(sourceRoot[type], targetRoot[type], mergedRoot[type],
                            content);
                    sourceConn.setShowAllChecks(repositoryMergeWindow);
                    if (content.getDifferenceType() != DifferenceType.EQUALS) {
                        sourceConn.showUnchangedItems(!hideUnchanged);
                    } else {
                        sourceConn.showUnchangedItems(true);
                    }
                    sourceConn.create(sourceRoot[type], -1);
                    sourceConn.initialize();
                    sourceConn.refreshConnector(false);
                    monitor.worked(1);
                }
                //               }
                for (int i = 0; i < 4; i++) {
                    final int count = sourceRoot[i].getItemCount();
                    if (count > 0) {
                        sourceRoot[i].setText(VCSUIMessages.getString(msgKeys[i]) + " (" + count + ")");
                        sourceRoot[i].setFont(FontFactory.FONT_BOLD);
                        // Unchecking everything to ensure reprocessing 
                        sourceRoot[i].setChecked(false);
                        targetRoot[i].setChecked(false);
                        mergedRoot[i].setChecked(false);
                        // Processing gray checks
                        gray(sourceRoot[i]);
                        gray(targetRoot[i]);
                        gray(mergedRoot[i]);
                    } else {
                        sourceRoot[i].setText(VCSUIMessages.getString(msgKeys[i]));
                        sourceRoot[i].setFont(null);
                    }
                }
                monitor.done();
            }

        });
    } catch (Exception e) {
        throw new ErrorException(e);
    }
}

From source file:com.nextep.designer.ui.wizards.ResolveProblemsWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    try {// www  . j a v a  2s .  com
        getContainer().run(false, false, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask(UIMessages.getString("wizard.problems.applyHints"), markers.size() + 1); //$NON-NLS-1$
                for (IMarker marker : markers) {
                    final Object markedObj = marker.getRelatedObject();
                    monitor.subTask(
                            MessageFormat.format(UIMessages.getString("wizard.problems.processingElemnt"), //$NON-NLS-1$
                                    NameHelper.getQualifiedName(markedObj)));
                    if (marker.getSelectedHint() != null) {
                        marker.getSelectedHint().execute(marker.getRelatedObject());
                    }
                    monitor.worked(1);
                    while (Display.getDefault().readAndDispatch()) {
                    }
                }
                // Refreshing viewer
                monitor.done();
            }
        });
    } catch (InterruptedException e) {
        LOGGER.error(MessageFormat.format(UIMessages.getString("wizard.problems.interruptedException"), //$NON-NLS-1$
                e.getMessage()), e);
        return false;
    } catch (InvocationTargetException e) {
        LOGGER.error(MessageFormat.format(UIMessages.getString("wizard.problems.targetException"), e //$NON-NLS-1$
                .getMessage()), e);
        return false;
    }
    return true;
}

From source file:com.nextep.designer.vcs.ui.controllers.MergeController.java

License:Open Source License

/**
 * @see com.nextep.datadesigner.gui.model.InvokableController#invoke(java.lang.Object)
 *//*from  www.  j a va2 s .  c  o  m*/
@Override
public Object invoke(Object... model) {
    if (model.length == 0) {
        throw new ErrorException("The merge controller need at least 1 non-null argument to proceed.");
    } else {
        final IVersionable<?> versionable = (IVersionable<?>) model[0];
        final MergeWizard wiz = new MergeWizard(new MergeInitGUI(versionable),
                new MergePreviewWizard(versionable));
        wiz.setToVersionable(versionable);
        WizardDialog w = new WizardDialog(
                VCSUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), wiz);
        w.setBlockOnOpen(true);
        w.open();
        if (w.getReturnCode() != Window.CANCEL) {
            // FIXME QUICKFIX calling this static method => TO remove !!!
            MergeStrategy.setIsGenerating(false);
            // try {
            final IMerger m = MergerFactory.getMerger(wiz.getToRelease());
            // Building compare command
            ICommand compareCommand = new ICommand() {

                @Override
                public Object execute(Object... parameters) {
                    return m.compare(wiz.getReference(), wiz.getFromRelease(), wiz.getToRelease(), true);
                }

                @Override
                public String getName() {
                    return "Computing differences between " + wiz.getToRelease().getLabel() + " and "
                            + wiz.getFromRelease().getLabel();
                }
            };
            final IComparisonItem comp = (IComparisonItem) CommandProgress.runWithProgress(compareCommand)
                    .iterator().next();

            ProgressMonitorDialog pd = new ProgressMonitorDialog(
                    VCSUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell());
            try {
                pd.run(true, false, new MergeProgress(comp, m));
            } catch (Exception e) {
                throw new ErrorException(e);
            }
            // } finally {
            MergeStrategy.setIsGenerating(true);
            // }
            MergeResultGUI mergeGUI = new MergeResultGUI(true, comp);
            mergeGUI.setIsRepositoryMerge(true);
            mergeGUI.setRootText(
                    "Source release " + wiz.getFromRelease().getLabel() + " ["
                            + wiz.getFromRelease().getBranch().getName() + "]",
                    "Current target release " + wiz.getToRelease().getLabel() + " ["
                            + wiz.getToRelease().getBranch().getName() + "]",
                    "Merge result");
            boolean doItAgain = true;
            while (doItAgain) {
                invokeGUI(new GUIWrapper(mergeGUI, "Merge results", 800, 600));
                // Checking that everything is resolved
                if (comp.getMergeInfo().getStatus() != MergeStatus.MERGE_RESOLVED) {
                    // IF not we ask if the user would like to edit again
                    doItAgain = MessageDialog.openQuestion(
                            VCSUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
                            VCSUIMessages.getString("mergeUnresolvedTitle"),
                            VCSUIMessages.getString("mergeUnresolved"));
                    if (!doItAgain) {
                        throw new CancelException("Merge operation aborted due to unresolved conflicts.");
                    }
                } else {
                    doItAgain = false;
                }
            }
            // We fall here if no cancel exception
            // HibernateUtil.getInstance().getSession().clear();
            // IdentifiableDAO.getInstance().loadAll(VersionReference.class);
            HibernateUtil.getInstance().clearAllSessions();
            pd = new ProgressMonitorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
            try {
                pd.run(false, false, new IRunnableWithProgress() {

                    @Override
                    public void run(IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {
                        monitor.beginTask("Merge in progress...", 5);
                        // Global listeners switch off
                        Observable.deactivateListeners();
                        // Refreshing progress
                        monitor.worked(1);
                        IVersionable<?> mergedObject = null;
                        try {
                            // Building the merge result
                            final String activityText = "Merged " + wiz.getFromRelease().getLabel() + " -> "
                                    + wiz.getFromRelease().getBranch().getName();
                            final IVersioningService versioningService = VCSPlugin
                                    .getService(IVersioningService.class);
                            final IActivity mergeActivity = versioningService.createActivity(activityText);
                            mergedObject = (IVersionable<?>) m.buildMergedObject(comp, mergeActivity);
                            // Checking if the merge did anything
                            if (mergedObject instanceof IVersionable<?>) {
                                if (((IVersionable<?>) mergedObject).getVersion()
                                        .getStatus() == IVersionStatus.CHECKED_IN) {
                                    final boolean forceMerge = MessageDialog.openQuestion(
                                            Display.getCurrent().getActiveShell(),
                                            VCSUIMessages.getString("mergeDidNothingTitle"),
                                            VCSUIMessages.getString("mergeDidNothing"));
                                    if (forceMerge) {
                                        comp.getMergeInfo().setMergeProposal(null);
                                        mergedObject = (IVersionable<?>) m.buildMergedObject(comp,
                                                mergeActivity);
                                    } else {
                                        return;
                                    }
                                }
                            }
                        } finally {
                            Observable.activateListeners();
                        }
                        log.info("Merged successfully!");
                        // Refreshing progress
                        monitor.worked(1);
                        monitor.setTaskName("Updating view contents...");

                        // Temporary bugfix for DES-710
                        // TODO refactor EVERYTHING as a service
                        final Session session = HibernateUtil.getInstance().getSandBoxSession();

                        // FIXME draft of view removal / addition of the merged object
                        // Switching versionables (for database only)
                        IVersionContainer parent = versionable.getContainer();
                        // First removing current versionable in current session
                        parent.getContents().remove(versionable);
                        versionable.setContainer(null);

                        // Forcing save of module without parent
                        final IIdentifiableDAO identifiableDao = CorePlugin.getIdentifiableDao();
                        identifiableDao.save(parent);
                        // Refreshing progress
                        monitor.worked(1);
                        // Reloading parent container in sandbox (because merged object is in
                        // sandbox)

                        if (parent instanceof IWorkspace) {
                            parent = (IVersionContainer) identifiableDao.load(Workspace.class, parent.getUID(),
                                    session, false);
                        } else {
                            parent = (IVersionContainer) identifiableDao.load(IVersionable.class,
                                    parent.getUID(), session, false);
                        }
                        // Refreshing progress
                        monitor.worked(1);
                        monitor.setTaskName("Committing to repository...");
                        // Adding sandbox merged object
                        mergedObject.setContainer(parent);
                        parent.getContents().add(mergedObject);
                        // Saving to sandbox before reloading view

                        identifiableDao.save(mergedObject);
                        session.flush();
                        // **************
                        // DES-710 urgent workaround
                        // Hibernate does not properly send the INSERT statements to the db
                        // But logs it properly in the logs !
                        final IRepositoryService repositoryService = CorePlugin.getRepositoryService();
                        final IDatabaseConnector connector = repositoryService.getRepositoryConnector();
                        final IConnection repositoryConnection = repositoryService.getRepositoryConnection();
                        Connection conn = null;
                        PreparedStatement stmt = null;
                        try {
                            conn = connector.connect(repositoryConnection);
                            String insertSql = null;
                            if (parent instanceof IWorkspace) {
                                insertSql = "INSERT INTO REP_VIEW_CONTENTS (VIEW_ID,VERSION_ID) VALUES (?,?)"; //$NON-NLS-1$
                            } else {
                                insertSql = "INSERT INTO REP_MODULE_CONTENTS (MODULE_ID,VERSION_ID) VALUES (?,?)"; //$NON-NLS-1$
                            }
                            stmt = conn.prepareStatement(insertSql);
                            stmt.setLong(1, parent.getUID().rawId());
                            stmt.setLong(2, mergedObject.getUID().rawId());
                            stmt.execute();
                            if (!conn.getAutoCommit()) {
                                conn.commit();
                            }
                        } catch (SQLException e) {
                            log.error(e);
                        } finally {
                            if (stmt != null) {
                                try {
                                    stmt.close();
                                } catch (SQLException e) {
                                    log.error(e);
                                }
                            }
                            if (conn != null) {
                                try {
                                    conn.close();
                                } catch (SQLException e) {
                                    log.error(e);
                                }
                            }
                        }
                        // End of DES-710 workaround
                        // **************

                        // HibernateUtil.getInstance().reconnectAll();
                        // Merger.save(mergedObject);
                        // Merger.save(parent);
                        monitor.worked(1);
                        log.info("Please wait while view is reloading...");
                        monitor.setTaskName("Finished: Reloading view...");
                        monitor.done();
                        // END OF the fixme part

                    }

                });
            } catch (Exception e) {
                throw new ErrorException(e);
            }

            // Restoring a new view
            log.info("Refreshing current view");
            VersionUIHelper.changeView(VersionHelper.getCurrentView().getUID());

            // Designer.getInstance().invokeSelection("com.neXtep.designer.vcs.SelectionInvoker",
            // "version.compare", comp);
        }
    }
    return null;
}

From source file:com.nextep.designer.vcs.ui.dialogs.VersionSettingsDialog.java

License:Open Source License

/**
 * Dispatches any current edition to the context. It is mainly meant to propagate the currently
 * edited release updates to all children.
 *///from  w  ww . j  a va 2 s . c  o  m
private void dispatchEditedRelease() {

    getUIComponentContainer().run(true, false, new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor m) throws InvocationTargetException, InterruptedException {
            SubMonitor monitor = SubMonitor.convert(m);
            monitor.beginTask(VCSUIMessages.getString("dialog.versionSettings.adjustReleaseTask"), //$NON-NLS-1$
                    100 * versionablesToReview.size());
            for (IVersionable<?> v : versionablesToReview) {
                final IVersionInfo targetVersion = context.getTargetVersionInfo(v);
                targetVersion.setActivity(context.getActivity());
                monitor.subTask(VCSUIMessages.getString("dialog.versionSettings.checkoutLookupTask")); //$NON-NLS-1$
                // Initializing checked out elements list
                Collection<IVersionable<?>> checkedOutChildren = new ArrayList<IVersionable<?>>();
                fillCheckedOutChildren((IVersionContainer) v, checkedOutChildren);
                monitor.worked(30);
                // Aligning every checked out children with the target version defined by the
                // user
                alignChildren(checkedOutChildren, targetVersion, monitor.newChild(40));
                monitor.setWorkRemaining(30);
                // Notifying
                monitor.subTask(VCSUIMessages.getString("dialog.versionSettings.workbenchNotificationTask")); //$NON-NLS-1$
                v.notifyListeners(ChangeEvent.MODEL_CHANGED, null);
            }
            monitor.done();
        }
    });
}