// Constructor public PrefixOperatorPanel( final VisualGraph<Operator> parent, GraphWrapper gw, final PrefixOperator prefix, String name, boolean startNode, boolean alsoSubClasses) { super(parent, gw, prefix, true); /* ************************************************ ** * EBNF: ** * ** * Prefix ::= 'Prefix' '(' NCName ANGLEBRACKIRI ')' ** * ************************************************ */ this.prefix = prefix; this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.prefixRowsPanel = new JPanel(new GridBagLayout()); this.prefixRowsPanel.setOpaque(false); Border raisedbevel = BorderFactory.createRaisedBevelBorder(); this.setBorder(raisedbevel); this.gbc = new GridBagConstraints(); this.gbc.anchor = GridBagConstraints.NORTHWEST; this.gbc.gridwidth = this.gbc.gridheight = 1; this.gbc.weightx = this.gbc.weighty = 1.0; this.gbc.insets = new Insets( (int) parent.PADDING, (int) parent.PADDING, (int) parent.PADDING, (int) parent.PADDING); this.gbc.gridx = this.gbc.gridy = 0; this.gbc.fill = GridBagConstraints.BOTH; if (this.prefix.hasElements()) { for (final String namespace : this.prefix.getPrefixList().keySet()) { this.createPrefixRow(this.prefix.getPrefixList().get(namespace), namespace); } } // Button Dimension buttonDimension = new Dimension(); buttonDimension.setSize(30d, 24d); final JIconButton addButton = new JIconButton("icons/001_01.png"); addButton.setPreferredSize(buttonDimension); addButton.setMaximumSize(buttonDimension); addButton.setMinimumSize(buttonDimension); addButton.setFont(parent.getFONT()); addButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (prefix.getPrefixCount() >= prefix.getPrefixRowCnt()) { prefix.setPrefixRowCnt(prefix.getPrefixRowCnt() + 1); createPrefixRow("", ""); updateSize(); } } }); this.add(this.prefixRowsPanel); this.add(addButton); // add add-button to row panel // if (!this.prefix.hasElements()){ this.createPrefixRow("", ""); // } this.addComponentListener( new ComponentAdapter() { public void componentResized(ComponentEvent e) { updateSize(); } }); this.updateSize(); }
public AnnotationPanel( final VisualGraph<Operator> parent, final AbstractRuleOperator operator, final AbstractRuleOperator child, Triple<Boolean, String, ModeEnum> data) { super(parent, new GraphWrapperOperator(operator), operator, false); this.parentOp = operator; this.child = child; boolean active = false; String opID = ""; ModeEnum mode = ModeEnum.EXISTS; if (data != null) { active = data.getFirst(); if (!data.getSecond().equals("-1")) { opID = data.getSecond(); } mode = data.getThird(); } this.setLayout(new GridBagLayout()); GridBagConstraints mainGBC = new GridBagConstraints(); mainGBC.gridwidth = 3; mainGBC.gridheight = 1; mainGBC.gridx = mainGBC.gridy = 0; mainGBC.fill = GridBagConstraints.NONE; mainGBC.anchor = GridBagConstraints.WEST; mainGBC.weighty = 1.0; // mainGBC.insets = new Insets((int) parent.PADDING, (int) parent.PADDING, (int) parent.PADDING, // (int) parent.PADDING); this.jTF_id = new JTextField(opID, 2); this.jTF_id.setFont(parent.getFONT()); this.jTF_id.setEnabled(active); this.jTF_id.addFocusListener( new FocusListener() { public void focusGained(FocusEvent fe) {} public void focusLost(FocusEvent fe) { String content = that.jTF_id.getText(); if (!content.equals("")) { try { child.setOpID(content, that.isActive()); operator.setChildOpID(child, content); } catch (ModificationException me) { int n = AbstractGuiComponent.showCorrectIgnoreOptionDialog(parent, me.getMessage()); if (n == JOptionPane.YES_OPTION) { (new FocusThread(that.jTF_id)).start(); } } } } }); this.jCB_activate = new JCheckBoxOwnIcon("activate", active, parent.getFONT()); this.jCB_activate.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent ie) { // get new state... boolean selected = (ie.getStateChange() == ItemEvent.SELECTED); that.jTF_id.setEnabled(selected); operator.setActiveConnection(child, selected); } }); final Color transparent = new Color(0, 0, 0, 0); this.jRB_mode_exists = new JRadioButton(ModeEnum.EXISTS.toString(), mode == ModeEnum.EXISTS); this.jRB_mode_exists.setFont(parent.getFONT()); this.jRB_mode_exists.setBackground(transparent); this.jRB_mode_exists.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { if (that.jRB_mode_exists.isSelected()) { operator.setMode(child, ModeEnum.EXISTS); } } }); this.jRB_mode_all_preceding = new JRadioButton(ModeEnum.ALL_PRECEDING.toString(), mode == ModeEnum.ALL_PRECEDING); this.jRB_mode_all_preceding.setFont(parent.getFONT()); this.jRB_mode_all_preceding.setBackground(transparent); this.jRB_mode_all_preceding.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { if (that.jRB_mode_all_preceding.isSelected()) { operator.setMode(child, ModeEnum.ALL_PRECEDING); } } }); this.jRB_mode_only_preceding = new JRadioButton(ModeEnum.ONLY_PRECEDING.toString(), mode == ModeEnum.ONLY_PRECEDING); this.jRB_mode_only_preceding.setFont(parent.getFONT()); this.jRB_mode_only_preceding.setBackground(transparent); this.jRB_mode_only_preceding.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { if (that.jRB_mode_only_preceding.isSelected()) { operator.setMode(child, ModeEnum.ONLY_PRECEDING); } } }); this.jRB_mode_all_succeeding = new JRadioButton(ModeEnum.ALL_SUCCEEDING.toString(), mode == ModeEnum.ALL_SUCCEEDING); this.jRB_mode_all_succeeding.setFont(parent.getFONT()); this.jRB_mode_all_succeeding.setBackground(transparent); this.jRB_mode_all_succeeding.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { if (that.jRB_mode_all_succeeding.isSelected()) { operator.setMode(child, ModeEnum.ALL_SUCCEEDING); } } }); this.jRB_mode_only_succeeding = new JRadioButton(ModeEnum.ONLY_SUCCEEDING.toString(), mode == ModeEnum.ONLY_SUCCEEDING); this.jRB_mode_only_succeeding.setFont(parent.getFONT()); this.jRB_mode_only_succeeding.setBackground(transparent); this.jRB_mode_only_succeeding.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { if (that.jRB_mode_only_succeeding.isSelected()) { operator.setMode(child, ModeEnum.ONLY_SUCCEEDING); } } }); this.jRB_mode_only_preceding_and_succeeding = new JRadioButton( ModeEnum.ONLY_PRECEDING_AND_SUCCEEDING.toString(), mode == ModeEnum.ONLY_PRECEDING_AND_SUCCEEDING); this.jRB_mode_only_preceding_and_succeeding.setFont(parent.getFONT()); this.jRB_mode_only_preceding_and_succeeding.setBackground(transparent); this.jRB_mode_only_preceding_and_succeeding.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ae) { if (that.jRB_mode_only_preceding_and_succeeding.isSelected()) { operator.setMode(child, ModeEnum.ONLY_PRECEDING_AND_SUCCEEDING); } } }); ButtonGroup group = new ButtonGroup(); group.add(this.jRB_mode_exists); group.add(this.jRB_mode_all_preceding); group.add(this.jRB_mode_only_preceding); group.add(this.jRB_mode_all_succeeding); group.add(this.jRB_mode_only_succeeding); group.add(this.jRB_mode_only_preceding_and_succeeding); if (operator.getClass() == JumpOverOperator.class || child.getClass() == JumpOverOperator.class) { this.jRB_mode_only_preceding_and_succeeding.setSelected(true); operator.setMode(child, ModeEnum.ONLY_PRECEDING_AND_SUCCEEDING); this.jRB_mode_exists.setEnabled(false); this.jRB_mode_all_preceding.setEnabled(false); this.jRB_mode_only_preceding.setEnabled(false); this.jRB_mode_all_succeeding.setEnabled(false); this.jRB_mode_only_succeeding.setEnabled(false); this.jRB_mode_only_preceding_and_succeeding.setEnabled(false); } this.jL_id = new JLabel("ID:"); this.jL_id.setFont(parent.getFONT()); this.jL_opID = new JLabel("OperandID"); this.jL_opID.setFont(parent.getFONT()); this.add(this.jL_opID, mainGBC); mainGBC.gridy++; mainGBC.gridx = 0; mainGBC.gridwidth = 1; this.add(this.jCB_activate, mainGBC); mainGBC.gridx++; this.add(this.jL_id, mainGBC); mainGBC.gridx++; this.add(this.jTF_id, mainGBC); mainGBC.gridy++; mainGBC.gridx = 0; mainGBC.gridwidth = 1; this.add(this.jRB_mode_exists, mainGBC); mainGBC.gridx++; this.add(this.jRB_mode_only_preceding, mainGBC); mainGBC.gridx++; this.add(this.jRB_mode_all_preceding, mainGBC); mainGBC.gridy++; mainGBC.gridx = 1; this.add(this.jRB_mode_only_succeeding, mainGBC); mainGBC.gridx++; this.add(this.jRB_mode_all_succeeding, mainGBC); mainGBC.gridy++; mainGBC.gridx = 1; mainGBC.gridwidth = 2; this.add(this.jRB_mode_only_preceding_and_succeeding, mainGBC); }