Search in sources :

Example 1 with Parameter

use of net.sf.mzmine.parameters.Parameter in project mzmine2 by mzmine.

the class MSMSLibrarySubmissionWindow method createMetaDataPanel.

private void createMetaDataPanel() {
    // Main panel which holds all the components in a grid
    pnMetaData = new GridBagPanel();
    scrollMeta = new JScrollPane(pnMetaData);
    scrollMeta.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollMeta.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    pnSideMenu.add(scrollMeta, BorderLayout.CENTER);
    int rowCounter = 0;
    int vertWeightSum = 0;
    // Create labels and components for each parameter
    for (Parameter p : paramMeta.getParameters()) {
        if (!(p instanceof UserParameter))
            continue;
        UserParameter up = (UserParameter) p;
        JComponent comp = up.createEditingComponent();
        comp.setToolTipText(up.getDescription());
        // Set the initial value
        Object value = up.getValue();
        if (value != null)
            up.setValueToComponent(comp, value);
        // By calling this we make sure the components will never be resized
        // smaller than their optimal size
        comp.setMinimumSize(comp.getPreferredSize());
        comp.setToolTipText(up.getDescription());
        JLabel label = new JLabel(p.getName());
        pnMetaData.add(label, 0, rowCounter);
        label.setLabelFor(comp);
        parametersAndComponents.put(p.getName(), comp);
        JComboBox t = new JComboBox();
        int comboh = t.getPreferredSize().height;
        int comph = comp.getPreferredSize().height;
        // Multiple selection will be expandable, other components not
        int verticalWeight = comph > 2 * comboh ? 1 : 0;
        vertWeightSum += verticalWeight;
        pnMetaData.add(comp, 1, rowCounter, 1, 1, 1, verticalWeight, GridBagConstraints.VERTICAL);
        rowCounter++;
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) UserParameter(net.sf.mzmine.parameters.UserParameter) JComboBox(javax.swing.JComboBox) JComponent(javax.swing.JComponent) UserParameter(net.sf.mzmine.parameters.UserParameter) Parameter(net.sf.mzmine.parameters.Parameter) JLabel(javax.swing.JLabel) GridBagPanel(net.sf.mzmine.util.components.GridBagPanel) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Example 2 with Parameter

use of net.sf.mzmine.parameters.Parameter in project mzmine2 by mzmine.

the class MSMSLibrarySubmissionWindow method createSubmitParamPanel.

private void createSubmitParamPanel() {
    // Main panel which holds all the components in a grid
    pnSubmitParam = new GridBagPanel();
    pnSideMenu.add(pnSubmitParam, BorderLayout.NORTH);
    int rowCounter = 0;
    // Create labels and components for each parameter
    for (Parameter p : paramSubmit.getParameters()) {
        if (!(p instanceof UserParameter))
            continue;
        UserParameter up = (UserParameter) p;
        JComponent comp = up.createEditingComponent();
        comp.setToolTipText(up.getDescription());
        // Set the initial value
        Object value = up.getValue();
        if (value != null)
            up.setValueToComponent(comp, value);
        // By calling this we make sure the components will never be resized
        // smaller than their optimal size
        comp.setMinimumSize(comp.getPreferredSize());
        comp.setToolTipText(up.getDescription());
        // add separator
        if (p.getName().equals(LibrarySubmitParameters.LOCALFILE.getName())) {
            pnSubmitParam.addSeparator(0, rowCounter, 2);
            rowCounter++;
        }
        JLabel label = new JLabel(p.getName());
        pnSubmitParam.add(label, 0, rowCounter);
        label.setLabelFor(comp);
        parametersAndComponents.put(p.getName(), comp);
        JComboBox t = new JComboBox();
        int comboh = t.getPreferredSize().height;
        int comph = comp.getPreferredSize().height;
        int verticalWeight = comph > 2 * comboh ? 1 : 0;
        pnSubmitParam.add(comp, 1, rowCounter, 1, 1, 1, verticalWeight, GridBagConstraints.VERTICAL);
        rowCounter++;
    }
}
Also used : UserParameter(net.sf.mzmine.parameters.UserParameter) JComboBox(javax.swing.JComboBox) JComponent(javax.swing.JComponent) UserParameter(net.sf.mzmine.parameters.UserParameter) Parameter(net.sf.mzmine.parameters.Parameter) JLabel(javax.swing.JLabel) GridBagPanel(net.sf.mzmine.util.components.GridBagPanel) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Example 3 with Parameter

use of net.sf.mzmine.parameters.Parameter in project mzmine2 by mzmine.

the class ParameterSetParameter method saveValueToXML.

@Override
public void saveValueToXML(Element xmlElement) {
    if (this.value == null)
        return;
    xmlElement.setAttribute("type", this.name);
    Document parent = xmlElement.getOwnerDocument();
    for (Parameter p : this.value.getParameters()) {
        Element newElement = parent.createElement(parameterElement);
        newElement.setAttribute(nameAttribute, p.getName());
        xmlElement.appendChild(newElement);
        p.saveValueToXML(newElement);
    }
}
Also used : Element(org.w3c.dom.Element) Parameter(net.sf.mzmine.parameters.Parameter) UserParameter(net.sf.mzmine.parameters.UserParameter) Document(org.w3c.dom.Document)

Example 4 with Parameter

use of net.sf.mzmine.parameters.Parameter in project mzmine2 by mzmine.

the class ParameterSetParameter method loadValueFromXML.

@Override
public void loadValueFromXML(Element xmlElement) {
    NodeList list = xmlElement.getElementsByTagName(parameterElement);
    for (int i = 0; i < list.getLength(); ++i) {
        Element nextElement = (Element) list.item(i);
        String paramName = nextElement.getAttribute(nameAttribute);
        for (Parameter p : this.value.getParameters()) {
            if (p.getName().equals(paramName)) {
                try {
                    p.loadValueFromXML(nextElement);
                } catch (Exception e) {
                    LOG.log(Level.WARNING, "Error while loading parameter values for " + p.getName(), e);
                }
            }
        }
    }
}
Also used : NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) Parameter(net.sf.mzmine.parameters.Parameter) UserParameter(net.sf.mzmine.parameters.UserParameter)

Example 5 with Parameter

use of net.sf.mzmine.parameters.Parameter in project mzmine2 by mzmine.

the class ParameterSetupDialog method addDialogComponents.

/**
 * Constructs all components of the dialog
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void addDialogComponents() {
    // Main panel which holds all the components in a grid
    mainPanel = new GridBagPanel();
    int rowCounter = 0;
    int vertWeightSum = 0;
    // Create labels and components for each parameter
    for (Parameter p : parameterSet.getParameters()) {
        if (!(p instanceof UserParameter))
            continue;
        UserParameter up = (UserParameter) p;
        JComponent comp = up.createEditingComponent();
        comp.setToolTipText(up.getDescription());
        // Set the initial value
        Object value = up.getValue();
        if (value != null)
            up.setValueToComponent(comp, value);
        // Add listeners so we are notified about any change in the values
        addListenersToComponent(comp);
        // By calling this we make sure the components will never be resized
        // smaller than their optimal size
        comp.setMinimumSize(comp.getPreferredSize());
        comp.setToolTipText(up.getDescription());
        JLabel label = new JLabel(p.getName());
        mainPanel.add(label, 0, rowCounter);
        label.setLabelFor(comp);
        parametersAndComponents.put(p.getName(), comp);
        JComboBox t = new JComboBox();
        int comboh = t.getPreferredSize().height;
        int comph = comp.getPreferredSize().height;
        // Multiple selection will be expandable, other components not
        int verticalWeight = comph > 2 * comboh ? 1 : 0;
        vertWeightSum += verticalWeight;
        mainPanel.add(comp, 1, rowCounter, 1, 1, 1, verticalWeight, GridBagConstraints.VERTICAL);
        rowCounter++;
    }
    // Add a single empty cell to the 99th row. This cell is expandable
    // (weightY is 1), therefore the other components will be
    // aligned to the top, which is what we want
    // JComponent emptySpace = (JComponent) Box.createVerticalStrut(1);
    // mainPanel.add(emptySpace, 0, 99, 3, 1, 0, 1);
    // Create a separate panel for the buttons
    pnlButtons = new JPanel();
    btnOK = GUIUtils.addButton(pnlButtons, "OK", null, this);
    btnCancel = GUIUtils.addButton(pnlButtons, "Cancel", null, this);
    if (helpURL != null) {
        btnHelp = GUIUtils.addButton(pnlButtons, "Help", null, this);
    }
    /*
     * Last row in the table will be occupied by the buttons. We set the row number to 100 and width
     * to 3, spanning the 3 component columns defined above.
     */
    if (vertWeightSum == 0) {
        mainPanel.add(Box.createGlue(), 0, 99, 3, 1, 1, 1);
    }
    if (footerMessage == null) {
        mainPanel.addCenter(pnlButtons, 0, 100, 3, 1);
    } else {
        // Footer
        JEditorPane editorPane = GUIUtils.addEditorPane(footerMessage);
        editorPane.addHyperlinkListener(new HyperlinkListener() {

            @Override
            public void hyperlinkUpdate(HyperlinkEvent e) {
                if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
                    try {
                        Desktop.getDesktop().browse(e.getURL().toURI());
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            }
        });
        // This line is important on Windows, where resizing the dialog has unexpected consequences on
        // some components
        editorPane.setMinimumSize(editorPane.getPreferredSize());
        mainPanel.add(editorPane, 0, 98, 3, 1);
        mainPanel.addCenter(pnlButtons, 0, 100, 3, 1);
    }
    // Add some space around the widgets
    GUIUtils.addMargin(mainPanel, 10);
    // Add the main panel as the only component of this dialog
    add(mainPanel);
    pack();
}
Also used : JPanel(javax.swing.JPanel) HyperlinkEvent(javax.swing.event.HyperlinkEvent) JComboBox(javax.swing.JComboBox) JComponent(javax.swing.JComponent) JLabel(javax.swing.JLabel) UserParameter(net.sf.mzmine.parameters.UserParameter) HyperlinkListener(javax.swing.event.HyperlinkListener) JEditorPane(javax.swing.JEditorPane) Parameter(net.sf.mzmine.parameters.Parameter) UserParameter(net.sf.mzmine.parameters.UserParameter) HiddenParameter(net.sf.mzmine.parameters.parametertypes.HiddenParameter) GridBagPanel(net.sf.mzmine.util.components.GridBagPanel)

Aggregations

Parameter (net.sf.mzmine.parameters.Parameter)8 UserParameter (net.sf.mzmine.parameters.UserParameter)5 JComboBox (javax.swing.JComboBox)3 JComponent (javax.swing.JComponent)3 JLabel (javax.swing.JLabel)3 ComboParameter (net.sf.mzmine.parameters.parametertypes.ComboParameter)3 GridBagPanel (net.sf.mzmine.util.components.GridBagPanel)3 DataPoint (net.sf.mzmine.datamodel.DataPoint)2 SimpleParameterSet (net.sf.mzmine.parameters.impl.SimpleParameterSet)2 BooleanParameter (net.sf.mzmine.parameters.parametertypes.BooleanParameter)2 DoubleParameter (net.sf.mzmine.parameters.parametertypes.DoubleParameter)2 IntegerParameter (net.sf.mzmine.parameters.parametertypes.IntegerParameter)2 StringParameter (net.sf.mzmine.parameters.parametertypes.StringParameter)2 ExitCode (net.sf.mzmine.util.ExitCode)2 Element (org.w3c.dom.Element)2 Color (java.awt.Color)1 Window (java.awt.Window)1 JEditorPane (javax.swing.JEditorPane)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1