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

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

Introduction

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

Prototype

@Override
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable)
        throws InvocationTargetException, InterruptedException 

Source Link

Document

This implementation of IRunnableContext#run(boolean, boolean, IRunnableWithProgress) runs the given IRunnableWithProgress using the progress monitor for this progress dialog and blocks until the runnable has been run, regardless of the value of fork.

Usage

From source file:it.eng.spagobi.meta.editor.business.actions.GenerateJPAMappingAction.java

License:Mozilla Public License

/**
 * This executes the command.//w w  w.  j  a  va2 s.c o m
 */
@Override
public void run() {
    try {
        int returnCode = Window.CANCEL;

        BusinessModel businessModel = (BusinessModel) ((BusinessRootItemProvider) owner).getParentObject();

        // First, check if there are any physical model objects marked as deleted
        PhysicalModelInitializer physicalModelInitializer = new PhysicalModelInitializer();
        List<ModelObject> markedElements = physicalModelInitializer
                .getElementsMarkedAsDeleted(businessModel.getPhysicalModel());
        if (!markedElements.isEmpty()) {
            DeleteElementsWarningDialog warningDialog = new DeleteElementsWarningDialog(markedElements);
            warningDialog.create();
            warningDialog.setBlockOnOpen(true);
            returnCode = warningDialog.open();
            if (returnCode == Window.OK) {
                // execute a command for mass delete of elements marked as deleted
                DeletePhysicalModelObjectAction deletePhysicalModelObjectAction = new DeletePhysicalModelObjectAction();
                final Command deleteCommand = deletePhysicalModelObjectAction.createCommand(markedElements);
                // this guard is for extra security, but should not be necessary
                if (editingDomain != null && deleteCommand != null) {
                    // use up the command

                    ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(new Shell());
                    progressDialog.setCancelable(false);
                    try {
                        progressDialog.run(false, false, new IRunnableWithProgress() {
                            @Override
                            public void run(IProgressMonitor monitor) {
                                // Note: this is a non-UI Thread
                                monitor.beginTask("Deleting marked elements, please wait...",
                                        IProgressMonitor.UNKNOWN);
                                // doing task...

                                editingDomain.getCommandStack().execute(deleteCommand);

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

            }
        }

        if (markedElements.isEmpty() || returnCode != Window.CANCEL) {
            // check the constraints for hibernate mappings
            BusinessModelInitializer businessModelInitializer = new BusinessModelInitializer();
            List<Pair<BusinessRelationship, Integer>> incorrectRelationships = businessModelInitializer
                    .checkRelationshipsConstraints(businessModel);
            int relationshipsWarningReturnCode = Window.CANCEL;
            if (!incorrectRelationships.isEmpty()) {
                BusinessModelRelationshipsCheckWarningDialog warningDialog = new BusinessModelRelationshipsCheckWarningDialog(
                        incorrectRelationships);
                warningDialog.create();
                warningDialog.setBlockOnOpen(true);
                relationshipsWarningReturnCode = warningDialog.open();
            }

            if (incorrectRelationships.isEmpty() || relationshipsWarningReturnCode == Window.OK) {
                GenerateJPAMappingWizard wizard = new GenerateJPAMappingWizard(businessModel, editingDomain,
                        (ISpagoBIModelCommand) command);
                WizardDialog dialog = new WizardDialog(new Shell(), wizard);
                dialog.create();
                dialog.open();
            }

        }

    } catch (Throwable t) {
        t.printStackTrace();
    }
}

From source file:it.eng.spagobi.meta.editor.multi.wizards.SelectionConnectionPage.java

License:Mozilla Public License

@Override
public void createControl(Composite parent) {
    profiles = dseBridge.getConnectionProfiles();

    Composite container = new Composite(parent, SWT.NULL);
    setControl(container);//from w w w .j  a va  2 s  .  co  m
    container.setLayout(new GridLayout(1, false));

    Group grpConnection = new Group(container, SWT.NONE);
    grpConnection.setText(RL.getString("multi.editor.wizard.selectionconnection.label"));
    grpConnection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    FillLayout fl_grpConnection = new FillLayout(SWT.HORIZONTAL);
    grpConnection.setLayout(fl_grpConnection);

    ListViewer listViewer = new ListViewer(grpConnection, SWT.BORDER | SWT.V_SCROLL);
    connectionList = listViewer.getList();
    connectionList.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            // reset combos
            catalogCombo.removeAll();
            catalogCombo.setEnabled(false);
            schemaCombo.removeAll();
            schemaCombo.setEnabled(false);

            selectedConnectionName = connectionList.getSelection()[0];
            // ProgressMonitorDialog to show a progress bar for long
            // operation
            ProgressMonitorDialog dialog = new ProgressMonitorDialog(new Shell());
            dialog.setCancelable(false);

            try {
                dialog.run(true, false, new IRunnableWithProgress() {
                    @Override
                    public void run(IProgressMonitor monitor) {
                        // Note: this is a non-UI Thread
                        monitor.beginTask("Checking connection, please wait...", IProgressMonitor.UNKNOWN);
                        // doing task...
                        jdbcConnection = dseBridge.connect(selectedConnectionName);
                        monitor.done();
                    }
                });
            } catch (InvocationTargetException e1) {
                e1.printStackTrace();
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }

            if (jdbcConnection != null) {
                setErrorMessage(null);
                setPageComplete(true);
                populateCatalogCombo(jdbcConnection);
            } else {
                setPageComplete(false);
                ErrorDialog.openError(null, "Connection failed",
                        "Connection to database failed, please check your settings",
                        new org.eclipse.core.runtime.Status(IStatus.ERROR, "id",
                                "Connection to database failed"));
                setErrorMessage("Please select a valid connection to continue");
            }
        }
    });
    listViewer.setContentProvider(new ArrayContentProvider());
    listViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            return ((IConnectionProfile) element).getName();
        }
    });
    listViewer.setInput(profiles);
    Group grpCatalogAndSchema = new Group(container, SWT.NONE);
    grpCatalogAndSchema.setText(RL.getString("multi.editor.wizard.selectionconnection.catalogschema.label"));
    grpCatalogAndSchema.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
    grpCatalogAndSchema.setLayout(new FillLayout(SWT.HORIZONTAL));

    Composite composite = new Composite(grpCatalogAndSchema, SWT.NONE);
    composite.setLayout(new GridLayout(4, false));

    Label lblCatalog = new Label(composite, SWT.NONE);
    lblCatalog.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblCatalog.setText(RL.getString("multi.editor.wizard.selectionconnection.catalog.label"));

    catalogCombo = new Combo(composite, SWT.READ_ONLY);
    catalogCombo.setEnabled(false);
    catalogCombo.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            int selectionIndex = catalogCombo.getSelectionIndex();
            String selectedCatalog = catalogCombo.getItem(selectionIndex);
            populateSchemaCombo(jdbcConnection, selectedCatalog);
        }
    });
    catalogCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Label lblSchema = new Label(composite, SWT.NONE);
    lblSchema.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblSchema.setText(RL.getString("multi.editor.wizard.selectionconnection.schema.label"));

    schemaCombo = new Combo(composite, SWT.READ_ONLY);
    schemaCombo.setEnabled(false);
    schemaCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

}

From source file:it.eng.spagobi.meta.editor.multi.wizards.SpagoBIModelEditorWizard.java

License:Mozilla Public License

private void createPhysicalModel() {
    try {/*from  w  w  w.j  a v a2 s  .co m*/
        catalogName = null;
        schemaName = null;

        connectionName = selectionConnectionPage.getConnectionName();
        logger.debug("Connection name is [{}]", connectionName);

        connectionDriver = selectionConnectionPage.getConnectionDriver();
        logger.debug("Connection Driver is [{}]", connectionDriver);

        connectionUrl = selectionConnectionPage.getConnectionUrl();
        logger.debug("Connection URL is [{}]", connectionUrl);

        connectionUsername = selectionConnectionPage.getConnectionUsername();
        logger.debug("Connection username is [{}]", connectionUsername);

        connectionPassword = selectionConnectionPage.getConnectionPassword();
        logger.debug("Connection password is [{}]", connectionPassword);

        connectionDatabaseName = selectionConnectionPage.getConnectionDatabaseName();
        logger.debug("Connection databaseName is [{}]", connectionDatabaseName);

        // Getting Catalog Name
        if (selectionConnectionPage.getCatalogName() != null) {
            catalogName = selectionConnectionPage.getCatalogName();
            logger.debug("Connection catalog name is [{}]", catalogName);
        }
        // Getting Schema Name
        if (selectionConnectionPage.getSchemaName() != null) {
            schemaName = selectionConnectionPage.getSchemaName();
            logger.debug("Connection schema name is [{}]", schemaName);
        }

        // Getting table to import inside physical model
        TableItem[] selectedPhysicalTableItem = physicalTableSelectionPage.getTablesToImport();
        selectedPhysicalTable = new ArrayList<String>();
        for (TableItem item : selectedPhysicalTableItem) {
            selectedPhysicalTable.add(item.getText());
        }

        // Getting Model Name
        modelName = newModelWizardFileCreationPage.getModelName();
        // Getting JDBC Connection
        connection = selectionConnectionPage.getConnection();

        ProgressMonitorDialog dialogPhysicalModel = new ProgressMonitorDialog(new Shell());
        dialogPhysicalModel.setCancelable(false);
        dialogPhysicalModel.run(true, false, new IRunnableWithProgress() {
            @Override
            public void run(IProgressMonitor monitor) {
                // Note: this is a non-UI Thread
                monitor.beginTask("Generating Physical Model of SpagoBI Model, please wait...",
                        IProgressMonitor.UNKNOWN);

                // doing task...
                PhysicalModelInitializer physicalModelInitializer = new PhysicalModelInitializer();
                physicalModelInitializer.setRootModel(spagobiModel);

                // Physical Model initialization
                if (selectedPhysicalTable.isEmpty()) {
                    spagobiModel.getPhysicalModels()
                            .add(physicalModelInitializer.initialize(modelName, connection, connectionName,
                                    connectionDriver, connectionUrl, connectionUsername, connectionPassword,
                                    connectionDatabaseName, catalogName, schemaName));
                } else {
                    // with table filtering
                    spagobiModel.getPhysicalModels()
                            .add(physicalModelInitializer.initialize(modelName, connection, connectionName,
                                    connectionDriver, connectionUrl, connectionUsername, connectionPassword,
                                    connectionDatabaseName, catalogName, schemaName, selectedPhysicalTable));
                }

                monitor.done();
            }
        });
    } catch (InvocationTargetException t) {
        throw new RuntimeException("Impossible to initialize the physical model", t);
    } catch (InterruptedException e) {
        logger.error("Physical Model generation, InterruptedException [{}]", e);
        e.printStackTrace();
    }
}

From source file:it.eng.spagobi.meta.editor.multi.wizards.SpagoBIModelEditorWizard.java

License:Mozilla Public License

private void createBusinessModel() {
    try {/*  w w  w.  ja v  a 2 s .c  om*/

        // Getting physical table to import inside business table
        TableItem[] selectedBusinessTableItem = businessTableSelectionPage.getTablesToImport();
        selectedBusinessTable = new ArrayList<PhysicalTable>();
        PhysicalModel physicalModel = spagobiModel.getPhysicalModels().get(0);
        // check if there are no selected table to import in the Business Model
        if (selectedBusinessTableItem != null) {
            for (TableItem item : selectedBusinessTableItem) {
                PhysicalTable physicalTable = physicalModel.getTable(item.getText());
                selectedBusinessTable.add(physicalTable);
            }
        }

        ProgressMonitorDialog dialogBusinessModel = new ProgressMonitorDialog(new Shell());
        dialogBusinessModel.setCancelable(false);

        dialogBusinessModel.run(true, false, new IRunnableWithProgress() {
            @Override
            public void run(IProgressMonitor monitor) {
                // Note: this is a non-UI Thread
                monitor.beginTask("Generating Business Model of SpagoBI Model, please wait...",
                        IProgressMonitor.UNKNOWN);
                logger.debug("start monitor");
                // doing task...
                // Business Model initialization
                if (selectedBusinessTable.isEmpty()) {
                    // create empty Business Model
                    BusinessModelInitializer businessModelInitializer = new BusinessModelInitializer();
                    spagobiModel.getBusinessModels().add(businessModelInitializer
                            .initializeEmptyBusinessModel(modelName, spagobiModel.getPhysicalModels().get(0)));

                } else {
                    // with table filtering
                    BusinessModelInitializer businessModelInitializer = new BusinessModelInitializer();
                    spagobiModel.getBusinessModels()
                            .add(businessModelInitializer.initialize(modelName,
                                    new PhysicalTableFilter(selectedBusinessTable),
                                    spagobiModel.getPhysicalModels().get(0)));
                }
                // end of task
                logger.debug("end monitor");
                monitor.done();
            }
        });
    } catch (InterruptedException e) {
        logger.error("Business Model generation, InterruptedException [{}]", e);
        e.printStackTrace();
    } catch (Throwable t) {
        throw new RuntimeException("Impossible to initialize the business model", t);
    }
}

From source file:it.eng.spagobi.meta.editor.olap.actions.CreateMondrianAction.java

License:Mozilla Public License

/**
 * This executes the command.//  w w w .j a  v  a  2s .co  m
 */
@Override
public void run() {
    try {
        int returnCode = Window.CANCEL;

        BusinessModel businessModel = (BusinessModel) ((BusinessRootItemProvider) owner).getParentObject();

        // First, check if there are any physical model objects marked as deleted
        PhysicalModelInitializer physicalModelInitializer = new PhysicalModelInitializer();
        List<ModelObject> markedElements = physicalModelInitializer
                .getElementsMarkedAsDeleted(businessModel.getPhysicalModel());
        if (!markedElements.isEmpty()) {
            DeleteElementsWarningDialog warningDialog = new DeleteElementsWarningDialog(markedElements);
            warningDialog.create();
            warningDialog.setBlockOnOpen(true);
            returnCode = warningDialog.open();
            if (returnCode == Window.OK) {
                // execute a command for mass delete of elements marked as deleted
                DeletePhysicalModelObjectAction deletePhysicalModelObjectAction = new DeletePhysicalModelObjectAction();
                final Command deleteCommand = deletePhysicalModelObjectAction.createCommand(markedElements);
                // this guard is for extra security, but should not be necessary
                if (editingDomain != null && deleteCommand != null) {
                    // use up the command

                    ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(new Shell());
                    progressDialog.setCancelable(false);
                    try {
                        progressDialog.run(false, false, new IRunnableWithProgress() {
                            @Override
                            public void run(IProgressMonitor monitor) {
                                // Note: this is a non-UI Thread
                                monitor.beginTask("Deleting marked elements, please wait...",
                                        IProgressMonitor.UNKNOWN);
                                // doing task...

                                editingDomain.getCommandStack().execute(deleteCommand);

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

            }
        }

        if (markedElements.isEmpty() || returnCode != Window.CANCEL) {
            Model model = businessModel.getParentModel();
            OlapModel olapModel = model.getOlapModels().get(0);

            NewMondrianFileWizard wizard = new NewMondrianFileWizard(olapModel, editingDomain,
                    (ISpagoBIModelCommand) command);
            wizard.init(PlatformUI.getWorkbench(), new StructuredSelection());
            WizardDialog dialog = new WizardDialog(wizard.getShell(), wizard);
            dialog.create();
            dialog.open();
        }

    } catch (Throwable t) {
        t.printStackTrace();
    }
}

From source file:it.eng.spagobi.meta.model.physical.commands.update.UpdatePhysicalModelCommand.java

License:Mozilla Public License

@Override
public void execute() {
    logger.debug("Executing UpdatePhysicalModelCommand");

    physicalModel = (PhysicalModel) parameter.getOwner();

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(new Shell());
    dialog.setCancelable(false);//  w w w  .ja v a 2  s .com

    try {
        dialog.run(true, false, new IRunnableWithProgress() {
            @Override
            public void run(IProgressMonitor monitor) {
                // Note: this is a non-UI Thread
                monitor.beginTask("Updating Physical Model, please wait...", IProgressMonitor.UNKNOWN);
                // doing task...
                updatePhysicalModel(physicalModel);

                monitor.done();
            }
        });
    } catch (InvocationTargetException e1) {
        e1.printStackTrace();
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }
    showInformation("Info", "Physical Model Updated ");

}

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;//from  ww  w  .  j ava 2s .c o  m

    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;
    }//from   w  w  w .j a v  a 2  s  . c  o  m

    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 w w w. j ava  2  s  .  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;

}

From source file:it.eng.spagobi.studio.core.services.modelTemplate.RefreshModelService.java

License:Mozilla Public License

public void refreshModelTemplate() {

    IStructuredSelection sel = (IStructuredSelection) selection;

    // go on only if you selected a document (a file)
    Object objSel = sel.toList().get(0);
    File fileSel = null;/*from  ww w  .j a  va  2s.  c  o  m*/
    try {
        fileSel = (File) objSel;
        projectName = fileSel.getProject().getName();
        modelName = fileSel.getName();
    } catch (Exception e) {
        logger.error("No file selected", e);

        MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Not a file",
                "You must select a file to refresh");
        return;
    }

    logger.debug("get datamart.jar of model file name " + fileSel.getName());

    EmfXmiSerializer emfXmiSerializer = new EmfXmiSerializer();

    Model root = null;
    BusinessModel businessModel = null;
    try {
        root = emfXmiSerializer.deserialize(fileSel.getContents(true));
        logger.debug("Model root is [{}] ", root);
        businessModel = root.getBusinessModels().get(0);
        logger.debug("model " + businessModel.getName());
    } catch (Exception e) {
        logger.error("error in retrieving business model; try refreshing model folder ", e);
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Warning",
                "error in retrieving business model: try refreshing model folder");
        return;
    }
    final BusinessModel finalBusinessModel = businessModel;

    ProgressMonitorPart monitor;
    monitor = new ProgressMonitorPart(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), null);
    logger.debug("Do the model template refresh, model with name  " + modelName);

    final org.eclipse.core.internal.resources.File fileSel2 = fileSel;
    final NoDocumentException documentException = new NoDocumentException();
    final NoActiveServerException noActiveServerException = new NoActiveServerException();

    IRunnableWithProgress op = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) throws InvocationTargetException {

            monitor.beginTask("Template Refresh for model " + modelName, IProgressMonitor.UNKNOWN);

            // document associated, upload the template
            SpagoBIServerObjectsFactory spagoBIServerObjects = null;
            try {
                spagoBIServerObjects = new SpagoBIServerObjectsFactory(projectName);

                documentException.setNoDocument(false);
                Template mytemplate = spagoBIServerObjects.getServerDocuments()
                        .downloadDatamartFile(finalBusinessModel.getName(), modelName);
                if (mytemplate == null) {
                    logger.error("The download operation has returned a null object!");
                    documentException.setNoDocument(true);
                    return;
                }
                template.setContent(mytemplate.getContent());
                template.setFileName(mytemplate.getFileName());
                overwriteTemplate(template, fileSel2);
            }

            catch (NoActiveServerException e1) {
                noActiveServerException.setNoServer(true);
                return;
            } catch (RemoteException re) {
                logger.error("Error comunicating with server", re);
                MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                        "Error comunicating with server",
                        "Error while uploading the template: missing comunication with server");
                return;
            } catch (CoreException ec) {
                logger.error("Error in fie creation", ec);
                MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                        "Error in file creation", "Error in file creation");
                return;
            }

            monitor.done();
            if (monitor.isCanceled())
                logger.error("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;
    } catch (InterruptedException e1) {
        logger.error("Error comunicating with server");
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error",
                "Missing comunication with server; check server definition and if service is avalaible");
        dialog.close();
        return;
    }
    if (noActiveServerException.isNoServer()) {
        logger.error("No server is defined active");
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error",
                "No server is defined active");
        return;
    }
    // check if document has been found (could have been deleted) 
    if (documentException.isNoDocument() || template.getContent() == null) {
        logger.warn("Document no more present on server or no permission " + modelName);
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error upload",
                "Document not retrieved; check it is still on server and you have enough permission to reach it. Make a new Upload.");
        return;
    }

    dialog.close();

    String succesfullMessage = "Succesfully replaced with the last model template (" + modelName + ")";

    logger.debug(succesfullMessage);
    MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
            "Refresh succesfull", succesfullMessage);

}