@SuppressWarnings("unchecked") public boolean validateOperatorPanel(boolean showErrors, Object data) { try { String idText = this.jTF_id.getText(); AbstractRuleOperator ruleOp = (AbstractRuleOperator) this.operator; AbstractRuleOperator ruleChildOp = (AbstractRuleOperator) this.child; ruleOp.setActiveConnection(ruleChildOp, this.jCB_activate.isSelected()); boolean ret = ruleChildOp.setOpID(idText, this.isActive()); if (ret) { ruleOp.setChildOpID(ruleChildOp, idText); } ruleOp.setMode(ruleChildOp, this.getMode()); if (!idText.equals("")) { try { Integer.parseInt(idText); } catch (NumberFormatException nfe) { HashMap<String, Operator> names = (HashMap<String, Operator>) data; if (names.containsKey(idText)) { throw new ModificationException("Name already in use!", this.operator); } else { names.put(idText, this.operator); } } } } catch (ModificationException me) { if (showErrors) { JOptionPane.showOptionDialog( this.parent.visualEditor, me.getMessage(), "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, null, null); this.jTF_id.grabFocus(); } return false; } return true; }
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); }