Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 68e521ec190228486cc49de508d12b9c31c7adbc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*******************************************************************************
 * Copyright (c) 2010, 2015 THALES GLOBAL SERVICES and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Obeo - initial API and implementation
 *******************************************************************************/
package org.eclipse.sirius.diagram.ui.tools.internal.commands;

import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.sirius.common.tools.api.listener.NotificationUtil;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.business.api.helper.concern.ConcernService;
import org.eclipse.sirius.diagram.ui.provider.Messages;

/**
 * Specific command to set current concern to default.
 *
 * @author mporhel
 */
public final class SetDefaultConcernCommand extends RecordingCommand {

    private final DDiagram diag;

    /**
     * Constructor.
     *
     * @param domain
     *            the editing domain.
     * @param diagram
     *            the current diagram.
     */
    public SetDefaultConcernCommand(TransactionalEditingDomain domain, DDiagram diagram) {
        super(domain, Messages.SetDefaultConcernCommand_label);
        this.diag = diagram;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected void doExecute() {
        if (diag == null) {
            return;
        }

        if (diag.getDescription() != null && diag.getDescription().getDefaultConcern() != null) {
            ConcernService.setCurrentConcern(diag, diag.getDescription().getDefaultConcern());
        } else {
            ConcernService.setCurrentConcern(diag, null);
        }

        NotificationUtil.sendNotification(diag, org.eclipse.sirius.common.tools.api.listener.Notification.Kind.START, org.eclipse.sirius.common.tools.api.listener.Notification.VISIBILITY_UPDATE);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean canUndo() {
        /* we should not be able to undo this */
        return false;
    }
}

Back to the top