@Override public Properties getDialogConfiguration() { Properties configuration = new Properties(); boolean isStructure = (mDefaultColumn != -1) ? CompoundTableConstants.cColumnTypeIDCode.equals( mTableModel.getColumnSpecialType(mDefaultColumn)) : mRadioButtonIsStructure.isSelected(); configuration.setProperty(PROPERTY_IS_STRUCTURE, isStructure ? "true" : "false"); String columnName = (mDefaultColumn == -1) ? (String) mComboBoxColumn.getSelectedItem() : mTableModel.getColumnTitleNoAlias(mDefaultColumn); configuration.setProperty(PROPERTY_COLUMN, columnName); if (mRadioButton.isSelected()) { if (mDefaultColumn != -1) { if (mActiveSortMode != -1) { configuration.setProperty(PROPERTY_SORT_MODE, SORT_MODE_CODE[mActiveSortMode]); configuration.setProperty( PROPERTY_SORT_IS_ASCENDING, mActiveSortIsAscending ? "true" : "false"); if (mActiveSortMode != cSortModeSize) configuration.setProperty( PROPERTY_SORT_COLUMN, mTableModel.getColumnTitleNoAlias(mActiveSortColumn)); } else { StringBuilder sb = new StringBuilder((String) mListModel.elementAt(0)); for (int i = 1; i < mListModel.getSize(); i++) sb.append('\t').append((String) mListModel.elementAt(i)); configuration.setProperty(PROPERTY_LIST, sb.toString()); } } else { if (mRadioButtonSort.isSelected()) { configuration.setProperty( PROPERTY_SORT_IS_ASCENDING, mComboBoxSortOrder.getSelectedIndex() == 0 ? "true" : "false"); configuration.setProperty( PROPERTY_SORT_MODE, SORT_MODE_CODE[mComboBoxSortMode.getSelectedIndex()]); if (mComboBoxSortMode.getSelectedIndex() != cSortModeSize) configuration.setProperty( PROPERTY_SORT_COLUMN, (String) mComboBoxSortColumn.getSelectedItem()); } else { if (mRadioButtonIsStructure.isSelected()) { CompoundCollectionModel<String> model = mStructurePane.getModel(); if (model.getSize() != 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < model.getSize(); i++) { sb.append(model.getCompound(i)); sb.append('\t'); } configuration.put(PROPERTY_LIST, sb.toString()); } } else { configuration.put(PROPERTY_LIST, mTextArea.getText().replace('\n', '\t')); } } } } return configuration; }
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); }
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(); } } }