コード例 #1
0
 private void updateMacroListEditor(boolean isStructure) {
   if (mIsStructure != isStructure) {
     mIsStructure = isStructure;
     if (isStructure) {
       String[] idcodeList = mTextArea.getText().split("\\n");
       if (mStructurePane == null) {
         DefaultCompoundCollectionModel.IDCode collectionModel =
             new DefaultCompoundCollectionModel.IDCode();
         mStructurePane = new CompoundCollectionPane<String>(collectionModel, true);
         mStructurePane.setSelectable(true);
         mStructurePane.setEditable(true);
         mStructurePane.setClipboardHandler(new ClipboardHandler());
         mStructurePane.setShowValidationError(true);
         mStructurePane.setStructureSize(80);
         mStructurePane.setPreferredSize(
             new Dimension(240, Math.max(240, Math.min(640, 80 * idcodeList.length))));
         mStructurePane.setEnabled(mRadioButton.isSelected() && !mRadioButtonSort.isSelected());
       }
       mStructurePane.getModel().clear();
       StereoMolecule mol = new StereoMolecule();
       for (String idcode : idcodeList) {
         try {
           idcode = idcode.trim();
           if (idcode.length() != 0) {
             new IDCodeParser().parse(mol, idcode); // test validity of idcode
             mStructurePane.getModel().addCompound(idcode);
           }
         } catch (Exception e) {
         }
       }
       mDialogPanel.remove(mScrollPane);
       mDialogPanel.add(mStructurePane, "1,7,3,7");
       mDialogPanel.validate();
       getDialog().pack();
     } else {
       StringBuilder sb = new StringBuilder();
       for (int i = 0; i < mStructurePane.getModel().getSize(); i++) {
         sb.append(mStructurePane.getModel().getCompound(i));
         sb.append('\n');
       }
       mTextArea.setText(sb.toString());
       mDialogPanel.remove(mStructurePane);
       mDialogPanel.add(mScrollPane, "1,7,3,7");
       mDialogPanel.validate();
       getDialog().pack();
       mScrollPane.repaint();
     }
   }
 }
コード例 #2
0
 private void enableItems() {
   boolean enabled = mRadioButton.isSelected();
   if (mDefaultColumn != -1) {
     mList.setEnabled(enabled);
     mButtonSort.setEnabled(enabled);
   } else {
     boolean listIsEnabled = enabled && !mRadioButtonSort.isSelected();
     mRadioButtonIsStructure.setEnabled(listIsEnabled);
     if (mStructurePane != null) mStructurePane.setEnabled(listIsEnabled);
     mTextArea.setEnabled(listIsEnabled);
     mRadioButtonSort.setEnabled(enabled);
   }
   boolean sortIsEnabled = enabled && (mRadioButtonSort == null || mRadioButtonSort.isSelected());
   mComboBoxSortOrder.setEnabled(sortIsEnabled);
   mComboBoxSortMode.setEnabled(sortIsEnabled);
   mComboBoxSortColumn.setEnabled(
       sortIsEnabled && mComboBoxSortMode.getSelectedIndex() != cSortModeSize);
 }