Changeset 12302


Ignore:
Timestamp:
2006-07-25T13:48:07+12:00 (18 years ago)
Author:
kjdon
Message:

removed an unused variable and unused method, blank feature and part now display some text, and the part is disabled/enabled properly when the assigned formats list is clicked

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/cdm/FormatManager.java

    r12273 r12302  
    162162        controls = null;
    163163    }
    164     }
    165 
    166     /** Gets the format indicated by the index.
    167      * @param index The location of the desired format, as an <i>int</i>.
    168      */
    169     private Format getFormat(int index) {
    170     Format result = null;
    171     if(0 < index && index < getSize()) {
    172         result = (Format) getElementAt(index);
    173     }
    174     return result;
    175164    }
    176165
     
    315304        JPanel header_pane = new DesignPaneHeader("CDM.GUI.Formats", "formatstatements");
    316305
    317         JLabel format_label = new JLabel(Dictionary.get("CDM.FormatManager.Assigned_Formats"));
    318306        format_list = new JList(model);
    319307
     
    527515        String p = "";
    528516        if (entry.canHavePart()) {
    529             p = part_combobox.getSelectedItem().toString();
     517            p = ((Part)part_combobox.getSelectedItem()).getName();
    530518        }
    531519
     
    776764               view_type = VALUE;
    777765               // Initial values
    778                
    779                // Try to match the part.
    780                String part_entry = format.getPart();
    781                // Set Selected Item doesn't work so I'll do this manually
    782                boolean found = false;
    783                for(int i=0; i < part_combobox.getItemCount(); i++) {
    784                   Part a_part = (Part) part_combobox.getItemAt(i);
    785                   if(a_part.equals(part_entry)) {
    786                  part_combobox.setSelectedItem(a_part);
    787                  found = true;
    788                   }
    789                   a_part = null;
     766               // do we have a part?
     767               if (format.canHavePart()) {
     768                   part_combobox.setEnabled(true);
     769                   // Try to match the part.
     770                   String part_entry = format.getPart();
     771                   // Set Selected Item doesn't work so I'll do this manually
     772                   boolean found = false;
     773                   for(int i=0; i < part_combobox.getItemCount(); i++) {
     774                   Part a_part = (Part) part_combobox.getItemAt(i);
     775                   if(a_part.equals(part_entry)) {
     776                       part_combobox.setSelectedItem(a_part);
     777                       found = true;
     778                   }
     779                   a_part = null;
     780                   }
     781                   // If we didn't match anything, add it and select it again
     782                   if(!found) {
     783                   Part a_part = new Part(part_entry, "");
     784                   part_combobox.insertItemAt(a_part, part_combobox.getItemCount());
     785                   part_combobox.setSelectedItem(a_part);
     786                   
     787                   }
     788               } else {
     789                   part_combobox.setEnabled(false);
     790                   part_combobox.setSelectedIndex(0);
    790791               }
    791                // If we didn't match anything, add it and select it again
    792                if(!found) {
    793                   Part a_part = new Part(part_entry, "");
    794                   part_combobox.insertItemAt(a_part, part_combobox.getItemCount());
    795                   part_combobox.setSelectedItem(a_part);
    796                
    797                            }
    798              
    799792               editor_textarea.setText(format.getValue());
    800793               editor_textarea.setCaretPosition(0);
     
    956949
    957950
    958  private class DefaultListener
     951    private class DefaultListener
    959952        implements ActionListener {
    960953
     
    11301123        // Return the classifier - less the 'classify ' prefix and with its CL index shown
    11311124        return classifier.getPositionString() + StaticStrings.COLON_CHARACTER + StaticStrings.SPACE_CHARACTER + classifier.toString().substring(9);
     1125        }
     1126        if (text.equals("")) {
     1127        return "<html><body><i>"+Dictionary.get("CDM.FormatManager.AllFeatures")+"</i></body></html>";
    11321128        }
    11331129        return text;
     
    11851181       */
    11861182      public int compareTo(Object obj) {
    1187      return name.compareTo(obj.toString());
     1183      if (obj instanceof Part) {
     1184          return name.compareTo(((Part)obj).getName());
     1185      }
     1186      return name.compareTo(obj.toString());
    11881187      }
    11891188     
     
    11931192       */
    11941193      public boolean equals(Object obj) {
    1195      return name.equals(obj.toString());
     1194      if (obj instanceof Part) {
     1195          return name.equals(((Part)obj).getName());
     1196      }
     1197      return name.equals(obj.toString());
    11961198      }
    11971199     
     
    12191221       */
    12201222      public String toString() {
    1221      return name;
     1223      if (name.equals("")) {
     1224          return "<html><body><i>"+Dictionary.get("CDM.FormatManager.AllParts")+"</i></body></html>";
     1225      }
     1226      return name;
    12221227      }
    12231228   } 
Note: See TracChangeset for help on using the changeset viewer.