Added ombustion Model Combo Box (UI only)
This commit is contained in:
parent
bd679dea07
commit
edc1fabbbd
1 changed files with 48 additions and 0 deletions
|
|
@ -24,7 +24,17 @@
|
|||
*******************************************************************************/
|
||||
package eu.engys.combustion;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.ListCellRenderer;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -45,6 +55,8 @@ public class CombustionSolutionView extends AbstractSolutionView {
|
|||
private PanelBuilder builder;
|
||||
|
||||
private JCheckBox reaction;
|
||||
|
||||
JComboBox<String> modelsCombo;
|
||||
|
||||
public CombustionSolutionView(CombustionModule module) {
|
||||
this.module = module;
|
||||
|
|
@ -54,6 +66,23 @@ public class CombustionSolutionView extends AbstractSolutionView {
|
|||
public void buildThermal(PanelBuilder builder) {
|
||||
this.builder = builder;
|
||||
this.reaction = (JCheckBox) builder.startCheck("Reaction");
|
||||
|
||||
modelsCombo = new JComboBox<String>();
|
||||
modelsCombo.setPrototypeDisplayValue("Laminar");
|
||||
final ListCellRenderer<? super String> renderer = modelsCombo.getRenderer();
|
||||
modelsCombo.setRenderer(new ListCellRenderer<String>() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<? extends String> list, String value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
Component c = renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
if (c instanceof JLabel && value instanceof String) {
|
||||
String model = (String) value;
|
||||
((JLabel) c).setText(model);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
});
|
||||
|
||||
builder.addComponent("Combustion Model", modelsCombo);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -88,6 +117,25 @@ public class CombustionSolutionView extends AbstractSolutionView {
|
|||
} else {
|
||||
reaction.setEnabled(false);
|
||||
}
|
||||
|
||||
String selectedItem = modelsCombo.getItemAt(modelsCombo.getSelectedIndex());
|
||||
|
||||
List<String> models = Arrays.asList(new String[]{"Laminar", "PaSR"});
|
||||
|
||||
modelsCombo.removeAllItems();
|
||||
String laminar = null;
|
||||
for (String combModel : models) {
|
||||
modelsCombo.addItem(combModel);
|
||||
if (combModel == "Laminar") {
|
||||
laminar = combModel;
|
||||
}
|
||||
}
|
||||
|
||||
if (((DefaultComboBoxModel<String>) modelsCombo.getModel()).getIndexOf(selectedItem) < 0) {
|
||||
modelsCombo.setSelectedItem(laminar);
|
||||
} else {
|
||||
modelsCombo.setSelectedItem(selectedItem);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue