Changeset 30701
- Timestamp:
- 2016-08-12T19:47:27+12:00 (7 years ago)
- Location:
- main/trunk/gli
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/classes/dictionary.properties
r29509 r30701 648 648 General.Redo:Redo 649 649 General.Redo_Tooltip:Restore the last undo 650 General.Save:Save 650 651 General.Undo:Undo 651 652 General.Undo_Tooltip:Undo the last edit … … 769 770 Menu.Edit_Cut:Cut ({0}-x) 770 771 Menu.Edit_Paste:Paste ({0}-v) 772 Menu.Edit_Config:Edit collectionConfig.xml 771 773 Menu.Expand:Open Folder 772 774 Menu.Explode_Metadata_Database:Explode metadata database … … 962 964 FormatConversionDialog.XHTML_Tidy_Tooltip:Will run HTML Tidy over the Greenstone3 format statement to try to fix up obvious XHTML errors. 963 965 FormatConversionDialog.XML_Still_Invalid:XML is still invalid. 966 967 #***** ConfigFileEditor ***** 968 ConfigFileEditor.Tooltip:Greenstone 3 collection configuration XML editor. 969 ConfigFileEditor.Save_Tooltip:Save changes and close. 970 ConfigFileEditor.Cancel_Tooltip:Close without saving. 964 971 965 972 #********************** -
main/trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java
r29036 r30701 257 257 DebugStream.println(cce.toString()); 258 258 } 259 } 260 else if(esrc == menu_bar.edit_config) { 261 if(Gatherer.c_man.getCollection() != null) { 262 //JOptionPane.showMessageDialog(this, "Not yet implemented", "Edit config", JOptionPane.INFORMATION_MESSAGE); 263 ConfigFileEditor configEditor = new ConfigFileEditor(); 264 configEditor.setVisible(true); 265 configEditor.setSize(900,700); 266 267 } 259 268 } 260 269 … … 1133 1142 } 1134 1143 } 1144 else if(e.getSource() == menu_bar.edit) { // someone clicked the toplevel Edit menu 1145 // gray out the Edit Config File menu if there's no collection currently open. 1146 if(Gatherer.c_man.getCollection() == null) { 1147 menu_bar.edit_config.setEnabled(false); 1148 } 1149 else { // don't forget to reenable the Edit ConfigXML menu item when applicable 1150 menu_bar.edit_config.setEnabled(true); 1151 } 1152 } 1153 1135 1154 } 1136 1155 } -
main/trunk/gli/src/org/greenstone/gatherer/gui/MenuBar.java
r28628 r30701 76 76 public JMenuItem edit_cut; 77 77 public JMenuItem edit_paste; 78 public JMenuItem edit_config; 78 79 public JMenuItem help_general; 79 80 public JMenuItem help_download; … … 162 163 edit.setText(Dictionary.get("Menu.Edit")); 163 164 edit.setComponentOrientation(Dictionary.getOrientation()); 164 165 165 String modkey = "ctrl"; 166 166 if(Utility.isMac()) { // on Mac, we now use the Apple key instead of Ctrl for GLI/GEMS edit shortcuts … … 182 182 edit_paste.addActionListener(Gatherer.g_man); 183 183 edit_paste.setComponentOrientation(Dictionary.getOrientation()); 184 184 185 // Layout (edit menu) 185 186 edit.add(edit_cut); 186 187 edit.add(edit_copy); 187 188 edit.add(edit_paste); 189 190 // if GS3, then we have a menu item that allows editing of config files 191 if(Gatherer.GS3) { 192 193 edit_config = new JMenuItem(Dictionary.get("Menu.Edit_Config")); 194 // handle the actual Edit > ColConfig.xml menu item 195 edit_config.addActionListener(Gatherer.g_man); 196 edit_config.setComponentOrientation(Dictionary.getOrientation()); 197 edit.add(edit_config); 198 // The Edit menu itself now listens, in order to gray out the 199 // Edit > collectionConfig.xml option when no collection is open 200 // (JMenu doesn't work with ActionListener only with MenuListener, see 201 // http://stackoverflow.com/questions/9862165/jmenu-actionlistener) 202 edit.addMenuListener(menu_listener); 203 204 } 188 205 189 206 // Help menu -
main/trunk/gli/src/org/greenstone/gatherer/util/Utility.java
r29972 r30701 74 74 static final public String PERL_EXECUTABLE_WINDOWS = "Perl.exe"; 75 75 76 77 /** 78 * Reads in a text file and returns the contents as a String 79 */ 80 static public String readFile(File file) { 81 BufferedReader fin = null; 82 StringBuffer contents = new StringBuffer(); 83 84 try { 85 fin = new BufferedReader(new FileReader(file)); 86 String line = null; 87 while((line = fin.readLine()) != null) { 88 contents.append(line); 89 contents.append("\n"); 90 } 91 } catch(IOException e) { 92 System.err.println("*** Could not read in file: " + file.toString()); 93 System.err.println("*** Exception occurred: " + e.getMessage()); 94 } finally { 95 try { 96 if(fin != null) { 97 fin.close(); 98 fin = null; 99 } 100 } catch(IOException ioe) { 101 fin = null; 102 103 } 104 } 105 106 return contents.toString(); 107 } 76 108 77 109 /** -
main/trunk/gli/src/org/greenstone/gatherer/util/XMLTools.java
r29730 r30701 13 13 import java.io.IOException; 14 14 import java.io.StringReader; 15 import java.io.StringWriter; // for elementToString() 15 16 16 17 // SAX … … 28 29 import javax.xml.parsers.SAXParser; 29 30 import javax.xml.parsers.SAXParserFactory; 31 // for elementToString(): 32 import javax.xml.transform.OutputKeys; 33 import javax.xml.transform.Transformer; 34 import javax.xml.transform.TransformerFactory; 35 import javax.xml.transform.dom.DOMSource; 36 import javax.xml.transform.stream.StreamResult; 30 37 31 38 … … 523 530 if (xml_file.exists() == false) 524 531 { 532 System.err.println("@@@ file " + xml_file + " does not exist."); 525 533 return null; 526 534 } … … 1224 1232 } 1225 1233 } 1234 1235 1236 1237 // This method will convert an Element to a String too, like xmlNodeToString() above. 1238 // But for a document root element (doc.getDocumentElement()), this method will additionally 1239 // return its processing instruction line at the start (<?xml ... ?>). 1240 // This method copied into GLI from src/java/org/greenstone/gsdl3/util/GSXML.java 1241 public static String elementToString(Element e, boolean indent) 1242 { 1243 String str = ""; 1244 try 1245 { 1246 TransformerFactory tf = TransformerFactory.newInstance(); 1247 Transformer trans = tf.newTransformer(); 1248 StringWriter sw = new StringWriter(); 1249 if (indent) 1250 { 1251 trans.setOutputProperty(OutputKeys.INDENT, "yes"); 1252 } 1253 else 1254 { 1255 trans.setOutputProperty(OutputKeys.INDENT, "no"); 1256 } 1257 trans.transform(new DOMSource(e), new StreamResult(sw)); 1258 str += sw.toString(); 1259 } 1260 catch (Exception ex) 1261 { 1262 str += "Exception: couldn't write " + e + " to log"; 1263 } 1264 finally 1265 { 1266 return str; 1267 } 1268 } 1226 1269 }
Note:
See TracChangeset
for help on using the changeset viewer.