123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- 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<HelloWorldInstallationNodeContribution> {
- 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<IO> ios) {
- Vector<IO> iov=new Vector<>();
- iov.addAll(ios);
- ddGrip.setModel(new DefaultComboBoxModel(iov));
- ddBlow.setModel(new DefaultComboBoxModel(iov));
- ddWaitFor.setModel(new DefaultComboBoxModel(iov));
- }
- }
|