コード例 #1
0
  /** Changes the thumb position to the specified grid component */
  void update(GridComponent gc) {
    DesignerDragSource dds =
        (DesignerDragSource) JETARegistry.lookup(DesignerDragSource.COMPONENT_ID);
    if (dds != null && dds != this && dds.isDragging()) {
      return;
    }

    if (isPaintMargin() && !m_dragging && m_compsrc.isSelectionTool()) {
      m_gc = gc;
      if (gc != null) {
        GridView parentview = gc.getParentView();
        if (parentview == m_view) {
          m_gc = null;
        } else {
          if (parentview != null) {
            Insets insets = parentview.getInsets();
            int col_offset = gc.getColumn() + gc.getColumnSpan() - 1;

            Point pt =
                javax.swing.SwingUtilities.convertPoint(
                    parentview,
                    parentview.getColumnOrgX(col_offset)
                        + parentview.getColumnWidth(col_offset)
                        + insets.left,
                    0,
                    this);
            m_xpos = pt.x;
          }
        }
      }
      repaint();
    }
  }
コード例 #2
0
  public void mousePressed(MouseEvent e) {
    GridView view = getView();
    if (view != null) view.deselectAll();

    GridComponent cell = getComponent(e);
    if (cell == m_comp) {
      if (!handleControlButton(e)) {
        GridView childview = m_comp.getChildView();
        childview.deselectAll();

        if (m_compsrc.isSelectionTool()) {
          m_comp.setSelected(true);
          m_comp.repaint();
          if (e.getClickCount() > 1) {
            m_comp.fireGridCellEvent(new GridCellEvent(GridCellEvent.EDIT_COMPONENT, m_comp));
          } else if (e.getClickCount() == 1) {
            setDragSource(this);
          }
        }
      }
    } else if (cell != null) {
      CellMouseHandler handler = cell.getMouseHandler();
      assert (handler != null);
      if (handler != null) {
        handler.mousePressed(e);
      }
      m_comp.repaint();
    }
  }
コード例 #3
0
 /**
  * Builds the set of FocusKey objects for all focusable components on the form. A FocusKey allows
  * us to store a reference to a focusable component and later find that component when a form has
  * been de-serialized. We don't use the component name to reference the component because we don't
  * want to keep track of when the user changes the name.
  */
 public void buildFocusKeys(
     HashSet currentFocusSet,
     HashMap focus_key_map,
     FormComponent form,
     CompositeFocusKey compositeKey) {
   for (int row = 1; row <= form.getRowCount(); row++) {
     for (int col = 1; col <= form.getColumnCount(); col++) {
       GridComponent gc = form.getGridComponent(col, row);
       if (gc instanceof StandardComponent) {
         Component comp = gc.getBeanDelegate();
         if (comp != null) {
           if (currentFocusSet.contains(comp)) {
             CompositeFocusKey ckey = (CompositeFocusKey) compositeKey.clone();
             ckey.add(new FormCellFocusKey(row, col, comp));
             focus_key_map.put(comp, ckey);
           } else {
             /**
              * This comp must be a container that contains components that are in the focus policy
              * This can happen for Java Beans that are also panels which contain other components.
              */
             if (comp instanceof Container) {
               CompositeFocusKey ckey = (CompositeFocusKey) compositeKey.clone();
               ckey.add(new FormCellFocusKey(row, col, comp));
               buildContainerFocusKeys(currentFocusSet, focus_key_map, (Container) comp, ckey);
             } else {
               // ignore because this could be a component like
               // a JLabel which does not need focus
             }
           }
         }
       } else if (gc instanceof FormComponent) {
         FormComponent childform = (FormComponent) gc;
         CompositeFocusKey ckey = (CompositeFocusKey) compositeKey.clone();
         ckey.add(new FormCellFocusKey(row, col, gc));
         buildFocusKeys(currentFocusSet, focus_key_map, childform, ckey);
       } else {
         if (gc != null) {
           System.out.println(
               "FormFocusManager.buildDefaultPolicyFailed  found unknown comp: " + gc.getClass());
         }
       }
     }
   }
 }
コード例 #4
0
  public void mouseReleased(MouseEvent e) {
    if (isDragging()) {
      GridComponent cell = getComponent(e);
      if (cell == m_comp) {
        if (getDragSource() != this) {
          // mouse released on this entire form, so we replace the
          // form.

        }
      } else if (cell != null) {
        if (getDragSource() != this) {
          // don't allow drops on children of this form if we are the
          // drag source
          CellMouseHandler handler = cell.getMouseHandler();
          if (handler != null) {
            handler.mouseReleased(e);
          }
          m_comp.repaint();
        }
      }
    }
  }
コード例 #5
0
  /**
   * MouseMotionListener implementation. Note that the source will always be the top level window.
   * So, we need to convert the mouse point to the coordinates of our associated overlay window
   * before any other operation.
   */
  public void mouseMoved(MouseEvent e) {
    if (!m_compsrc.isSelectionTool() || isDragging()) {
      GridView view = getView();
      if (view != null) view.deselectAll();
    }

    GridOverlay overlay = m_comp.getChildOverlay();
    GridComponent cell = getComponent(e);
    if (cell != null) {
      CellMouseHandler handler = cell.getMouseHandler();
      if (handler == null) {
        // System.out.println( "found null handler at row: " +
        // cell.getRow() + " col: " + cell.getColumn() + " for: " +
        // cell.getComponent() );
        assert (false);
      } else {
        if (getDragSource() != this) {
          if (handler != this) {
            handler.mouseMoved(e);
          }
        }
      }
    }
  }