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