blob: 0ed79e8ef46c4c6157982185634f81acf5ce4bf4 (
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
|
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
*
*
* 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
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.timing.custom.edit.commands;
import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.RootEditPart;
import org.eclipse.gef.commands.Command;
import org.eclipse.papyrus.infra.gmfdiag.common.helper.DiagramHelper;
/**
* Refresh the {@link IFigure} of a given {@link GraphicalEditPart}.
*/
public abstract class AbstractRefreshCommand extends Command {
private final GraphicalEditPart editPartToRefresh;
private final RootEditPart rootEditPart;
public AbstractRefreshCommand(final GraphicalEditPart editPartToRefresh) {
this.editPartToRefresh = editPartToRefresh;
this.rootEditPart = editPartToRefresh.getRoot();
}
public GraphicalEditPart getEditPartToRefresh() {
return this.editPartToRefresh;
}
protected void refresh() {
if (this.editPartToRefresh.isActive()) {
DiagramHelper.refresh(this.editPartToRefresh, true);
// this is needed in order to update the bounds of the Figures from their layout manager constraints
this.editPartToRefresh.getFigure().invalidateTree();
} else if (this.rootEditPart.isActive()) {
/*
* If the EditPart we needed to refresh is not active anymore, then it probably means that we undid its
* creation, and re-created the object as part of a redo, with a different EditPart. In this case, just
* refresh everything.
*/
DiagramHelper.refresh(this.rootEditPart, true);
}
}
}
|