Logo Search packages:      
Sourcecode: pcalendar version File versions  Download package

JComponent net::sf::linuxorg::pcal::bbtgui::BBTWidget::getBBTWidget (  ) [inline]

The main BBT Grid widget factory

Parameters:
startDatethe start date for the calendar. If null - the today date will be centered.
Returns:
the new instance of the widget

Definition at line 122 of file BBTWidget.java.

References net::sf::linuxorg::pcal::MainWindow::createToolbarButton(), generateHorizontalLabels(), getBBTRowHeadersModel(), net::sf::linuxorg::pcal::MainWindow::getGraphics(), and resetTableColumns().

Referenced by net::sf::linuxorg::pcal::bbtgui::PCaBBTDialog::PCaBBTDialog().

                                       {
            // the observations table

            bbtTableModel = new BBTTableModel(this);
            bbtTable = new JTable(bbtTableModel) {
                  private static final long serialVersionUID = 1L;

                  // delegate the painting stuff to the external function
                  @Override
                  protected void paintComponent(Graphics g) {
                        super.paintComponent(g);
                        paintBBTGraph(g);
                  }
            };          
            bbtTable.setPreferredScrollableViewportSize(new Dimension(400, 70));
            bbtTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            bbtTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            bbtTable.getTableHeader().setResizingAllowed(false);
            bbtTable.getTableHeader().setReorderingAllowed(false);
            bbtTable.setRowSelectionAllowed(false);
            bbtTable.setColumnSelectionAllowed(false);
            bbtTable.setColumnSelectionAllowed(true);

            bbtTable.addKeyListener(getBBTKeyListener());
            bbtTable.addMouseListener(getBBTMouseListener());
            bbtTable.addMouseMotionListener(getBBTMouseMoutionListener());

            bbtTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
                  public void valueChanged(ListSelectionEvent e) {
                        //Ignore extra messages.
                        if (e.getValueIsAdjusting()) return;
                        bbtTable.repaint();
                  }
            });

            genericRowHeight = bbtTable.getRowHeight();

            resetTableColumns();
            bbtTable.setDefaultRenderer(Object.class, getBBTTableCellRenderer());

            bbtRowHeader = new JTable(getBBTRowHeadersModel());   

            //Calculate row header width basing on the current font
            FontMetrics fm = PCalendar.mainWindow.getGraphics().getFontMetrics();
            int rowHeaderWidth = fm.stringWidth(Messages.getString("BBTWidget.0")) + 8; //$NON-NLS-1$
            Dimension d = bbtRowHeader.getPreferredScrollableViewportSize();
            d.width = rowHeaderWidth;
            bbtRowHeader.setPreferredScrollableViewportSize(d);
            bbtRowHeader.setIntercellSpacing(new Dimension(0, 0));

            //bbtRowHeader.getColumnModel().getColumn(0).setPreferredWidth(); // the widest string
            bbtRowHeader.setDefaultRenderer(Object.class, new RowHeaderRenderer(bbtTable, this));

            bbtScrollPane = new JScrollPane(bbtTable);
            bbtScrollPane.setRowHeaderView(bbtRowHeader);
            bbtScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
            //listen to the table resize
            bbtScrollPane.addComponentListener(
                        new ComponentAdapter() {
                              public void componentResized(ComponentEvent e) {
                                    int bbtDaysCount = bbtScrollPane.getViewportBorderBounds().width / genericRowHeight;
                                    if(dateLabels.length != bbtDaysCount) {
                                          generateHorizontalLabels(bbtDaysCount);
                                          resizeRowHeights();
                                    }
                              }
                        });

            actionAddOvulation = new ActionAddOvulation();
            actionDeleteRecord = new ActionDeleteRecord();

            bbtPopupMenu = new JPopupMenu();
            bbtPopupMenu.add(actionAddOvulation);
            bbtPopupMenu.add(actionDeleteRecord);
            sympthomsPopupMenu = new JPopupMenu();

            sympthomsMenuActionListener = getSympthomsMenuActionListener();

            ActionListener bbtActionListener = getBBTActionListener();

            JToolBar bbtToolBar = new JToolBar();
            bbtToolBar.setFloatable(false);
            bbtToolBar.add(MainWindow.createToolbarButton("16x16/first2.png", //$NON-NLS-1$ 
                        "prevYear", Messages.getString("BBTWidget.1"),  //$NON-NLS-1$ //$NON-NLS-2$
                        bbtActionListener));
            bbtToolBar.add(MainWindow.createToolbarButton("16x16/first.png", //$NON-NLS-1$ 
                        "prevMonth", Messages.getString("BBTWidget.2"), //$NON-NLS-1$ //$NON-NLS-2$
                        bbtActionListener));
            bbtToolBar.add(MainWindow.createToolbarButton("16x16/backward.png", //$NON-NLS-1$ 
                        "prevDay", Messages.getString("BBTWidget.3"), //$NON-NLS-1$ //$NON-NLS-2$
                        bbtActionListener));
            bbtToolBar.addSeparator();
            bbtToolBar.addSeparator();
            bbtToolBar.add(MainWindow.createToolbarButton("16x16/forward.png",      //$NON-NLS-1$ 
                        "nextDay", Messages.getString("BBTWidget.4"),   //$NON-NLS-1$ //$NON-NLS-2$
                        bbtActionListener));
            bbtToolBar.add(MainWindow.createToolbarButton("16x16/last.png",   //$NON-NLS-1$ 
                        "nextMonth", Messages.getString("BBTWidget.5"), //$NON-NLS-1$ //$NON-NLS-2$
                        bbtActionListener));
            bbtToolBar.add(MainWindow.createToolbarButton("16x16/last2.png",  //$NON-NLS-1$ 
                        "nextYear", Messages.getString("BBTWidget.6"),  //$NON-NLS-1$ //$NON-NLS-2$
                        bbtActionListener));
            bbtToolBar.addSeparator();
            bbtToolBar.add(MainWindow.createToolbarButton("16x16/jump-to.png",      //$NON-NLS-1$ 
                        "centerToday", Messages.getString("BBTWidget.7"),     //$NON-NLS-1$ //$NON-NLS-2$
                        bbtActionListener));
            bbtToolBar.addSeparator();

            currentMonthLabel = new JLabel();
            bbtToolBar.add(currentMonthLabel);

            JPanel bbtPanel = new JPanel(new BorderLayout());
            bbtPanel.add(bbtScrollPane, BorderLayout.CENTER);
            bbtPanel.add(bbtToolBar, BorderLayout.PAGE_START);

            return bbtPanel;
      }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index