public ListButtonSkin() { listView = new ListView(); listViewPopup = new Window(); listViewPopup.getComponentMouseButtonListeners().add(listViewPopupMouseButtonListener); listViewPopup.getComponentKeyListeners().add(listViewPopupKeyListener); listViewPopup.getWindowStateListeners().add(listViewPopupWindowStateListener); }
@Override public boolean mouseDown(Component component, Mouse.Button button, int x, int y) { boolean consumed = super.mouseDown(component, button, x, y); pressed = true; repaintComponent(); if (calendarPopup.isOpen()) { calendarPopup.close(); } else { calendarPopup.open(component.getWindow()); } return consumed; }
@Override public void layout() { Display display = (Display)getComponent(); // Set all components to their preferred sizes for (Component component : display) { Window window = (Window)component; if (window.isVisible()) { if (window.isMaximized()) { window.setSize(display.getSize()); } else { Dimensions preferredSize = window.getPreferredSize(); if (window.getWidth() != preferredSize.width || window.getHeight() != preferredSize.height) { window.setSize(preferredSize.width, preferredSize.height); } } } } } }
/** * Requests that this window become the active window. * * @return * <tt>true</tt> if the window became active; <tt>false</tt>, otherwise. */ public boolean requestActive() { if (isOpen() && isVisible() && isEnabled()) { setActiveWindow(this); } return isActive(); }
/** * Opens the window. * * @param ownerArgument * The window's owner. The window is opened on the owner's display. */ public final void open(Window ownerArgument) { if (ownerArgument == null) { throw new IllegalArgumentException(); } open(ownerArgument.getDisplay(), ownerArgument); }
@Override public void setEnabled(boolean enabled) { super.setEnabled(enabled); if (!enabled && isActive()) { clearActive(); } }
/** * Moves the window to the bottom of the window stack. If the window is * active, the active window will be cleared. If the window is the focus * host, the focus will be cleared. */ public void moveToBack() { if (!isOpen()) { throw new IllegalStateException("Window is not open."); } if (isActive()) { clearActive(); } if (containsFocus()) { clearFocus(); } // Ensure that the window and all of its owning ancestors are moved // to the back Display display = getDisplay(); int i = display.indexOf(this); if (i > 0) { display.move(i, 0); } if (owner != null) { owner.moveToBack(); } }
if (!isOpen()) { throw new IllegalStateException("Window is not open."); Display display = getDisplay(); int top = display.getLength() - 1; if (isShowing() && isEnabled() && focusDescendant != null) { focusDescendant.requestFocus(); if (ownedWindow.isOpen()) { ownedWindowIndexes.add(display.indexOf(ownedWindow)); ownedWindow.moveToFront();
/** * Opens the window. * * @param display */ public final void open(Display display) { open(display, null); }
@Override public boolean shutdown(boolean optional) { if (window != null) { window.close(); } return false; }
@Override public void setVisible(boolean visible) { if (visible && owner != null && !owner.isVisible()) { throw new IllegalStateException("Owner is not visible."); } super.setVisible(visible); if (visible && isActive()) { clearActive(); } for (Window ownedWindow : ownedWindows) { ownedWindow.setVisible(visible); } }
public void close(boolean resultArgument) { if (!isClosed()) { closing = true; Vote vote = sheetStateListeners.previewSheetClose(this, resultArgument); if (vote == Vote.APPROVE) { Window owner = getOwner(); super.close(); closing = super.isClosing(); if (isClosed()) { this.result = resultArgument; // Move the owner to the front if (owner.isOpen()) { owner.moveToFront(); } // Notify listeners sheetStateListeners.sheetClosed(this); if (sheetCloseListener != null) { sheetCloseListener.sheetClosed(this); sheetCloseListener = null; } } } else { if (vote == Vote.DENY) { closing = false; } sheetStateListeners.sheetCloseVetoed(this, vote); } } }
@Override public boolean mouseDown(Container container, Mouse.Button button, int x, int y) { Display display = (Display)container; Component descendant = display.getDescendantAt(x, y); if (!listViewPopup.isAncestor(descendant) && descendant != ListButtonSkin.this.getComponent()) { listViewPopup.close(); } return false; }
@Override public void focusedChanged(Component component, Component obverseComponent) { super.focusedChanged(component, obverseComponent); repaintComponent(); // Close the popup if focus was transferred to a component whose // window is not the popup if (!component.isFocused()) { pressed = false; if (!calendarPopup.containsFocus()) { calendarPopup.close(); } } }
public void close(boolean immediate) { if (!isClosed()) { closing = true; Vote vote = menuPopupStateListeners.previewMenuPopupClose(this, immediate); if (vote == Vote.APPROVE) { super.close(); closing = super.isClosing(); if (isClosed()) { menuPopupStateListeners.menuPopupClosed(this); } } else if (vote == Vote.DENY){ closing = false; menuPopupStateListeners.menuPopupCloseVetoed(this, vote); } } if (isClosed()) { contextMenu = false; } }
@Override public void install(Component component) { super.install(component); Window window = (Window)component; window.getWindowListeners().add(this); window.getWindowStateListeners().add(this); window.setFocusTraversalPolicy(new WindowFocusTraversalPolicy()); }
int y = 0; Dimensions size = getSize(); setLocation(x, y);
@Override protected void doDetach(@Nonnull Window window) { requireNonNull(window, ERROR_WINDOW_NULL); window.getWindowStateListeners().remove(windowStateHelper); }
@Override public Vote previewWindowClose(Window window) { if (window.containsFocus()) { getComponent().requestFocus(); } return Vote.APPROVE; }