Package lupos.gui.operatorgraph.visualeditor.queryeditor.operators

Examples of lupos.gui.operatorgraph.visualeditor.queryeditor.operators.RetrieveDataWithSolutionModifier


    this.add(fromNamedPanel);
  }

  private void createOrderByElements() {
    final RetrieveDataWithSolutionModifier operator = (RetrieveDataWithSolutionModifier) this.operator;

    JPanel orderByPanel = this.getRowPanel(); // get panel for row

    // determine initial state of orderBy CheckBox...
    boolean orderBy = operator.getOrderByList().size() > 0;

    // create orderBy CheckBox...
    JCheckBoxOwnIcon orderByCB = new JCheckBoxOwnIcon("Order By", orderBy, this.parent.getFONT());
    orderByCB.setOpaque(false);

    elementStatus.put("orderBy", orderBy);

    orderByPanel.add(orderByCB); // add orderBy CheckBox to row panel

    // create panel for orderBy elements...
    final JPanel orderByElementsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    orderByElementsPanel.setOpaque(false);

    // walk through orderBy elements of the select operator...
    for(int i = 0; i < operator.getOrderByList().size(); ++i) {
      SortContainer sortContainer = operator.getOrderByList().get(i);

      // add spacer if this is not the first element...
      if(this.orderByElementsList.size() > 0) {
        orderByElementsPanel.add(Box.createRigidArea(new Dimension(10, 3)));
      }

      // determine right selectedIndex for ComboBox...
      int selectedIndex = (sortContainer.isDesc()) ? 1 : 0;

      // create new orderBy element panel and set the initial state...
      JPanel orderByElement = this.createOrderByElement(orderBy, i, sortContainer, selectedIndex, sortContainer.getSortString());

      orderByElementsPanel.add(orderByElement); // add orderBy element
      // panel to row panel
    }

    orderByPanel.add(orderByElementsPanel); // add panel for orderBy
    // elements to row panel

    final LinkedList<JComponent> needsEnableList = new LinkedList<JComponent>();

    if(operator.getOrderByList().size() == 0) {
      SortContainer sortContainer = null;

      try {
        sortContainer = new SortContainer(((VisualGraphOperatorWithPrefix) this.parent).prefix, false, "");
        sortContainer.setOperator(operator);
      }
      catch(ModificationException me) {
        me.printStackTrace();
      }

      // create new orderBy element panel and set the initial state...
      JPanel orderByElement = this.createOrderByElement(true, operator.getOrderByList().size(), sortContainer, 0, "");
      orderByElement.setVisible(orderBy);

      orderByElementsPanel.add(orderByElement); // add orderBy element
      // panel to row panel

      needsEnableList.add(orderByElement);
    }

    // create add button...
    final JLabel addLabel = new JLabel(this.parent.addIcon);
    addLabel.setVisible(orderBy);
    addLabel.addMouseListener(new MouseAdapter() {
      public void mouseClicked(MouseEvent me) {
        // add spacer if this is not the first element...
        if(orderByElementsList.size() > 0) {
          orderByElementsPanel.add(Box.createRigidArea(new Dimension(10, 3)));
        }

        SortContainer sortContainer = null;

        try {
          sortContainer = new SortContainer(((VisualGraphOperatorWithPrefix) parent).prefix, false, "");
          sortContainer.setOperator(operator);
        }
        catch(ModificationException mex) {
          mex.printStackTrace();
        }

        operator.addOrderByElement(sortContainer);

        // create new orderBy element panel and set the initial state...
        JPanel orderByElement = createOrderByElement(true, operator.getOrderByList().size(), sortContainer, 0, "");

        orderByElementsPanel.add(orderByElement); // add orderBy element
        // panel to row
        // panel

        updateSize(); // update the size of the RetrieveDataPanel
      }
    });

    orderByPanel.add(addLabel); // add add button to row panel

    needsEnableList.add(addLabel);

    // define listener for orderBy CheckBox...
    orderByCB.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent ie) {
        // get new state...
        boolean selected = (ie.getStateChange() == ItemEvent.SELECTED);

        elementStatus.put("orderBy", selected);

        // walk through fromNamed TextFields...
        for(int i = 0; i < orderByComboBoxesList.size(); ++i) {
          JComboBox jCoBo = orderByComboBoxesList.get(i);
          JTextField jTF = orderByElementsList.get(i);

          // set new state to current elements...
          jCoBo.setEnabled(selected);
          jTF.setEnabled(selected);

          if(selected) { // if state is selected and field is not
            // empty...
            // create SortContainer for current elements...
            SortContainer sc = null;

            try {
              sc = new SortContainer(((VisualGraphOperatorWithPrefix) parent).prefix, (jCoBo.getSelectedIndex() == 1), jTF.getText());
              sc.setOperator(operator);
            }
            catch(ModificationException me) {
              int n = AbstractGuiComponent.showCorrectIgnoreOptionDialog(parent, me.getMessage());

              if(n == JOptionPane.YES_OPTION) {
                (new FocusThread(jTF)).start();
              }
            }

            // add current element to orderBy list of SelectOP...
            operator.addOrderByElement(sc);
          }
        }

        // walk through Delete-Labels...
        for(JLabel delLabel : orderByElementsDelLabelsList) {
          delLabel.setEnabled(selected); // set new state of current Delete-Label
        }

        if(!selected) { // if state is not selected...
          operator.setNewOrderByList(new LinkedList<SortContainer>()); // clear
          // orderBy
          // list
          // of
          // SelectOP
          addLabel.setVisible(false);
View Full Code Here


    this.add(orderByPanel);
  }

  private void createLimitOffsetElements() {
    final RetrieveDataWithSolutionModifier operator = (RetrieveDataWithSolutionModifier) this.operator;

    JPanel limitOffsetPanel = this.getRowPanel(); // get panel for row

    // create limit CheckBox...
    JCheckBoxOwnIcon limitCB = new JCheckBoxOwnIcon("Limit", (operator.getLimitValue() > -1), this.parent.getFONT());
    limitCB.setOpaque(false);

    elementStatus.put("limit", (operator.getLimitValue() > -1));

    limitOffsetPanel.add(limitCB); // add limit CheckBox to row panel

    this.limitTF.addFocusListener(new FocusAdapter() {
      public void focusLost(FocusEvent fe) {
        String content = limitTF.getText();

        if(!content.equals("")) {
          try {
            operator.setLimitValue(content);
          }
          catch(ModificationException me) {
            int n = AbstractGuiComponent.showCorrectIgnoreOptionDialog(parent, me.getMessage());

            if(n == JOptionPane.YES_OPTION) {
              (new FocusThread(limitTF)).start();
            }
          }
        }
      }
    });

    if(operator.getLimitValue() > -1) { // if there is a limit value...
      this.limitTF.setText("" + operator.getLimitValue()); // set it
    }
    else { // if there is no limit value...
      this.limitTF.setText("-1"); // set "0" as default value
      this.limitTF.setEnabled(false); // disable the limit TextField
    }

    // set new preferred size of the limit TextField...
    this.limitTF.setPreferredSize(new Dimension(this.limitTF.getPreferredSize().width + 20, this.limitTF.getPreferredSize().height));

    // define listener for limit CheckBox...
    limitCB.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent ie) {
        // get new state...
        boolean selected = (ie.getStateChange() == ItemEvent.SELECTED);

        elementStatus.put("limit", selected);

        limitTF.setEnabled(selected); // enable or disable limit
        // TextField according to new
        // state

        // set limit value in selectOP...
        try {
          if(!selected) {
            operator.setLimitValue("-1");
          }
          else if(selected) {
            operator.setLimitValue(limitTF.getText());
          }
        }
        catch(ModificationException me) {
          int n = AbstractGuiComponent.showCorrectIgnoreOptionDialog(parent, me.getMessage());

          if(n == JOptionPane.YES_OPTION) {
            (new FocusThread(limitTF)).start();
          }
        }
      }
    });

    limitOffsetPanel.add(this.limitTF); // add limit TextField to row panel

    limitOffsetPanel.add(Box.createRigidArea(new Dimension(10, 3))); // spacer

    // create offset CheckBox...
    JCheckBoxOwnIcon offsetCB = new JCheckBoxOwnIcon("Offset", (operator.getOffsetValue() > -1), this.parent.getFONT());
    offsetCB.setOpaque(false);

    elementStatus.put("offset", (operator.getOffsetValue() > -1));

    limitOffsetPanel.add(offsetCB); // add offset CheckBox to row panel

    this.offsetTF.addFocusListener(new FocusAdapter() {
      public void focusLost(FocusEvent fe) {
        String content = offsetTF.getText();

        if(!content.equals("")) {
          try {
            operator.setOffsetValue(content);
          }
          catch(ModificationException me) {
            int n = AbstractGuiComponent.showCorrectIgnoreOptionDialog(parent, me.getMessage());

            if(n == JOptionPane.YES_OPTION) {
              (new FocusThread(offsetTF)).start();
            }
          }
        }
      }
    });

    if(operator.getOffsetValue() > -1) { // if there is an offset value...
      this.offsetTF.setText("" + operator.getOffsetValue()); // set it
    }
    else { // if there is no offset value...
      this.offsetTF.setText("0"); // set "0" as default value
      this.offsetTF.setEnabled(false); // disable the offset TextField
    }

    // set new preferred size of the offset TextField...
    this.offsetTF.setPreferredSize(new Dimension(this.offsetTF.getPreferredSize().width + 20, this.offsetTF.getPreferredSize().height));

    // define listener for offset CheckBox...
    offsetCB.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent ie) {
        // get new state...
        boolean selected = (ie.getStateChange() == ItemEvent.SELECTED);

        elementStatus.put("offset", selected);

        offsetTF.setEnabled(selected); // enable or disable offset
        // TextField according to new
        // state

        // set offset value in selectOP...
        try {
          if(!selected) {
            operator.setOffsetValue("-1");
          }
          else if(selected) {
            operator.setOffsetValue(offsetTF.getText());
          }
        }
        catch(ModificationException me) {
          int n = AbstractGuiComponent.showCorrectIgnoreOptionDialog(parent, me.getMessage());
View Full Code Here

    return panel;
  }

  private JPanel createOrderByElement(boolean active, final int tmpIndex, final SortContainer sortContainer, int selectedIndex, String orderByString) {
    final RetrieveDataWithSolutionModifier operator = (RetrieveDataWithSolutionModifier) this.operator;

    final JPanel panel = new JPanel();
    panel.setOpaque(false);

    final JComboBox orderByCoBo = new JComboBox(new String[] { "ASC", "DESC" });
    orderByCoBo.setFont(this.parent.getFONT());
    orderByCoBo.setSelectedIndex(selectedIndex);
    orderByCoBo.setEnabled(active);
    orderByCoBo.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) {
        int chosen = orderByCoBo.getSelectedIndex(); // get new
        // state

        // update sortContainer of current element...
        sortContainer.setDesc((chosen == 1));

        // add current element to orderBy list of SelectOP...
        operator.setOrderByElement(tmpIndex, sortContainer);
      }
    });

    this.orderByComboBoxesList.add(orderByCoBo); // add ComboBox to orderBy
    // ComboBoxes list

    final JTextFieldResizing jtf = new JTextFieldResizing(orderByString, this.parent.getFONT(), this);
    jtf.setEnabled(active);
    jtf.addFocusListener(new FocusAdapter() {
      public void focusLost(final FocusEvent fe) {
        String content = jtf.getText();

        if(!content.equals("")) {
          try {
            // update sortContainer of current element...
            sortContainer.setSortString(jtf.getText());

            // add current element to orderBy list of SelectOP...
            operator.setOrderByElement(tmpIndex, sortContainer);
          }
          catch(ModificationException me) {
            int n = AbstractGuiComponent.showCorrectIgnoreOptionDialog(parent, me.getMessage());

            if(n == JOptionPane.YES_OPTION) {
              (new FocusThread(jtf)).start();
            }
          }
        }
      }
    });

    if(orderByString.equals("")) {
      jtf.setPreferredSize(new Dimension(20, jtf.getPreferredSize().height));
    }

    this.textElements.add(jtf);
    this.orderByElementsList.add(jtf); // add TextField to orderBy
    // TextFields list

    final JLabel delLabel = new JLabel(this.parent.delIcon);
    delLabel.setEnabled(active);
    delLabel.addMouseListener(new MouseAdapter() {
      public void mouseClicked(MouseEvent me) {
        if(delLabel.isEnabled()) { // only process click if label is
          // enabled...
          orderByComboBoxesList.remove(orderByCoBo);
          orderByElementsList.remove(jtf);
          orderByElementsDelLabelsList.remove(delLabel);
          textElements.remove(jtf);

          operator.removeOrderByElement(tmpIndex); // remove orderBy
          // element from
          // operator

          JPanel parentPanel = (JPanel) panel.getParent(); // get
          // parent
View Full Code Here

        return false;
      }
    }

    if(this.operator instanceof RetrieveDataWithSolutionModifier) {
      RetrieveDataWithSolutionModifier operator = (RetrieveDataWithSolutionModifier) this.operator;

      // ORDER BY...
      for(int i = 0; i < this.orderByElementsList.size(); ++i) {
        JTextField jtf = this.orderByElementsList.get(i);

        if(jtf.getText().equals("")) {
          continue;
        }

        SortContainer sortContainer = operator.getOrderByList().get(i);

        try {
          // update sortContainer of current element...
          sortContainer.setSortString(jtf.getText());

          // add current element to orderBy list of SelectOP...
          operator.setOrderByElement(i, sortContainer);
        }
        catch(ModificationException me) {
          if(showErrors) {
            JOptionPane.showOptionDialog(this.parent.visualEditor, me.getMessage(), "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, null, null);

            jtf.grabFocus();
          }

          return false;
        }
      }

      // LIMIT...
      try {
        operator.setLimitValue(this.limitTF.getText());
      }
      catch(ModificationException me) {
        if(showErrors) {
          JOptionPane.showOptionDialog(this.parent.visualEditor, me.getMessage(), "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, null, null);

          this.limitTF.grabFocus();
        }

        return false;
      }

      // OFFSET
      try {
        operator.setOffsetValue(this.offsetTF.getText());
      }
      catch(ModificationException me) {
        if(showErrors) {
          JOptionPane.showOptionDialog(this.parent.visualEditor, me.getMessage(), "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, null, null);
View Full Code Here

TOP

Related Classes of lupos.gui.operatorgraph.visualeditor.queryeditor.operators.RetrieveDataWithSolutionModifier

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.