package urgrip.installation; import com.ur.urcap.api.contribution.installation.swing.SwingInstallationNodeView; import com.ur.urcap.api.domain.io.IO; import com.ur.urcap.api.domain.userinteraction.keyboard.KeyboardTextInput; import urgrip.programnodes.Style; import javax.swing.*; import javax.swing.text.SimpleAttributeSet; import javax.swing.text.StyleConstants; import java.awt.Component; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Collection; import java.util.Vector; import static urgrip.installation.HelloWorldInstallationNodeContribution.*; public class HelloWorldInstallationNodeView implements SwingInstallationNodeView { private final Style style; private JComboBox ddGrip; private JComboBox ddBlow; private JComboBox ddWaitFor; public HelloWorldInstallationNodeView(Style style) { this.style = style; } @Override public void buildUI(JPanel jPanel, final HelloWorldInstallationNodeContribution installationNode) { jPanel.setLayout(new BoxLayout(jPanel, BoxLayout.Y_AXIS)); jPanel.add(createInfo()); jPanel.add(createVerticalSpacing()); // jPanel.add(createInput(installationNode)); ddGrip = createDropdown(KEY_GRIP); jPanel.add(ddGrip); ddBlow = createDropdown(KEY_BLOWOUT); jPanel.add(ddBlow); ddWaitFor = createDropdown(KEY_WAITFOR); jPanel.add(ddWaitFor); } private JComboBox createDropdown(String key) { Box section = Box.createHorizontalBox(); section.setAlignmentX(Component.LEFT_ALIGNMENT); JComboBox jcb = new JComboBox(); jcb.setPreferredSize(style.getInputfieldSize()); jcb.setMaximumSize(style.getInputfieldSize()); jcb.setMinimumSize(style.getInputfieldSize()); jcb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { } }); section.add(new JLabel(key)); section.add(jcb); return jcb; } private Box createInfo() { Box infoBox = Box.createVerticalBox(); infoBox.setAlignmentX(Component.LEFT_ALIGNMENT); JTextPane pane = new JTextPane(); pane.setBorder(BorderFactory.createEmptyBorder()); SimpleAttributeSet attributeSet = new SimpleAttributeSet(); StyleConstants.setLineSpacing(attributeSet, 0.5f); StyleConstants.setLeftIndent(attributeSet, 0f); pane.setParagraphAttributes(attributeSet, false); pane.setText("The popup title below is shared between all Hello World program nodes.\nThe title cannot be empty."); pane.setEditable(false); pane.setMaximumSize(pane.getPreferredSize()); pane.setBackground(infoBox.getBackground()); infoBox.add(pane); return infoBox; } private Component createHorizontalSpacing() { return Box.createRigidArea(new Dimension(style.getHorizontalSpacing(), 0)); } private Component createVerticalSpacing() { return Box.createRigidArea(new Dimension(0, style.getVerticalSpacing())); } public void setIO(Collection ios) { Vector iov=new Vector<>(); iov.addAll(ios); ddGrip.setModel(new DefaultComboBoxModel(iov)); ddBlow.setModel(new DefaultComboBoxModel(iov)); ddWaitFor.setModel(new DefaultComboBoxModel(iov)); } }