equal
deleted
inserted
replaced
700 // create a view hierarchy |
700 // create a view hierarchy |
701 ViewFactory f = rootView.getViewFactory(); |
701 ViewFactory f = rootView.getViewFactory(); |
702 Document doc = editor.getDocument(); |
702 Document doc = editor.getDocument(); |
703 Element elem = doc.getDefaultRootElement(); |
703 Element elem = doc.getDefaultRootElement(); |
704 setView(f.create(elem)); |
704 setView(f.create(elem)); |
705 rootViewNeedsLayout = false; |
|
706 } |
705 } |
707 |
706 |
708 /** |
707 /** |
709 * Sets the current root of the view hierarchy and calls invalidate(). |
708 * Sets the current root of the view hierarchy and calls invalidate(). |
710 * If there were any child components, they will be removed (i.e. |
709 * If there were any child components, they will be removed (i.e. |
946 } |
945 } |
947 try { |
946 try { |
948 if ((d.width > (i.left + i.right + caretMargin)) && (d.height > (i.top + i.bottom))) { |
947 if ((d.width > (i.left + i.right + caretMargin)) && (d.height > (i.top + i.bottom))) { |
949 rootView.setSize(d.width - i.left - i.right - |
948 rootView.setSize(d.width - i.left - i.right - |
950 caretMargin, d.height - i.top - i.bottom); |
949 caretMargin, d.height - i.top - i.bottom); |
951 } if (!rootViewNeedsLayout) { |
950 } else if (d.width == 0 && d.height == 0) { |
952 // Probably haven't been layed out yet, force some sort of |
951 // Probably haven't been layed out yet, force some sort of |
953 // initial sizing. |
952 // initial sizing. |
954 rootViewNeedsLayout = true; |
|
955 rootView.setSize(Integer.MAX_VALUE, Integer.MAX_VALUE); |
953 rootView.setSize(Integer.MAX_VALUE, Integer.MAX_VALUE); |
956 } |
954 } |
957 d.width = (int) Math.min((long) rootView.getPreferredSpan(View.X_AXIS) + |
955 d.width = (int) Math.min((long) rootView.getPreferredSpan(View.X_AXIS) + |
958 (long) i.left + (long) i.right + caretMargin, Integer.MAX_VALUE); |
956 (long) i.left + (long) i.right + caretMargin, Integer.MAX_VALUE); |
959 d.height = (int) Math.min((long) rootView.getPreferredSpan(View.Y_AXIS) + |
957 d.height = (int) Math.min((long) rootView.getPreferredSpan(View.Y_AXIS) + |
1401 private static final TransferHandler defaultTransferHandler = new TextTransferHandler(); |
1399 private static final TransferHandler defaultTransferHandler = new TextTransferHandler(); |
1402 private final DragListener dragListener = getDragListener(); |
1400 private final DragListener dragListener = getDragListener(); |
1403 private static final Position.Bias[] discardBias = new Position.Bias[1]; |
1401 private static final Position.Bias[] discardBias = new Position.Bias[1]; |
1404 private DefaultCaret dropCaret; |
1402 private DefaultCaret dropCaret; |
1405 private int caretMargin; |
1403 private int caretMargin; |
1406 private boolean rootViewNeedsLayout; |
|
1407 |
1404 |
1408 /** |
1405 /** |
1409 * Root view that acts as a gateway between the component |
1406 * Root view that acts as a gateway between the component |
1410 * and the View hierarchy. |
1407 * and the View hierarchy. |
1411 */ |
1408 */ |
1964 } |
1961 } |
1965 |
1962 |
1966 // normal insert update |
1963 // normal insert update |
1967 Rectangle alloc = (painted) ? getVisibleEditorRect() : null; |
1964 Rectangle alloc = (painted) ? getVisibleEditorRect() : null; |
1968 rootView.insertUpdate(e, alloc, rootView.getViewFactory()); |
1965 rootView.insertUpdate(e, alloc, rootView.getViewFactory()); |
1969 rootViewNeedsLayout = false; |
|
1970 } |
1966 } |
1971 |
1967 |
1972 /** |
1968 /** |
1973 * The remove notification. Gets sent to the root of the view structure |
1969 * The remove notification. Gets sent to the root of the view structure |
1974 * that represents the portion of the model being represented by the |
1970 * that represents the portion of the model being represented by the |
1980 * @see DocumentListener#removeUpdate |
1976 * @see DocumentListener#removeUpdate |
1981 */ |
1977 */ |
1982 public final void removeUpdate(DocumentEvent e) { |
1978 public final void removeUpdate(DocumentEvent e) { |
1983 Rectangle alloc = (painted) ? getVisibleEditorRect() : null; |
1979 Rectangle alloc = (painted) ? getVisibleEditorRect() : null; |
1984 rootView.removeUpdate(e, alloc, rootView.getViewFactory()); |
1980 rootView.removeUpdate(e, alloc, rootView.getViewFactory()); |
1985 rootViewNeedsLayout = false; |
|
1986 } |
1981 } |
1987 |
1982 |
1988 /** |
1983 /** |
1989 * The change notification. Gets sent to the root of the view structure |
1984 * The change notification. Gets sent to the root of the view structure |
1990 * that represents the portion of the model being represented by the |
1985 * that represents the portion of the model being represented by the |
1996 * @see DocumentListener#changedUpdate(DocumentEvent) |
1991 * @see DocumentListener#changedUpdate(DocumentEvent) |
1997 */ |
1992 */ |
1998 public final void changedUpdate(DocumentEvent e) { |
1993 public final void changedUpdate(DocumentEvent e) { |
1999 Rectangle alloc = (painted) ? getVisibleEditorRect() : null; |
1994 Rectangle alloc = (painted) ? getVisibleEditorRect() : null; |
2000 rootView.changedUpdate(e, alloc, rootView.getViewFactory()); |
1995 rootView.changedUpdate(e, alloc, rootView.getViewFactory()); |
2001 rootViewNeedsLayout = false; |
|
2002 } |
1996 } |
2003 |
1997 |
2004 // --- LayoutManager2 methods -------------------------------- |
1998 // --- LayoutManager2 methods -------------------------------- |
2005 |
1999 |
2006 /** |
2000 /** |