drools-eclipse/org.guvnor.tools/src/org/guvnor/tools/actions/ShowHistoryAction.java
public void selectionChanged(IAction action, ISelection selection) {
        // Reset state to default
        selectedFile = null;
        selectedNode = null;
        props = null;
        action.setEnabled(false);

        if (!(selection instanceof IStructuredSelection)) {
            return;
        }

        IStructuredSelection sel = (IStructuredSelection)selection;
        if (sel.size() != 1) {
            return;
        }

        if (sel.getFirstElement() instanceof IFile) {
            try {
                props = GuvnorMetadataUtils.getGuvnorMetadata((IFile)sel.getFirstElement());
                if (props != null) {
                    selectedFile = (IFile)sel.getFirstElement();
                    action.setEnabled(true);
                }
            } catch (Exception e) {
                Activator.getDefault().writeLog(IStatus.ERROR, e.getMessage(), e);
            }
        }
        if (sel.getFirstElement() instanceof TreeObject) {
            if (((TreeObject)sel.getFirstElement()).getNodeType() == TreeObject.Type.RESOURCE) {
                selectedNode = (TreeObject)sel.getFirstElement();
                action.setEnabled(true);
            }
        }
    }
public void selectionChanged(IAction action, ISelection selection) {
        // Reset state to default
        selectedFile = null;
        selectedNode = null;
        props = null;
        action.setEnabled(false);

        if (!(selection instanceof IStructuredSelection)) {
            return;
        }

        IStructuredSelection sel = (IStructuredSelection)selection;
        if (sel.size() != 1) {
            return;
        }

        if (sel.getFirstElement() instanceof IFile) {
            try {
                props = GuvnorMetadataUtils.getGuvnorMetadata((IFile)sel.getFirstElement());
                if (props != null) {
                    selectedFile = (IFile)sel.getFirstElement();
                    action.setEnabled(true);
                }
            } catch (Exception e) {
                Activator.getDefault().writeLog(IStatus.ERROR, e.getMessage(), e);
            }
        }
        if (sel.getFirstElement() instanceof TreeObject) {
            if (((TreeObject)sel.getFirstElement()).getNodeType() == TreeObject.Type.RESOURCE) {
                selectedNode = (TreeObject)sel.getFirstElement();
                action.setEnabled(true);
            }
        }
    }
/*
(non-Javadoc)
@see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)