Package DisplayProject

Examples of DisplayProject.ArrayColumn


          //                 
          TextGraphic label = new TextGraphic();
          label.setStandardJavaSizing(true);
          label.setText(value.toString());

          ArrayColumn ac = (ArrayColumn)ArrayField.this.getColumnModel().getColumn(column);
          label.setOpaque(true);
          if (ac.getHeaderFont() != null) label.setFont(ac.getHeaderFont());
          if (ac.getHeaderForeground() != null) label.setForeground(ac.getHeaderForeground());
          label.setHorizontalAlignment(ac.getHeaderHorizontalAlignment());
          label.setVerticalAlignment(ac.getHeaderVerticalAlignment());

          // CraigM:31/07/2008 - Use the defined header background if one exists
          if (ArrayField.this.headerBackground != null) {
            label.setBackground(ArrayField.this.headerBackground);
          }
          else {
            label.setBackground(header.getBackground());
          }

          // Put a margin around the labels.  CraigM: 07/08/2008.
          if (ArrayField.this.getColumnCount() == 1) {
            label.setBorder(ArrayField.headerRendererBorderOneCol);
          }
          else if (column == 0) {
            label.setBorder(ArrayField.headerRendererBorderLeft);
          }
          else if (column == ArrayField.this.getColumnCount()-1) {
            label.setBorder(ArrayField.headerRendererBorderRight);
          }
          else {
            label.setBorder(ArrayField.headerRendererBorderMiddle); // Put a margin around the labels
          }

          // CraigM: 15/07/2008 - If we are html formatted, we need to get Java to realise the label and calculate its actual size
          if (label.getText().startsWith("<html>")) {
            // TF:01/11/2008:Changed this expensive way of getting the size of a label with a much cheaper one.
            label.setPreferredSize(null);
            label.setMinimumSize(null);
            // TF:28/08/2009:We must validate the label, or we get the wrong size
            label.validate();
            Dimension d = label.getMinimumSize();
            View v = (View) label.getClientProperty(BasicHTML.propertyKey);
            if (v != null) {
              d.width = (int)v.getPreferredSpan(View.X_AXIS);
            }
            label.setPreferredSize(d);
            label.setMinimumSize(d);
            /*
                      label.setPreferredSize(null);
                      label.setMinimumSize(null);
                    final JFrame f = new JFrame();
                    f.setUndecorated(true);
                    f.getContentPane().add(label);
                    f.pack();
                    Dimension dim = label.getSize();
                    label.setPreferredSize(dim);
                    label.setMinimumSize(dim);
                    f.getContentPane().remove(label);

                    // Not sure why I can't just call f.dispose() directly, but for some reason, it deadlocks the EDT.
                    SwingUtilities.invokeLater(new Runnable() {
                      public void run() {
                        f.dispose();
                      }
                    });
             */
          }

          if (ac.getSizePolicy() == Constants.FP_FIXED) {
            Dimension size = label.getPreferredSize();
            size.width = ac.getWidth();
            label.setMinimumSize(size);
          }

          // COLET 13/01/2009 : Add support for rendering the label as disabled based on a hint from the array column.
          label.setEnabled(ac.isHeaderEnabled());
          return label;
        }
        else {
          return new JLabel("Column: "+column); // For visual editors.  CraigM 20/02/2008
        }
View Full Code Here


  public JComponent getColumnTemplate(String pCol) {
    Enumeration<TableColumn> cols = this.getColumnModel().getColumns();

    while (cols.hasMoreElements()) {
      ArrayColumn aCol = (ArrayColumn)cols.nextElement();

      if (aCol.getName().equals(pCol)) {
        return this.getColumnTemplate(aCol);
      }
    }
    return null;
  }
View Full Code Here

  }

  public boolean isCellEditable(int row, int column) {
    if (isEnabled()){
      // TF:10/02/2009:Changed this to cater for the stateColourForRow interface
      ArrayColumn ac = (ArrayColumn) getColumnModel().getColumn(column);
      if (ac.getStateColour() != null) {
        return ac.getStateColour().isEnabled(row);
      }
      ArrayFieldModel alm = (ArrayFieldModel)getModel();
      return alm.isCellEditable(row, column);
    }
    else
View Full Code Here

      ArrayFieldModel model = (ArrayFieldModel)getModel();
      Stroke defaultStroke = ((Graphics2D)g).getStroke();
      for (int row = rowCount; row <= currentHeightOfAllRows/rowHeight; row++) {
        int xPos = 0; // PM this needs to be zero because the line does not repaint correctly
        for (int col = 0; col < colModel.getColumnCount(); col++) {
          ArrayColumn column = (ArrayColumn)this.getColumnModel().getColumn(col);
          Color backgroundColour = this.getBackground();

          // Rectangle place holders
          g.setColor(backgroundColour);
          g.fillRect(xPos, row*rowHeight, column.getWidth(), rowHeight);

          // Details in rectangle place holders
          if (this.paintEmptyRowRectangles && rowHeight > inset*2 && column.getWidth() > inset*2) {

            // If we can append a row, we are on the last row, and this column is editable
            if (this.isAllowsAppendAndEditable() && row == rowCount && model.isColumnEditable(col)) {
              TableCellRenderer renderer = ((ArrayFieldCellRenderer)column.getCellRenderer()).getRenderer();

              // The renderer supports painting in an empty row.  CraigM:20/01/2009.
              if (renderer instanceof ArrayFieldEmptyCellRenderer) {
                // Paint an editable row (not faded)
                // TF:27/11/2009:Changed this to pass in the width, which allows us to draw the proper image when the column is resized.
                BufferedImage img = ((ArrayFieldEmptyCellRenderer)renderer).getImage(column.getWidth());
                g.drawImage(img, xPos + ((column.getWidth() - img.getWidth()) / 2), (row*rowHeight) + ((rowHeight - img.getHeight()) / 2), null);
              }

              // Draw a filled white rectangle
              else {
                Color emptyCellColor = backgroundColour.equals(Color.gray) ? Color.lightGray : Color.gray;
                g.setColor(emptyCellColor);
                g.drawRect(xPos+inset, (row*rowHeight)+inset, column.getWidth()-(inset*2), rowHeight-(inset*2));
              }
            }
            else {
              TableCellRenderer renderer = ((ArrayFieldCellRenderer)column.getCellRenderer()).getRenderer();

              // The renderer supports painting in an empty row.  CraigM:20/01/2009.
              if (renderer instanceof ArrayFieldEmptyCellRenderer) {
                // These are non editable rows, so fade them out a little
                ((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f));
                BufferedImage img = ((ArrayFieldEmptyCellRenderer)renderer).getImage(column.getWidth());
                g.drawImage(img, xPos + ((column.getWidth() - img.getWidth()) / 2), (row*rowHeight) + ((rowHeight - img.getHeight()) / 2), null);
                ((Graphics2D)g).setComposite(AlphaComposite.Src);
              }
              else {
                Color emptyCellColor = backgroundColour.equals(Color.lightGray) ? Color.gray : Color.lightGray;
                g.setColor(emptyCellColor);
                ((Graphics2D)g).setStroke(dashed);
                g.drawRect(xPos+inset, (row*rowHeight)+inset, column.getWidth()-(inset*2), rowHeight-(inset*2));
              }
            }
          }
          // --- End ---
          xPos += column.getWidth();
        }
      }
      ((Graphics2D)g).setStroke(defaultStroke);
    }
  }
View Full Code Here

            qq_OrderList.setVisibleRows(8);

            //  === Column model setup ===

            // CustomerName converted from qqds_DataField
            ArrayColumn qq_OrderListArray_CustomerName_Column = new ArrayColumn("CustomerName", 0, new FormattedCellRenderer(getqq_OrderListArray_CustomerName()), new FormattedCellEditor(getqq_OrderListArray_CustomerName()), false);
            qq_OrderListArray_CustomerName_Column.setHeaderValue("CustomerName");
            qq_OrderListArray_CustomerName_Column.setVisible(true);
            qq_OrderList.addColumn(qq_OrderListArray_CustomerName_Column);

            // StockName converted from qqds_DataField
            ArrayColumn qq_OrderListArray_StockName_Column = new ArrayColumn("StockName", 1, new FormattedCellRenderer(getqq_OrderListArray_StockName()), new FormattedCellEditor(getqq_OrderListArray_StockName()), true);
            qq_OrderListArray_StockName_Column.setHeaderValue("StockName");
            qq_OrderListArray_StockName_Column.setVisible(true);
            qq_OrderList.addColumn(qq_OrderListArray_StockName_Column);

            // Quantity converted from qqds_DataField
            ArrayColumn qq_OrderListArray_Quantity_Column = new ArrayColumn("Quantity", 2, new FormattedCellRenderer(getqq_OrderListArray_Quantity()), new FormattedCellEditor(getqq_OrderListArray_Quantity()), true);
            qq_OrderListArray_Quantity_Column.setHeaderValue("Quantity");
            qq_OrderListArray_Quantity_Column.setVisible(true);
            qq_OrderList.addColumn(qq_OrderListArray_Quantity_Column);

            // Price converted from qqds_DataField
            ArrayColumn qq_OrderListArray_Price_Column = new ArrayColumn("Price", 3, new FormattedCellRenderer(getqq_OrderListArray_Price()), new FormattedCellEditor(getqq_OrderListArray_Price()), true);
            qq_OrderListArray_Price_Column.setHeaderValue("Price");
            qq_OrderListArray_Price_Column.setVisible(true);
            qq_OrderList.addColumn(qq_OrderListArray_Price_Column);

            // Type converted from qqds_DataField
            ArrayColumn qq_OrderListArray_Type_Column = new ArrayColumn("Type", 4, new FormattedCellRenderer(getqq_OrderListArray_Type()), new FormattedCellEditor(getqq_OrderListArray_Type()), true);
            qq_OrderListArray_Type_Column.setHeaderValue("Type");
            qq_OrderListArray_Type_Column.setVisible(true);
            qq_OrderList.addColumn(qq_OrderListArray_Type_Column);

            // SelectedForTrade converted from qqds_ToggleField
            ArrayColumn qq_OrderListArray_SelectedForTrade_Column = new ArrayColumn("SelectedForTrade", 5, new CheckBoxCellRenderer(getqq_OrderListArray_SelectedForTrade()), new CheckBoxCellEditor(getqq_OrderListArray_SelectedForTrade()), true);
            qq_OrderListArray_SelectedForTrade_Column.setHeaderValue("Trade");
            qq_OrderListArray_SelectedForTrade_Column.setVisible(true);
            qq_OrderList.addColumn(qq_OrderListArray_SelectedForTrade_Column);

            //  === End column model ===

            TableFactory.postModelArrayField(qq_OrderList);
View Full Code Here

              af = ArrayFieldCellHelper.getArrayField(component);
            }
            if (af != null) {
                int col = ArrayFieldCellHelper.getArrayFieldColumn((JComponent)component);
                //PM:23/11/07 correct for invisible columns
                ArrayColumn ac = (ArrayColumn)((ArrayColumnModel)af.getColumnModel()).getRealColumn(col);
                col = ((ArrayColumnModel)af.getColumnModel()).getColumnIndex(ac.getIdentifier());

                // If an explicit focus request occurs on an empty array field that allows append, then create
                // a new row (that's what Forte did).  CraigM 16/10/2007.
                if (af.getRowCount() == 0 && af.isAllowsAppend()) {
                    af.appendRow(col);
View Full Code Here

            return false;
        }
    }

    public void performAction() {
        ArrayColumn tc;
        // TF:5/11/08:If we're search by name, do a column lookup
        if (this.name != null) {
          ArrayColumnModel columnModel = (ArrayColumnModel)((JTable)this._component).getColumnModel();
          tc = columnModel.findColumn(this.name);
          if (tc == null) {
            // Nothing to do, couldn't find the column
            return;
          }
        }
        else {
          tc = ((ArrayColumnModel)((JTable)this._component).getColumnModel()).getRealColumn(column);
        }
        tc.setHeaderValue(title);
        TableModel model = ((JTable)_component).getModel();
        if (model instanceof ArrayFieldModel) {
          ((ArrayFieldModel)model).resizeTable();
        }
        // TF:29/3/08:Added a repaint to force the new change to reflect to the screen
View Full Code Here

        TextData title = null;
        ArrayColumnTitle action = (ArrayColumnTitle)ActionMgr.getAction(new ActionFilter(comp, columnName));
        if (action != null ) {
            title = TextData.getInstance(action.title);
        } else {
            ArrayColumn tc = ((ArrayColumnModel)comp.getColumnModel()).findColumnByName(columnName);

            title = TextData.getInstance(tc.getHeaderValue().toString());  
        }
        return title;
    }
View Full Code Here

        MaxCharacters action = ActionMgr.getAction(comp, MaxCharacters.class);
        if (action != null) {
            return action.getValue();
        }
        int max = 0;
        ArrayColumn ac = (ArrayColumn)comp;
        if ((ac.getCellEditor() != null)
                && (ac.getCellEditor() instanceof JTextComponent)){
            Document doc = ((JTextComponent)ac.getCellEditor()).getDocument();
            if ((doc != null) && (doc instanceof FixedLengthDocument)){
                max = ((FixedLengthDocument)doc).getMaxLength();
            }
        } else {
            max = ac.getMaxCharacters();
        }
        return max;
    }
View Full Code Here

                  try {
                    // CraigM:22/08/2008 - Corrected checking of column.
                    // CraigM:07/11/2008 - Note: If an object was replaced that maps to 0 or more columns, then updatedColumn will be set to -1.
                    if (ObjectTableModel.this.table.getColumnModel() instanceof ArrayColumnModel) {
                      ArrayColumn ac = ((ArrayColumnModel)ObjectTableModel.this.table.getColumnModel()).findColumn(columnAttributeName);
                      if (ac != null) {
                        updatedColumn = ac.getModelIndex();
                      }
                    }
                  }
                  catch (Throwable e) {
                    // The data may not even be mapped to a column in the table
View Full Code Here

TOP

Related Classes of DisplayProject.ArrayColumn

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.