コード例 #1
0
  @Override
  public void settingsChanged(AbstractSettings settings) {
    ConstructionProtocolSettings cps = (ConstructionProtocolSettings) settings;

    boolean gcv[] = cps.getColsVisibility();
    if (gcv != null) if (gcv.length > 0) setColsVisibility(gcv);

    update();
    ((ConstructionTableData) getData()).initView();
    repaintScrollpane();
  }
コード例 #2
0
  public ConstructionProtocolViewD(final AppD app) {
    // cpPanel = new JPanel(new BorderLayout());

    this.app = app;
    kernel = app.getKernel();
    data = new ConstructionTableData(this);
    useColors = true;
    addIcons = false;

    table = new JTable();
    table.setAutoCreateColumnsFromModel(false);
    table.setModel(((GAbstractTableModelD) data.getImpl()).getImpl());
    table.setRowSelectionAllowed(true);
    table.setGridColor(Color.lightGray);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);

    // header
    JTableHeader header = table.getTableHeader();
    // header.setUpdateTableInRealTime(true);
    header.setReorderingAllowed(false);

    // init model
    ConstructionTableCellRenderer renderer;
    HeaderRenderer headerRend = new HeaderRenderer();
    tableColumns = new TableColumn[data.columns.length];

    for (int k = 0; k < data.columns.length; k++) {
      renderer = new ConstructionTableCellRenderer();
      renderer.setHorizontalAlignment(data.columns[k].getAlignment());
      tableColumns[k] = new TableColumn(k, data.columns[k].getPreferredWidth(), renderer, null);
      tableColumns[k].setMinWidth(data.columns[k].getMinWidth());
      tableColumns[k].setHeaderRenderer(headerRend);
      if (data.columns[k].getInitShow()) table.addColumn(tableColumns[k]);
      if (data.columns[k].getTitle() == "Caption") {
        tableColumns[k].setCellEditor(new ConstructionTableCellEditor());
      }
    }
    // first column "No." should have fixed width
    tableColumns[0].setMaxWidth(tableColumns[0].getMinWidth());

    table
        .getColumnModel()
        .addColumnModelListener(((ConstructionTableData) data).new ColumnMovementListener());

    scrollPane = new JScrollPane(table);
    scrollPane.getViewport().setBackground(Color.white);
    // cpPanel.add(scrollPane, BorderLayout.CENTER);

    // clicking
    ConstructionMouseListener ml = new ConstructionMouseListener();
    table.addMouseListener(ml);
    table.addMouseMotionListener(ml);
    header.addMouseListener(ml); // double clicking, right-click menu
    scrollPane.addMouseListener(ml); // right-click menu

    // keys
    ConstructionKeyListener keyListener = new ConstructionKeyListener();
    table.addKeyListener(keyListener);

    app.getGuiManager().registerConstructionProtocolView(this);

    // navigation bar
    // protNavBar = new ConstructionProtocolNavigationD(app);
    // protNavBar.register(this);
    // protNavBar.setPlayButtonVisible(false);
    // protNavBar.setConsProtButtonVisible(false);
    // this.cpPanel.add(protNavBar.getImpl(), BorderLayout.SOUTH);
    // org.geogebra.desktop.util.Util.addKeyListenerToAll(protNavBar.getImpl(),
    // keyListener);

    initGUI();
    initActions();

    ConstructionProtocolSettings cps = app.getSettings().getConstructionProtocol();
    settingsChanged(cps);
    cps.addListener(this);
  }