Bug 100156 [IDE] RenameResourceAction should use IAdaptable for IResource lookuop
Consider the following setup: there is a tree viewer that contains TreeElementWrapper instances. TreeElementWrapper class is an IAdaptable and may sometimes adapt to IResource instance. When RenameResourceAction receives selectionChanged() it enables itself (since wrapper adapts to resource) but in runWithInlineEditor() method it queries raw selection instead of adapted resources list - thus CCE. java.lang.ClassCastException: com.xcom.TreeElementWrapper at org.eclipse.ui.actions.RenameResourceAction.runWithInlineEditor(RenameResourceAction.java:462) at org.eclipse.ui.actions.RenameResourceAction.run(RenameResourceAction.java:454) at org.eclipse.ui.actions.BaseSelectionListenerAction.runWithEvent(BaseSelectionListenerAction.java:167) at com.xcom.CompositeAction.runWithEvent(CompositeAction.java:26) at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:182) at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:108) at org.eclipse.core.commands.Command.execute(Command.java:311) at org.eclipse.core.commands.ParameterizedCommand.execute(ParameterizedCommand.java:396) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:452) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:722) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:766) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:543) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:486) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:110)
bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/RenameResourceAction.java
if (currentResource.isReadOnly())
            return MessageDialog.openQuestion(getShell(), CHECK_RENAME_TITLE,
                    MessageFormat.format(CHECK_RENAME_MESSAGE,
                            new Object[] { currentResource.getName() }));
        
        return true;
    }
    Composite createParent() {
        Tree tree = getTree();
        Composite result = new Composite(tree, SWT.NONE);
        TreeItem[] selectedItems = tree.getSelection();
        treeEditor.horizontalAlignment = SWT.LEFT;
        treeEditor.grabHorizontal = true;
        treeEditor.setEditor(result, selectedItems[0]);
        return result;
    }
    /**
     * On Mac the text widget already provides a border when it has focus, so there is no need to draw another one.
     * The value of returned by this method is usd to control the inset we apply to the text field bound's in order to get space for drawing a border.
     * A value of 1 means a one-pixel wide border around the text field. A negative value supresses the border.
     * However, in M9 the system property "org.eclipse.swt.internal.carbon.noFocusRing" has been introduced
     * as a temporary workaround for bug #28842. The existence of the property turns the native focus ring off
     * if the widget is contained in a main window (not dialog).
     * The check for the property should be removed after a final fix for #28842 has been provided.
     */
    private static int getCellEditorInset(Control c) {
        if ("carbon".equals(SWT.getPlatform())) { 
            if (System
                    .getProperty("org.eclipse.swt.internal.carbon.noFocusRing") == null || c.getShell().getParent() != null)