Search in sources :

Example 1 with RenameViewDialog

use of org.talend.mdm.repository.ui.dialogs.RenameViewDialog in project tmdm-studio-se by Talend.

the class RenameViewAction method renameViewObject.

private void renameViewObject(IRepositoryViewObject viewObj) {
    MDMServerObjectItem item = (MDMServerObjectItem) viewObj.getProperty().getItem();
    MDMServerObject serverObject = item.getMDMServerObject();
    IProxyRepositoryFactory factory = getFactory();
    try {
        if (serverObject != null) {
            String oldName = serverObject.getName();
            RenameViewDialog dialog = getRenameDialog(oldName);
            int returnCode = dialog.open();
            if (returnCode == IDialogConstants.OK_ID) {
                String newName = dialog.getValue();
                if (RepositoryTransformUtil.getInstance().getViewType(oldName) == TYPE_WEBFILTER) {
                    newName = PREFIX_VIEW_UPPER + newName;
                } else {
                    if (newName.startsWith(PREFIX_VIEW_UPPER)) {
                        viewTypeChanged = true;
                        item.getState().setPath(IPath.SEPARATOR + PATH_WEBFILTER);
                    }
                }
                if (newName != null && factory.isEditableAndLockIfPossible(item)) {
                    serverObject.setName(newName);
                    viewObj.getProperty().setLabel(newName);
                    viewObj.getProperty().setDisplayName(newName);
                    factory.save(viewObj.getProperty().getItem(), false);
                    MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(viewObj);
                    if (lastServerDef != null) {
                        CommandManager.getInstance().pushCommand(ICommand.CMD_RENAME, viewObj.getId(), new String[] { oldName, newName });
                    }
                }
                commonViewer.refresh(viewObj);
            }
        }
    } catch (PersistenceException e) {
        log.error(e.getMessage(), e);
    } finally {
        try {
            factory.unlock(item);
        } catch (PersistenceException e) {
            log.error(e.getMessage(), e);
        } catch (LoginException e) {
            log.error(e.getMessage(), e);
        }
    }
}
Also used : MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) PersistenceException(org.talend.commons.exception.PersistenceException) RenameViewDialog(org.talend.mdm.repository.ui.dialogs.RenameViewDialog) LoginException(org.talend.commons.exception.LoginException) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 2 with RenameViewDialog

use of org.talend.mdm.repository.ui.dialogs.RenameViewDialog in project tmdm-studio-se by Talend.

the class RenameViewAction method getRenameDialog.

private RenameViewDialog getRenameDialog(String oldName) {
    RenameViewDialog dialog = null;
    IWorkbenchPartSite site = commonViewer.getCommonNavigator().getSite();
    if (RepositoryTransformUtil.getInstance().getViewType(oldName) == TYPE_WEBFILTER) {
        dialog = new RenameViewDialog(getShell(), Messages.RenameObjectAction_rename, Messages.Common_rename, oldName.substring(PREFIX_VIEW_UPPER.length()), getInputValidator(), site);
    } else {
        dialog = new RenameViewDialog2(getShell(), Messages.RenameObjectAction_rename, Messages.Common_rename, oldName, getInputValidator(), site);
    }
    return dialog;
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) RenameViewDialog2(org.talend.mdm.repository.ui.dialogs.RenameViewDialog2) RenameViewDialog(org.talend.mdm.repository.ui.dialogs.RenameViewDialog)

Aggregations

RenameViewDialog (org.talend.mdm.repository.ui.dialogs.RenameViewDialog)2 IWorkbenchPartSite (org.eclipse.ui.IWorkbenchPartSite)1 LoginException (org.talend.commons.exception.LoginException)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)1 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)1 MDMServerObject (org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)1 RenameViewDialog2 (org.talend.mdm.repository.ui.dialogs.RenameViewDialog2)1 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)1