Merge remote-tracking branch 'origin/master'

This commit is contained in:
anna
2012-03-14 13:12:49 +01:00
2 changed files with 0 additions and 165 deletions
@@ -1,76 +0,0 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package git4idea.history.browser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
import com.intellij.openapi.fileChooser.FileSystemTree;
import com.intellij.openapi.fileChooser.FileSystemTreeFactory;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.ScrollPaneFactory;
import javax.swing.*;
import java.awt.*;
public class GitLogTreeFileSelector extends DialogWrapper {
private final JPanel myPanel;
private final Project myProject;
private final VirtualFile myRoot;
private FileSystemTree myFileSystemTree;
public GitLogTreeFileSelector(final Project project, final VirtualFile root) {
super(project, true);
setTitle(root.getPath());
myProject = project;
myRoot = root;
myPanel = new JPanel(new BorderLayout());
myPanel.setMinimumSize(new Dimension(400, 500));
initUi();
init();
}
@Override
public JComponent getPreferredFocusedComponent() {
return myFileSystemTree.getTree();
}
@Override
protected String getDimensionServiceKey() {
return "git4idea.history.browser.GitLogTreeFileSelector";
}
private void initUi() {
final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createAllButJarContentsDescriptor();
descriptor.setRoot(myRoot);
myFileSystemTree = FileSystemTreeFactory.SERVICE.getInstance().createFileSystemTree(myProject, descriptor);
final JTree tree = myFileSystemTree.getTree();
tree.setCellRenderer(new GitLogTreeFileSelectorRenderer(myProject));
myFileSystemTree.select(myRoot, null);
myPanel.add(ScrollPaneFactory.createScrollPane(tree), BorderLayout.CENTER);
}
@Override
protected JComponent createCenterPanel() {
return myPanel;
}
public VirtualFile[] getSelectedFiles() {
return myFileSystemTree.getSelectedFiles();
}
}
@@ -1,89 +0,0 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package git4idea.history.browser;
import com.intellij.ide.util.treeView.NodeDescriptor;
import com.intellij.ide.util.treeView.NodeRenderer;
import com.intellij.openapi.fileChooser.FileElement;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.PlatformIcons;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import java.util.HashSet;
import java.util.Set;
public class GitLogTreeFileSelectorRenderer extends NodeRenderer {
private final Set<VirtualFile> myModules;
public GitLogTreeFileSelectorRenderer(final Project project) {
myModules = new HashSet<VirtualFile>();
final Module[] modules = ModuleManager.getInstance(project).getModules();
for (Module module : modules) {
myModules.add(module.getModuleFile());
}
}
@Override
public void customizeCellRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
super.customizeCellRenderer(tree, value, selected, expanded, leaf, row, hasFocus);
if (value instanceof DefaultMutableTreeNode) {
DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
Object userObject = node.getUserObject();
if (userObject instanceof NodeDescriptor) {
NodeDescriptor descriptor = (NodeDescriptor)userObject;
Object element = descriptor.getElement();
if (element instanceof FileElement) {
final FileElement fileElement = (FileElement)element;
final VirtualFile file = fileElement.getFile();
if (myModules.contains(file)) {
setIcon(expanded ? PlatformIcons.CONTENT_ROOT_ICON_OPEN : PlatformIcons.CONTENT_ROOT_ICON_CLOSED);
}
}
}
}
}
/*private static class MyModuleNodeDescriptor extends NodeDescriptor {
private final NodeDescriptor myProxiedDescriptor;
private MyModuleNodeDescriptor(final NodeDescriptor proxiedDescriptor) {
super(proxiedDescriptor.getProject(), proxiedDescriptor.getParentDescriptor());
myProxiedDescriptor = proxiedDescriptor;
// a hack
myName = proxiedDescriptor.toString();
myOpenIcon = PlatformIcons.CONTENT_ROOT_ICON_OPEN;
myClosedIcon = PlatformIcons.CONTENT_ROOT_ICON_CLOSED;
setChildrenSortingStamp(proxiedDescriptor.getChildrenSortingStamp());
setIndex(proxiedDescriptor.getIndex());
setUpdateCount(proxiedDescriptor.getUpdateCount());
setWasDeclaredAlwaysLeaf(proxiedDescriptor.isWasDeclaredAlwaysLeaf());
}
@Override
public Object getElement() {
return myProxiedDescriptor.getElement();
}
@Override
public boolean update() {
return myProxiedDescriptor.update();
}
}*/
}