Search in sources :

Example 11 with ICommand

use of org.talend.mdm.repository.core.command.ICommand in project tmdm-studio-se by Talend.

the class TransformerMainPage2 method isReferedViewObjModified.

private boolean isReferedViewObjModified() {
    IEditorInput editorInput = editor2.getEditorInput();
    if (editorInput instanceof XObjectEditorInput2) {
        XObjectEditorInput2 editorInput2 = (XObjectEditorInput2) editorInput;
        IRepositoryViewObject viewObj = editorInput2.getViewObject();
        CommandStack stack = CommandManager.getInstance().findCommandStack(viewObj.getId());
        if (stack != null) {
            ICommand command = stack.getValidDeployCommand();
            if (command.getCommandType() == ICommand.CMD_MODIFY) {
                return true;
            }
        }
    }
    return false;
}
Also used : CommandStack(org.talend.mdm.repository.core.command.CommandStack) ICommand(org.talend.mdm.repository.core.command.ICommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IEditorInput(org.eclipse.ui.IEditorInput)

Example 12 with ICommand

use of org.talend.mdm.repository.core.command.ICommand in project tmdm-studio-se by Talend.

the class UpdateLastServerService method updateLastServerDefInfo.

public void updateLastServerDefInfo(Object serverDef, IRepositoryViewObject ViewObject) {
    if (serverDef == null || ViewObject == null || !(serverDef instanceof MDMServerDef)) {
        return;
    }
    CommandManager cmdManager = CommandManager.getInstance();
    DeployService deployService = DeployService.getInstance();
    ICommand deployCmd = cmdManager.getNewCommand(ICommand.CMD_MODIFY);
    deployCmd.init(ViewObject);
    // $NON-NLS-1$ //$NON-NLS-2$
    MultiStatus mStatus = new MultiStatus("PLUGIN_ID", Status.OK, "", null);
    // $NON-NLS-1$
    DeployStatus deployStatus = DeployStatus.getOKStatus(deployCmd, "");
    mStatus.add(deployStatus);
    cmdManager.removeCommandStack(deployCmd, ICommand.PHASE_DEPLOY);
    deployService.pushRestoreCommand(cmdManager, deployCmd, (MDMServerDef) serverDef);
    deployService.updateLastServer(mStatus, new NullProgressMonitor());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CommandManager(org.talend.mdm.repository.core.command.CommandManager) ICommand(org.talend.mdm.repository.core.command.ICommand) DeployStatus(org.talend.mdm.repository.core.service.DeployService.DeployStatus) MultiStatus(org.eclipse.core.runtime.MultiStatus) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 13 with ICommand

use of org.talend.mdm.repository.core.command.ICommand in project tmdm-studio-se by Talend.

the class RemoveFromServerAction method doRun.

protected void doRun() {
    SelectServerDefDialog dialog = new SelectServerDefDialog(getShell());
    if (dialog.open() == IDialogConstants.OK_ID) {
        // save editors
        LockedDirtyObjectDialog lockDirtyDialog = new LockedDirtyObjectDialog(getShell(), Messages.AbstractDeployAction_promptToSaveEditors, getSelectedRepositoryViewObject());
        if (lockDirtyDialog.needShowDialog() && lockDirtyDialog.open() == IDialogConstants.CANCEL_ID) {
            return;
        }
        lockDirtyDialog.saveDirtyObjects();
        // remove
        MDMServerDef serverDef = dialog.getSelectedServerDef();
        List<AbstractDeployCommand> commands = new LinkedList<AbstractDeployCommand>();
        CommandManager commandManager = CommandManager.getInstance();
        for (Object obj : getSelectedObject()) {
            IRepositoryViewObject viewObj = (IRepositoryViewObject) obj;
            ICommand deleteCommand = commandManager.getNewCommand(ICommand.CMD_DELETE);
            deleteCommand.init(viewObj);
            commands.add((AbstractDeployCommand) deleteCommand);
        }
        // 
        IStatus status = DeployService.getInstance().runCommands(commands, serverDef);
        if (status.isMultiStatus()) {
            showDeployStatus(status);
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) CommandManager(org.talend.mdm.repository.core.command.CommandManager) ICommand(org.talend.mdm.repository.core.command.ICommand) LockedDirtyObjectDialog(org.talend.mdm.repository.ui.dialogs.lock.LockedDirtyObjectDialog) SelectServerDefDialog(org.talend.mdm.workbench.serverexplorer.ui.dialogs.SelectServerDefDialog) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef) LinkedList(java.util.LinkedList)

Example 14 with ICommand

use of org.talend.mdm.repository.core.command.ICommand in project tmdm-studio-se by Talend.

the class DeployService method runCommands.

public IStatus runCommands(List<AbstractDeployCommand> commands, MDMServerDef serverDef) {
    reorderCommandObjects(commands);
    CommandManager manager = CommandManager.getInstance();
    List<ICommand> compundCommands = manager.convertToDeployCompundCommands(commands, serverDef);
    manager.arrangeForJobCommands(compundCommands);
    // 
    try {
        IProgressService progressService = null;
        if (PlatformUI.isWorkbenchRunning()) {
            progressService = PlatformUI.getWorkbench().getProgressService();
        } else {
            progressService = ConsoleProgressService.getInstance();
        }
        DeployProcess runnable = new DeployProcess(compundCommands);
        progressService.run(true, true, runnable);
        return runnable.getStatus();
    } catch (InvocationTargetException e) {
        log.error(e.getMessage(), e);
    } catch (InterruptedException e) {
    }
    return Status.CANCEL_STATUS;
}
Also used : CommandManager(org.talend.mdm.repository.core.command.CommandManager) ICommand(org.talend.mdm.repository.core.command.ICommand) IProgressService(org.eclipse.ui.progress.IProgressService) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 15 with ICommand

use of org.talend.mdm.repository.core.command.ICommand in project tmdm-studio-se by Talend.

the class DeployService method generateValidationFailedDeployStatus.

public void generateValidationFailedDeployStatus(IStatus mainStatus, List<IRepositoryViewObject> cancelViewObjs) {
    for (IRepositoryViewObject viewObj : cancelViewObjs) {
        ICommand cancelCmd = CommandManager.getInstance().getNewCommand(ICommand.CMD_NOP);
        cancelCmd.updateViewObject(viewObj);
        DeployStatus cancelStatus = DeployStatus.getInfoStatus(cancelCmd, Messages.bind(Messages.Deploy_cancel_text, viewObj.getLabel()));
        ((MultiStatus) mainStatus).add(cancelStatus);
    }
}
Also used : ICommand(org.talend.mdm.repository.core.command.ICommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MultiStatus(org.eclipse.core.runtime.MultiStatus)

Aggregations

ICommand (org.talend.mdm.repository.core.command.ICommand)18 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)8 CommandManager (org.talend.mdm.repository.core.command.CommandManager)8 IStatus (org.eclipse.core.runtime.IStatus)6 CommandStack (org.talend.mdm.repository.core.command.CommandStack)6 AbstractDeployCommand (org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand)6 MultiStatus (org.eclipse.core.runtime.MultiStatus)5 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 BatchDeployJobCommand (org.talend.mdm.repository.core.command.deploy.job.BatchDeployJobCommand)3 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 DeployStatus (org.talend.mdm.repository.core.service.DeployService.DeployStatus)2 SelectServerDefDialog (org.talend.mdm.workbench.serverexplorer.ui.dialogs.SelectServerDefDialog)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashSet (java.util.HashSet)1 List (java.util.List)1 IEditorInput (org.eclipse.ui.IEditorInput)1 IProgressService (org.eclipse.ui.progress.IProgressService)1