Esempio n. 1
0
  public OptionsPanel(Application app, StatDialog statDialog, StatPanelSettings settings) {

    this.app = app;
    this.statDialog = statDialog;
    this.settings = settings;

    // create option panels
    createHistogramPanel();
    createGraphPanel();
    createScatterplotPanel();

    mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(histogramPanel);
    mainPanel.add(scatterplotPanel);
    mainPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

    tabbedPane = new JTabbedPane();
    tabbedPane.addFocusListener(this);
    tabbedPane.setBorder(BorderFactory.createEmptyBorder());

    this.setLayout(new BorderLayout());
    this.add(tabbedPane, BorderLayout.CENTER);
    this.setBorder(BorderFactory.createMatteBorder(0, 1, 0, 0, SystemColor.controlShadow));

    // update
    setLabels();
    updateGUI();
    // this.setPreferredSize(tabbedPane.getPreferredSize());

    this.requestFocusInWindow();
  }
Esempio n. 2
0
  /**
   * ********************************************************** Constructs an OptionPanel
   *
   * @param app App
   * @param settings
   * @param statDialog statDialog
   * @param settings settings
   */
  public OptionsPanelD(AppD app, DataAnalysisModel model, StatPanelSettings settings) {

    this.app = app;
    this.loc = app.getLocalization();
    this.daModel = model;
    this.settings = settings;

    // create option panels
    createHistogramPanel();
    createGraphPanel();
    createScatterplotPanel();
    createBarChartPanel();
    createBoxPlotPanel();

    mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(histogramPanel);
    mainPanel.add(scatterplotPanel);
    mainPanel.add(barChartPanel);
    mainPanel.add(boxPlotPanel);
    mainPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

    tabbedPane = new JTabbedPane();
    tabbedPane.addFocusListener(this);
    tabbedPane.setBorder(BorderFactory.createEmptyBorder());

    this.setLayout(new BorderLayout());
    this.add(tabbedPane, BorderLayout.CENTER);
    this.setBorder(BorderFactory.createMatteBorder(0, 1, 0, 0, SystemColor.controlShadow));

    // update
    setLabels();
    updateGUI();
    // this.setPreferredSize(tabbedPane.getPreferredSize());

    this.requestFocusInWindow();
  }
  @NotNull
  private Content createContent(String contentName) {
    if (project == null) {
      throw new IllegalStateException("Project not opened");
    }

    ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    ToolWindow wm = ToolWindowManager.getInstance(project).getToolWindow(QUERY_RESULT_PANE);

    if (wm == null) {
      wm = toolWindowManager.registerToolWindow(QUERY_RESULT_PANE, true, ToolWindowAnchor.BOTTOM);
      wm.setIcon(Icons.QUERY_RESULT_PANE);
      wm.setToHideOnEmptyContent(true);
    }

    Content content = wm.getContentManager().findContent(contentName);
    if (content == null) {
      JTabbedPane tabbedPane = new JTabbedPane();
      tabbedPane.addContainerListener(new JTabbedPaneListener());

      tabbedPane.addKeyListener(
          new KeyAdapter() {
            public void keyPressed(KeyEvent e) {
              ((JComponent) e.getComponent()).putClientProperty(JTABBED_CONTROL, e.isControlDown());
            }

            public void keyReleased(KeyEvent e) {
              ((JComponent) e.getComponent()).putClientProperty(JTABBED_CONTROL, e.isControlDown());
            }
          });
      tabbedPane.addFocusListener(
          new FocusAdapter() {
            public void focusGained(FocusEvent e) {
              Object source = e.getSource();
              Component c = e.getOppositeComponent();
            }

            public void focusLost(FocusEvent e) {
              ((JComponent) e.getSource()).putClientProperty(JTABBED_CONTROL, false);
            }
          });

      JPanel jpanel = new JPanel(new BorderLayout());

      DefaultActionGroup actionGroup = new DefaultActionGroup("PsiActionGroup22", false);
      actionGroup.add(
          new LocalToggleAction(
              "Refresh Query Result",
              "Refresh Query Result",
              Icons.REFRESH_RESULTSET,
              REFRESH_RESULTSET));
      actionGroup.add(new LocalToggleAction("Copy", "Copy", Icons.EXPORT_DATA, EXPORT_DATA));

      // todo -- problem with keeping sql markers and tabs in sync
      //            actionGroup.add(new LocalToggleAction("Close", "Close", Icons.CLOSE_PANEL,
      // CLOSE_PANEL));

      ActionManager actionManager = ActionManager.getInstance();
      ActionToolbar toolBar =
          actionManager.createActionToolbar("DataGridActionToolbar", actionGroup, false);
      jpanel.add(toolBar.getComponent(), "West");
      jpanel.add(tabbedPane, "Center");

      //            ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
      //            ContentFactory contentFactory = PeerFactory.getInstance().getContentFactory();
      ContentFactory contentFactory = ContentFactoryEx.getContentFactory();
      content = contentFactory.createContent(jpanel, contentName, false);
      // content.setActions(actionGroup, "UKNOWN", null);
      content.setIcon(Icons.DISCONNECT);
      wm.getContentManager().addContent(content);
    }

    return content;
  }