コード例 #1
0
 /** Retrieve item types and fill in the item types combo box. */
 private void init() {
   Response res = ClientUtils.getData("loadItemTypes", new GridParams());
   Domain d = new Domain("ITEM_TYPES");
   if (!res.isError()) {
     ItemTypeVO vo = null;
     list = ((VOListResponse) res).getRows();
     for (int i = 0; i < list.size(); i++) {
       vo = (ItemTypeVO) list.get(i);
       d.addDomainPair(vo.getProgressiveHie02ITM02(), vo.getDescriptionSYS10());
     }
   }
   controlHierarchy.setDomain(d);
   controlHierarchy
       .getComboBox()
       .addItemListener(
           new ItemListener() {
             public void itemStateChanged(ItemEvent e) {
               if (e.getStateChange() == e.SELECTED) {
                 ItemTypeVO typeVO = (ItemTypeVO) list.get(controlHierarchy.getSelectedIndex());
                 treePanel.setCompanyCode(typeVO.getCompanyCodeSys01ITM02());
                 treePanel.setProgressiveHIE02((BigDecimal) controlHierarchy.getValue());
                 DetailSupplierVO vo =
                     (DetailSupplierVO) supplierPanel.getVOModel().getValueObject();
                 treePanel.setCompanyCode(vo.getCompanyCodeSys01REG04());
                 treePanel.reloadTree();
                 itemsGrid.clearData();
               }
             }
           });
   if (d.getDomainPairList().length == 1) controlHierarchy.getComboBox().setSelectedIndex(0);
   else controlHierarchy.getComboBox().setSelectedIndex(-1);
 }
コード例 #2
0
 /**
  * Method invoked when pressing import all items button: it add all items to the supplier items
  * collection.
  */
 void impAllItemsButton_actionPerformed(ActionEvent e) {
   DetailSupplierVO vo = (DetailSupplierVO) supplierPanel.getVOModel().getValueObject();
   SupplierItemVO itemVO = new SupplierItemVO();
   itemVO.setCompanyCodeSys01PUR02(vo.getCompanyCodeSys01REG04());
   itemVO.setProgressiveReg04PUR02(vo.getProgressiveREG04());
   itemVO.setProgressiveHie02PUR02((BigDecimal) controlHierarchy.getValue());
   Response res = ClientUtils.getData("importAllItemsToSupplier", itemVO);
   if (!res.isError()) itemsGrid.reloadData();
 }
コード例 #3
0
  public void processOK(Response responseCloned, ClientTransaction clientTransaction) {
    try {
      logger.debug("Processing OK for SUBSCRIBE in progress...");

      ExpiresHeader expiresHeader = (ExpiresHeader) responseCloned.getHeader(ExpiresHeader.NAME);
      if (expiresHeader != null && expiresHeader.getExpires() == 0) {
        logger.debug(
            "DEBUG, IMSubscribeProcessing, processOK(), we got" + " the OK for the unsubscribe...");
      } else {

        // We have to create or update the presentity!
        PresenceManager presenceManager = imUA.getPresenceManager();
        String presentityURL = IMUtilities.getKey(responseCloned, "To");

        Dialog dialog = clientTransaction.getDialog();
        if (dialog != null) presenceManager.addPresentity(presentityURL, responseCloned, dialog);
        else {
          logger.debug(
              "ERROR, IMSubscribeProcessing, processOK(), the"
                  + " dialog for the SUBSCRIBE we sent is null!!!"
                  + " No presentity added....");
        }

        // WE have to create a new Buddy in the GUI!!!
        InstantMessagingGUI imGUI = imUA.getInstantMessagingGUI();
        BuddyList buddyList = imGUI.getBuddyList();
        if (!buddyList.hasBuddy(presentityURL)) {
          buddyList.addBuddy(presentityURL, "offline");
        } else {
          logger.debug("The buddy is already in the Buddy list...");
        }
      }
      logger.debug("Processing OK for SUBSCRIBE completed...");
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
コード例 #4
0
  /** Load data from server and construct panel content. */
  public final void reloadData(DocumentsFrame frame) {
    try {
      // remove all panel content...
      clearData();
      frame.getGrid().getOtherGridParams().put(ApplicationConsts.PROPERTIES_FILTER, filters);

      // retrieve customized input controls list...
      GridParams gridParams = new GridParams();
      DefaultMutableTreeNode node = frame.getHierarTreePanel().getSelectedNode();
      if (node != null) {
        HierarchyLevelVO vo = (HierarchyLevelVO) node.getUserObject();
        HierarchyLevelVO root =
            (HierarchyLevelVO) ((DefaultMutableTreeNode) node.getRoot()).getUserObject();
        gridParams
            .getOtherGridParams()
            .put(ApplicationConsts.PROGRESSIVE_HIE01, vo.getProgressiveHIE01());
        gridParams
            .getOtherGridParams()
            .put(ApplicationConsts.ROOT_PROGRESSIVE_HIE01, root.getProgressiveHIE01());
      } else gridParams.getOtherGridParams().remove(ApplicationConsts.PROGRESSIVE_HIE01);
      gridParams
          .getOtherGridParams()
          .put(
              ApplicationConsts.PROGRESSIVE_HIE02,
              frame.getHierarTreePanel().getProgressiveHIE02());
      gridParams.getOtherGridParams().put(ApplicationConsts.LOAD_ANCIENTS, Boolean.TRUE);
      Response res = ClientUtils.getData("loadLevelProperties", gridParams);
      if (res.isError()) {
        JOptionPane.showMessageDialog(
            ClientUtils.getParentFrame(this),
            ClientSettings.getInstance().getResources().getResource("Error while loading data")
                + ":\n"
                + res.getErrorMessage(),
            ClientSettings.getInstance().getResources().getResource("Loading Data Error"),
            JOptionPane.ERROR_MESSAGE);
        return;
      }
      ArrayList rows = ((VOListResponse) res).getRows();
      if (rows.size() > 0) {
        // adding customized input controls...
        LevelPropertyVO inputControlInfo = null;
        int row = 0;
        int col = 0;
        LabelControl labelControl = null;
        TextControl textControl = null;
        DateControl dateControl = null;
        NumericControl numericControl = null;
        for (int i = 0; i < rows.size(); i++) {
          inputControlInfo = (LevelPropertyVO) rows.get(i);
          labelControl = new LabelControl();
          labelControl.setText(inputControlInfo.getDescriptionSYS10());
          innerPanel.add(
              labelControl,
              new GridBagConstraints(
                  col++,
                  row,
                  1,
                  1,
                  0.0,
                  0.0,
                  GridBagConstraints.WEST,
                  GridBagConstraints.NONE,
                  new Insets(5, 5, 5, 5),
                  0,
                  0));

          if (inputControlInfo.getPropertyTypeDOC21().equals(ApplicationConsts.TYPE_TEXT)) {
            textControl = new TextControl();
            textControl.setMaxCharacters(255);
            textControl.setLinkLabel(labelControl);
            innerPanel.add(
                textControl,
                new GridBagConstraints(
                    col,
                    row,
                    1,
                    1,
                    1.0,
                    0.0,
                    GridBagConstraints.WEST,
                    GridBagConstraints.HORIZONTAL,
                    new Insets(5, 5, 5, 15),
                    0,
                    0));
            textControl.addFocusListener(new ControlFocusListener(inputControlInfo, textControl));
          } else if (inputControlInfo.getPropertyTypeDOC21().equals(ApplicationConsts.TYPE_DATE)) {
            dateControl = new DateControl();
            dateControl.setLinkLabel(labelControl);
            innerPanel.add(
                dateControl,
                new GridBagConstraints(
                    col,
                    row,
                    1,
                    1,
                    1.0,
                    0.0,
                    GridBagConstraints.WEST,
                    GridBagConstraints.NONE,
                    new Insets(5, 5, 5, 15),
                    0,
                    0));
            dateControl.addFocusListener(new ControlFocusListener(inputControlInfo, dateControl));
          } else if (inputControlInfo.getPropertyTypeDOC21().equals(ApplicationConsts.TYPE_NUM)) {
            numericControl = new NumericControl();
            numericControl.setDecimals(5);
            numericControl.setLinkLabel(labelControl);
            innerPanel.add(
                numericControl,
                new GridBagConstraints(
                    col,
                    row,
                    1,
                    1,
                    1.0,
                    0.0,
                    GridBagConstraints.WEST,
                    GridBagConstraints.HORIZONTAL,
                    new Insets(5, 5, 5, 15),
                    0,
                    0));
            numericControl.addFocusListener(
                new ControlFocusListener(inputControlInfo, numericControl));
          }

          col++;
          if (col >= 2) {
            innerPanel.add(
                new JPanel(),
                new GridBagConstraints(
                    col,
                    row,
                    1,
                    1,
                    1.0,
                    0.0,
                    GridBagConstraints.WEST,
                    GridBagConstraints.HORIZONTAL,
                    new Insets(5, 5, 5, 5),
                    0,
                    0));
            row++;
            col = 0;
          }
        }
        row++;
        innerPanel.add(
            new JPanel(),
            new GridBagConstraints(
                col,
                row,
                1,
                1,
                0.0,
                0.0,
                GridBagConstraints.WEST,
                GridBagConstraints.NONE,
                new Insets(5, 5, 5, 5),
                0,
                0));

        innerPanel.add(
            new JPanel(),
            new GridBagConstraints(
                0,
                row,
                1,
                1,
                0.0,
                1.0,
                GridBagConstraints.WEST,
                GridBagConstraints.VERTICAL,
                new Insets(5, 5, 5, 5),
                0,
                0));
        this.revalidate();
        this.repaint();
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
コード例 #5
0
  public void processSubscribe(Request request, ServerTransaction serverTransaction) {
    logger.debug("Processing SUBSCRIBE in progress ");
    try {

      MessageFactory messageFactory = imUA.getMessageFactory();
      HeaderFactory headerFactory = imUA.getHeaderFactory();
      AddressFactory addressFactory = imUA.getAddressFactory();
      Dialog dialog = serverTransaction.getDialog();

      // ********** Terminating subscriptions **********
      ExpiresHeader expiresHeader = (ExpiresHeader) request.getHeader(ExpiresHeader.NAME);
      if (expiresHeader != null && expiresHeader.getExpires() == 0) {
        if (dialog != null) {
          // Terminating an existing subscription
          Response response = messageFactory.createResponse(Response.OK, request);
          serverTransaction.sendResponse(response);
          IMNotifyProcessing imNotifyProcessing = imUA.getIMNotifyProcessing();
          imNotifyProcessing.sendNotify(response, null, dialog);
          return;
        } else {
          // Terminating an non existing subscription
          Response response =
              messageFactory.createResponse(Response.CALL_OR_TRANSACTION_DOES_NOT_EXIST, request);
          serverTransaction.sendResponse(response);
          return;
        }
      }

      // ********** Non-terminating subscriptions ************

      // send a 202 Accepted while waiting for authorization from user
      Response response = messageFactory.createResponse(Response.ACCEPTED, request);
      // Tag:
      ToHeader toHeader = (ToHeader) response.getHeader(ToHeader.NAME);
      if (toHeader.getTag() == null)
        toHeader.setTag(new Integer((int) (Math.random() * 10000)).toString());
      serverTransaction.sendResponse(response);
      logger.debug(response.toString());

      // We have to ask the user to authorize the guy to be in his buddy
      // list
      String presentityURL = IMUtilities.getKey(request, "From");
      SipProvider sipProvider = imUA.getSipProvider();
      InstantMessagingGUI imGUI = imUA.getInstantMessagingGUI();
      boolean authorization = imGUI.getAuthorizationForBuddy(presentityURL);
      if (authorization) {
        logger.debug(
            "DEBUG: SubscribeProcessing, processSubscribe(), " + " Response 202 Accepted sent.");

        // We have to create or update the subscriber!
        PresenceManager presenceManager = imUA.getPresenceManager();
        String subscriberURL = IMUtilities.getKey(request, "From");

        if (dialog != null) presenceManager.addSubscriber(subscriberURL, response, dialog);
        else {
          logger.debug(
              "ERROR, IMSubscribeProcessing, processSubscribe(), the"
                  + " dialog for the SUBSCRIBE we received is null!!! No subscriber added....");
          return;
        }

        // Let's see if this buddy is in our buddy list
        // if not let's ask to add him!
        BuddyList buddyList = imGUI.getBuddyList();
        ListenerInstantMessaging listenerIM = imGUI.getListenerInstantMessaging();
        if (!buddyList.hasBuddy(subscriberURL)) {
          // Let's ask:
          listenerIM.addContact(subscriberURL);
        }

        /** ********************** send NOTIFY ************************* */
        // We send a NOTIFY for any of our status but offline
        String localStatus = listenerIM.getLocalStatus();
        if (!localStatus.equals("offline")) {
          IMNotifyProcessing imNotifyProcessing = imUA.getIMNotifyProcessing();
          Subscriber subscriber = presenceManager.getSubscriber(subscriberURL);
          // Response okSent=subscriber.getOkSent();

          subscriberURL = subscriber.getSubscriberName();

          String contactAddress = imUA.getIMAddress() + ":" + imUA.getIMPort();

          String subStatus = listenerIM.getLocalStatus();
          String status = null;
          if (subStatus.equals("offline")) status = "closed";
          else status = "open";
          String xmlBody =
              imNotifyProcessing.xmlPidfParser.createXMLBody(
                  status, subStatus, subscriberURL, contactAddress);
          imNotifyProcessing.sendNotify(response, xmlBody, dialog);
        }
      } else {
        // User did not authorize subscription. Terminate it!
        logger.debug(
            "DEBUG, IMSubsribeProcessing, processSubscribe(), " + " Subscription declined!");
        logger.debug(
            "DEBUG, IMSubsribeProcessing, processSubscribe(), "
                + " Sending a Notify with Subscribe-state=terminated");

        IMNotifyProcessing imNotifyProcessing = imUA.getIMNotifyProcessing();
        if (dialog != null) {
          imNotifyProcessing.sendNotify(response, null, dialog);
          logger.debug(
              "DEBUG, IMSubsribeProcessing, processSubscribe(), "
                  + " Sending a Notify with Subscribe-state=terminated");
        } else {
          logger.debug(
              "ERROR, IMSubscribeProcessing, processSubscribe(), the"
                  + " dialog for the SUBSCRIBE we received is null!!! \n"
                  + "   No terminating Notify sent");
        }
        imNotifyProcessing.sendNotify(response, null, dialog);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }