Example #1
1
  private void updateTemplateFromEditor(PrintfTemplate template) {
    ArrayList params = new ArrayList();
    String format = null;
    int text_length = editorPane.getDocument().getLength();
    try {
      format = editorPane.getDocument().getText(0, text_length);
    } catch (BadLocationException ex1) {
    }
    Element section_el = editorPane.getDocument().getDefaultRootElement();
    // Get number of paragraphs.
    int num_para = section_el.getElementCount();
    for (int p_count = 0; p_count < num_para; p_count++) {
      Element para_el = section_el.getElement(p_count);
      // Enumerate the content elements
      int num_cont = para_el.getElementCount();
      for (int c_count = 0; c_count < num_cont; c_count++) {
        Element content_el = para_el.getElement(c_count);
        AttributeSet attr = content_el.getAttributes();
        // Get the name of the style applied to this content element; may be null
        String sn = (String) attr.getAttribute(StyleConstants.NameAttribute);
        // Check if style name match
        if (sn != null && sn.startsWith("Parameter")) {
          // we extract the label.
          JLabel l = (JLabel) StyleConstants.getComponent(attr);
          if (l != null) {
            params.add(l.getName());
          }
        }
      }
    }

    template.setFormat(format);
    template.setTokens(params);
  }
Example #2
0
  @Override
  public void mouseClicked(MouseEvent e) {
    // TODO Auto-generated method stub
    JLabel now = (JLabel) e.getSource();
    try {
      // Check now
      if (now.getName().equals("checknow")) {
        now.setText("Checking ...");
        now.setCursor(new Cursor(Cursor.WAIT_CURSOR));
        ExternalCommandPipe.forceCheckService(
            DIMS.getInstance().getCurrentHostName(), DIMS.getInstance().getCurrentServiceName());
        Thread.sleep(1000);

        DIMS myApp = DIMS.getInstance();
        UpdateWholeSystem updater = new UpdateWholeSystem();
        updater.update(myApp);
      }

      // Reschedule
      else if (now.getName().equals("reschedule")) {
        if (active == 0) {
          reschedule.setVisible(true);
          active = 1;
        } else {
          reschedule.setVisible(false);
          active = 0;
        }
      }

      // History
      else if (now.getName().equals("history")) {
        try {
          ShowServiceHistory shower = new ShowServiceHistory();
          DIMS.getInstance().getDetailContent().reloadContent(shower);
        } catch (SQLException e1) {
          // TODO Auto-generated catch block
          new FrameNotification(
              "Maybe something went wrong when you were trying to open a service<br>"
                  + e1.getMessage());
        }
      }

      // Service group
      else {
        if (IsServiceGroup.check(now.getName())) {
          DIMS.getInstance().setCurrentObjectID(Integer.parseInt(now.getName()));
          ShowServiceInGroup shower = new ShowServiceInGroup();
          DIMS.getInstance().getDetailContent().reloadContent(shower);
        }
      }
    } catch (Exception e1) {
      new FrameNotification(
          "Maybe something went wrong when you were trying to open a service<br>"
              + e1.getMessage());
    }
  }
 /**
  * This method initializes jpnlFields
  *
  * @return javax.swing.JPanel
  */
 private JPanel getJpnlFields() {
   if (jpnlFields == null) {
     jlblPasswd = new JLabel();
     jlblPasswd.setText("Password");
     jlblUserName = new JLabel();
     jlblUserName.setText("UserName");
     jpnlFields = new JPanel();
     jpnlFields.setLayout(new GridLayout(2, 2));
     jpnlFields.add(jlblUserName, jlblUserName.getName());
     jpnlFields.add(getJtxtUserName(), getJtxtUserName().getName());
     jpnlFields.add(jlblPasswd, jlblPasswd.getName());
     jpnlFields.add(getJtxtPasswd(), getJtxtPasswd().getName());
   }
   return jpnlFields;
 }
  public void addRequestWater() {
    JButton jb1 = new JButton();
    JLabel l1 = new JLabel("Request");
    JLabel l2 = new JLabel("Water");

    l1.setFont(new Font(l1.getName(), Font.PLAIN, 30));
    l1.setHorizontalAlignment(SwingConstants.CENTER);
    l2.setFont(new Font(l2.getName(), Font.PLAIN, 30));
    l2.setHorizontalAlignment(SwingConstants.CENTER);
    jb1.addActionListener(new WaterListener());
    jb1.setPreferredSize(new Dimension(150, 90));
    jb1.setLayout(new GridLayout(2, 1));
    jb1.add(l1);
    jb1.add(l2);
    frame.add(jb1);
  }
  public void addReadyToOrder() {
    JButton jb1 = new JButton();
    JLabel l1 = new JLabel("Ready");
    JLabel l2 = new JLabel("To");
    JLabel l3 = new JLabel("Order");

    l1.setFont(new Font(l1.getName(), Font.BOLD, 30));
    l1.setHorizontalAlignment(SwingConstants.CENTER);
    l2.setFont(new Font(l2.getName(), Font.BOLD, 20));
    l2.setHorizontalAlignment(SwingConstants.CENTER);
    l3.setFont(new Font(l3.getName(), Font.BOLD, 30));
    l3.setHorizontalAlignment(SwingConstants.CENTER);
    jb1.addActionListener(new OrderListener());
    jb1.setPreferredSize(new Dimension(150, 90));
    jb1.setLayout(new GridLayout(3, 1));
    jb1.add(l1);
    jb1.add(l2);
    jb1.add(l3);
    frame.add(jb1);
  }
  // int jlabel3_state=0;
  public void mouseClicked(MouseEvent e) {
    JLabel source = (JLabel) e.getSource();
    if (label_state.get(source) == 0) {
      if (source.getName() == "jLabel11") {
        if (challenge_file == null) {
          JOptionPane.showMessageDialog(null, "Challenge File Not Loaded");
        } else {
          reset_labelState();
          active_label = (JLabel) source;
          label_state.put(source, 1);
          try {
            ImageIcon icon =
                new javax.swing.ImageIcon(getClass().getResource("resources/images/pause.jpg"));
            jLabel11.setIcon(icon);
          } catch (Exception et) {
            JOptionPane.showMessageDialog(null, et.toString());
          }
        }

      } else {
        reset_labelState();
        active_label = (JLabel) source;
        label_state.put(source, 1);
      }
      source.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.BLUE));
    } else {
      active_label = null;
      label_state.put(source, 0);
      if (source.getName() == "jLabel11") {
        try {
          ImageIcon icon =
              new javax.swing.ImageIcon(getClass().getResource("resources/images/play.jpg"));
          jLabel11.setIcon(icon);
        } catch (Exception et) {
          JOptionPane.showMessageDialog(null, et.toString());
        }
      }
      source.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, Color.BLUE));
    }
  }
Example #7
0
 @Override
 public void mouseClicked(MouseEvent e) {
   JLabel dado = (JLabel) e.getSource();
   int numeroDado = Integer.valueOf(dado.getName());
   if (tocaNumero) {
     if (numeroDado < 4)
       resultado.setText(
           resultado.getText() + String.valueOf(numerosAlmacenadosDados3[numeroDado - 1] + 1));
     else
       resultado.setText(
           resultado.getText() + String.valueOf(numerosAlmacenadosDados6[numeroDado - 4] + 1));
     dado.removeMouseListener(this);
     dado.setIcon(dadoGris);
     tocaNumero = false;
     if (numeroDado < 4) setOperacion(numerosAlmacenadosDados3[numeroDado - 1] + 1);
     else setOperacion(numerosAlmacenadosDados6[numeroDado - 4] + 1);
   }
 }
  public void possibleValuesChanged(final CellEvent cellEvent) {
    //		java.awt.EventQueue.invokeLater(new Runnable() {
    //			public void run() {
    //		System.out.println("-=- " + settings);
    boolean hints = ServiceManager.isSelected(HintsSettingsProvider.HINTS);
    boolean notes = (Boolean) settings.getValue(HintsSettingsProvider.NOTES, Boolean.FALSE);
    //		System.out.println(" hints=" + hints + ", notes=" + notes);
    Cell cell = (Cell) cellEvent.getSource();
    for (Component component : getComponents()) {
      JLabel label = (JLabel) component;
      Integer value = Integer.valueOf(label.getName());
      label.setVisible(
          cell.isClear() && (notes || (hints && cell.getPossibleValues().contains(value))));
    }

    //				setVisible(cell.isClear());

    //				}
    //			});
  }