View Javadoc

1   /*
2   
3       dsh-venn-cytoscape3-app  Cytoscape3 app for venn and euler diagrams.
4       Copyright (c) 2012-2013 held jointly by the individual authors.
5   
6       This library is free software; you can redistribute it and/or modify it
7       under the terms of the GNU Lesser General Public License as published
8       by the Free Software Foundation; either version 3 of the License, or (at
9       your option) any later version.
10  
11      This library is distributed in the hope that it will be useful, but WITHOUT
12      ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
13      FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14      License for more details.
15  
16      You should have received a copy of the GNU Lesser General Public License
17      along with this library;  if not, write to the Free Software Foundation,
18      Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA.
19  
20      > http://www.fsf.org/licensing/licenses/lgpl.html
21      > http://www.opensource.org/licenses/lgpl-license.php
22  
23  */
24  package org.dishevelled.venn.cytoscape3.internal;
25  
26  import static javax.swing.SwingUtilities.windowForComponent;
27  import static org.dishevelled.venn.cytoscape3.internal.VennDiagramsUtils.installCloseKeyBinding;
28  
29  import java.awt.Component;
30  import java.awt.event.ActionEvent;
31  
32  import javax.swing.JDialog;
33  import javax.swing.JFrame;
34  
35  import org.cytoscape.application.CyApplicationManager;
36  import org.cytoscape.application.swing.AbstractCyAction;
37  import org.cytoscape.group.CyGroupManager;
38  import org.cytoscape.service.util.CyServiceRegistrar;
39  
40  /**
41   * Venn diagrams action.
42   *
43   * @author  Michael Heuer
44   */
45  final class VennDiagramsAction extends AbstractCyAction
46  {
47      /** Application manager. */
48      private final CyApplicationManager applicationManager;
49  
50      /** Group manager. */
51      private final CyGroupManager groupManager;
52  
53      /** Service registrar. */
54      private final CyServiceRegistrar serviceRegistrar;
55  
56  
57      /**
58       * Create a new venn diagrams action.
59       *
60       * @param applicationManager application manager, must not be null
61       * @param groupManager group manager, must not be null
62       * @param serviceRegistrar service registrar, must not be null
63       */
64      VennDiagramsAction(final CyApplicationManager applicationManager, final CyGroupManager groupManager, final CyServiceRegistrar serviceRegistrar)
65      {
66          super("Venn and Euler Diagrams");
67          if (applicationManager == null)
68          {
69              throw new IllegalArgumentException("applicationManager must not be null");
70          }
71          if (groupManager == null)
72          {
73              throw new IllegalArgumentException("groupManager must not be null");
74          }
75          if (serviceRegistrar == null)
76          {
77              throw new IllegalArgumentException("serviceRegistrar must not be null");
78          }
79          this.applicationManager = applicationManager;
80          this.groupManager = groupManager;
81          this.serviceRegistrar = serviceRegistrar;
82  
83          setPreferredMenu("Apps");
84      }
85  
86  
87      @Override
88      public void actionPerformed(final ActionEvent event)
89      {
90          if (event == null)
91          {
92              throw new NullPointerException("event must not be null");
93          }
94          JFrame frame = (JFrame) windowForComponent((Component) event.getSource());
95          JDialog dialog = new JDialog(frame, "Venn and Euler Diagrams"); // i18n
96          dialog.setContentPane(new GroupsView(applicationManager, groupManager, serviceRegistrar));
97          dialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
98          installCloseKeyBinding(dialog);
99          dialog.setBounds(200, 200, 400, 400);
100         dialog.setVisible(true);
101     }
102 }