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++;
}
}
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++;
}
}
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);
}
}
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);
}
}
}
}
}
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();
}
Aggregations