diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2012-05-30 08:37:45 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2012-05-30 08:37:45 +0200 |
| commit | b086f57f56bf0eb9dab9cf321a0f69aaaae84347 (patch) | |
| tree | 8e6e26e8b7eed6abad7a17b093bdbb55c5e6b1ba /source/com/c2kernel/graph/controller/DeletionController.java | |
| parent | 22088ae8d2d5ff390518dbe1c4372325ffb3a647 (diff) | |
Initial Maven Conversion
Diffstat (limited to 'source/com/c2kernel/graph/controller/DeletionController.java')
| -rw-r--r-- | source/com/c2kernel/graph/controller/DeletionController.java | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/source/com/c2kernel/graph/controller/DeletionController.java b/source/com/c2kernel/graph/controller/DeletionController.java deleted file mode 100644 index 44ea990..0000000 --- a/source/com/c2kernel/graph/controller/DeletionController.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.c2kernel.graph.controller;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.util.Observable;
-import java.util.Observer;
-
-import javax.swing.JButton;
-
-import com.c2kernel.graph.event.SelectionChangedEvent;
-import com.c2kernel.graph.model.DirectedEdge;
-import com.c2kernel.graph.model.GraphModelManager;
-import com.c2kernel.graph.model.Vertex;
-
-
-// The deletion controller is responsible for deleting the present
-// selection within the graph.
-//
-// The controller listens to:
-// * The graph model to determine if there is a selection
-// * The delete button
-// * The graph panel for the typing of the delete key
-//
-// The controller modifies:
-// * The graph model to delete the current selection
-// * The delete button to enable it only when there is a selection
-public class DeletionController extends KeyAdapter implements Observer, ActionListener
-{
- private GraphModelManager mGraphModelManager = null;
- private JButton mDeleteButton = null;
-
-
- public void setGraphModelManager(GraphModelManager graphModelManager)
- {
- mGraphModelManager = graphModelManager;
- mGraphModelManager.addObserver(this);
- }
-
-
- public void setDeleteButton(JButton deleteButton)
- {
- mDeleteButton = deleteButton;
- mDeleteButton.addActionListener(this);
- }
-
-
- // Invoked by the graph model
- @Override
- public void update(Observable o, Object arg)
- {
- SelectionChangedEvent event = null;
- DirectedEdge selectedEdge = null;
- Vertex[] selectedVertices = null;
-
-
- // If the selected edge has changed
- if(arg instanceof SelectionChangedEvent && mDeleteButton != null && mGraphModelManager.isEditable())
- {
- // Enable the button if a single edge or single vertex is selected
- event = (SelectionChangedEvent)arg;
-
- selectedEdge = event.mSelection.mEdge;
- selectedVertices = event.mSelection.mVertices;
-
- mDeleteButton.setEnabled((selectedEdge != null) || (selectedVertices != null));
- }
- }
-
-
- // Invoked by the graph panel
- @Override
- public void keyPressed(KeyEvent e)
- {
- if(e.getKeyCode() == KeyEvent.VK_DELETE && mGraphModelManager.isEditable())
- {
- mGraphModelManager.getModel().deleteSelection();
- }
- }
-
-
- // Invoked by the delete button
- @Override
- public void actionPerformed(ActionEvent ae)
- {
- if(mGraphModelManager != null && mGraphModelManager.isEditable())
- {
- mGraphModelManager.getModel().deleteSelection();
- }
- }
-}
|
