@Override
 public void leaveNotice(String who, String from, String context) {
   consolePanel.p(who + " left " + from);
   peepLists.get(from).removeEntry(who);
   if (currentConvo != null && currentConvo.equals(from))
     peepListPane.setViewportView(peepLists.get(from).PANEL);
 }
 @Override
 public void notice(String notice) {
   if (USERNAME == null) {
     serverTalkLabel.setText(notice);
   }
   consolePanel.p(notice);
 }
  static void initLookAndFeel() {
    MetalLookAndFeel mlf = new MetalLookAndFeel();
    mlf.setCurrentTheme(new SipCommunicatorColorTheme());

    try {
      UIManager.setLookAndFeel(mlf);
    } catch (UnsupportedLookAndFeelException ex) {
      console.error("Failed to set custom look and feel", ex);
    }
  }
 @Override
 public void joinNotice(String who, String where, String context) {
   consolePanel.p(who + " joined " + where);
   EntryPanel peepList = peepLists.get(where);
   if (peepList != null) {
     peepList.addEntry(who);
     if (currentConvo != null && currentConvo.equals(where))
       peepListPane.setViewportView(peepLists.get(where).PANEL);
   }
 }
Example #5
0
  public void showConsole() {
    java.awt.Dimension d = new java.awt.Dimension(400, 400);

    if (console == null) {
      console = new Console();
      console.setPreferredSize(d);
      console.setSize(d);
      console.setLocationRelativeTo(getCurrentDocument());
      console.setVisible(true);
    }

    console.setLocationRelativeTo(getCurrentDocument());
    console.setVisible(true);

    for (NodeBoxDocument document : documents) {
      // document.onConsoleVisibleEvent(true);
    }
  }
Example #6
0
  public static void main(String[] args) {

    Console application = new Console(args);
    application.setVisible(true);
  }
Example #7
0
 public static void main(String[] args) {
   Console.run(new SineWave(), 700, 400);
 }
Example #8
0
 public static void main(String[] args) {
   Console.run(new Button2(), 200, 75);
 }
/**
 * The class is used to request user SubscriptionAuthorisations. When an incoming subscription is
 * received the user must approve or refuse it for notifications to be sent.
 *
 * <p>Company: Network Research Team, Louis Pasteur University
 *
 * @author Emil Ivov
 * @version 1.0
 */
public class SubscriptionAuthorizationDialog extends JDialog implements ActionListener {
  private static final Console console = Console.getConsole(SubscriptionAuthorizationDialog.class);
  private JPanel contentPane = new JPanel();
  private Border border1;
  private JPanel controlsPane = new JPanel();
  private BorderLayout borderLayout1 = new BorderLayout();
  private GridLayout gridLayout1 = new GridLayout();
  private JComboBox responsesComboBox = new JComboBox();
  private JPanel buttonsPane = new JPanel();
  private JButton okButton = new JButton();
  private FlowLayout flowLayout1 = new FlowLayout();
  private JEditorPane messagePane = new JEditorPane();

  private String messageString1 =
      "The following user has requested to subscribe for your presence status.";
  private String namePrefix = "Name: <b>";
  private String nameSuffix = "</b>";
  private String addressPrefix = "Address: <b>";
  private String addressSuffix = "</b>";
  private String messagePrefix = "Message: ";
  private String messageSuffix = "";
  private String messageString2 = "What would you like to do?";

  private String name = null;
  private String address = null;
  JScrollPane messageScrollPane = new JScrollPane();

  public SubscriptionAuthorizationDialog(JFrame owner) throws HeadlessException {
    super(owner, true);
    try {
      jbInit();
      initComponents();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void initComponents() {
    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

    messagePane.setBackground(contentPane.getBackground());
    messagePane.setEditorKit(new HTMLEditorKit());
    messagePane.setForeground(contentPane.getForeground());

    setSize(450, 360);

    // center the window
    int x = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() - getWidth()) / 2;
    int y = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() - getHeight()) / 2;
    setLocation(x, y);

    okButton.addActionListener(this);
  }

  private void jbInit() throws Exception {
    border1 = BorderFactory.createEmptyBorder(20, 20, 20, 20);
    contentPane.setBorder(border1);
    contentPane.setLayout(borderLayout1);
    controlsPane.setLayout(gridLayout1);
    gridLayout1.setColumns(1);
    gridLayout1.setHgap(10);
    gridLayout1.setRows(0);
    gridLayout1.setVgap(10);
    okButton.setVerifyInputWhenFocusTarget(true);
    okButton.setMnemonic('O');
    okButton.setText("OK");
    buttonsPane.setLayout(flowLayout1);
    flowLayout1.setAlignment(FlowLayout.CENTER);
    messagePane.setEditable(false);
    messagePane.setText("");
    borderLayout1.setHgap(10);
    borderLayout1.setVgap(10);
    this.setTitle("Subscription Authorization");
    this.getContentPane().add(contentPane, BorderLayout.CENTER);
    contentPane.add(controlsPane, BorderLayout.SOUTH);
    controlsPane.add(responsesComboBox, null);
    controlsPane.add(buttonsPane, null);
    buttonsPane.add(okButton, null);
    contentPane.add(messageScrollPane, BorderLayout.CENTER);
    messageScrollPane.getViewport().add(messagePane, null);
  }

  private void setSubscriberDetails(
      String subscriberName, String subscriberAddress, String message) {
    this.name = subscriberName;
    this.address = subscriberAddress;

    Color color = messagePane.getForeground();

    messagePane.setText(
        "<FONT COLOR=\"#"
            + Integer.toHexString(color.getRGB()).substring(2)
            + "\">"
            + messageString1
            + "<p>"
            + namePrefix
            + name
            + nameSuffix
            + "<br>"
            + addressPrefix
            + address
            + addressSuffix
            + "<p>"
            + ((message != null && message.trim().length() > 0)
                ? messagePrefix + message + messageSuffix + "<p>"
                : "")
            + messageString2
            + "</FONT>");
  }

  public static String obtainAuthorisationResponse(
      JFrame owner, SubscriptionRequestUIModel request) {
    SubscriptionAuthorizationDialog sad = new SubscriptionAuthorizationDialog(owner);
    sad.setSubscriberDetails(
        request.getRequestingPartyDisplayName(),
        request.getRequestingPartyAddress(),
        request.getReasonPhrase());

    String[] responses = request.getAcceptedResponses();
    Vector resVector = new Vector();

    for (int i = 0; i < responses.length; i++) resVector.add(responses[i]);

    sad.responsesComboBox.setModel(new DefaultComboBoxModel(resVector));
    sad.responsesComboBox.setSelectedIndex(0);

    sad.show();
    return sad.responsesComboBox.getSelectedItem().toString();
  }

  public static void main(String[] args) {
    initLookAndFeel();
    String response =
        obtainAuthorisationResponse(
            null,
            new SubscriptionRequestUIModel() {
              public String[] getAcceptedResponses() {
                String[] arr = new String[3];
                arr[0] = "response 1";
                arr[1] = "ouaba daba";
                arr[2] = "ouaba dabaasdfaf";

                return arr;
              }

              public String getRequestingPartyDisplayName() {
                return "Emil Ivov";
              }

              public String getRequestingPartyAddress() {
                return "*****@*****.**";
              }

              public String getReasonPhrase() {
                return "Hello, could I please add you to my contact list?";
              }
            });

    System.out.println("Returned response = " + response);
  }

  static void initLookAndFeel() {
    MetalLookAndFeel mlf = new MetalLookAndFeel();
    mlf.setCurrentTheme(new SipCommunicatorColorTheme());

    try {
      UIManager.setLookAndFeel(mlf);
    } catch (UnsupportedLookAndFeelException ex) {
      console.error("Failed to set custom look and feel", ex);
    }
  }

  public void actionPerformed(ActionEvent evt) {
    dispose();
  }
}
 public static void main(String[] args) {
   AgentsForageWithUI antsForage = new AgentsForageWithUI();
   Console c = new Console(antsForage);
   c.setVisible(true);
 }
Example #11
0
 public static void main(String[] args) {
   Console.run(new Applet3(), 250, 50);
 }
Example #12
0
 public boolean isConsoleOpened() {
   if (console == null) return false;
   return console.isVisible();
 }
Example #13
0
 public void hideConsole() {
   console.setVisible(false);
   onHideConsole();
 }
 @Override
 public void info(String info) {
   consolePanel.p(info);
 }