Search in sources :

Example 6 with IComparisonLevel

use of org.talend.cwm.compare.factory.IComparisonLevel in project tdq-studio-se by Talend.

the class ReloadDatabaseAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    returnCode = new ReturnCode(true);
    if (!isSupport()) {
        // $NON-NLS-1$
        returnCode.setReturnCode(Messages.getString("ReloadDatabaseAction.NotSupportMessage"), false);
        return;
    }
    // MOD TDQ-7528 20130627 yyin: if needCompare=false,no need to popup select compare dialog
    if (this.needCompare) {
        // popup a dialog to warn the user better do the compare before the reload, and provide two buttons:
        // if the user click the compare button, the compare will be executed.
        // if the user click the reload button, the reload will continue.
        // $NON-NLS-1$
        String[] dialogButtonLabels = { Messages.getString("ReloadDatabaseAction.ReloadLabel") };
        MessageDialog dialog = new MessageDialog(CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString("ReloadDatabaseAction.ReloadLabel"), null, Messages.getString("ReloadDatabaseAction.IsContinue"), 3, dialogButtonLabels, // $NON-NLS-1$ //$NON-NLS-2$
        SWT.NONE);
        int open = dialog.open();
        // when click close, do nothing.
        if (open == -1) {
            return;
        }
    // when click compare
    // if (open == 0) {
    // // go to compare instead of reloading now
    // new PopComparisonUIAction(selectedObject, Messages.getString("ReloadDatabaseAction.CompareLabel")).run();//$NON-NLS-1$
    // returnCode.setReturnCode(Messages.getString("ReloadDatabaseAction.IsContinue"), false);//$NON-NLS-1$
    // return;
    // }// ~
    }
    Connection conn = getConnection();
    List<ModelElement> dependencyClients = EObjectHelper.getDependencyClients(conn);
    if (!(dependencyClients == null || dependencyClients.isEmpty())) {
        int isOk = DeleteModelElementConfirmDialog.showElementImpactConfirmDialog(null, new ModelElement[] { conn }, // $NON-NLS-1$
        DefaultMessagesImpl.getString("TOPRepositoryService.dependcyTile"), // $NON-NLS-1$
        DefaultMessagesImpl.getString("TOPRepositoryService.dependcyMessage", conn.getLabel()));
        if (isOk != Dialog.OK) {
            // $NON-NLS-1$
            returnCode.setReturnCode("The user canceled the operation!", false);
            return;
        }
    }
    IRunnableWithProgress op = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException {
            final IComparisonLevel creatComparisonLevel = ComparisonLevelFactory.creatComparisonLevel(selectedObject);
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    try {
                        Connection oldDataProvider = creatComparisonLevel.reloadCurrentLevelElement();
                        // MOD mzhao 2009-07-13 bug 7454 Impact existing analysis.
                        // MOD qiongli 2011-9-8,move method 'impactExistingAnalyses(...)' to class WorkbenchUtils
                        // update the sql explore.
                        Property property = PropertyHelper.getProperty(oldDataProvider);
                        if (property != null) {
                            Item newItem = property.getItem();
                            if (newItem != null) {
                                CWMPlugin.getDefault().updateConnetionAliasByName(oldDataProvider, oldDataProvider.getLabel());
                            }
                        }
                        // update the related analyses.
                        WorkbenchUtils.impactExistingAnalyses(oldDataProvider);
                        // Update software system.
                        updateSoftwareSystem(oldDataProvider);
                    } catch (ReloadCompareException e) {
                        // $NON-NLS-1$
                        MessageUI.openError(Messages.getString("ReloadDatabaseAction.Error", e.getMessage()));
                        log.error(e, e);
                        returnCode.setReturnCode(e.getMessage(), false);
                    } catch (PartInitException e) {
                        log.error(e, e);
                        returnCode.setReturnCode(e.getMessage(), false);
                    }
                }
            });
        }
    };
    try {
        ProgressUI.popProgressDialog(op);
        CorePlugin.getDefault().refreshDQView(selectedObject);
    } catch (InvocationTargetException e) {
        // $NON-NLS-1$
        MessageUI.openError(Messages.getString("ReloadDatabaseAction.checkConnectionFailured", e.getCause().getMessage()));
        log.error(e, e);
    } catch (InterruptedException e) {
        log.error(e, e);
    }
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) PartInitException(org.eclipse.ui.PartInitException) Property(org.talend.core.model.properties.Property) IComparisonLevel(org.talend.cwm.compare.factory.IComparisonLevel)

Example 7 with IComparisonLevel

use of org.talend.cwm.compare.factory.IComparisonLevel in project tdq-studio-se by Talend.

the class TOPRepositoryService method reloadTableList.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.core.ITDQRepositoryService#reloadTableList(org.talend.core.model.properties.DatabaseConnectionItem)
     */
public void reloadTableList(final DatabaseConnectionItem hiveConnectionItem2) {
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRunnable operation = new IWorkspaceRunnable() {

        public void run(IProgressMonitor monitor) throws CoreException {
            RepositoryNode tableFolder = TableUtils.getTableFolder(hiveConnectionItem2);
            if (tableFolder != null) {
                IComparisonLevel creatComparisonLevel = ComparisonLevelFactory.creatComparisonLevel(tableFolder);
                try {
                    creatComparisonLevel.reloadCurrentLevelElement();
                } catch (ReloadCompareException e) {
                    log.error(e, e);
                }
                CorePlugin.getDefault().refreshDQView(tableFolder);
            }
        }
    };
    try {
        workspace.run(operation, null);
    } catch (CoreException e) {
        log.error(e, e);
    }
}
Also used : IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IWorkspace(org.eclipse.core.resources.IWorkspace) ReloadCompareException(org.talend.cwm.compare.exception.ReloadCompareException) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IComparisonLevel(org.talend.cwm.compare.factory.IComparisonLevel)

Aggregations

IComparisonLevel (org.talend.cwm.compare.factory.IComparisonLevel)7 ReloadCompareException (org.talend.cwm.compare.exception.ReloadCompareException)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)3 Connection (org.talend.core.model.metadata.builder.connection.Connection)3 PartInitException (org.eclipse.ui.PartInitException)2 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)2 ConnectionItem (org.talend.core.model.properties.ConnectionItem)2 Item (org.talend.core.model.properties.Item)2 Property (org.talend.core.model.properties.Property)2 TdColumn (org.talend.cwm.relational.TdColumn)2 IFolderNode (org.talend.dq.nodes.foldernode.IFolderNode)2 ReturnCode (org.talend.utils.sugars.ReturnCode)2 ColumnSet (orgomg.cwm.resource.relational.ColumnSet)2 IWorkspace (org.eclipse.core.resources.IWorkspace)1 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)1 CoreException (org.eclipse.core.runtime.CoreException)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1