/** * Initializes this popup menu. */ private void init() { super.removeAll(); scrollPane = new JScrollPane(); scrollPane.setViewportView(menuPanel); scrollPane.setBorder(null); int minWidth = resources.getInteger("ScrollPane.minWidth"); int minHeight = resources.getInteger("ScrollPane.minHeight"); int maxWidth = resources.getInteger("ScrollPane.maxWidth"); int maxHeight = resources.getInteger("ScrollPane.maxHeight"); scrollPane.setMinimumSize(new Dimension(minWidth, minHeight)); scrollPane.setMaximumSize(new Dimension(maxWidth, maxHeight)); scrollPane.setHorizontalScrollBarPolicy (ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); add(scrollPane, BorderLayout.CENTER); addFooter(new DefaultScrollablePopupMenuItem(this, "")); }
/** * Removes the item from this component. * * @param menuItem * the item to remove */ public void remove(ScrollablePopupMenuItem menuItem, int oldSize, int newSize) { menuPanel.remove((Component) menuItem); if (newSize == 0) { this.setEnabled(false); } }
/** * Adds the ScrollablePopupMenuItem to the item list and to the parent. * Fires the event 'itemsWereAdded' on the parent pop up menu * * @param item * The item to add * @param details * The details for the 'itemsWereAdded' event */ protected void addItem(ScrollablePopupMenuItem item, String details) { int oldSize = items.size(); items.add(0, item); parent.add(item, 0, oldSize, items.size()); parent.fireItemsWereAdded (new ScrollablePopupMenuEvent(parent, ScrollablePopupMenuEvent.ITEMS_ADDED, 1, details)); }
popupMenu = new ScrollablePopupMenu(this); popupMenu.setEnabled(false); popupMenu.addPropertyChangeListener ("enabled", new PropertyChangeListener() { popupMenu.addListener (new ScrollablePopupMenuAdapter() {
popupMenu = new ScrollablePopupMenu(this); popupMenu.setEnabled(false); popupMenu.addPropertyChangeListener ("enabled", new PropertyChangeListener() { popupMenu.addListener (new ScrollablePopupMenuAdapter() {
/** * Invoked when item selection changes. */ public void selectionChanged(ScrollablePopupMenuItem targetItem, boolean wasSelected) { Component[] comps = menuPanel.getComponents(); int n = comps.length; // Deselect all if something was selected if (!wasSelected) { for (int i = n - 1; i >= 0; i--) { ScrollablePopupMenuItem item = (ScrollablePopupMenuItem) comps[i]; item.setSelected(wasSelected); } } else { for (int i = 0; i < n; i++) { ScrollablePopupMenuItem item = (ScrollablePopupMenuItem) comps[i]; if (item == targetItem) { break; } item.setSelected(true); } } footer.setText(model.getFooterText() + getSelectedItemsCount()); repaint(); }
/** * Invoked when item selection changes. */ public void selectionChanged(ScrollablePopupMenuItem targetItem, boolean wasSelected) { Component[] comps = menuPanel.getComponents(); int n = comps.length; // Deselect all if something was selected if (!wasSelected) { for (int i = n - 1; i >= 0; i--) { ScrollablePopupMenuItem item = (ScrollablePopupMenuItem) comps[i]; item.setSelected(wasSelected); } } else { for (Component comp : comps) { ScrollablePopupMenuItem item = (ScrollablePopupMenuItem) comp; if (item == targetItem) { break; } item.setSelected(true); } } footer.setText(model.getFooterText() + getSelectedItemsCount()); repaint(); }
/** * Removes the ScrollablePopupMenuItem from the item list and from the * parent. Fires the event 'itemsWereRemoved' on the parent pop up menu * * @param item * The item to remove * @param details * The details for the 'itemsWereRemoved' event */ protected void removeItem(ScrollablePopupMenuItem item, String details) { int oldSize = items.size(); items.remove(item); parent.remove(item, oldSize, items.size()); parent.fireItemsWereRemoved (new ScrollablePopupMenuEvent(parent, ScrollablePopupMenuEvent.ITEMS_REMOVED, 1, details)); }
/** * Removes the ScrollablePopupMenuItem from the item list and from the * parent. Fires the event 'itemsWereRemoved' on the parent pop up menu * * @param item * The item to remove * @param details * The details for the 'itemsWereRemoved' event */ protected void removeItem(ScrollablePopupMenuItem item, String details) { int oldSize = items.size(); items.remove(item); parent.remove(item, oldSize, items.size()); parent.fireItemsWereRemoved (new ScrollablePopupMenuEvent(parent, ScrollablePopupMenuEvent.ITEMS_REMOVED, 1, details)); }
/** * Adds the ScrollablePopupMenuItem to the item list and to the parent. * Fires the event 'itemsWereAdded' on the parent pop up menu * * @param item * The item to add * @param details * The details for the 'itemsWereAdded' event */ protected void addItem(ScrollablePopupMenuItem item, String details) { int oldSize = items.size(); items.add(0, item); parent.add(item, 0, oldSize, items.size()); parent.fireItemsWereAdded (new ScrollablePopupMenuEvent(parent, ScrollablePopupMenuEvent.ITEMS_ADDED, 1, details)); }
/** * Initializes this popup menu. */ private void init() { super.removeAll(); scrollPane = new JScrollPane(); scrollPane.setViewportView(menuPanel); scrollPane.setBorder(null); int minWidth = resources.getInteger("ScrollPane.minWidth"); int minHeight = resources.getInteger("ScrollPane.minHeight"); int maxWidth = resources.getInteger("ScrollPane.maxWidth"); int maxHeight = resources.getInteger("ScrollPane.maxHeight"); scrollPane.setMinimumSize(new Dimension(minWidth, minHeight)); scrollPane.setMaximumSize(new Dimension(maxWidth, maxHeight)); scrollPane.setHorizontalScrollBarPolicy (ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); add(scrollPane, BorderLayout.CENTER); addFooter(new DefaultScrollablePopupMenuItem(this, "")); }
public Dimension getPreferredSize() { return new Dimension(getPreferredWidth(), getPreferredHeight()); }
public Dimension getPreferredSize() { return new Dimension(getPreferredWidth(), getPreferredHeight()); }
/** * Adds the item to this component at the specified location. * * @param menuItem * the item to add */ public void add(ScrollablePopupMenuItem menuItem, int index, int oldSize, int newSize) { menuPanel.add((Component) menuItem, index); if (oldSize == 0) { this.setEnabled(true); } }
/** * Removes the item from this component. * * @param menuItem * the item to remove */ public void remove(ScrollablePopupMenuItem menuItem, int oldSize, int newSize) { menuPanel.remove((Component) menuItem); if (newSize == 0) { this.setEnabled(false); } }
/** * Adds the item to this component at the specified location. * * @param menuItem * the item to add */ public void add(ScrollablePopupMenuItem menuItem, int index, int oldSize, int newSize) { menuPanel.add((Component) menuItem, index); if (oldSize == 0) { this.setEnabled(true); } }
/** * Adds the footer item to this pop up menu. */ private void addFooter(ScrollablePopupMenuItem footer) { this.footer = footer; this.footer.setEnabled(false); add((Component)this.footer, BorderLayout.SOUTH); }
public void processItemClicked() { historyBrowserInterface.getHistoryBrowser().compoundRedo (parent.getSelectedItemsCount()); } }
public void doCompoundEdit(HistoryBrowserEvent event) { if (!parent.isEnabled()) { parent.setEnabled(true); } }
public void doCompoundEdit(HistoryBrowserEvent event) { if (parent.isEnabled()) { parent.setEnabled(false); } }