use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.
the class CutTask method run.
@Override
public void run(TaskMonitor tm) throws Exception {
final VisualMappingManager vmMgr = serviceRegistrar.getService(VisualMappingManager.class);
final VisualLexicon lexicon = vmMgr.getAllVisualLexicon().iterator().next();
final Collection<VisualProperty<?>> edgeProps = lexicon.getAllDescendants(BasicVisualLexicon.EDGE);
tm.setTitle("Cut Task");
// so they can be restored later on undo
for (CyNode node : selNodes) {
List<CyEdge> adjacentEdgeList = netView.getModel().getAdjacentEdgeList(node, CyEdge.Type.ANY);
for (CyEdge edge : adjacentEdgeList) {
if (!selEdges.contains(edge)) {
deletedEdges.put(edge, new HashMap<VisualProperty<?>, Object>());
// Save the bypass values for this edge
View<CyEdge> edgeView = netView.getEdgeView(edge);
if (edgeView != null)
ClipboardImpl.saveLockedValues(edgeView, edgeProps, deletedEdges);
}
}
}
clipMgr.cut(netView, selNodes, selEdges);
tm.setStatusMessage("Cut " + selNodes.size() + " nodes and " + selEdges.size() + " edges and copied them to the clipboard");
final UndoSupport undoSupport = serviceRegistrar.getService(UndoSupport.class);
undoSupport.postEdit(new CutEdit());
}
use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.
the class SetLockedValuesTask method run.
// ==[ PUBLIC METHODS ]=============================================================================================
@Override
public void run(final TaskMonitor taskMonitor) throws Exception {
if (values != null && views != null && netView != null) {
final boolean removed = setLockedValues(true);
if (removed) {
final UndoSupport undo = servicesUtil.get(UndoSupport.class);
undo.postEdit(new SetLockedValuesEdit());
}
}
}
use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.
the class CopyVisualStyleTask method run.
@Override
public void run(final TaskMonitor monitor) throws Exception {
if (vsName != null && originalStyle != null) {
copyVisualStyle();
final UndoSupport undo = servicesUtil.get(UndoSupport.class);
undo.postEdit(new CopyVisualStyleEdit());
}
}
use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.
the class CreateNewVisualStyleTask method run.
@Override
public void run(final TaskMonitor tm) {
if (vsName != null) {
createVisualStyle();
final UndoSupport undo = servicesUtil.get(UndoSupport.class);
undo.postEdit(new CreateNewVisualStyleEdit());
}
}
use of org.cytoscape.work.undo.UndoSupport in project cytoscape-impl by cytoscape.
the class VizMapperMediator method onSelectedVisualStyleChanged.
private void onSelectedVisualStyleChanged(final PropertyChangeEvent e) {
final VisualStyle newStyle = (VisualStyle) e.getNewValue();
final VisualStyle oldStyle = vmProxy.getCurrentVisualStyle();
if (!ignoreVisualStyleSelectedEvents && newStyle != null && !newStyle.equals(oldStyle)) {
// Update proxy
vmProxy.setCurrentVisualStyle(newStyle);
// Undo support
final UndoSupport undo = servicesUtil.get(UndoSupport.class);
undo.postEdit(new AbstractCyEdit("Set Current Style") {
@Override
public void undo() {
vmProxy.setCurrentVisualStyle(oldStyle);
}
@Override
public void redo() {
vmProxy.setCurrentVisualStyle(newStyle);
}
});
}
}
Aggregations