public void mouseMoved(MouseEvent ev) {
      JRootPane root = getRootPane();

      if (root.getWindowDecorationStyle() == JRootPane.NONE) {
        return;
      }

      Window w = (Window) ev.getSource();

      Frame f = null;
      Dialog d = null;

      if (w instanceof Frame) {
        f = (Frame) w;
      } else if (w instanceof Dialog) {
        d = (Dialog) w;
      }

      // Update the cursor
      int cursor = getCursor(calculateCorner(w, ev.getX(), ev.getY()));

      if (cursor != 0
          && ((f != null && (f.isResizable() && (f.getExtendedState() & Frame.MAXIMIZED_BOTH) == 0))
              || (d != null && d.isResizable()))) {
        w.setCursor(Cursor.getPredefinedCursor(cursor));
      } else {
        w.setCursor(lastCursor);
      }
    }
Example #2
0
  @Override
  public void setModalBlocked(Dialog blocker, boolean blocked) {
    synchronized (getPeerTreeLock()) {
      if (blocked && blocker.getPeer() instanceof LWWindowPeer) {
        this.blocker = (LWWindowPeer) blocker.getPeer();
      } else {
        this.blocker = null;
      }
    }

    platformWindow.setModalBlocked(blocked);
  }
    @Override
    public Dialog show() {
      Dialog picker = super.show();
      myTimer.start();
      // it seems like it's the lowest value for opacity for mouse events to be processed correctly
      WindowManager.getInstance().setAlphaModeRatio(picker, SystemInfo.isMac ? 0.95f : 0.99f);

      if (SystemInfo.isJavaVersionAtLeast("1.7")) {
        Area area = new Area(new Rectangle(0, 0, DIALOG_SIZE, DIALOG_SIZE));
        area.subtract(new Area(new Rectangle(SIZE / 2 - 1, SIZE / 2 - 1, 3, 3)));
        picker.setShape(area);
      }
      return picker;
    }
Example #4
0
 public void paint(Graphics g) {
   super.paint(g);
   if (firstPaint) {
     yesB.requestFocus();
     firstPaint = false;
   }
 }
 public void dispose(boolean toDispose) {
   if (toDispose) {
     super.dispose();
     frame.toFront();
   }
   if (client != null) client.dialogDismissed(this);
 }
  public void centerDialog(Dialog dialog) {
    // For centering dialogs

    Dimension size = dialog.getSize();
    Dimension parentSize = getSize();
    Point parentLocation = getLocationOnScreen();
    if ((parentSize.width <= size.width) || (parentSize.height <= size.height))
      // If this window is bigger than the parent window,
      // place it at the same coordinates as the parent.
      dialog.setLocation(parentLocation.x, parentLocation.y);
    else
      // Otherwise, place it centered within the parent window.
      dialog.setLocation(
          (((parentSize.width - size.width) / 2) + parentLocation.x),
          (((parentSize.height - size.height) / 2) + parentLocation.y));
  }
 @SuppressWarnings("deprecation")
 public void setModalBlocked(Dialog dialog, boolean blocked) {
   synchronized (
       ((Component) getTarget()).getTreeLock()) // State lock should always be after awtLock
   {
     // use WWindowPeer instead of WDialogPeer because of FileDialogs and PrintDialogs
     WWindowPeer blockerPeer = (WWindowPeer) dialog.getPeer();
     if (blocked) {
       modalBlocker = blockerPeer;
       // handle native dialogs separately, as they may have not
       // got HWND yet; modalEnable/modalDisable is called from
       // their setHWnd() methods
       if (blockerPeer instanceof WFileDialogPeer) {
         ((WFileDialogPeer) blockerPeer).blockWindow(this);
       } else if (blockerPeer instanceof WPrintDialogPeer) {
         ((WPrintDialogPeer) blockerPeer).blockWindow(this);
       } else {
         modalDisable(dialog, blockerPeer.getHWnd());
       }
     } else {
       modalBlocker = null;
       if (blockerPeer instanceof WFileDialogPeer) {
         ((WFileDialogPeer) blockerPeer).unblockWindow(this);
       } else if (blockerPeer instanceof WPrintDialogPeer) {
         ((WPrintDialogPeer) blockerPeer).unblockWindow(this);
       } else {
         modalEnable(dialog);
       }
     }
   }
 }
 /* WARNING: THIS METHOD WILL BE REGENERATED. */
 private java.awt.Dialog getDialog1() {
   if (ivjDialog1 == null) {
     try {
       ivjDialog1 = new java.awt.Dialog(new java.awt.Frame());
       ivjDialog1.setName("Dialog1");
       ivjDialog1.setLayout(new java.awt.BorderLayout());
       ivjDialog1.setBounds(65, 335, 204, 95);
       getDialog1().add(getContentsPane(), "Center");
       // user code begin {1}
       // user code end
     } catch (java.lang.Throwable ivjExc) {
       // user code begin {2}
       // user code end
       handleException(ivjExc);
     }
   }
   return ivjDialog1;
 }
Example #9
0
 @Override
 public void actionPerformed(java.awt.event.ActionEvent e) {
   try {
     PropertyEditor propEd = property.getPropertyEditor();
     propEd.setValue(property.getValue());
     final Component custEditor = propEd.getCustomEditor();
     Object[] options = buttons();
     DialogDescriptor descriptor =
         new DialogDescriptor(
             custEditor,
             (String) getValue(Action.NAME),
             true,
             options,
             DialogDescriptor.CANCEL_OPTION,
             DialogDescriptor.DEFAULT_ALIGN,
             HelpCtx.DEFAULT_HELP,
             (ActionEvent e1) -> {
               try {
                 String action = e1.getActionCommand();
                 switch (action) {
                   case OK_COMMAND:
                     Object value = property.getPropertyEditor().getValue();
                     property.setValue(value);
                     break;
                   case RESTORE_COMMAND:
                     property.restoreDefaultValue();
                     break;
                 }
                 dialog.dispose();
               } catch (Exception ex) {
                 NotifyDescriptor descriptor2 =
                     new NotifyDescriptor.Message(
                         NbBundle.getMessage(PropertyAction.class, "MSG_InvalidValue")); // NOI18N
                 DialogDisplayer.getDefault().notify(descriptor2);
               }
             });
     descriptor.setClosingOptions(new Object[0]);
     dialog = DialogDisplayer.getDefault().createDialog(descriptor);
     dialog.setVisible(true);
     dialog = null;
   } catch (Exception ex) {
     ErrorManager.getDefault().notify(ex);
   }
 }
  public void start() {
    Toolkit.getDefaultToolkit()
        .addAWTEventListener(
            new AWTEventListener() {
              public void eventDispatched(AWTEvent e) {
                System.out.println(e.toString());
              }
            },
            FocusEvent.FOCUS_EVENT_MASK
                | WindowEvent.WINDOW_FOCUS_EVENT_MASK
                | WindowEvent.WINDOW_EVENT_MASK);

    frame = new Frame("Frame");
    frame.setName("Frame-owner");
    frame.setBounds(100, 0, 100, 100);
    dialog = new Dialog(frame, "Dialog");
    dialog.setName("Dialog-owner");
    dialog.setBounds(100, 0, 100, 100);

    window1 = new Window(frame);
    window1.setName("1st child");
    window1.setBounds(100, 300, 100, 100);
    window2 = new Window(window1);
    window2.setName("2nd child");
    window2.setBounds(100, 500, 100, 100);

    test1(frame, window1);
    test2(frame, window1, window2);
    test3(frame, window1, window2);

    window1 = new Window(dialog);
    window1.setBounds(100, 300, 100, 100);
    window1.setName("1st child");
    window2 = new Window(window1);
    window2.setName("2nd child");
    window2.setBounds(100, 500, 100, 100);

    test1(dialog, window1);
    test2(dialog, window1, window2);
    test3(dialog, window1, window2);

    System.out.println("Test passed.");
  }
    public void mousePressed(MouseEvent ev) {
      JRootPane rootPane = getRootPane();

      if (rootPane.getWindowDecorationStyle() == JRootPane.NONE) {
        return;
      }
      Point dragWindowOffset = ev.getPoint();
      Window w = (Window) ev.getSource();
      if (w != null) {
        w.toFront();
      }
      Point convertedDragWindowOffset =
          SwingUtilities.convertPoint(w, dragWindowOffset, getTitlePane());

      Frame f = null;
      Dialog d = null;

      if (w instanceof Frame) {
        f = (Frame) w;
      } else if (w instanceof Dialog) {
        d = (Dialog) w;
      }

      int frameState = (f != null) ? f.getExtendedState() : 0;

      if (getTitlePane() != null && getTitlePane().contains(convertedDragWindowOffset)) {
        if ((f != null && ((frameState & Frame.MAXIMIZED_BOTH) == 0) || (d != null))
            && dragWindowOffset.y >= BORDER_DRAG_THICKNESS
            && dragWindowOffset.x >= BORDER_DRAG_THICKNESS
            && dragWindowOffset.x < w.getWidth() - BORDER_DRAG_THICKNESS) {
          isMovingWindow = true;
          dragOffsetX = dragWindowOffset.x;
          dragOffsetY = dragWindowOffset.y;
        }
      } else if (f != null && f.isResizable() && ((frameState & Frame.MAXIMIZED_BOTH) == 0)
          || (d != null && d.isResizable())) {
        dragOffsetX = dragWindowOffset.x;
        dragOffsetY = dragWindowOffset.y;
        dragWidth = w.getWidth();
        dragHeight = w.getHeight();
        dragCursor = getCursor(calculateCorner(w, dragWindowOffset.x, dragWindowOffset.y));
      }
    }
Example #12
0
 public void paint(Graphics g) {
   super.paint(g);
   if (firstPaint) {
     if (numberField != null && IJ.isMacOSX()) {
       // work around for bug on Intel Macs that caused 1st field to be un-editable
       TextField tf = (TextField) (numberField.elementAt(0));
       tf.setEditable(false);
       tf.setEditable(true);
     }
     if (numberField == null && stringField == null) okay.requestFocus();
     firstPaint = false;
   }
 }
    private void updatePipette() {
      Dialog pickerDialog = getPickerDialog();
      if (pickerDialog != null && pickerDialog.isShowing()) {
        Point mouseLoc = updateLocation();
        if (mouseLoc == null) return;
        final Color c = getPixelColor(mouseLoc);
        if (!c.equals(getColor()) || !mouseLoc.equals(myPreviousLocation)) {
          setColor(c);
          myPreviousLocation.setLocation(mouseLoc);
          myCaptureRect.setBounds(
              mouseLoc.x - HOT_SPOT.x + SIZE / 2 - 2, mouseLoc.y - HOT_SPOT.y + SIZE / 2 - 2, 5, 5);

          BufferedImage capture = myRobot.createScreenCapture(myCaptureRect);

          // Clear the cursor graphics
          myGraphics.setComposite(AlphaComposite.Src);
          myGraphics.setColor(UIUtil.TRANSPARENT_COLOR);
          myGraphics.fillRect(0, 0, myImage.getWidth(), myImage.getHeight());

          myGraphics.drawImage(
              capture, myZoomRect.x, myZoomRect.y, myZoomRect.width, myZoomRect.height, this);

          // cropping round image
          myGraphics.setComposite(AlphaComposite.getInstance(AlphaComposite.DST_OUT));
          myGraphics.drawImage(
              myMaskImage, myZoomRect.x, myZoomRect.y, myZoomRect.width, myZoomRect.height, this);

          // paint magnifier
          myGraphics.setComposite(AlphaComposite.SrcOver);

          UIUtil.drawImage(
              myGraphics, myPipetteImage, SIZE - AllIcons.Ide.Pipette.getIconWidth(), 0, this);

          pickerDialog.setCursor(
              myParent.getToolkit().createCustomCursor(myImage, HOT_SPOT, "ColorPicker"));
          notifyListener(c, 300);
        }
      }
    }
 public void setVisible(boolean visible) {
   pack();
   if (centered) {
     Dimension frameSize = getParent().getSize();
     Point frameLoc = getParent().getLocation();
     Dimension mySize = getSize();
     int x, y;
     x = frameLoc.x + (frameSize.width / 2) - (mySize.width / 2);
     y = frameLoc.y + (frameSize.height / 2) - (mySize.height / 2);
     setBounds(x, y, getSize().width, getSize().height);
   }
   super.setVisible(visible);
 }
  // implementation of java.awt.event.ActionListener interface
  public void actionPerformed(JCActionEvent e) {
    if (e.getSource() == ok || e.getSource() == cancel) {
      if (e.getSource() == ok) {
        accept = true;
      } else {
        accept = false;
      }

      dialog.dispose();
    } else {
      JCButton b = (JCButton) e.getSource();
      Color c = b.getBackground();

      updateColor(c, e.getSource());
    }
  }
Example #16
0
  void showWarning(Frame frame, String warning) {
    warningDialog = new Dialog(frame, "警告", true);
    warningDialog.setSize(200, 100);
    warningDialog.setLayout(new FlowLayout());
    warningDialog.setResizable(false);
    warningDialog.setLocationRelativeTo(frame);

    warningText = new Label(warning);
    warningButton = new Button("确认");

    warningDialog.add(warningText);
    warningDialog.add(warningButton);

    warningDialog.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            warningDialog.setVisible(false);
            warningDialog.dispose();
          }
        });

    warningButton.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            int keyCode = e.getKeyCode();

            if (keyCode == KeyEvent.VK_ENTER) {
              warningDialog.setVisible(false);
              warningDialog.dispose();
            }
          }
        });

    warningButton.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            warningDialog.setVisible(false);
            warningDialog.dispose();
          }
        });

    warningDialog.setVisible(true);
  }
Example #17
0
 protected void processWindowEvent(WindowEvent e) {
   if (e.getID() == WindowEvent.WINDOW_CLOSING) {
     cancel();
   }
   super.processWindowEvent(e);
 }
Example #18
0
  public ServerDialog(OptionsDialog options_, Options opts_, CConn cc_) {

    super(true);
    cc = cc_;
    opts = opts_;

    options = options_;

    JLabel serverLabel = new JLabel("VNC server:", JLabel.RIGHT);
    String valueStr = null;
    if (opts.serverName != null) {
      String[] s = new String[1];
      s[0] = opts.serverName;
      server = new JComboBox(s);
    } else if ((valueStr = UserPreferences.get("ServerDialog", "history")) != null) {
      server = new JComboBox(valueStr.split(","));
    } else {
      server = new JComboBox();
    }

    // Hack to set the left inset on editable JComboBox
    if (UIManager.getLookAndFeel().getID() == "Windows") {
      server.setBorder(
          BorderFactory.createCompoundBorder(
              server.getBorder(), BorderFactory.createEmptyBorder(0, 2, 0, 0)));
    } else if (UIManager.getLookAndFeel().getID() == "Metal") {
      ComboBoxEditor editor = server.getEditor();
      JTextField jtf = (JTextField) editor.getEditorComponent();
      jtf.setBorder(new CompoundBorder(jtf.getBorder(), new EmptyBorder(0, 2, 0, 0)));
    }

    server.setEditable(true);
    editor = server.getEditor();
    editor
        .getEditorComponent()
        .addKeyListener(
            new KeyListener() {
              public void keyTyped(KeyEvent e) {}

              public void keyReleased(KeyEvent e) {}

              public void keyPressed(KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                  server.insertItemAt(editor.getItem(), 0);
                  server.setSelectedIndex(0);
                  commit();
                  endDialog();
                }
              }
            });

    topPanel = new JPanel(new GridBagLayout());

    Dialog.addGBComponent(
        new JLabel(VncViewer.logoIcon),
        topPanel,
        0,
        0,
        1,
        1,
        0,
        0,
        0,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.LINE_START,
        new Insets(5, 5, 5, 15));
    Dialog.addGBComponent(
        serverLabel,
        topPanel,
        1,
        0,
        1,
        1,
        0,
        0,
        0,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.LINE_END,
        new Insets(10, 0, 5, 5));
    Dialog.addGBComponent(
        server,
        topPanel,
        2,
        0,
        1,
        1,
        0,
        0,
        1,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.CENTER,
        new Insets(10, 0, 5, 20));

    optionsButton = new JButton("Options...");
    aboutButton = new JButton("About...");
    okButton = new JButton("Connect");
    cancelButton = new JButton("Cancel");
    buttonPanel = new JPanel(new GridBagLayout());
    buttonPanel.setPreferredSize(new Dimension(350, 40));
    Dialog.addGBComponent(
        aboutButton,
        buttonPanel,
        0,
        3,
        1,
        1,
        0,
        0,
        0.8,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.CENTER,
        new Insets(0, 2, 0, 5));
    Dialog.addGBComponent(
        optionsButton,
        buttonPanel,
        1,
        3,
        1,
        1,
        0,
        0,
        1,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.CENTER,
        new Insets(0, 2, 0, 5));
    Dialog.addGBComponent(
        okButton,
        buttonPanel,
        2,
        3,
        1,
        1,
        0,
        0,
        0.7,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.CENTER,
        new Insets(0, 2, 0, 5));
    Dialog.addGBComponent(
        cancelButton,
        buttonPanel,
        3,
        3,
        1,
        1,
        0,
        0,
        0.6,
        1,
        GridBagConstraints.HORIZONTAL,
        GridBagConstraints.CENTER,
        new Insets(0, 2, 0, 5));

    server.addActionListener(this);
    optionsButton.addActionListener(this);
    aboutButton.addActionListener(this);
    okButton.addActionListener(this);
    cancelButton.addActionListener(this);
  }
Example #19
0
 /* Display the dialog at the specified location. */
 public void setLocation(int x, int y) {
   super.setLocation(x, y);
   centerDialog = false;
 }
Example #20
0
 public void actionPerformed(ActionEvent e) {
   Dialog d = new ToeDialog(Integer.parseInt(rows.getText()), Integer.parseInt(cols.getText()));
   d.show();
 }
Example #21
0
 public void repaint() {
   super.repaint();
   if (imagePanels != null) {
     for (int i = 0; i < imagePanels.size(); i++) ((ImagePanel) imagePanels.get(i)).repaint();
   }
 }
    @NotNull
    @SuppressWarnings("UseJBColor")
    protected Dialog getOrCreatePickerDialog() {
      Dialog pickerDialog = getPickerDialog();
      if (pickerDialog == null) {
        pickerDialog = super.getOrCreatePickerDialog();
        pickerDialog.addMouseListener(
            new MouseAdapter() {
              @Override
              public void mouseExited(MouseEvent event) {
                updatePipette();
              }
            });
        pickerDialog.addMouseMotionListener(
            new MouseAdapter() {
              @Override
              public void mouseMoved(MouseEvent e) {
                updatePipette();
              }
            });
        pickerDialog.addFocusListener(
            new FocusAdapter() {
              @Override
              public void focusLost(FocusEvent e) {
                if (e.isTemporary()) {
                  pickAndClose();
                } else {
                  cancelPipette();
                }
              }
            });

        pickerDialog.setSize(DIALOG_SIZE, DIALOG_SIZE);
        myMaskImage = UIUtil.createImage(SIZE, SIZE, BufferedImage.TYPE_INT_ARGB);
        Graphics2D maskG = myMaskImage.createGraphics();
        maskG.setColor(Color.BLUE);
        maskG.fillRect(0, 0, SIZE, SIZE);

        maskG.setColor(Color.RED);
        maskG.setComposite(AlphaComposite.SrcOut);
        maskG.fillRect(0, 0, SIZE, SIZE);
        maskG.dispose();

        myPipetteImage =
            UIUtil.createImage(
                AllIcons.Ide.Pipette.getIconWidth(),
                AllIcons.Ide.Pipette.getIconHeight(),
                BufferedImage.TYPE_INT_ARGB);
        Graphics2D graphics = myPipetteImage.createGraphics();
        //noinspection ConstantConditions
        AllIcons.Ide.Pipette.paintIcon(null, graphics, 0, 0);
        graphics.dispose();

        myImage =
            myParent
                .getGraphicsConfiguration()
                .createCompatibleImage(SIZE, SIZE, Transparency.TRANSLUCENT);

        myGraphics = (Graphics2D) myImage.getGraphics();
        myGraphics.setRenderingHint(
            RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
      }

      return pickerDialog;
    }
  public void sendSubscribe(String localURL, String buddyURI, boolean EXPIRED) {
    try {
      logger.debug("Sending SUBSCRIBE in progress to the buddy: " + buddyURI);
      int proxyPort = imUA.getProxyPort();
      String proxyAddress = imUA.getProxyAddress();
      String imProtocol = imUA.getIMProtocol();
      SipStack sipStack = imUA.getSipStack();
      SipProvider sipProvider = imUA.getSipProvider();
      MessageFactory messageFactory = imUA.getMessageFactory();
      HeaderFactory headerFactory = imUA.getHeaderFactory();
      AddressFactory addressFactory = imUA.getAddressFactory();

      // Request-URI:
      // URI requestURI=addressFactory.createURI(buddyURI);
      SipURI requestURI = addressFactory.createSipURI(null, proxyAddress);
      requestURI.setPort(proxyPort);
      requestURI.setTransportParam(imProtocol);

      // Call-Id:
      CallIdHeader callIdHeader = null;

      // CSeq:
      CSeqHeader cseqHeader = null;

      // To header:
      ToHeader toHeader = null;

      // From Header:
      FromHeader fromHeader = null;

      // Via header
      String branchId = Utils.generateBranchId();
      ViaHeader viaHeader =
          headerFactory.createViaHeader(
              imUA.getIMAddress(), imUA.getIMPort(), imProtocol, branchId);
      Vector viaList = new Vector();
      viaList.addElement(viaHeader);

      PresenceManager presenceManager = imUA.getPresenceManager();
      Presentity presentity = presenceManager.getPresentity(buddyURI);
      Dialog dialog = null;
      if (presentity != null) dialog = presentity.getDialog();

      if (dialog != null) {

        // We have to remove the subscriber and the Presentity related
        // with this Buddy...
        presenceManager.removePresentity(buddyURI);
        Subscriber subscriber = presenceManager.getSubscriber(buddyURI);
        if (subscriber == null) {
          // It means that the guy does not have us in his buddy list
          // nothing to do!!!
        } else {
          presenceManager.removeSubscriber(buddyURI);
        }

        Address localAddress = dialog.getLocalParty();
        Address remoteAddress = dialog.getRemoteParty();

        fromHeader = headerFactory.createFromHeader(localAddress, dialog.getLocalTag());
        toHeader = headerFactory.createToHeader(remoteAddress, dialog.getRemoteTag());

        long cseq = dialog.getLocalSeqNumber();
        cseqHeader = headerFactory.createCSeqHeader(cseq, "MESSAGE");

        callIdHeader = dialog.getCallId();
      } else {
        String localTag = Utils.generateTag();

        Address toAddress = addressFactory.createAddress(buddyURI);
        Address fromAddress = addressFactory.createAddress(localURL);

        fromHeader = headerFactory.createFromHeader(fromAddress, localTag);
        toHeader = headerFactory.createToHeader(toAddress, null);

        // CSeq:
        cseqHeader = headerFactory.createCSeqHeader(1L, "SUBSCRIBE");

        callIdCounter++;
        // Call-ID:
        callIdHeader =
            (CallIdHeader)
                headerFactory.createCallIdHeader("nist-sip-im-subscribe-callId" + callIdCounter);
      }

      // MaxForwards header:
      MaxForwardsHeader maxForwardsHeader = headerFactory.createMaxForwardsHeader(70);

      Request request =
          messageFactory.createRequest(
              requestURI,
              "SUBSCRIBE",
              callIdHeader,
              cseqHeader,
              fromHeader,
              toHeader,
              viaList,
              maxForwardsHeader);

      RouteHeader rh = this.imUA.getRouteToProxy();
      request.setHeader(rh);

      // Contact header:
      SipURI sipURI = addressFactory.createSipURI(null, imUA.getIMAddress());
      sipURI.setPort(imUA.getIMPort());
      sipURI.setTransportParam(imUA.getIMProtocol());
      Address contactAddress = addressFactory.createAddress(sipURI);
      ContactHeader contactHeader = headerFactory.createContactHeader(contactAddress);
      request.setHeader(contactHeader);

      ExpiresHeader expiresHeader = null;
      if (EXPIRED) {
        expiresHeader = headerFactory.createExpiresHeader(0);
      } else {
        expiresHeader = headerFactory.createExpiresHeader(presenceManager.getExpiresTime());
      }
      request.setHeader(expiresHeader);

      // WE have to add a new Header: "Event"
      Header eventHeader = headerFactory.createHeader("Event", "presence");
      request.setHeader(eventHeader);

      // Add Acceptw Header
      Header acceptHeader = headerFactory.createHeader("Accept", "application/pidf+xml");
      request.setHeader(acceptHeader);

      // ProxyAuthorization header if not null:
      ProxyAuthorizationHeader proxyAuthHeader = imUA.getProxyAuthorizationHeader();
      if (proxyAuthHeader != null) request.setHeader(proxyAuthHeader);

      ClientTransaction clientTransaction = sipProvider.getNewClientTransaction(request);

      if (dialog != null) {
        dialog.sendRequest(clientTransaction);
      } else {
        clientTransaction.sendRequest();
      }

      logger.debug("IMSubscribeProcessing, sendSubscribe(), SUBSCRIBE sent:\n" + request);
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Example #24
0
 public void run() {
   d.setVisible(true);
   thread = null;
 }