diff -r aa973ed4ecc4 o.n.swing.outline/src/org/netbeans/swing/outline/Outline.java --- a/o.n.swing.outline/src/org/netbeans/swing/outline/Outline.java Sat Sep 11 13:04:49 2010 +0200 +++ b/o.n.swing.outline/src/org/netbeans/swing/outline/Outline.java Mon Sep 13 18:02:12 2010 +0200 @@ -69,6 +69,8 @@ import javax.swing.Timer; import javax.swing.UIManager; import javax.swing.border.Border; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; import javax.swing.event.TableModelEvent; import javax.swing.event.TreeModelEvent; import javax.swing.table.TableCellEditor; @@ -206,6 +208,9 @@ private ComponentListener componentListener = null; private boolean selectionDisabled = false; private boolean rowHeightIsSet = false; + private int selectedRow = -1; + private int[] lastEditPosition; + /** Creates a new instance of Outline */ public Outline() { init(); @@ -225,6 +230,16 @@ am.put("selectNextColumn", new ExpandAction(true, a)); //NOI18N a = am.get("selectPreviousColumn"); //NOI18N am.put("selectPreviousColumn", new ExpandAction(false, a)); //NOI18N + getSelectionModel().addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent e) { + if (getSelectedRowCount() == 1) { + selectedRow = getSelectedRow(); + } else { + selectedRow = -1; + } + } + }); } /** Always returns the default renderer for Object.class for the tree column */ @@ -611,7 +626,7 @@ } boolean res = false; - if (!isTreeColumn || e instanceof MouseEvent && ((MouseEvent)e).getClickCount() > 1) { + if (!isTreeColumn || e instanceof MouseEvent && isEditEvent(row, column, (MouseEvent) e)) { res = super.editCellAt(row, column, e); } if( res && isTreeColumn && null != getEditorComponent() ) { @@ -624,6 +639,36 @@ return res; } + private boolean isEditEvent(int row, int column, MouseEvent me) { + if (me.getClickCount() > 1) { + return true; + } + boolean noModifiers = me.getModifiersEx() == me.BUTTON1_DOWN_MASK; + if (lastEditPosition != null && selectedRow == row && noModifiers && + lastEditPosition[0] == row && lastEditPosition[1] == column) { + + int handleWidth = DefaultOutlineCellRenderer.getExpansionHandleWidth(); + Insets ins = getInsets(); + TreePath path = getLayoutCache().getPathForRow(convertRowIndexToModel(row)); + int nd = path.getPathCount() - (isRootVisible() ? 1 : 2); + if (nd < 0) { + nd = 0; + } + int handleStart = ins.left + (nd * DefaultOutlineCellRenderer.getNestingWidth()); + int handleEnd = ins.left + handleStart + handleWidth; + // Translate 'x' to position of column if non-0: + int columnStart = getCellRect(row, column, false).x; + handleStart += columnStart; + handleEnd += columnStart; + if (me.getX() >= handleEnd) { + lastEditPosition = null; + return true; + } + } + lastEditPosition = new int[] { row, column }; + return false; + } + private boolean checkAt(int row, int column, MouseEvent me) { RenderDataProvider render = getRenderDataProvider(); TableCellRenderer tcr = getDefaultRenderer(Object.class); diff -r aa973ed4ecc4 openide.explorer/apichanges.xml --- a/openide.explorer/apichanges.xml Sat Sep 11 13:04:49 2010 +0200 +++ b/openide.explorer/apichanges.xml Mon Sep 13 18:02:12 2010 +0200 @@ -50,6 +50,20 @@ Explorer API + + + It's possible to define whether the default action is allowed or not in OutlineView. + + + + + + Methods setDefaultActionAllowed() and isDefaultActionAllowed() + added to OutlineView to control invocation of the default action. + + + + OutlineView can provide horizontal scroll bar in the tree column. diff -r aa973ed4ecc4 openide.explorer/manifest.mf --- a/openide.explorer/manifest.mf Sat Sep 11 13:04:49 2010 +0200 +++ b/openide.explorer/manifest.mf Mon Sep 13 18:02:12 2010 +0200 @@ -2,5 +2,5 @@ OpenIDE-Module: org.openide.explorer OpenIDE-Module-Localizing-Bundle: org/openide/explorer/Bundle.properties AutoUpdate-Essential-Module: true -OpenIDE-Module-Specification-Version: 6.30 +OpenIDE-Module-Specification-Version: 6.31 diff -r aa973ed4ecc4 openide.explorer/src/org/openide/explorer/view/OutlineView.java --- a/openide.explorer/src/org/openide/explorer/view/OutlineView.java Sat Sep 11 13:04:49 2010 +0200 +++ b/openide.explorer/src/org/openide/explorer/view/OutlineView.java Mon Sep 13 18:02:12 2010 +0200 @@ -573,6 +573,27 @@ } /** + * Enable/disable double click to invoke default action. + * If the default action is not enabled, double click expand/collapse node. + * @param defaultActionAllowed Provide true to enable + * @see {@link #isDefaultActionAllowed()} + * @since 6.31 + */ + public void setDefaultActionAllowed(boolean defaultActionAllowed) { + outline.setDefaultActionAllowed(defaultActionAllowed); + } + + /** + * Tells if double click invokes default action. + * @return true if the default action is invoked, or false when it's not. + * @see {@link #setDefaultActionAllowed(boolean)} + * @since 6.31 + */ + public boolean isDefaultActionAllowed() { + return outline.isDefaultActionAllowed(); + } + + /** * Set the tree column as sortable * @param treeSortable true to make the tree column sortable, * false otherwise. The tree column is sortable by default. @@ -1187,6 +1208,7 @@ private int treePositionX = 0; private int[] rowWidths; private RequestProcessor.Task changeTask; + private boolean defaultActionAllowed = true; //private int maxRowWidth; public OutlineViewOutline(final OutlineModel mdl, PropertiesRowModel rowModel) { @@ -1296,6 +1318,14 @@ return width; } + void setDefaultActionAllowed(boolean defaultActionAllowed) { + this.defaultActionAllowed = defaultActionAllowed; + } + + boolean isDefaultActionAllowed() { + return defaultActionAllowed = false; + } + /** Translate the tree column renderer */ @Override public TableCellRenderer getCellRenderer(int row, int column) { @@ -1331,7 +1361,7 @@ // Default action. Node node = Visualizer.findNode (o); if (node != null) { - if (node.isLeaf () && !node.canRename()) { + if (defaultActionAllowed) { Action a = TreeView.takeAction (node.getPreferredAction (), node); if (a != null) {