Changeset 5058
- Timestamp:
- 2003-07-29T10:48:16+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/WarningDialog.java
r4675 r5058 15 15 implements ActionListener { 16 16 17 static final private Dimension SIZE = new Dimension(400,160); 17 static final private Dimension LABEL_SIZE = new Dimension(150, 25); 18 static final private Dimension NORMAL_SIZE = new Dimension(400, 160); 19 static final private Dimension SETTING_SIZE = new Dimension(400, 200); 18 20 21 private Dictionary dictionary; 19 22 private int result = JOptionPane.CANCEL_OPTION; 20 23 private JButton cancel_button; 21 24 private JButton ok_button; 22 25 private JCheckBox show_check; 26 private JTextField value_field; 27 private String affected_property; 23 28 private String full_property; 24 29 private String warning_name; 25 30 31 public WarningDialog(String full_property) { 32 this(full_property, false, null, Gatherer.dictionary); 33 } 34 26 35 public WarningDialog(String full_property, boolean can_cancel) { 36 this(full_property, can_cancel, null, Gatherer.dictionary); 37 } 38 39 public WarningDialog(String full_property, String affected_property) { 40 this(full_property, false, affected_property, Gatherer.dictionary); 41 } 42 43 public WarningDialog(String full_property, boolean can_cancel, Dictionary dictionary) { 44 this(full_property, can_cancel, null, dictionary); 45 } 46 47 public WarningDialog(String full_property, String affected_feature, Dictionary dictionary) { 48 this(full_property, false, affected_feature, dictionary); 49 } 50 51 public WarningDialog(String full_property, boolean can_cancel, String affected_property) { 52 this(full_property, can_cancel, affected_property, Gatherer.dictionary); 53 } 54 55 public WarningDialog(String full_property, boolean can_cancel, String affected_property, Dictionary dictionary) { 27 56 super(Gatherer.g_man, "Warning", true); 28 57 // Determine the name of this prompt. 58 this.affected_property = affected_property; 59 this.dictionary = dictionary; 29 60 this.full_property = full_property; 30 61 warning_name = full_property.substring(full_property.indexOf(".") + 1); 31 62 // Now build dialog. 32 setSize(SIZE); 63 if(affected_property != null) { 64 setSize(SETTING_SIZE); 65 } 66 else { 67 setSize(NORMAL_SIZE); 68 } 33 69 setTitle(get("Title")); 34 70 // Creation … … 40 76 text_area.setLineWrap(true); 41 77 text_area.setWrapStyleWord(true); 78 JPanel value_panel = new JPanel(); 79 JLabel value_label = new JLabel(get("WarningDialog.Value")); 80 value_label.setPreferredSize(LABEL_SIZE); 81 value_field = new JTextField(); 42 82 JPanel bottom_pane = new JPanel(); 43 83 show_check = new JCheckBox(get("WarningDialog.Dont_Show_Again"), false); … … 51 91 icon_label.setBorder(BorderFactory.createEmptyBorder(0,0,0,5)); 52 92 93 value_label.setBorder(BorderFactory.createEmptyBorder(0, icon_label.getPreferredSize().width, 0, 0)); 94 95 value_panel.setBorder(BorderFactory.createEmptyBorder(5,0,0,0)); 96 value_panel.setLayout(new BorderLayout()); 97 value_panel.add(value_label, BorderLayout.WEST); 98 value_panel.add(value_field, BorderLayout.CENTER); 99 53 100 text_pane.setLayout(new BorderLayout()); 54 101 text_pane.add(icon_label, BorderLayout.WEST); 55 102 text_pane.add(new JScrollPane(text_area), BorderLayout.CENTER); 103 if(affected_property != null) { 104 text_pane.add(value_panel, BorderLayout.SOUTH); 105 } 56 106 57 107 if(can_cancel) { … … 75 125 content_pane.add(bottom_pane, BorderLayout.SOUTH); 76 126 // Position 127 Dimension size = getSize(); 77 128 if(Gatherer.g_man != null) { 78 129 Rectangle frame_bounds = Gatherer.g_man.getBounds(); 79 setLocation(frame_bounds.x + (frame_bounds.width - SIZE.width) / 2, frame_bounds.y + (frame_bounds.height - SIZE.height) / 2);130 setLocation(frame_bounds.x + (frame_bounds.width - size.width) / 2, frame_bounds.y + (frame_bounds.height - size.height) / 2); 80 131 } 81 132 else { 82 133 Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize(); 83 setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2);134 setLocation((screen_size.width - size.width) / 2, (screen_size.height - size.height) / 2); 84 135 } 85 136 } … … 88 139 if(event.getSource() == ok_button) { 89 140 result = JOptionPane.OK_OPTION; 141 if(Gatherer.config != null) { 142 // Store the value of the property 143 Gatherer.config.setString(affected_property, true, value_field.getText()); 144 } 90 145 } 91 // Store the state of the show message checkbox. 92 Gatherer.config.set(full_property, true, !show_check.isSelected()); 146 if(Gatherer.config != null) { 147 // Store the state of the show message checkbox. 148 Gatherer.config.set(full_property, true, !show_check.isSelected()); 149 } 93 150 // Done. 94 151 dispose(); … … 97 154 public int display() { 98 155 ///ystem.err.println("Show " + full_property + ": " + Gatherer.config.get(full_property, false)); 99 if(Gatherer.config .get(full_property, false)) {156 if(Gatherer.config == null || Gatherer.config.get(full_property, false)) { 100 157 // We only show if the warning has not been disabled. 101 158 show(); … … 112 169 key = warning_name + "." + key; 113 170 } 114 return Gatherer.dictionary.get(key);171 return dictionary.get(key); 115 172 } 116 173 }
Note:
See TracChangeset
for help on using the changeset viewer.