import org.openmolecules.datawarrior.plugin.IPluginHelper; import org.openmolecules.datawarrior.plugin.IPluginTask; import org.openmolecules.datawarrior.plugin.IUserInterfaceHelper; import javax.swing.*; import java.awt.*; import java.util.ArrayList; import java.util.Properties; /** * This PluginTask offers three different properties to be calculated from the chemical structure. * The user is asked, which of the properties shall be calculated. Then the plugin generates * the respective number of new columns. Then, in a loop over all rows, the plugin gets the * chemical structures from the currently open DataWarrior table, calculates the properties, * and writes them into the new columns. Finally, it calls finalizeNewColumns(), which causes * DataWarrior to analyse the columns and to create new default filters for them. */ public class ExamplePluginTask3 implements IPluginTask { private static final String CONFIGURATION_PROPERTY_LIST = "propertyList"; private static final String[] PROPERTY_NAME = { "Smiles Length", "Smiles 'C' Count", "Ratio O/C" }; private static final String[] PROPERTY_CODE = { "slen", "ccount", "o/c" }; private JCheckBox[] mCheckBox; @Override public String getTaskCode() { return "OpenMoleculesExample003"; } @Override public String getTaskName() { return "Plugin Example: Add Properties"; } /** * This method expects a JPanel with all UI-elements for defining a database query. * These may include elements to define a structure search and/or alphanumerical * search criteria. 'Cancel' and 'OK' buttons are provided outside of this panel. * @param dialogHelper is not used in this example * @return */ @Override public JComponent createDialogContent(IUserInterfaceHelper dialogHelper) { mCheckBox = new JCheckBox[PROPERTY_NAME.length]; JPanel panel = new JPanel(); panel.setLayout(new GridLayout(1+PROPERTY_NAME.length, 1, 8, 8)); panel.add(new JLabel("Select Properties")); for (int i=0; i * - to run the query independent from the actual dialog
* - to populate a dialog with a query that has been performed earlier
* @return query configuration */ @Override public Properties getDialogConfiguration() { StringBuilder sb = new StringBuilder(); Properties configuration = new Properties(); for (int i=0; i columnTitleList = new ArrayList<>(); boolean[] calcProperty = new boolean[PROPERTY_CODE.length]; String[] propertyCode = configuration.getProperty(CONFIGURATION_PROPERTY_LIST, "").split(","); for (int i = 0; i