/** Show the filter dialog */
 public void showDialog() {
   empty_border = new EmptyBorder(5, 5, 0, 5);
   indent_border = new EmptyBorder(5, 25, 5, 5);
   include_panel =
       new ServiceFilterPanel("Include messages based on target service:", filter_include_list);
   exclude_panel =
       new ServiceFilterPanel("Exclude messages based on target service:", filter_exclude_list);
   status_box = new JCheckBox("Filter messages based on status:");
   status_box.addActionListener(this);
   status_active = new JRadioButton("Active messages only");
   status_active.setSelected(true);
   status_active.setEnabled(false);
   status_complete = new JRadioButton("Complete messages only");
   status_complete.setEnabled(false);
   status_group = new ButtonGroup();
   status_group.add(status_active);
   status_group.add(status_complete);
   if (filter_active || filter_complete) {
     status_box.setSelected(true);
     status_active.setEnabled(true);
     status_complete.setEnabled(true);
     if (filter_complete) {
       status_complete.setSelected(true);
     }
   }
   status_options = new JPanel();
   status_options.setLayout(new BoxLayout(status_options, BoxLayout.Y_AXIS));
   status_options.add(status_active);
   status_options.add(status_complete);
   status_options.setBorder(indent_border);
   status_panel = new JPanel();
   status_panel.setLayout(new BorderLayout());
   status_panel.add(status_box, BorderLayout.NORTH);
   status_panel.add(status_options, BorderLayout.CENTER);
   status_panel.setBorder(empty_border);
   ok_button = new JButton("Ok");
   ok_button.addActionListener(this);
   cancel_button = new JButton("Cancel");
   cancel_button.addActionListener(this);
   buttons = new JPanel();
   buttons.setLayout(new FlowLayout());
   buttons.add(ok_button);
   buttons.add(cancel_button);
   panel = new JPanel();
   panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
   panel.add(include_panel);
   panel.add(exclude_panel);
   panel.add(status_panel);
   panel.add(buttons);
   dialog = new JDialog();
   dialog.setTitle("SOAP Monitor Filter");
   dialog.setContentPane(panel);
   dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
   dialog.setModal(true);
   dialog.pack();
   Dimension d = dialog.getToolkit().getScreenSize();
   dialog.setLocation((d.width - dialog.getWidth()) / 2, (d.height - dialog.getHeight()) / 2);
   ok_pressed = false;
   dialog.show();
 }
예제 #2
0
  protected void populateDialog(JDialog dlg) {
    dlg.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    dlg.setResizable(false);
    dlg.setSize(new Dimension(350, 135));
    dlg.setTitle("New TurboVNC Connection");

    dlg.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            if (VncViewer.nViewers == 1) {
              if (cc.viewer instanceof VncViewer) {
                ((VncViewer) cc.viewer).exit(1);
              }
            } else {
              ret = false;
              endDialog();
            }
          }
        });

    dlg.getContentPane().setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.gridheight = 1;
    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.ipadx = 0;
    gbc.ipady = 0;
    gbc.weightx = 1;
    gbc.weighty = 1;

    dlg.getContentPane().add(topPanel, gbc);
    dlg.getContentPane().add(buttonPanel);
    dlg.pack();
  }
  /**
   * Creates a dialog where the user can specify the location of the database,including the type of
   * network connection (if this is a networked client)and IP address and port number; or search and
   * select the database on a local drive if this is a standalone client.
   *
   * @param parent Defines the Component that is to be the parent of this dialog box. For
   *     information on how this is used, see <code>JOptionPane</code>
   * @param connectionMode Specifies the type of connection (standalone or networked)
   * @see JOptionPane
   */
  public DatabaseLocationDialog(Frame parent, ApplicationMode connectionMode) {
    configOptions = (new ConfigOptions(connectionMode));
    configOptions.getObservable().addObserver(this);

    // load saved configuration
    SavedConfiguration config = SavedConfiguration.getSavedConfiguration();

    // the port and connection type are irrelevant in standalone mode
    if (connectionMode == ApplicationMode.STANDALONE_CLIENT) {
      validPort = true;
      validCnx = true;
      networkType = ConnectionType.DIRECT;
      location = config.getParameter(SavedConfiguration.DATABASE_LOCATION);
    } else {
      // there may not be a network connectivity type defined and, if
      // not, we do not set a default - force the user to make a choice
      // the at least for the first time they run this.
      String tmp = config.getParameter(SavedConfiguration.NETWORK_TYPE);
      if (tmp != null) {
        try {
          networkType = ConnectionType.valueOf(tmp);
          configOptions.setNetworkConnection(networkType);
          validCnx = true;
        } catch (IllegalArgumentException e) {
          log.warning("Unknown connection type: " + networkType);
        }
      }

      // there is always at least a default port number, so we don't have
      // to validate this.
      port = config.getParameter(SavedConfiguration.SERVER_PORT);
      configOptions.setPortNumberText(port);
      validPort = true;

      location = config.getParameter(SavedConfiguration.SERVER_ADDRESS);
    }

    // there may not be a default database location, so we had better
    // validate before using the returned value.
    if (location != null) {
      configOptions.setLocationFieldText(location);
      validDb = true;
    }

    options =
        new JOptionPane(configOptions, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);

    connectButton.setActionCommand(CONNECT);
    connectButton.addActionListener(this);

    boolean allValid = validDb && validPort && validCnx;
    connectButton.setEnabled(allValid);

    exitButton.setActionCommand(EXIT);
    exitButton.addActionListener(this);

    options.setOptions(new Object[] {connectButton, exitButton});

    dialog = options.createDialog(parent, TITLE);
    dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    dialog.addWindowListener(this);
    dialog.setVisible(true);
  }
예제 #4
0
  public void initComponents() {
    final Browser browser = new Browser();
    BrowserView browserView = new BrowserView(browser);
    JFrame parent = new JFrame();
    final JDialog dialog = new JDialog(parent, "QUIZ", true);

    browser.addLoadListener(
        new LoadAdapter() {
          @Override
          public void onFinishLoadingFrame(FinishLoadingEvent event) {
            if (event.isMainFrame()) {
              String videoUrl =
                  "https://www.youtube.com/embed/" + url + "?rel=0&amp;controls=0&amp;showinfo=0";
              DOMDocument document = event.getBrowser().getDocument();
              DOMNode root = document.findElement(By.id("video"));
              DOMElement iframe = document.createElement("iframe");
              iframe.setAttribute("src", videoUrl);
              iframe.setAttribute("frameborder", "0");
              root.appendChild(iframe);
              DOMNode root2 = document.findElement(By.id("text"));
              DOMElement p = document.createElement("p");
              p.setAttribute("class", "text");
              DOMNode n = document.createTextNode(question.getText());
              root2.appendChild(p);
              p.appendChild(n);
              DOMNode answers = document.findElement(By.id("answers"));
              if (question.getAnswerType().equals(AnswerType.MULTIPLE_CHOICE)) {
                DOMNode form = document.createElement("form");

                AnswerManager am = new AnswerManager(session);
                List<String> answerList = am.getAnswerByQuestionId(question.getId());

                for (String answer : answerList) {
                  DOMElement trueBox = document.createElement("input");
                  trueBox.setAttribute("type", "radio");
                  trueBox.setAttribute("name", "tf");
                  DOMNode dataTrue = document.createTextNode(answer);
                  DOMElement labeltrue = document.createElement("label");
                  labeltrue.appendChild(dataTrue);

                  form.appendChild(trueBox);
                  form.appendChild(labeltrue);
                  DOMElement br = document.createElement("br");
                  form.appendChild(br);
                }

                answers.appendChild(form);
              }

              if (question.getAnswerType().equals(AnswerType.TRUE_FALSE)) {
                DOMNode form = document.createElement("form");
                DOMElement trueBox = document.createElement("input");
                trueBox.setAttribute("type", "radio");
                trueBox.setAttribute("name", "tf");
                DOMNode dataTrue = document.createTextNode("true");
                DOMElement labeltrue = document.createElement("label");
                labeltrue.appendChild(dataTrue);
                DOMElement falseBox = document.createElement("input");
                DOMNode dataFalse = document.createTextNode("false");
                DOMElement labelFalse = document.createElement("label");
                labelFalse.appendChild(dataFalse);
                falseBox.setAttribute("type", "radio");
                falseBox.setAttribute("name", "tf");
                form.appendChild(labeltrue);
                form.appendChild(trueBox);
                DOMElement br = document.createElement("br");
                form.appendChild(br);
                form.appendChild(labelFalse);
                form.appendChild(falseBox); //
                answers.appendChild(form);
              }
            }
          }
        });

    browser.loadURL("http://dtprojecten.ehb.be/~PR-Ready/question/videoFrame.html?853954951951959");
    dialog.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            browser.dispose();
            dialog.setVisible(false);
            dialog.dispose();
          }
        });

    browser.registerFunction(
        "nextQuestion",
        new BrowserFunction() {

          public JSValue invoke(JSValue... jsValues) {
            browser.dispose();
            dialog.setVisible(false);
            dialog.dispose();
            quizLauncher.setIncrement(quizLauncher.getIncrement() + 1);
            quizLauncher.windowChoice();
            return JSValue.createUndefined();
          }
        });

    browser.registerFunction(
        "previousQuestion",
        new BrowserFunction() {

          public JSValue invoke(JSValue... jsValues) {
            browser.dispose();
            dialog.setVisible(false);
            dialog.dispose();
            quizLauncher.setIncrement(quizLauncher.getIncrement() - 1);
            quizLauncher.windowChoice();
            return JSValue.createUndefined();
          }
        });

    dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    dialog.add(new BrowserView(browser), BorderLayout.CENTER);
    dialog.setResizable(false);
    dialog.setUndecorated(true);
    dialog.setBounds(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds());
    dialog.setLocationRelativeTo(parent);
    dialog.setVisible(true);
  }