Example usage for org.eclipse.jface.dialogs ProgressMonitorDialog close

List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog close

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs ProgressMonitorDialog close.

Prototype

@Override
public boolean close() 

Source Link

Document

The ProgressMonitorDialog implementation of this method only closes the dialog if there are no currently running runnables.

Usage

From source file:com.microsoft.tfs.client.eclipse.ui.actions.sync.ExternalCompareAction.java

License:Open Source License

@Override
public void run() {
    final AdaptedSelectionInfo selectionInfo = ActionHelpers.adaptSelectionToStandardResources(
            getStructuredSelection(), PluginResourceFilters.IN_REPOSITORY_FILTER, false);

    if (ActionHelpers.ensureNonZeroResourceCountAndSingleRepository(selectionInfo, getShell()) == false) {
        return;/*w  w w .  j a  v  a  2s . co m*/
    }

    final IResource localResource = selectionInfo.getResources()[0];

    String localFile = localResource.exists() ? localResource.getLocation().toOSString() : null;
    String remoteTempFile = null;

    /*
     * Open a progress dialog because we'll be fetching content from the
     * server.
     */
    final ProgressMonitorDialog monitorDialog = new ProgressMonitorDialog(getShell());
    monitorDialog.open();

    final IProgressMonitor progressMonitor = monitorDialog.getProgressMonitor();
    progressMonitor.beginTask(Messages.getString("ExternalCompareAction.ProgressText"), 100); //$NON-NLS-1$

    try {
        /*
         * If the local file doesn't exist (due to deletion or incoming
         * addition, etc) then we need to make a dummy blank file for it so
         * that the external compare tool doesn't choke.
         */
        if (localFile == null) {
            try {
                final File tempDir = TempStorageService.getInstance().createTempDirectory();

                localFile = File.createTempFile("LocalNonexistant", //$NON-NLS-1$
                        "." + localResource.getFileExtension(), //$NON-NLS-1$
                        tempDir).getAbsolutePath();
            } catch (final IOException e) {
                log.error("Error creating an empty local file as substitute for missing resource", e); //$NON-NLS-1$
                // let the localFile == null test show errors
            }
        }

        /*
         * Get the remote file as a temp file.
         */
        try {
            final SyncInfo syncInfo = SynchronizeSubscriber.getInstance().getSyncInfo(localResource);

            if (syncInfo != null) {
                final IResourceVariant variant = syncInfo.getRemote();

                // variant is non-null normally...
                if (variant != null) {
                    final SubProgressMonitor getMonitor = new SubProgressMonitor(progressMonitor, 75);
                    final IStorage storage = variant.getStorage(getMonitor);

                    // if there's a path to the storage, then the remote
                    // item
                    // was found normally
                    if (storage != null && storage.getFullPath() != null) {
                        remoteTempFile = storage.getFullPath().toOSString();
                    }

                    // otherwise, the remote item is a deletion or a rename,
                    // create a blank temp file for the external compare
                    // tool
                    else {
                        final File tempDir = TempStorageService.getInstance().createTempDirectory();

                        remoteTempFile = File.createTempFile("RemoteNonexistant", //$NON-NLS-1$
                                "." + localResource.getFileExtension(), //$NON-NLS-1$
                                tempDir).getAbsolutePath();
                    }
                }
            }
        } catch (final Exception e) {
            log.error("Error getting the remote file contents", e); //$NON-NLS-1$
            // suppress, fall-through to remoteFile == null test
        }
    } finally {
        progressMonitor.done();
        monitorDialog.close();
    }

    // SynchronizeSusbcriber.getSyncInfo().getRemote().getStorage()
    // should always return (even when in-sync, it will hit the
    // server intelligently.)
    if (remoteTempFile == null) {
        MessageDialog.openError(getShell(), Messages.getString("ExternalCompareAction.CompareErrorDialogTitle"), //$NON-NLS-1$
                Messages.getString("ExternalCompareAction.CompareErrorDialogText")); //$NON-NLS-1$
        return;
    }

    final Compare compare = new Compare();

    compare.setModified(CompareUtils.createCompareElementForLocalPath(localFile, ResourceType.FILE));

    compare.setOriginal(CompareUtils.createCompareElementForLocalPath(remoteTempFile, ResourceType.FILE));

    compare.addComparator(TFSItemContentComparator.INSTANCE);

    compare.setExternalCompareHandler(new UserPreferenceExternalCompareHandler(getShell()));
    compare.open();
}

From source file:com.salesforce.ide.schemabrowser.ui.SchemaBrowser.java

License:Open Source License

private void createTree(Composite composite) {
    imageNotChecked = ForceImages.get(ForceImages.IMAGE_NOT_CHECKED);
    imageChecked = ForceImages.get(ForceImages.IMAGE_CHECKED);
    imageArrowDown = ForceImages.get(ForceImages.IMAGE_ARROW_DOWN);
    imageArrowUp = ForceImages.get(ForceImages.IMAGE_ARROW_UP);
    imageBlank = ForceImages.get(ForceImages.IMAGE_BLANK);

    final Composite thisComposite = composite;

    provider = new SchemaTreeLabelProvider();

    Tree tree = this.schemaEditorComposite.getTree();
    tree.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            if (event.item instanceof TreeItem) {
                selectedItem = (TreeItem) event.item;
            } else {
                selectedItem = null;/*from   ww  w. j  a v  a 2 s .c  o  m*/
            }
        }

    });
    tree.addTreeListener(new org.eclipse.swt.events.TreeListener() {
        public void treeExpanded(org.eclipse.swt.events.TreeEvent e) {
            final TreeItem selectedItem = (TreeItem) e.item;
            Boolean isTopLevel = (Boolean) selectedItem.getData(IS_TOP_LEVEL);
            if ((isTopLevel != null) && isTopLevel.booleanValue()) {
                if (selectedItem.getItemCount() == 1) {
                    Runnable lt = new Runnable() {
                        public void run() {
                            ProgressMonitorDialog mon = new ProgressMonitorDialog(getShell());
                            mon.getProgressMonitor();
                            mon.setBlockOnOpen(false);
                            mon.open();
                            loadTreeData(selectedItem, thisComposite, mon.getProgressMonitor());
                            setHasCheckableChildren(selectedItem, Boolean.TRUE);
                            setIsTopLevel(selectedItem, Boolean.TRUE);
                            setItemNotChecked(selectedItem);
                            selectedItem.setImage(
                                    provider.getImage(0, selectedItem.getText(), selectedItem.getParent()));
                            mon.close();
                        }
                    };
                    Runnable lb = new Runnable() {
                        public void run() {
                            ProgressMonitorDialog mon = new ProgressMonitorDialog(getShell());
                            mon.getProgressMonitor();
                            mon.setBlockOnOpen(false);
                            mon.open();
                            mon.getProgressMonitor().beginTask("Get object definition...", 2);
                            loadObject(selectedItem.getText(), mon.getProgressMonitor());
                            mon.close();
                        }
                    };

                    getSite().getShell().getDisplay().asyncExec(lb);
                    getSite().getShell().getDisplay().asyncExec(lt);
                }
            } else {
                Integer type = (Integer) selectedItem.getData(TYPE);
                if (type != null) {
                    if (type.equals(SchemaBrowser.CHILD_RELATIONSHIP_NODE)
                            && selectedItem.getData(LOADED).equals(Boolean.FALSE)) {
                        Runnable getThisChildSchema = new Runnable() {
                            public void run() {
                                ProgressMonitorDialog mon = new ProgressMonitorDialog(getShell());
                                mon.getProgressMonitor();
                                mon.setBlockOnOpen(false);
                                mon.open();
                                mon.getProgressMonitor().beginTask(MESSAGE_GETTING_CHILD, 2);
                                loadOneChildRelationship(selectedItem, mon.getProgressMonitor());
                                mon.close();
                            }
                        };

                        getSite().getShell().getDisplay().asyncExec(getThisChildSchema);

                    } else if (SchemaBrowser.LOOKUP_RELATIONSHIP_NODE.equals(type)
                            && Boolean.FALSE.equals(selectedItem.getData(LOADED))) {
                        Runnable getThisChildSchema = new Runnable() {
                            public void run() {
                                ProgressMonitorDialog mon = new ProgressMonitorDialog(getShell());
                                mon.getProgressMonitor();
                                mon.setBlockOnOpen(false);
                                mon.open();
                                mon.getProgressMonitor().beginTask(MESSAGE_GETTING_LOOKUP, 2);
                                loadOneChildRelationship(selectedItem, mon.getProgressMonitor());
                                mon.close();
                            }
                        };

                        getSite().getShell().getDisplay().asyncExec(getThisChildSchema);
                    }
                }

            }
            wasExpanded = true;
        }

        public void treeCollapsed(org.eclipse.swt.events.TreeEvent e) {
            wasExpanded = true;
        }
    });

    tree.addMouseListener(new org.eclipse.swt.events.MouseListener() {
        public void mouseUp(org.eclipse.swt.events.MouseEvent e) {
            if (!wasExpanded) {
                if (selectedItem != null) {
                    if (selectedItem.getImage() != null) {
                        Rectangle rect = selectedItem.getBounds();
                        Image img = selectedItem.getImage();
                        Rectangle imgRect = img.getBounds();
                        int leftMost = rect.x - imgRect.width - 3;
                        int rightMost = rect.x - 3;
                        if ((e.x >= leftMost) && (e.x <= rightMost)) {
                            Integer imageType = (Integer) selectedItem.getData(IMAGE_TYPE);
                            if (imageType != null) {
                                if (imageType.intValue() == IMAGE_TYPE_CHECKED) {
                                    setItemChecked(selectedItem);
                                } else {
                                    setItemNotChecked(selectedItem);
                                }

                                Integer type = (Integer) selectedItem.getData(TYPE);
                                if (SchemaBrowser.CHILD_RELATIONSHIP_NODE.equals(type)
                                        && Boolean.FALSE.equals(selectedItem.getData(LOADED))) {
                                    if ((selectedItem.getData(LOADED) != null)
                                            && Boolean.FALSE.equals(selectedItem.getData(LOADED))) {
                                        Runnable getThisChildSchema = new Runnable() {
                                            public void run() {
                                                ProgressMonitorDialog mon = new ProgressMonitorDialog(
                                                        getShell());
                                                mon.getProgressMonitor();
                                                mon.setBlockOnOpen(false);
                                                mon.open();
                                                mon.getProgressMonitor().beginTask(MESSAGE_GETTING_CHILD, 2);
                                                loadOneChildRelationship(selectedItem,
                                                        mon.getProgressMonitor());
                                                mon.close();
                                            }
                                        };

                                        getSite().getShell().getDisplay().syncExec(getThisChildSchema);

                                    }
                                } else if (SchemaBrowser.LOOKUP_RELATIONSHIP_NODE.equals(type)
                                        && Boolean.FALSE.equals(selectedItem.getData(LOADED))) {
                                    Runnable getThisChildSchema = new Runnable() {
                                        public void run() {
                                            ProgressMonitorDialog mon = new ProgressMonitorDialog(getShell());
                                            mon.getProgressMonitor();
                                            mon.setBlockOnOpen(false);
                                            mon.open();
                                            mon.getProgressMonitor().beginTask(MESSAGE_GETTING_LOOKUP, 2);
                                            loadOneChildRelationship(selectedItem, mon.getProgressMonitor());
                                            mon.close();
                                        }
                                    };

                                    getSite().getShell().getDisplay().asyncExec(getThisChildSchema);
                                }

                                setChildren(selectedItem,
                                        ((Integer) selectedItem.getData(IMAGE_TYPE)).intValue());

                                while (selectedItem.getParentItem() != null) {
                                    TreeItem parent = selectedItem.getParentItem();
                                    boolean setParent = true;
                                    for (int i = 0; i < parent.getItemCount(); i++) {
                                        if (!parent.getItem(i).equals(selectedItem)
                                                && parent.getItem(i).getImage().equals(imageChecked)) {
                                            setParent = false;
                                            break;
                                        }
                                    }

                                    if (!setParent) {
                                        break;
                                    }
                                    if (imageType.intValue() == 0) {
                                        setItemChecked(parent);
                                    } else {
                                        setItemNotChecked(parent);
                                    }
                                    selectedItem = parent;
                                }
                                fireSelectionChanged(selectedItem);
                            }
                        }
                    }
                }
            }
            wasExpanded = false;
        }

        public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e) {
        }

        public void mouseDown(org.eclipse.swt.events.MouseEvent e) {
        }
    });
    initialize();
}

From source file:de.tukl.cs.softech.agilereview.views.reviewexplorer.handler.CleanupHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

    IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getActiveMenuSelection(event);
    Object firstElement = selection.getFirstElement();

    if (firstElement instanceof MultipleReviewWrapper) {
        MultipleReviewWrapper reviewWrapper = ((MultipleReviewWrapper) firstElement);

        if (!checkReviewOpen(event, reviewWrapper)) {
            return null;
        }/*ww w  .  java2  s  . co  m*/

        // ask user whether to delete comments and tags or only tags
        boolean deleteComments = true;
        MessageBox messageDialog = new MessageBox(HandlerUtil.getActiveShell(event),
                SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.CANCEL);
        messageDialog.setText("AgileReview Cleanup");
        messageDialog.setMessage("Delete comments? Otherwise they will be converted to global comments!");
        int result = messageDialog.open();

        if (result == SWT.CANCEL) {
            // cancel selected -> quit method
            return null;
        } else if (result == SWT.NO) {
            deleteComments = false;
        }

        // get selected project
        try {
            ProgressMonitorDialog pmd = new ProgressMonitorDialog(HandlerUtil.getActiveShell(event));
            pmd.open();
            pmd.run(true, false, new CleanupProcess(reviewWrapper.getWrappedReview(), deleteComments));
            pmd.close();
        } catch (InvocationTargetException e) {
            PluginLogger.logError(this.getClass().toString(), "execute", "InvocationTargetException", e);
            MessageDialog.openError(HandlerUtil.getActiveShell(event), "Error while performing cleanup",
                    "An Eclipse internal error occured!\nRetry and please report the bug to the AgileReview team when it occurs again.\nCode:1");
        } catch (InterruptedException e) {
            PluginLogger.logError(this.getClass().toString(), "execute", "InterruptedException", e);
            MessageDialog.openError(HandlerUtil.getActiveShell(event), "Error while performing cleanup",
                    "An Eclipse internal error occured!\nRetry and please report the bug to the AgileReview team when it occurs again.\nCode:2");
        }
    }

    if (ViewControl.isOpen(CommentTableView.class)) {
        CommentTableView.getInstance().reparseAllEditors();
    }
    ViewControl.refreshViews(ViewControl.COMMMENT_TABLE_VIEW | ViewControl.REVIEW_EXPLORER, true);

    return null;
}

From source file:eu.modelwriter.marker.ui.internal.wizards.markallinwswizard.MarkAllInWsWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    final Object[] checkedElements = MarkAllInWsPage.checkboxTreeViewer.getCheckedElements();
    final String text = this.textSelection.getText();
    final String leader_id = UUID.randomUUID().toString();
    boolean success = false;

    final Image image = MarkerActivator.getDefault().getImageRegistry()
            .get(MarkerActivator.Images.IMAGE_MODELWRITER_ID);
    final ProgressMonitorDialog pmd = new ProgressMonitorDialog(
            Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell());
    ProgressMonitorDialog.setDefaultImage(image);
    pmd.open();// ww w.  jav  a 2s  .c  o  m
    final IProgressMonitor pmdmoni = pmd.getProgressMonitor();
    try {
        pmdmoni.beginTask("Marking", checkedElements.length);
        for (int i = 0; i < checkedElements.length && !pmdmoni.isCanceled(); i++) {
            try {
                if (checkedElements[i] instanceof IFile) {
                    final IFile iFile = (IFile) checkedElements[i];
                    pmdmoni.subTask(iFile.getName());
                    pmdmoni.worked(1);

                    if (!iFile.getFileExtension().equals("xmi") && !iFile.getFileExtension().equals("ecore")
                            && !iFile.getFileExtension().equals("reqif")) {
                        final String charSet = iFile.getCharset();
                        final Scanner scanner = new Scanner(iFile.getContents(), charSet);
                        final IDocument document = new Document(scanner.useDelimiter("\\A").next());
                        scanner.close();

                        final String fullText = document.get();
                        boolean hasLeader = false;
                        int index = 0;
                        int offset = 0;
                        final int lenght = this.textSelection.getLength();
                        final String id = UUID.randomUUID().toString();

                        if (lenght != 0) {
                            while ((offset = fullText.indexOf(text, index)) != -1) {
                                final TextSelection nextSelection = new TextSelection(document, offset, lenght);
                                if (MarkerFactory.findMarkerByOffset(iFile, offset) == null) {
                                    final IMarker mymarker = MarkerFactory.createMarker(iFile, nextSelection);
                                    MarkUtilities.setGroupId(mymarker, id);
                                    if (!iFile.equals(this.file)) {
                                        if (hasLeader == false) {
                                            MarkUtilities.setLeaderId(mymarker, leader_id);
                                            hasLeader = true;
                                        }
                                    } else {
                                        if (this.textSelection.getOffset() == offset) {
                                            MarkUtilities.setLeaderId(mymarker, leader_id);
                                        }
                                    }

                                    this.addToAlloyXML(mymarker);
                                    AnnotationFactory.addAnnotation(mymarker,
                                            AnnotationFactory.ANNOTATION_MARKING);
                                }
                                index = offset + lenght;
                            }
                        }
                        success = true;
                    } else {
                        final MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(),
                                "Mark All In Workspace", null,
                                iFile.getName() + " doesn't supported for this command.",
                                MessageDialog.INFORMATION, new String[] { "OK" }, 0);
                        dialog.open();
                        MarkAllInWsPage.checkboxTreeViewer.setChecked(iFile, false);
                    }
                }
            } catch (final CoreException e) {
                e.printStackTrace();
            }
        }
    } finally {
        pmdmoni.done();
    }
    pmd.close();

    if (success == true) {
        final MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "Mark All In Workspace",
                null, "Selected project(s) have been marked by selected text", MessageDialog.INFORMATION,
                new String[] { "OK" }, 0);
        dialog.open();
        return true;
    } else {
        return false;
    }
}

From source file:eu.numberfour.n4js.ui.dialog.ModuleSpecifierSelectionDialog.java

License:Open Source License

@Override
protected void createPressed() {
    InputDialog dialog = new InputDialog(getShell(), CREATE_A_NEW_FOLDER_TITLE, CREATE_A_NEW_FOLDER_MESSAGE, "",
            new ModuleFolderValidator());
    dialog.open();//  w ww. j a v a  2 s.  c  o  m

    Object selection = treeViewer.getStructuredSelection().getFirstElement();

    // Infer parent folder from selection
    IContainer parent;
    if (selection instanceof IFile) {
        parent = ((IFile) selection).getParent();
    } else if (selection instanceof IContainer) {
        parent = (IContainer) selection;
    } else { // Use the source folder as default
        parent = this.sourceFolder;
    }

    String dialogValue = dialog.getValue();

    if (OSInfo.isWindows()) {
        dialogValue = convertToUnixPath(dialogValue);
    }

    IPath folderPath = new Path(dialogValue);
    IContainer createdFolder = null;

    if (Window.OK == dialog.getReturnCode()) {
        ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(getShell());
        progressMonitorDialog.open();
        IProgressMonitor progressMonitor = progressMonitorDialog.getProgressMonitor();

        createdFolder = createFolderPath(folderPath, parent, null);

        progressMonitor.done();
        progressMonitorDialog.close();

        if (null != createdFolder) {
            treeViewer.setSelection(new StructuredSelection(createdFolder));
        }
    }

}

From source file:eu.numberfour.n4js.ui.dialog.ModuleSpecifierSelectionDialog.java

License:Open Source License

/**
 * Processes the initial string selection.
 *
 * For existing resources it just sets the initial selection to the specified file system resource.
 *
 * In the case that the initial module specifier points to a non-existing location, a dialog is displayed which
 * allows the user to automatically create not yet existing folders.
 *
 * @param initialModuleSpecifier/*  ww w.ja v a2 s .  com*/
 *            The module specifier
 * @return A {@link IWorkbenchAdapter} adaptable object or null on failure
 */
private Object processInitialSelection(String initialModuleSpecifier) {

    IPath sourceFolderPath = sourceFolder.getFullPath();
    IPath initialModulePath = new Path(initialModuleSpecifier);

    // Use the root element source folder for an empty initial selection
    if (initialModuleSpecifier.isEmpty()) {
        return this.sourceFolder;
    }

    // Use the root element source folder for invalid module specifiers
    if (!WorkspaceWizardValidatorUtils.isValidFolderPath(initialModulePath)) {
        return this.sourceFolder;
    }

    // The project relative path of a module specifier
    IPath fullPath = sourceFolderPath.append(new Path(initialModuleSpecifier));

    // If the module specifier refers to an existing n4js resource
    if (!fullPath.hasTrailingSeparator()) {
        IFile n4jsModuleFile = workspaceRoot
                .getFile(fullPath.addFileExtension(N4JSGlobals.N4JS_FILE_EXTENSION));
        IFile n4jsdModuleFile = workspaceRoot
                .getFile(fullPath.addFileExtension(N4JSGlobals.N4JSD_FILE_EXTENSION));

        // Just use it as initial selection
        if (n4jsModuleFile.exists()) {
            return n4jsModuleFile;
        }
        if (n4jsdModuleFile.exists()) {
            return n4jsdModuleFile;
        }

    }

    //// Otherwise use the existing part of the path as initial selection:

    // If the module specifier specifies the module name, extract it and remove its segment.
    if (isModuleFileSpecifier(initialModulePath)) {
        initialModuleName = initialModulePath.lastSegment();
        initialModulePath = initialModulePath.removeLastSegments(1);
    }

    IResource selection = this.sourceFolder;

    // Accumulate path segments to search for the longest existing path
    IPath accumulatedPath = sourceFolderPath;

    // Collect the paths of all non-existing segments
    // These are relative to the last existing segment of the path
    List<IPath> nonExistingSegmentPaths = new ArrayList<>();

    for (Iterator<String> segmentIterator = Arrays.asList(initialModulePath.segments())
            .iterator(); segmentIterator.hasNext(); /**/) {

        accumulatedPath = accumulatedPath.append(segmentIterator.next());

        // Results in null if non-existing
        IResource nextSegmentResource = workspaceRoot.findMember(accumulatedPath);

        // If the current segment is an existing file and not the last specifier segment
        // show a file overlap error message
        if (null != nextSegmentResource && !(nextSegmentResource instanceof IContainer)
                && segmentIterator.hasNext()) {

            MessageDialog.open(MessageDialog.ERROR, getShell(), SPECIFIER_OVERLAPS_WITH_FILE_TITLE, String
                    .format(SPECIFIER_OVERLAPS_WITH_FILE_MESSAGE, initialModuleSpecifier, accumulatedPath),
                    SWT.NONE);

            return selection;
        }

        // If the segment exist go ahead with the next one
        if (null != nextSegmentResource && nextSegmentResource.exists()) {
            selection = nextSegmentResource;
        } else { // If not add it to the list of non existing segments.
            nonExistingSegmentPaths.add(accumulatedPath.makeRelativeTo(selection.getFullPath()));
        }
    }

    // If any non-existing folders need to be created
    if (nonExistingSegmentPaths.size() > 0) {
        // Ask the user if he wants to create the missing folders
        boolean create = MessageDialog.open(MessageDialog.QUESTION, getShell(),
                NON_EXISTING_MODULE_LOCATION_TITLE, NON_EXISTING_MODULE_LOCATION_MESSAGE, SWT.NONE);

        // Create the missing folders
        if (create) {
            ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(getShell());
            progressMonitorDialog.open();
            IProgressMonitor progressMonitor = progressMonitorDialog.getProgressMonitor();

            IPath deepestPath = nonExistingSegmentPaths.get(nonExistingSegmentPaths.size() - 1);
            selection = createFolderPath(deepestPath, (IContainer) selection, progressMonitor);

            progressMonitor.done();
            progressMonitorDialog.close();
        }

    }
    return selection;
}

From source file:gov.us.fhim.ui.actions.ImportSpreadsheet.java

License:Open Source License

/**
 * @see IActionDelegate#run(IAction)/*from  w w w. j  a  v a 2s. c om*/
 */
public void run(IAction action) {

    ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell);

    ObjectPluginAction opa = (ObjectPluginAction) action;

    final TreeSelection selection = (TreeSelection) opa.getSelection();

    final String ActionTitle = "Import Terminology";

    final FileDialog fdlg = new FileDialog(shell, SWT.SINGLE);

    fdlg.setText("Select Terminology Source File");

    fdlg.setFilterNames(FILTER_NAMES);
    fdlg.setFilterExtensions(FILTER_EXTS);

    IRunnableWithProgress runnableWithProgress = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {

            IWorkspaceRoot myWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot();

            File f = (File) selection.getFirstElement();

            String umlPath = myWorkspaceRoot.getLocation().toOSString() + f.getFullPath().toOSString();

            try {
                importMapping(monitor, umlPath, fdlg);
            } catch (Exception e) {
                e.printStackTrace();
            }

            try {
                myWorkspaceRoot.refreshLocal(IResource.DEPTH_INFINITE, null);
            } catch (CoreException e) {
            }

            if (monitor.isCanceled()) {
                monitor.done();
                return;
            }

            monitor.done();

        }

    };

    try {
        if (fdlg.open() != null) {
            progressDialog.run(false, true, runnableWithProgress);
            MetricsDialog dlg = new MetricsDialog(shell);
            dlg.create();
            dlg.open();
        }

    } catch (InvocationTargetException invocationTargetException) {
        MessageDialog.openError(shell, ActionTitle,
                "Error Processing Export " + invocationTargetException.getMessage());

    } catch (InterruptedException interruptedException) {
        MessageDialog.openError(shell, ActionTitle,
                "Error Processing Export " + interruptedException.getMessage());

    } finally {
        progressDialog.close();

    }
}

From source file:it.eng.spagobi.studio.core.properties.DocumentPropertyPageSettings.java

License:Mozilla Public License

public Control createContents(final Composite _container) {
    logger.debug("IN");
    container = _container;/*  w w  w  .  ja v a 2  s  .  c om*/

    monitor = new ProgressMonitorPart(container.getShell(), null);

    String documentIdS = null;
    try {
        documentIdS = fileSel.getPersistentProperty(SpagoBIStudioConstants.DOCUMENT_ID);
    } catch (CoreException e2) {
        logger.error("Error in retrieving Id", e2);
    }
    if (documentIdS != null)
        documentId = Integer.valueOf(documentIdS);
    else
        documentId = null;

    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.horizontalSpacing = 10;

    Composite servers = new Composite(container, SWT.NULL);
    servers.setLayout(layout);

    Label titleLabel = new Label(servers, SWT.NULL);
    titleLabel.setForeground(new Color(servers.getDisplay(), SpagoBIStudioConstants.BLUE));
    titleLabel.setText("Current active server ");
    activeServerLabel = new Label(servers, SWT.NULL);

    titleLabel = new Label(servers, SWT.NULL);
    titleLabel.setForeground(new Color(servers.getDisplay(), SpagoBIStudioConstants.BLUE));
    titleLabel.setText("Last server deployd: ");
    prevServerLabel = new Label(servers, SWT.NULL);

    Button buttonRefresh = new Button(servers, SWT.PUSH);
    buttonRefresh.setText("Refresh Metadata on active server");

    docGroup = new Group(container, SWT.NULL);
    docGroup.setText("Document's information:");
    docGroup.setLayout(new FillLayout());
    Composite docContainer = new Composite(docGroup, SWT.NULL);
    docContainer.setLayout(layout);

    dataSetGroup = new Group(container, SWT.NULL);
    dataSetGroup.setText("Dataset's information:");
    dataSetGroup.setLayout(new FillLayout());
    Composite datasetContainer = new Composite(dataSetGroup, SWT.NULL);
    datasetContainer.setLayout(layout);

    dataSourceGroup = new Group(container, SWT.NULL);
    dataSourceGroup.setText("Datasource's information:");
    dataSourceGroup.setLayout(new FillLayout());
    Composite datasourceContainer = new Composite(dataSourceGroup, SWT.NULL);
    datasourceContainer.setLayout(layout);

    engineGroup = new Group(container, SWT.NULL);
    engineGroup.setText("Engine's information:");
    engineGroup.setLayout(new FillLayout());
    Composite engineContainer = new Composite(engineGroup, SWT.NULL);
    engineContainer.setLayout(layout);

    parametersGroup = new Group(container, SWT.NULL);
    parametersGroup.setText("Parameters's information:");
    parametersGroup.setLayout(new FillLayout());
    Composite parametersContainer = new Composite(parametersGroup, SWT.NULL);
    parametersContainer.setLayout(layout);

    new Label(docContainer, SWT.NULL).setText(SpagoBIStudioConstants.DOCUMENT_ID.getLocalName());
    documentIdValue = new Label(docContainer, SWT.NULL);
    new Label(docContainer, SWT.NULL).setText(SpagoBIStudioConstants.DOCUMENT_LABEL.getLocalName());
    documentLabelValue = new Label(docContainer, SWT.NULL);
    new Label(docContainer, SWT.NULL).setText(SpagoBIStudioConstants.DOCUMENT_NAME.getLocalName());
    documentNameValue = new Label(docContainer, SWT.NULL);
    new Label(docContainer, SWT.NULL).setText(SpagoBIStudioConstants.DOCUMENT_DESCRIPTION.getLocalName());
    documentDescriptionValue = new Label(docContainer, SWT.NULL);
    new Label(docContainer, SWT.NULL).setText(SpagoBIStudioConstants.DOCUMENT_TYPE.getLocalName());
    documentTypeValue = new Label(docContainer, SWT.NULL);
    new Label(docContainer, SWT.NULL).setText(SpagoBIStudioConstants.DOCUMENT_STATE.getLocalName());
    documentStateValue = new Label(docContainer, SWT.NULL);
    new Label(engineContainer, SWT.NULL).setText(SpagoBIStudioConstants.ENGINE_ID.getLocalName());
    engineIdValue = new Label(engineContainer, SWT.NULL);
    new Label(engineContainer, SWT.NULL).setText(SpagoBIStudioConstants.ENGINE_LABEL.getLocalName());
    engineLabelValue = new Label(engineContainer, SWT.NULL);
    new Label(engineContainer, SWT.NULL).setText(SpagoBIStudioConstants.ENGINE_NAME.getLocalName());
    engineNameValue = new Label(engineContainer, SWT.NULL);
    new Label(engineContainer, SWT.NULL).setText(SpagoBIStudioConstants.ENGINE_DESCRIPTION.getLocalName());
    engineDescriptionValue = new Label(engineContainer, SWT.NULL);
    new Label(datasetContainer, SWT.NULL).setText(SpagoBIStudioConstants.DATASET_ID.getLocalName());
    datasetIdValue = new Label(datasetContainer, SWT.NULL);
    new Label(datasetContainer, SWT.NULL).setText(SpagoBIStudioConstants.DATASET_LABEL.getLocalName());
    datasetLabelValue = new Label(datasetContainer, SWT.NULL);
    new Label(datasetContainer, SWT.NULL).setText(SpagoBIStudioConstants.DATASET_NAME.getLocalName());
    datasetNameValue = new Label(datasetContainer, SWT.NULL);
    new Label(datasetContainer, SWT.NULL).setText(SpagoBIStudioConstants.DATASET_DESCRIPTION.getLocalName());
    datasetDescriptionValue = new Label(datasetContainer, SWT.NULL);
    new Label(datasourceContainer, SWT.NULL).setText(SpagoBIStudioConstants.DATA_SOURCE_ID.getLocalName());
    dataSourceIdValue = new Label(datasourceContainer, SWT.NULL);
    new Label(datasourceContainer, SWT.NULL).setText(SpagoBIStudioConstants.DATA_SOURCE_LABEL.getLocalName());
    dataSourceLabelValue = new Label(datasourceContainer, SWT.NULL);
    new Label(datasourceContainer, SWT.NULL).setText(SpagoBIStudioConstants.DATA_SOURCE_NAME.getLocalName());
    dataSourceNameValue = new Label(datasourceContainer, SWT.NULL);
    new Label(datasourceContainer, SWT.NULL)
            .setText(SpagoBIStudioConstants.DATA_SOURCE_DESCRIPTION.getLocalName());
    dataSourceDescriptionValue = new Label(datasourceContainer, SWT.NULL);

    parametersTable = new Table(parametersContainer,
            SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL);
    parametersTable.setLinesVisible(true);
    parametersTable.setHeaderVisible(true);
    String[] titles = { "Parameter Name", "Parameter Url" };
    for (int i = 0; i < titles.length; i++) {
        TableColumn column = new TableColumn(parametersTable, SWT.NONE);
        column.setText(titles[i]);
    }
    for (int i = 0; i < titles.length; i++) {
        parametersTable.getColumn(i).pack();
    }

    new Label(container, SWT.NULL).setText(SpagoBIStudioConstants.LAST_REFRESH_DATE.getLocalName());
    lastRefreshDateLabel = new Label(container, SWT.NULL);
    try {
        fillValues();
    } catch (Exception e) {
        MessageDialog.openError(container.getShell(), "Error", "Error while retrieving metadata informations");
        logger.error("Error in retrieving metadata", e);
    }

    // refresh button listener
    Listener refreshListener = new Listener() {
        public void handleEvent(Event event) {

            if (documentId == null) {
                logger.error("Cannot retrieve metadata cause no document is associated");
                MessageDialog.openWarning(container.getShell(), "Warning",
                        "No document is associated: cannot retrieve metadata");
            } else {
                final NoDocumentException noDocumentException = new NoDocumentException();
                final NoActiveServerException noActiveServerException = new NoActiveServerException();

                IRunnableWithProgress op = new IRunnableWithProgress() {
                    public void run(IProgressMonitor monitor) throws InvocationTargetException {
                        monitor.beginTask("Refreshing ", IProgressMonitor.UNKNOWN);
                        try {
                            new MetadataHandler().refreshMetadata(fileSel, noDocumentException,
                                    noActiveServerException);
                        } catch (Exception e) {
                            logger.error("Error in monitor retieving metadata ", e);
                            MessageDialog.openError(container.getShell(), "Exception", "Exception");
                        }
                    }
                };
                ProgressMonitorDialog dialog = new ProgressMonitorDialog(container.getShell());
                try {
                    dialog.run(true, true, op);
                } catch (InvocationTargetException e1) {
                    logger.error("No comunication with SpagoBI server: could not refresh metadata", e1);
                    dialog.close();
                    MessageDialog.openError(container.getShell(), "Error",
                            "No comunication with server: Could not refresh metadata");
                    return;
                } catch (InterruptedException e1) {
                    logger.error("No comunication with SpagoBI server: could not refresh metadata", e1);
                    dialog.close();
                    MessageDialog.openError(container.getShell(), "Error",
                            "No comunication with server: Could not refresh metadata");
                    return;
                }

                dialog.close();

                if (noActiveServerException.isNoServer()) {
                    logger.error("No Server is defined active");
                    MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                            "Error refresh", "No Server is defined active");
                    return;
                }
                if (noDocumentException.isNoDocument()) {
                    logger.error(
                            "Document not retrieved; check it is still on server and you have enough permission to reach it");
                    MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                            "Error",
                            "Document not retrieved; check it is still on server and you have enough permission to reach it");
                    return;
                }

                try {
                    // fill current values
                    fillValues();
                } catch (Exception e) {
                    MessageDialog.openError(container.getShell(), "Error",
                            "Error while retrieving metadata informations from file");
                    logger.error("Error in retrieving metadata informations from file", e);
                    return;
                }

                MessageDialog.openInformation(container.getShell(), "Information", "Metadata refreshed");
            }
        }
    };

    buttonRefresh.addListener(SWT.Selection, refreshListener);

    return container;
}

From source file:it.eng.spagobi.studio.core.services.datamartTemplate.UploadDatamartTemplateService.java

License:Mozilla Public License

boolean generateJarAndUpload(BusinessModel businessModel, File fileSel) {
    // generate the jar

    // Create temp dir
    long ll = System.currentTimeMillis();
    String UUID = Long.valueOf(ll).toString();

    String tempDirPath = System.getProperty("java.io.tmpdir");
    logger.debug("Temp dir is: " + tempDirPath + " check if ends with " + java.io.File.pathSeparator);
    if (!tempDirPath.endsWith(java.io.File.separator)) {
        tempDirPath += java.io.File.separator;
    }/* w  w w  .  j a va  2s .com*/

    String idFolderPath = businessModel.getName() + "_" + UUID;
    String tempDirPathId = tempDirPath + idFolderPath;
    logger.debug("create model in temporary folder " + tempDirPathId);

    try {
        ModelManager modelManager = new ModelManager(businessModel.getParentModel());
        modelManager.setMappingsFolder(new java.io.File(tempDirPathId));
        modelManager.setModelFile(fileSel);
        modelManager.generateMapping(false);
    } catch (Exception e) {
        logger.error("Error in generating the datamart for model " + businessModel.getName(), e);
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error",
                "Error in generating datamart.jar for model " + businessModel.getName());
        return false;
    }
    logger.debug("model datamart.jar created in " + tempDirPathId);

    // search for file datamart.jar, is rooted in the folder created
    String pathToSearch = tempDirPathId + java.io.File.separator + businessModel.getName()
            + java.io.File.separator + "dist" + java.io.File.separator + DATAMART_JAR;
    logger.debug("try reatrieving datamart.jar file " + pathToSearch);
    Path tmppath = new Path(pathToSearch);
    java.io.File datamart = tmppath.toFile();
    if (datamart == null) {
        logger.error("could not retrieve file " + pathToSearch);
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error",
                "could not retrieve file " + pathToSearch);
        return false;
    } else {
        logger.debug("found file " + businessModel.getName() + "/dist/datamart.jar");
    }

    // search for non mandatory file calculatedFields, rooted in the folder created too
    // String pathToSearchXml = tempDirPathId + java.io.File.separator + businessModel.getName() + java.io.File.separator +
    // "dist"+java.io.File.separator +CALCULATED_FIELD;
    // logger.debug("try reatrieving calculatedFields xml file "+pathToSearch);
    // Path tmppathXml = new Path(pathToSearchXml);
    // java.io.File xmlFile = tmppathXml.toFile();
    // if(xmlFile == null || !xmlFile.exists()){
    // logger.warn("Xml file for calculate dields was not found in "+pathToSearchXml);
    // xmlFile = null;
    // }
    // else{
    // logger.debug("found file for calculate dfields in "+pathToSearchXml+"/dist/datamart.jar");
    // }

    SpagoBIServerObjectsFactory spagoBIServerObjects = null;
    try {
        spagoBIServerObjects = new SpagoBIServerObjectsFactory(projectname);
    } catch (NoActiveServerException e) {
        logger.error("No server is defined active");
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error",
                "No server is defined active");
    }

    final NoActiveServerException noActiveServerException = new NoActiveServerException();

    IRunnableWithProgress monitorCheckExistance = getMonitorCheckExistance(businessModel, spagoBIServerObjects,
            fileSel);
    IRunnableWithProgress monitorForDatasources = getMonitorForDatasources(businessModel, spagoBIServerObjects);
    IRunnableWithProgress monitorForCategory = getMonitorForCategory(businessModel, spagoBIServerObjects);
    IRunnableWithProgress monitorForUpload = getMonitorForUpload(businessModel, spagoBIServerObjects, datamart,
            fileSel);

    // Start monitor for upload operation
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());

    try {

        // the dataSource should be asked only if there is not already a documetn present with datamartnamein system

        // check if document is already present
        dialog.run(true, true, monitorCheckExistance);

        if (!modelAlreadyPresent) {
            // get datasources
            dialog.run(true, true, monitorForCategory);

            // ask datasource to user
            if (domains != null) {
                logger.debug("found " + (domains != null ? domains.length : "0")
                        + " category domains: make user choose one");

                String[] domOptionsArray = null;
                if (domains != null) {
                    Map<String, Domain> mapLabelToDomain = new HashMap<String, Domain>();
                    int size = domains.length;
                    domOptionsArray = new String[size];
                    for (int i = 0; i < domains.length; i++) {
                        Domain dom = domains[i];
                        mapLabelToDomain.put(dom.getValueCd(), dom);
                        domOptionsArray[i] = dom.getValueCd();
                    }
                }

                final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
                ComboSelectionDialog csd = new ComboSelectionDialog(shell);
                csd = new ComboSelectionDialog(shell);
                csd.setMessage("Select Category for model (optional)");
                csd.setText("Category Selection");
                csd.setOptions(domOptionsArray);
                logger.debug("Open category selection dialog");
                userCategory = csd.open();
                logger.debug("user selected category  " + userCategory);
            }
        }

        if (!modelAlreadyPresent || !documentAlreadyPresent) {
            // get datasources
            dialog.run(true, true, monitorForDatasources);

            // ask datasource to user
            if (dataSources != null) {
                logger.debug("found " + (dataSources != null ? dataSources.length : "0")
                        + " datasources: make user choose one");

                String[] dsOptionsArray = null;
                if (dataSources != null) {
                    Map<String, DataSource> mapLabelToDatasource = new HashMap<String, DataSource>();
                    int size = dataSources.length;
                    dsOptionsArray = new String[size];
                    for (int i = 0; i < dataSources.length; i++) {
                        DataSource ds = dataSources[i];
                        mapLabelToDatasource.put(ds.getLabel(), ds);
                        dsOptionsArray[i] = ds.getLabel();
                    }
                }

                final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
                ComboSelectionDialog csd = new ComboSelectionDialog(shell);
                csd.setMessage("Select data source for QBE document (optional)");
                csd.setText("Data source Selection");
                csd.setOptions(dsOptionsArray);
                logger.debug("Open datasource selection dialog");
                userDataSource = csd.open();
                logger.debug("user selected dataSource " + userDataSource);
            }
        }

        // do the uploads
        dialog.run(true, true, monitorForUpload);
    } catch (InvocationTargetException e1) {
        logger.error("error in uploading datamart", e1);
        String detailMessage = e1.getTargetException() != null
                ? "\n\nDetail: " + e1.getTargetException().getMessage()
                : "";
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "error",
                "Error in uploading datamart: check if the server definition is right, if the server is avaiable and the model file is not in use/locked on server."
                        + detailMessage);
        dialog.close();
        return false;
    } catch (Exception e1) {
        logger.error("error in uploading datamart", e1);
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "error",
                "error in uploading datamart: check if the server definition is right and the server is avaiable");
        dialog.close();
        return false;
    }
    dialog.close();

    if (noActiveServerException.isNoServer()) {
        logger.error("No server is defined active");
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error",
                "No server is defined active");
        return false;
    }

    // if here success
    MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
            "Upload succesfull", "Succesfully uploaded to resources\n\n" + messageStatusDocument);
    logger.debug("Uploaded to resources in " + businessModel.getName());

    // delete the temporary file

    try {
        Path pathToDelete = new Path(tempDirPathId);
        java.io.File toDelete = pathToDelete.toFile();
        boolean deleted = toDelete.delete();
        if (deleted) {
            logger.warn("deleted folder " + tempDirPathId);
        }
    } catch (Exception e) {
        logger.warn("could not delete folder " + tempDirPathId);
    }
    logger.debug("OUT");
    return true;
}

From source file:it.eng.spagobi.studio.core.services.dataset.DeployDatasetService.java

License:Mozilla Public License

/** if document has meadata associated do the automated deploy
 * /*from   ww  w .  ja va 2s.c om*/
 * @return if automated eply has been done
 */
public boolean tryAutomaticDeploy() {
    logger.debug("IN");

    IStructuredSelection sel = (IStructuredSelection) selection;

    // go on only if ysou selected a document
    Object objSel = sel.toList().get(0);
    org.eclipse.core.internal.resources.File fileSel = null;
    fileSel = (org.eclipse.core.internal.resources.File) objSel;
    projectname = fileSel.getProject().getName();

    //if file has document metadata associated upload it, else call wizard

    String datasetId = null;
    String datasetLabel = null;
    String datasetCategory = null;
    try {
        datasetId = fileSel.getPersistentProperty(SpagoBIStudioConstants.DATASET_ID);
        datasetLabel = fileSel.getPersistentProperty(SpagoBIStudioConstants.DATASET_LABEL);
        datasetCategory = fileSel.getPersistentProperty(SpagoBIStudioConstants.DATASET_CATEGORY);
    } catch (CoreException e) {
        logger.error("Error in retrieving dataset Label", e);
    }

    // IF File selected has already an id of datasetassociated do the upload wiyhout asking further informations
    boolean automatic = false;
    boolean newDeployFromOld = false;
    if (datasetId != null) {
        logger.debug("Query already associated to dataset" + datasetId + " - " + datasetLabel
                + " - of category " + datasetCategory);
        final Integer idInteger = Integer.valueOf(datasetId);
        final String label2 = datasetLabel;
        final org.eclipse.core.internal.resources.File fileSel2 = fileSel;
        final NoDocumentException datasetException = new NoDocumentException();
        final NoActiveServerException noActiveServerException = new NoActiveServerException();
        final NotAllowedOperationStudioException notAllowedOperationStudioException = new NotAllowedOperationStudioException();
        IRunnableWithProgress op = new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException {
                monitor.beginTask(
                        "Deploying to dataset existing dataset with label: " + label2 + " and ID: " + idInteger,
                        IProgressMonitor.UNKNOWN);

                if (projectname == null) {
                    projectname = fileSel2.getProject().getName();
                }

                try {
                    logger.debug("dataset associated, upload the query to dataset " + label2);

                    SpagoBIServerObjectsFactory spagoBIServerObjects = new SpagoBIServerObjectsFactory(
                            projectname);

                    // check dataset still exists
                    IDataSet ds = spagoBIServerObjects.getServerDatasets().getDataSet(idInteger);
                    if (ds == null) {
                        datasetException.setNoDocument(true);
                        logger.warn("Dataset no more present on server: with id " + idInteger);
                    } else {
                        logger.debug("update query to dataset");

                        String queryStr = null;
                        String adaptedQueryStrList = null;
                        try {
                            JSONObject obj = JSONReader.createJSONObject(fileSel2);
                            queryStr = obj.optString("query");
                            logger.debug("query is " + queryStr);
                            adaptedQueryStrList = DeployDatasetService.adaptQueryToList(queryStr);
                            logger.debug("adapted query list is " + adaptedQueryStrList);

                            //solvedeccoqui
                            // only the query may be modified by meta so it is the only refreshed
                            ds.addToConfiguration(Dataset.QBE_JSON_QUERY, adaptedQueryStrList);
                            //ds.setJsonQuery(adaptedQueryStrList);
                            datasetException.setNoDocument(false);
                            Integer dsId = spagoBIServerObjects.getServerDatasets().saveDataSet(ds);
                            if (ds == null) {
                                logger.error("Error while uploading dataset on server; check log on server");
                                MessageDialog.openError(
                                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                                        "Error on deploy",
                                        "Error while uploading dataset; check server log to have details");

                            }

                            BiObjectUtilities.setFileDataSetMetaData(fileSel2, ds);

                        } catch (Exception e) {
                            logger.error("error in reading JSON object, update failed", e);
                        }

                    }
                }

                catch (NoActiveServerException e1) {
                    // no active server found 
                    noActiveServerException.setNoServer(true);
                } catch (RemoteException e) {
                    if (e.getClass().toString().equalsIgnoreCase(
                            "class it.eng.spagobi.sdk.exceptions.NotAllowedOperationException")) {
                        logger.error("Current User has no permission to deploy dataset", e);
                        notAllowedOperationStudioException.setNotAllowed(true);
                    } else {
                        logger.error("Error comunicating with server", e);
                        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                                "Error comunicating with server",
                                "Error while uploading the template: missing comunication with server");
                    }
                }

                monitor.done();
                if (monitor.isCanceled())
                    logger.error("Operation not ended",
                            new InterruptedException("The long running operation was cancelled"));
            }
        };

        ProgressMonitorDialog dialog = new ProgressMonitorDialog(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
        try {
            dialog.run(true, true, op);
        } catch (InvocationTargetException e1) {
            logger.error("Error comunicating with server", e1);
            MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error",
                    "Missing comunication with server; check server definition and if service is avalaible");
            dialog.close();
            return false;
        } catch (InterruptedException e1) {
            logger.error("Error comunicating with server", e1);
            MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error",
                    "Missing comunication with server; check server definition and if service is avalaible");
            dialog.close();
            return false;
        }
        if (datasetException.isNoDocument()) {
            logger.error("Document no more present");
            MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    "Error upload",
                    "Dataset with ID " + idInteger + "  no more present on server; you can do a new deploy");
            sbdw.setNewDeployFromOld(true);
            newDeployFromOld = true;
        }
        if (noActiveServerException.isNoServer()) {
            logger.error("No server is defined active");
            MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error",
                    "No server is defined active");
            return false;
        }

        dialog.close();

        if (notAllowedOperationStudioException.isNotAllowed()) {
            logger.error("Current User has no permission to deploy dataset");
            MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "",
                    "Current user has no permission to deploy dataset");
            return false;
        }

        if (!newDeployFromOld) {
            MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                    "Deploy succesfull", "Deployed to the associated dataset with label: " + datasetLabel
                            + " and ID: " + idInteger + " succesfull");
            logger.debug(
                    "Deployed to the associated document " + datasetLabel + " succesfull: ID: is " + idInteger);
            automatic = true;
        }
    } else {
        automatic = false;
    }

    if (!automatic || newDeployFromOld) {
        logger.debug("deploy a new Dataset: start wizard");
        // init wizard
        sbdw.init(PlatformUI.getWorkbench(), sel);
        // Create the wizard dialog
        WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                sbdw);
        dialog.setPageSize(650, 300);
        // Open the wizard dialog
        dialog.open();
    }

    logger.debug("OUT");
    return automatic;

}