Changeset 10877
- Timestamp:
- 2005-11-09T15:11:09+13:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java
r10462 r10877 1408 1408 private JComboBox existingSetJComboBox = new JComboBox(); 1409 1409 1410 private String DO_NOT_INHERIT = Dictionary.get("GEMS.Add_Set.No_Inherit"); 1411 1410 1412 public AddSetActionListener() { 1411 1413 super(self); … … 1488 1490 Dictionary.setText(dummyl, "GEMS.Add_Set.No_Inherit"); 1489 1491 1490 existingSetJComboBox.addItem("Do not inherit");1492 existingSetJComboBox.addItem(DO_NOT_INHERIT); 1491 1493 existingSetJComboBox.setSelectedIndex(getSetsLen); 1492 1494 boxes_pane.add(existingSetJComboBox); … … 1535 1537 String name_str = Codec.transform(Codec.transformUnicode(name_field.getText()), Codec.TEXT_TO_DOM); 1536 1538 1537 if (existingSetJComboBox.getSelectedItem().toString().trim().compareTo("Do not inherit") == 0){ 1538 1539 // Ensure the set doesn't already exist 1540 if(a_set_exists_with_this_namespace(namespace_str) == false){ 1541 1539 // first check whether the namespace is valid, i.e. hasn't been used before 1540 if(a_set_exists_with_this_namespace(namespace_str)) { 1541 JOptionPane.showMessageDialog(self, Dictionary.get("GEMS.Set_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 1542 return; // return back to the dialog 1543 } 1544 1545 //not based on another set 1546 if (existingSetJComboBox.getSelectedItem().toString().equals(DO_NOT_INHERIT)){ 1542 1547 MetadataSet set = msm.addSet(namespace_str, name_str); 1543 1544 1545 1546 1547 1548 1549 //mark as set changed = true 1550 set.setSetChanged(true); 1551 atLeastOneSetChanged = true; 1552 1548 1553 // Update tree. 1549 1554 model.add(null, set, GEMSNode.SET); … … 1551 1556 set = null; 1552 1557 setVisible(false); 1553 1554 } 1555 else{ 1556 JOptionPane.showMessageDialog(self, Dictionary.get("GEMS.Set_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 1557 } 1558 1559 name_str = null; 1560 namespace_str = null; 1561 }//end do not inherit 1558 1559 } 1562 1560 else { 1563 1561 //Should change this to use XML parsing utilites --Matthew … … 1565 1563 String anitem = existingSetJComboBox.getSelectedItem().toString(); 1566 1564 1567 if(a_set_exists_with_this_namespace(namespace_field.getText()) == false){ 1568 //setup to read the filename from mds file 1569 String [] items = anitem.split("#%"); 1570 try { 1571 FileInputStream fstream = new FileInputStream(items[1].trim()); 1572 BufferedReader in = new BufferedReader(new InputStreamReader(fstream, "UTF8")); 1565 //setup to read the filename from mds file 1566 String [] items = anitem.split("#%"); 1567 try { 1568 FileInputStream fstream = new FileInputStream(items[1].trim()); 1569 BufferedReader in = new BufferedReader(new InputStreamReader(fstream, "UTF8")); 1573 1570 1574 FileOutputStream out; 1575 PrintWriter p; 1576 //setup to write to filename from existing file 1577 try { 1578 out = new FileOutputStream(getGLIMetadataDirectoryPath() + namespace_str + ".mds"); 1579 OutputStreamWriter pout = new OutputStreamWriter(out, "UTF8"); 1580 p = new PrintWriter(pout); 1571 FileOutputStream out; 1572 PrintWriter p; 1573 //setup to write to filename from existing file 1574 try { 1575 out = new FileOutputStream(getGLIMetadataDirectoryPath() + namespace_str + ".mds"); 1576 OutputStreamWriter pout = new OutputStreamWriter(out, "UTF8"); 1577 p = new PrintWriter(pout); 1578 1579 while(in.ready()){ 1580 String nextline = in.readLine(); 1581 1581 1582 while(in.ready()){ 1583 String nextline = in.readLine(); 1584 1585 if(nextline.matches(".+namespace=\".+\".*") == true) { 1586 nextline = nextline.replaceFirst("namespace=\".+\"","namespace=\"" + namespace_str+ "\""); 1587 } 1588 else { 1589 nextline = nextline.replaceFirst(">.+</Name>",">" + name_str + "</Name>"); 1590 } 1591 p.print(nextline + "\n"); 1582 if(nextline.matches(".+namespace=\".+\".*") == true) { 1583 nextline = nextline.replaceFirst("namespace=\".+\"","namespace=\"" + namespace_str+ "\""); 1592 1584 } 1593 p.close();1594 1595 MetadataSet loadedset = msm.loadMetadataSet(new File(getGLIMetadataDirectoryPath() + namespace_str + ".mds"));1596 model.add(null, loadedset, GEMSNode.SET);1585 else { 1586 nextline = nextline.replaceFirst(">.+</Name>",">" + name_str + "</Name>"); 1587 } 1588 p.print(nextline + "\n"); 1597 1589 } 1598 catch(Exception e){ 1599 System.out.println("Print file error"); 1600 } 1601 } 1602 catch(Exception e){ 1603 System.out.println("File Input error"); 1604 } 1605 1606 }//msm.getset(namespacE) == null 1607 else{ 1608 JOptionPane.showMessageDialog(self, Dictionary.get("GEMS.Set_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 1609 } 1610 setVisible(false); 1611 } 1590 p.close(); 1591 1592 MetadataSet loadedset = msm.loadMetadataSet(new File(getGLIMetadataDirectoryPath() + namespace_str + ".mds")); 1593 model.add(null, loadedset, GEMSNode.SET); 1594 } 1595 catch(Exception e){ 1596 System.out.println("Print file error"); 1597 } 1598 } 1599 catch(Exception e){ 1600 System.out.println("File Input error"); 1601 } 1602 1603 } 1604 1605 name_str = null; 1606 namespace_str = null; 1607 setVisible(false); 1612 1608 } //if(source == ok_button) 1613 1609 else if(source == cancel_button) {
Note:
See TracChangeset
for help on using the changeset viewer.