001 // GraphLab Project: http://graphlab.sharif.edu 002 // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology 003 // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ 004 package graphlab.plugins.main.core.actions.graph; 005 006 import graphlab.graph.atributeset.GraphAttrSet; 007 import graphlab.graph.graph.AbstractGraphRenderer; 008 import graphlab.graph.graph.GraphModel; 009 import graphlab.platform.core.BlackBoard; 010 import graphlab.ui.UIUtils; 011 012 import javax.swing.*; 013 014 015 public class ClearGraph extends graphlab.platform.core.AbstractAction { 016 017 public static final String event = UIUtils.getUIEventKey("Clear"); 018 019 public ClearGraph(BlackBoard bb) { 020 super(bb); 021 this.listen4Event(event); 022 } 023 024 public void performAction(String eventName, Object value) { 025 GraphModel g = ((GraphModel) (blackboard.getData(GraphAttrSet.name))); 026 if (true || JOptionPane.showConfirmDialog(null, "Current graph will be REMOVED from screen! Do you want to continue?", 027 "GraphLab", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { 028 029 // UndoableActionOccuredData uaod=new UndoableActionOccuredData("Clear Graph", this) ; 030 // uaod.properties.put("ClearedGrapg",g); 031 // blackboard.set(UndoableActionOccuredData.name, uaod); 032 destroyGraph(g); 033 AbstractGraphRenderer agr = blackboard.getData(AbstractGraphRenderer.EVENT_KEY); 034 agr.repaint(); 035 } 036 } 037 038 public static void destroyGraph(GraphModel g) { 039 g.clear(); 040 } 041 }