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);
}
}
Aggregations