mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -33,7 +33,6 @@ import com.intellij.ui.CheckedTreeNode;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ui.ColumnInfo;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import com.intellij.util.ui.update.UiNotifyConnector;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -642,7 +641,6 @@ class TemplateListPanel extends JPanel {
|
||||
value = ((DefaultMutableTreeNode)value).getUserObject();
|
||||
|
||||
if (value instanceof TemplateImpl) {
|
||||
//getTextRenderer().setIcon(TEMPLATE_ICON);
|
||||
getTextRenderer().append (((TemplateImpl)value).getKey(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
String description = ((TemplateImpl)value).getDescription();
|
||||
if (description != null && description.length() > 0) {
|
||||
@@ -650,11 +648,9 @@ class TemplateListPanel extends JPanel {
|
||||
}
|
||||
}
|
||||
else if (value instanceof TemplateGroup) {
|
||||
//getTextRenderer().setIcon(TEMPLATE_GROUP_ICON);
|
||||
getTextRenderer().append (((TemplateGroup)value).getName(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}, myTreeRoot) {
|
||||
@Override
|
||||
|
||||
@@ -23,9 +23,6 @@ public abstract class CachingSimpleNode extends SimpleNode {
|
||||
|
||||
SimpleNode[] myChildren;
|
||||
|
||||
protected CachingSimpleNode() {
|
||||
}
|
||||
|
||||
protected CachingSimpleNode(SimpleNode aParent) {
|
||||
super(aParent);
|
||||
}
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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 com.intellij.ui.treeStructure;
|
||||
|
||||
import com.intellij.ide.util.treeView.NodeDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
|
||||
/**
|
||||
* @author kir
|
||||
*/
|
||||
public class FolderNode extends SimpleNode {
|
||||
|
||||
private final String myFQName;
|
||||
private final String myName;
|
||||
|
||||
public FolderNode(FolderNode aParent, String name) {
|
||||
super(aParent);
|
||||
myName = name;
|
||||
|
||||
final String parentFqn = aParent.myFQName;
|
||||
myFQName = "".equals(parentFqn) ? myName : parentFqn + '.' + myName;
|
||||
init();
|
||||
}
|
||||
|
||||
public FolderNode(Project aProject) {
|
||||
this(aProject, null);
|
||||
}
|
||||
|
||||
public FolderNode(Project aProject, NodeDescriptor parent) {
|
||||
super(aProject, parent);
|
||||
myName = "";
|
||||
myFQName = "";
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setPlainText(myName);
|
||||
setIcons(IconLoader.getIcon("/nodes/folder.png"), IconLoader.getIcon("/nodes/folderOpen.png"));
|
||||
}
|
||||
|
||||
public final SimpleNode[] getChildren() {
|
||||
throw new UnsupportedOperationException("Not Implemented in: " + getClass().getName());
|
||||
}
|
||||
|
||||
public Object[] getEqualityObjects() {
|
||||
return new Object[]{myFQName, getClass()};
|
||||
}
|
||||
|
||||
public String getFullyQualifiedName() {
|
||||
return myFQName;
|
||||
}
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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 com.intellij.ui.treeStructure;
|
||||
|
||||
import com.intellij.ide.util.treeView.NodeRenderer;
|
||||
import com.intellij.ui.components.panels.NonOpaquePanel;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.TreeCellEditor;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
/**
|
||||
* @author kir
|
||||
*/
|
||||
public abstract class InplaceEditor extends AbstractCellEditor implements TreeCellEditor, FocusListener {
|
||||
|
||||
protected JTree myTree;
|
||||
protected JTextField myTextField;
|
||||
protected JPanel myComponent;
|
||||
protected JLabel myIconLabel;
|
||||
protected int myIconTextGap;
|
||||
|
||||
public InplaceEditor() {
|
||||
myIconLabel = new JLabel();
|
||||
|
||||
myTextField = new JTextField() {
|
||||
public Dimension getPreferredSize() {
|
||||
Dimension prefSize = super.getPreferredSize();
|
||||
Dimension minSize = new Dimension(getColumnWidth() * 3, prefSize.height - 1);
|
||||
prefSize.width = prefSize.width + 15;
|
||||
return computeNotSmallerDimension(prefSize, minSize);
|
||||
}
|
||||
};
|
||||
|
||||
myTextField.addKeyListener(new KeyAdapter() {
|
||||
public void keyPressed(KeyEvent e) {
|
||||
switch (e.getKeyCode()) {
|
||||
case KeyEvent.VK_ENTER:
|
||||
case KeyEvent.VK_TAB:
|
||||
if (stopCellEditing()) {
|
||||
myTree.stopEditing();
|
||||
myTree.requestFocusInWindow();
|
||||
}
|
||||
break;
|
||||
case KeyEvent.VK_ESCAPE:
|
||||
if (myTree instanceof SimpleTree) {
|
||||
((SimpleTree)myTree).setEscapePressed();
|
||||
}
|
||||
|
||||
myTree.cancelEditing();
|
||||
myTree.requestFocusInWindow();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
myComponent = new NonOpaquePanel() {
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
Dimension size = getSize();
|
||||
size.width = myTextField.getPreferredSize().width + myIconLabel.getPreferredSize().width + myIconTextGap;
|
||||
myComponent.setSize(size);
|
||||
myTree.revalidate();
|
||||
}
|
||||
};
|
||||
myComponent.addFocusListener(new FocusAdapter() {
|
||||
public void focusGained(FocusEvent e) {
|
||||
myTextField.requestFocus();
|
||||
myTextField.selectAll();
|
||||
}
|
||||
|
||||
public void focusLost(FocusEvent e) {
|
||||
if (e.getOppositeComponent() != myTextField) {
|
||||
myTree.stopEditing();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Dimension computeNotSmallerDimension(final Dimension prefSize, final Dimension minSize) {
|
||||
int resultWidth = (prefSize.width < minSize.width) ? minSize.width : prefSize.width;
|
||||
int resultHeight = (prefSize.height < minSize.height) ? minSize.height : prefSize.height;
|
||||
|
||||
return new Dimension(resultWidth, resultHeight);
|
||||
}
|
||||
|
||||
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) {
|
||||
myTree = tree;
|
||||
|
||||
NodeRenderer renderer = ((NodeRenderer) tree.getCellRenderer().getTreeCellRendererComponent(tree, value, isSelected, expanded, leaf, row, false));
|
||||
rebuildUI(renderer);
|
||||
|
||||
myIconLabel.setIcon(renderer.getIcon());
|
||||
myTextField.setText(getText(((DefaultMutableTreeNode) value).getUserObject()));
|
||||
|
||||
myTextField.addFocusListener(this);
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
myTextField.selectAll();
|
||||
}
|
||||
});
|
||||
|
||||
return myComponent;
|
||||
}
|
||||
|
||||
protected abstract String getText(Object userObject);
|
||||
|
||||
public abstract boolean setTextIfValid(String text);
|
||||
|
||||
public JTextField getTextField() {
|
||||
return myTextField;
|
||||
}
|
||||
|
||||
public boolean stopCellEditing() {
|
||||
boolean stopped = setTextIfValid(myTextField.getText());
|
||||
if (stopped) {
|
||||
myTextField.removeFocusListener(this);
|
||||
return super.stopCellEditing();
|
||||
}
|
||||
return stopped;
|
||||
}
|
||||
|
||||
public void cancelCellEditing() {
|
||||
myTextField.removeFocusListener(this);
|
||||
super.cancelCellEditing();
|
||||
}
|
||||
|
||||
private void rebuildUI(NodeRenderer aRenderer) {
|
||||
myComponent.removeAll();
|
||||
myIconTextGap = aRenderer.getIconTextGap() - myTextField.getBorder().getBorderInsets(myTextField).left + 1;
|
||||
myComponent.setLayout(new BorderLayout(myIconTextGap, 0));
|
||||
myComponent.add(myTextField, BorderLayout.CENTER);
|
||||
myComponent.add(myIconLabel, BorderLayout.WEST);
|
||||
|
||||
Insets padding = aRenderer.getIpad();
|
||||
myComponent.setBorder(BorderFactory.createEmptyBorder(padding.top, padding.left, padding.bottom, padding.right));
|
||||
}
|
||||
|
||||
public void focusGained(FocusEvent e) {
|
||||
|
||||
}
|
||||
|
||||
public void focusLost(FocusEvent e) {
|
||||
if (myTree.isEditing() && !e.isTemporary()) {
|
||||
if (stopCellEditing()) {
|
||||
myTree.stopEditing();
|
||||
}
|
||||
else {
|
||||
myTree.cancelEditing();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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 com.intellij.ui.treeStructure;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
/**
|
||||
* @author kir
|
||||
*/
|
||||
public class RootFolder extends FolderNode {
|
||||
|
||||
public RootFolder(Project aProject) {
|
||||
super(aProject, null);
|
||||
}
|
||||
|
||||
public boolean isAutoExpandNode() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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 com.intellij.ui.treeStructure;
|
||||
|
||||
import com.intellij.ide.util.treeView.NodeDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class SimpleMutableNode extends CachingSimpleNode {
|
||||
|
||||
private final List<SimpleNode> myChildren = new ArrayList<SimpleNode>();
|
||||
|
||||
public SimpleMutableNode() {
|
||||
}
|
||||
|
||||
public SimpleMutableNode(SimpleNode aParent) {
|
||||
super(aParent);
|
||||
}
|
||||
|
||||
public SimpleMutableNode(Project aProject, NodeDescriptor aParentDescriptor) {
|
||||
super(aProject, aParentDescriptor);
|
||||
}
|
||||
|
||||
protected final SimpleNode[] buildChildren() {
|
||||
return myChildren.isEmpty() ? NO_CHILDREN : myChildren.toArray(new SimpleNode[myChildren.size()]);
|
||||
}
|
||||
|
||||
public final SimpleNode add(SimpleNode child) {
|
||||
myChildren.add(child);
|
||||
cleanUpCache();
|
||||
return child;
|
||||
}
|
||||
|
||||
|
||||
public final SimpleNode[] addAll(SimpleNode[] children) {
|
||||
for (SimpleNode aChildren : children) {
|
||||
add(aChildren);
|
||||
}
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
public final void remove(SimpleNode child) {
|
||||
myChildren.remove(child);
|
||||
cleanUpCache();
|
||||
}
|
||||
|
||||
public final void clear() {
|
||||
myChildren.clear();
|
||||
cleanUpCache();
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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 com.intellij.ui.treeStructure;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
public abstract class SimpleRoot extends SimpleNode {
|
||||
|
||||
public SimpleRoot(Project aProject) {
|
||||
super(aProject, null);
|
||||
}
|
||||
}
|
||||
-134
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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 com.intellij.ui.treeStructure.treetable;
|
||||
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
import javax.swing.event.TreeSelectionListener;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import javax.swing.table.TableColumn;
|
||||
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||
import javax.swing.tree.TreeCellRenderer;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
* Date: 02-Dec-2005
|
||||
*/
|
||||
public class StripedTreeTable extends TreeTable{
|
||||
private Color myStripeColor1;
|
||||
private Color myStripeColor2;
|
||||
|
||||
public StripedTreeTable(final TreeTableModel treeTableModel, Color stripeColor1) {
|
||||
this(treeTableModel, stripeColor1, Color.white);
|
||||
}
|
||||
|
||||
public StripedTreeTable(final TreeTableModel treeTableModel, Color stripeColor1, Color stripeColor2) {
|
||||
super(treeTableModel);
|
||||
myStripeColor1 = stripeColor1;
|
||||
myStripeColor2 = stripeColor2;
|
||||
setOpaque(false);
|
||||
getTree().setOpaque(false);
|
||||
getTree().getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
final int[] selectionRows = getTree().getSelectionRows();
|
||||
if (selectionRows != null && selectionRows.length > 0) {
|
||||
addColumnSelectionInterval(0, getColumnCount() - 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
for(int i = 0; i < getColumnCount(); i++){
|
||||
final TableColumn column = getColumn(getColumnName(i));
|
||||
final TableCellRenderer cellRenderer = getCellRenderer(i);
|
||||
if (cellRenderer != null) {
|
||||
column.setCellRenderer(new TableCellRenderer() {
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
|
||||
Component component = cellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
|
||||
drawStripe(isSelected, component, row, UIUtil.getTableSelectionBackground(), UIUtil.getTableBackground());
|
||||
return component;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
final TreeCellRenderer treeRenderer = getTreeRenderer();
|
||||
if (treeRenderer != null) {
|
||||
getTree().setCellRenderer(new DefaultTreeCellRenderer(){
|
||||
public Component getTreeCellRendererComponent(JTree tree,
|
||||
Object value,
|
||||
boolean selected,
|
||||
boolean expanded,
|
||||
boolean leaf,
|
||||
int row,
|
||||
boolean hasFocus) {
|
||||
final Component component = treeRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
|
||||
drawStripe(selected, component, row, UIUtil.getTreeSelectionBackground(), UIUtil.getTreeTextBackground());
|
||||
return component;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected TableCellRenderer getCellRenderer(int column){
|
||||
return null;
|
||||
}
|
||||
|
||||
protected TreeCellRenderer getTreeRenderer(){
|
||||
return null;
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
final Color color = g.getColor();
|
||||
for (int i = 0; i < getRowCount(); i++){
|
||||
if (getSelectedRow() == i){
|
||||
drawStripe(g, i, UIUtil.getTableSelectionBackground());
|
||||
} else if (i % 2 == 0){
|
||||
drawStripe(g, i, myStripeColor1);
|
||||
} else {
|
||||
drawStripe(g, i, myStripeColor2);
|
||||
}
|
||||
}
|
||||
g.setColor(color);
|
||||
super.paint(g);
|
||||
}
|
||||
|
||||
private void drawStripe(final Graphics g, final int i, final Color color) {
|
||||
g.setColor(color);
|
||||
final Rectangle cellRect = getCellRect(i, 0, true);
|
||||
g.fillRect(cellRect.x, cellRect.y, cellRect.width, cellRect.height);
|
||||
}
|
||||
|
||||
private void drawStripe(final boolean isSelected,
|
||||
final Component component,
|
||||
final int row,
|
||||
final Color selectionColor,
|
||||
final Color bgColor) {
|
||||
if (isSelected){
|
||||
component.setBackground(selectionColor);
|
||||
} else {
|
||||
if (row % 2 == 0) {
|
||||
component.setBackground(myStripeColor1);
|
||||
} else {
|
||||
component.setBackground(bgColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user