Search in sources :

Example 1 with IDuplicateHandle

use of org.talend.dataprofiler.core.ui.action.actions.handle.IDuplicateHandle in project tdq-studio-se by Talend.

the class DuplicateAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.ui.actions.AContextualAction#doRun()
     */
@Override
protected void doRun() {
    repositoryObjectCRUD.refreshDQViewForRemoteProject();
    // ADD msjian TDQ-7006 2013-7-24: after refresh get the selection to check.
    if (!repositoryObjectCRUD.isSelectionAvailable()) {
        repositoryObjectCRUD.showWarningDialog();
        return;
    }
    try {
        String newLabel = null;
        Item lastDuplicateItem = null;
        for (final IRepositoryNode node : nodeArray) {
            IRepositoryViewObject viewObject = node.getObject();
            validateOriginalObject(viewObject);
            final IDuplicateHandle handle = ActionHandleFactory.getInstance().createDuplicateHandle(node);
            if (handle != null) {
                // MOD msjian TDQ-4672 2012-2-17: modified the check duplicate name method
                String initLabel = generateInitialLabel(node);
                InputDialog dialog = createInputNewNameDialog(node, initLabel);
                // TDQ-4672~
                if (dialog.open() == Window.OK) {
                    newLabel = dialog.getValue().trim();
                    lastDuplicateItem = handle.duplicateItem(viewObject.getProperty().getItem(), newLabel);
                }
            } else {
                // if can not find the related handler for the current node, log it and continue for others
                // $NON-NLS-1$
                log.error(DefaultMessagesImpl.getString("DuplicateAction.HandleNull", node.getLabel()));
            }
        }
        // if the user select cancel, the item will be null, then no need to refresh.
        if (lastDuplicateItem != null) {
            CorePlugin.getDefault().refreshWorkSpace();
            // show the last new success duplicated one as selected on the repository view.
            selectAndReveal(newLabel, lastDuplicateItem);
        }
    } catch (BusinessException e) {
        ExceptionHandler.process(e, Level.FATAL);
    }
}
Also used : Item(org.talend.core.model.properties.Item) TDQFileItem(org.talend.dataquality.properties.TDQFileItem) BusinessException(org.talend.commons.exception.BusinessException) IDuplicateHandle(org.talend.dataprofiler.core.ui.action.actions.handle.IDuplicateHandle) InputDialog(org.eclipse.jface.dialogs.InputDialog) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Aggregations

InputDialog (org.eclipse.jface.dialogs.InputDialog)1 BusinessException (org.talend.commons.exception.BusinessException)1 Item (org.talend.core.model.properties.Item)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 IDuplicateHandle (org.talend.dataprofiler.core.ui.action.actions.handle.IDuplicateHandle)1 TDQFileItem (org.talend.dataquality.properties.TDQFileItem)1 IRepositoryNode (org.talend.repository.model.IRepositoryNode)1