private void initializeDlg() {
    if (pst.isEmbeddedView()) {
      return;
    }
    JDialog dlg = (JDialog) parentContainer;

    dlg.add(viewLayout.mainPanel, BorderLayout.CENTER);

    //        SwingUtils.locateOnScreenCenter(dlg);
    SwingUtils.locateRelativeToMenu(dlg);
    dlg.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    dlg.addWindowListener(
        new java.awt.event.WindowAdapter() {
          // todo ver cómo se va a hacer esto en la versión Filthy
          public void windowOpened(WindowEvent e) {
            if (pst != null) {
              pst.onWindowsOpened(e);
              pst.onWindowsOpenedInternalOnlyForAWFW(e);
              if (!pst.isReadOnly()) {
                //                        pst.setFocusToCmpOnWindowOpen();
                //
                // ActionManager.instance().getVisualMgrForActions().repaintMainDisabledActions(pst.getActionRsr());
              } else {
                pst.configureAsReanOnly();
                JButton btnCancel = (JButton) pst.getIpView().getComponent("btnCancel");
                if (btnCancel != null) {
                  btnCancel.requestFocusInWindow();
                }
              }
            }
          }

          public void windowClosing(WindowEvent e) {
            MsgDisplayer.showMessage("sw.common.closeWindowDisabled");
          }

          public void windowActivated(WindowEvent e) {
            Object oppositeWindow = e.getOppositeWindow();

            if (oppositeWindow instanceof DlgMensaje) {
              logger.debug("Ignoring Windows activated for DlgMensaje");
              return;
            }
            if (oppositeWindow instanceof JDialog) {
              JDialog dlg = (JDialog) oppositeWindow;
              if (MessageDisplayer.GENERIC_MESSAGE_TITLE.equals(dlg.getTitle())) {
                logger.debug("Ignoring Windows activated for System Msg");
                return;
              }
            }
            logger.debug("Windows Activated:" + pst);
            AWWindowsManager.instance().setPresenterActivated(pst);
          }
        });
  }
示例#2
0
  public static JDialog createDialog(JComponent parent, OWLEditorKit editorKit) {
    JFrame parentFrame = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, parent);
    final JDialog dialog = new JDialog(parentFrame, "Search", Dialog.ModalityType.MODELESS);

    final SearchDialogPanel searchDialogPanel = new SearchDialogPanel(editorKit);
    searchDialogPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

    searchDialogPanel
        .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "CLOSE_DIALOG");
    searchDialogPanel
        .getActionMap()
        .put(
            "CLOSE_DIALOG",
            new AbstractAction() {
              @Override
              public void actionPerformed(ActionEvent e) {
                dialog.setVisible(false);
              }
            });

    searchDialogPanel
        .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "CLOSE_DIALOG_WITH_ENTER");
    searchDialogPanel
        .getActionMap()
        .put(
            "CLOSE_DIALOG_WITH_ENTER",
            new AbstractAction() {
              @Override
              public void actionPerformed(ActionEvent e) {
                dialog.setVisible(false);
                searchDialogPanel.selectEntity();
              }
            });

    dialog.setContentPane(searchDialogPanel);
    dialog.setResizable(true);
    dialog.pack();
    dialog.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowOpened(WindowEvent e) {
            searchDialogPanel.searchField.requestFocusInWindow();
          }
        });
    return dialog;
  }
示例#3
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);
  }
示例#5
0
  public static void initComponents() {
    final Browser browser = new Browser();
    JFrame parent = new JFrame();
    final JDialog dialog = new JDialog(parent, "QUIZ", true);

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

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

          public JSValue invoke(JSValue... jsValues) {
            browser.dispose();
            dialog.setVisible(false);
            dialog.dispose();

            PieChartData[] dataArr = new PieChartData[6];
            dataArr[0] = new PieChartData("De grote quiz", 50);
            dataArr[1] = new PieChartData("Test uw IQ!", 1);
            dataArr[2] = new PieChartData("Gestolen rijexamens", 15);
            dataArr[3] = new PieChartData("Win een reis!", 4);
            dataArr[4] = new PieChartData("Test uw kennis!", 10);
            dataArr[5] = new PieChartData("Kan u de verschillen aanwijzen?", 20);
            new PieChartWindow(factory, dataArr, "Populariteit per quiz");

            return JSValue.createUndefined();
          }
        });

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

          public JSValue invoke(JSValue... jsValues) {
            browser.dispose();
            dialog.setVisible(false);
            dialog.dispose();

            LineChartData[] lineData = new LineChartData[3];
            String title = "User creation";
            String subtitle = "By month";
            String leftTitle = "Users";
            String[] categories = new String[3];
            categories[0] = "September";
            categories[1] = "Oktober";
            categories[2] = "November";
            double[] data = new double[3];
            data[0] = 10;
            data[1] = 2;
            data[2] = 50;

            lineData[0] = new LineChartData("September", data);
            lineData[1] = new LineChartData("Oktober", data);
            lineData[2] = new LineChartData("November", data);
            new LineChartWindow(factory, lineData, title, subtitle, leftTitle, categories);

            return JSValue.createUndefined();
          }
        });

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

          public JSValue invoke(JSValue... jsValues) {
            browser.dispose();
            dialog.setVisible(false);
            dialog.dispose();
            ColumnData[] dataColumn = new ColumnData[1];
            double[] data = new double[3];
            data[0] = 33.6;
            data[1] = 88;
            data[2] = 66;
            String title = "Gemiddelde score per quiz";
            String subtitle = "";
            dataColumn[0] = new ColumnData("Gemiddelde Score", data);

            new ColumnChartWindow(factory, dataColumn, title, subtitle);

            return JSValue.createUndefined();
          }
        });

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

          public JSValue invoke(JSValue... jsValues) {
            browser.dispose();
            dialog.setVisible(false);
            dialog.dispose();
            System.out.println("exit");
            try {
              AdminMenuWindow amw = new AdminMenuWindow(factory);
            } catch (UserNoPermissionException e) {
              e.printStackTrace();
            }

            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);
  }
示例#6
0
  public SheetMessage(
      final Window owner,
      final String title,
      final String message,
      final Icon icon,
      final String[] buttons,
      final DialogWrapper.DoNotAskOption doNotAskOption,
      final String defaultButton,
      final String focusedButton) {
    myWindow =
        new JDialog(owner, "This should not be shown", Dialog.ModalityType.APPLICATION_MODAL);
    myWindow.getRootPane().putClientProperty("apple.awt.draggableWindowBackground", Boolean.FALSE);

    myWindow.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowActivated(WindowEvent e) {
            super.windowActivated(e);
          }
        });

    myParent = owner;

    myWindow.setUndecorated(true);
    myWindow.setBackground(Gray.TRANSPARENT);
    myController =
        new SheetController(
            this, title, message, icon, buttons, defaultButton, doNotAskOption, focusedButton);

    imageHeight = 0;
    registerMoveResizeHandler();
    myWindow.setFocusable(true);
    myWindow.setFocusableWindowState(true);
    if (SystemInfo.isJavaVersionAtLeast("1.7")) {
      myWindow.setSize(myController.SHEET_NC_WIDTH, 0);

      setWindowOpacity(0.0f);

      myWindow.addComponentListener(
          new ComponentAdapter() {
            @Override
            public void componentShown(ComponentEvent e) {
              super.componentShown(e);
              setWindowOpacity(1.0f);
              myWindow.setSize(myController.SHEET_NC_WIDTH, myController.SHEET_NC_HEIGHT);
            }
          });
    } else {
      myWindow.setModal(true);
      myWindow.setSize(myController.SHEET_NC_WIDTH, myController.SHEET_NC_HEIGHT);
      setPositionRelativeToParent();
    }
    startAnimation(true);
    restoreFullscreenButton = couldBeInFullScreen();
    if (restoreFullscreenButton) {
      FullScreenUtilities.setWindowCanFullScreen(myParent, false);
    }

    LaterInvocator.enterModal(myWindow);
    myWindow.setVisible(true);
    LaterInvocator.leaveModal(myWindow);
  }
  public SheetMessage(
      final Window owner,
      final String title,
      final String message,
      final Icon icon,
      final String[] buttons,
      final DialogWrapper.DoNotAskOption doNotAskOption,
      final String defaultButton,
      final String focusedButton) {
    final Window activeWindow =
        KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
    final Component recentFocusOwner =
        activeWindow == null ? null : activeWindow.getMostRecentFocusOwner();
    WeakReference<Component> beforeShowFocusOwner = new WeakReference<Component>(recentFocusOwner);

    maximizeIfNeeded(owner);

    myWindow =
        new JDialog(owner, "This should not be shown", Dialog.ModalityType.APPLICATION_MODAL);
    myWindow.getRootPane().putClientProperty("apple.awt.draggableWindowBackground", Boolean.FALSE);

    myWindow.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowActivated(@NotNull WindowEvent e) {
            super.windowActivated(e);
          }
        });

    myParent = owner;

    myWindow.setUndecorated(true);
    myWindow.setBackground(Gray.TRANSPARENT);
    myController =
        new SheetController(
            this, title, message, icon, buttons, defaultButton, doNotAskOption, focusedButton);

    imageHeight = 0;
    registerMoveResizeHandler();
    myWindow.setFocusable(true);
    myWindow.setFocusableWindowState(true);
    if (SystemInfo.isJavaVersionAtLeast("1.7")) {
      myWindow.setSize(myController.SHEET_NC_WIDTH, 0);

      setWindowOpacity(0.0f);

      myWindow.addComponentListener(
          new ComponentAdapter() {
            @Override
            public void componentShown(@NotNull ComponentEvent e) {
              super.componentShown(e);
              setWindowOpacity(1.0f);
              myWindow.setSize(myController.SHEET_NC_WIDTH, myController.SHEET_NC_HEIGHT);
            }
          });
    } else {
      myWindow.setModal(true);
      myWindow.setSize(myController.SHEET_NC_WIDTH, myController.SHEET_NC_HEIGHT);
      setPositionRelativeToParent();
    }
    startAnimation(true);
    restoreFullScreenButton = couldBeInFullScreen();
    if (restoreFullScreenButton) {
      FullScreenUtilities.setWindowCanFullScreen(myParent, false);
    }

    LaterInvocator.enterModal(myWindow);
    myWindow.setVisible(true);
    LaterInvocator.leaveModal(myWindow);

    Component focusCandidate = beforeShowFocusOwner.get();

    if (focusCandidate == null) {
      focusCandidate =
          IdeFocusManager.getGlobalInstance()
              .getLastFocusedFor(IdeFocusManager.getGlobalInstance().getLastFocusedFrame());
    }

    // focusCandidate is null if a welcome screen is closed and ide frame is not opened.
    // this is ok. We set focus correctly on our frame activation.
    if (focusCandidate != null) {
      focusCandidate.requestFocus();
    }
  }
示例#8
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);
  }