AccessRightsDialog.java
01 /*
02  *  Copyright (c) 1995-2010, The University of Sheffield. See the file
03  *  COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
04  *
05  *  This file is part of GATE (see http://gate.ac.uk/), and is free
06  *  software, licenced under the GNU Library General Public License,
07  *  Version 2, June 1991 (in the distribution as file licence.html,
08  *  and also available at http://gate.ac.uk/gate/licence.html).
09  *
10  *  Kalina Bontcheva 19/11/2001
11  *
12  *  $Id: AccessRightsDialog.java 12006 2009-12-01 17:24:28Z thomas_heitz $
13  *
14  */
15 
16 package gate.gui;
17 
18 import java.awt.Component;
19 
20 import javax.swing.*;
21 
22 import gate.security.SecurityInfo;
23 
24 public class AccessRightsDialog {
25   protected static JRadioButton gr_gw = new JRadioButton();
26   protected static JRadioButton gr_ow = new JRadioButton();
27   protected static JRadioButton or_ow = new JRadioButton();
28   protected static JRadioButton wr_gw = new JRadioButton();
29   protected static ButtonGroup group;
30 
31   public static boolean showDialog(Component parentComponent){
32     gr_gw.setText("Group read/group write");
33     gr_ow.setText("Group read/owner write");
34     or_ow.setText("Owner read/owner write");
35     wr_gw.setText("All read/group write");
36 
37     JPanel panel1 = new JPanel();
38     panel1.setLayout(new BoxLayout(panel1,BoxLayout.Y_AXIS));
39 
40     group = new ButtonGroup();
41     group.add(gr_gw);
42     group.add(gr_ow);
43     group.add(or_ow);
44     group.add(wr_gw);
45     gr_gw.setSelected(true);
46 
47     panel1.add(wr_gw);
48     panel1.add(Box.createHorizontalStrut(30));
49     panel1.add(gr_gw);
50     panel1.add(Box.createHorizontalStrut(30));
51     panel1.add(gr_ow);
52     panel1.add(Box.createHorizontalStrut(30));
53     panel1.add(or_ow);
54     panel1.add(Box.createHorizontalStrut(30));
55 
56     return
57       OkCancelDialog.showDialog(parentComponent,
58                                 panel1,
59                                 "Choose access mode");
60 
61   }
62 
63   public static int getSelectedMode() {
64     if(gr_gw.isSelected())
65       return SecurityInfo.ACCESS_GR_GW;
66     else if(gr_ow.isSelected())
67       return SecurityInfo.ACCESS_GR_OW;
68     else if(or_ow.isSelected())
69       return SecurityInfo.ACCESS_OR_OW;
70     else if(wr_gw.isSelected())
71       return SecurityInfo.ACCESS_WR_GW;
72 
73     return -1;
74   }
75 
76 }