Search in sources :

Example 1 with AbstractCommand

use of org.eclipse.emf.common.command.AbstractCommand in project tmdm-studio-se by Talend.

the class XSDEditor2 method innerSave.

private void innerSave(final IProgressMonitor monitor) {
    IRepositoryViewObject viewObject = getCurrentViewObject();
    final Item item = viewObject.getProperty().getItem();
    int activePage = getActivePage();
    // 
    final TransactionalEditingDomain editingDomain = (TransactionalEditingDomain) getAdapter(TransactionalEditingDomain.class);
    if (editingDomain != null && (activePage != MODEL_PAGE_INDEX && activePage != SOURCE_PAGE_INDEX)) {
        editingDomain.getCommandStack().execute(new AbstractCommand() {

            @Override
            public boolean canExecute() {
                return true;
            }

            @Override
            public void redo() {
            // do nothing
            }

            @Override
            public void execute() {
                doSave(item, monitor);
            }
        });
    } else {
        doSave(item, monitor);
    }
    DeployService deployService = DeployService.getInstance();
    if (deployService.isAutoDeploy()) {
        deployService.autoDeploy(getSite().getShell(), viewObject);
    } else {
        MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(item);
        if (lastServerDef != null) {
            CommandManager.getInstance().pushCommand(ICommand.CMD_MODIFY, viewObject);
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) AbstractCommand(org.eclipse.emf.common.command.AbstractCommand) DeployService(org.talend.mdm.repository.core.service.DeployService) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Aggregations

AbstractCommand (org.eclipse.emf.common.command.AbstractCommand)1 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)1 Item (org.talend.core.model.properties.Item)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 DeployService (org.talend.mdm.repository.core.service.DeployService)1 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)1