1*9a1eeea9SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9a1eeea9SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9a1eeea9SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9a1eeea9SAndrew Rist * distributed with this work for additional information 6*9a1eeea9SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9a1eeea9SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9a1eeea9SAndrew Rist * "License"); you may not use this file except in compliance 9*9a1eeea9SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9a1eeea9SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9a1eeea9SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9a1eeea9SAndrew Rist * software distributed under the License is distributed on an 15*9a1eeea9SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9a1eeea9SAndrew Rist * KIND, either express or implied. See the License for the 17*9a1eeea9SAndrew Rist * specific language governing permissions and limitations 18*9a1eeea9SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9a1eeea9SAndrew Rist *************************************************************/ 21*9a1eeea9SAndrew Rist 22*9a1eeea9SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir package org.openoffice.setup.PanelHelper; 25cdf0e10cSrcweir 26cdf0e10cSrcweir import org.openoffice.setup.SetupData.DisplayPackageDescription; 27cdf0e10cSrcweir import org.openoffice.setup.SetupData.PackageDescription; 28cdf0e10cSrcweir import org.openoffice.setup.ResourceManager; 29cdf0e10cSrcweir import java.awt.Component; 30cdf0e10cSrcweir import javax.swing.ImageIcon; 31cdf0e10cSrcweir import javax.swing.JTree; 32cdf0e10cSrcweir import javax.swing.tree.DefaultMutableTreeNode; 33cdf0e10cSrcweir import javax.swing.tree.DefaultTreeCellRenderer; 34cdf0e10cSrcweir 35cdf0e10cSrcweir public class TreeNodeRenderer extends DefaultTreeCellRenderer { 36cdf0e10cSrcweir 37cdf0e10cSrcweir ImageIcon InstallIcon; 38cdf0e10cSrcweir ImageIcon InstalledIcon; 39cdf0e10cSrcweir ImageIcon DontInstallIcon; 40cdf0e10cSrcweir ImageIcon DontKnowIcon; 41cdf0e10cSrcweir ImageIcon RemoveIcon; 42cdf0e10cSrcweir TreeNodeRenderer()43cdf0e10cSrcweir public TreeNodeRenderer() { 44cdf0e10cSrcweir InstallIcon = ResourceManager.getIcon("Icon_Install"); 45cdf0e10cSrcweir InstalledIcon = ResourceManager.getIcon("Icon_Installed"); 46cdf0e10cSrcweir DontInstallIcon = ResourceManager.getIcon("Icon_DontInstall"); 47cdf0e10cSrcweir DontKnowIcon = ResourceManager.getIcon("Icon_DontKnow"); 48cdf0e10cSrcweir RemoveIcon = ResourceManager.getIcon("Icon_Remove"); 49cdf0e10cSrcweir } 50cdf0e10cSrcweir getTreeCellRendererComponent( JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus)51cdf0e10cSrcweir public Component getTreeCellRendererComponent( 52cdf0e10cSrcweir JTree tree, Object value, boolean sel, boolean expanded, 53cdf0e10cSrcweir boolean leaf, int row, boolean hasFocus) { 54cdf0e10cSrcweir 55cdf0e10cSrcweir super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); 56cdf0e10cSrcweir 57cdf0e10cSrcweir DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; 58cdf0e10cSrcweir Object nodeObject = node.getUserObject(); 59cdf0e10cSrcweir 60cdf0e10cSrcweir if (DisplayPackageDescription.is(nodeObject)) { 61cdf0e10cSrcweir DisplayPackageDescription nodeInfo = (DisplayPackageDescription)nodeObject; 62cdf0e10cSrcweir 63cdf0e10cSrcweir switch (nodeInfo.getState()) { 64cdf0e10cSrcweir case PackageDescription.INSTALL: setIcon(InstallIcon); break; 65cdf0e10cSrcweir case PackageDescription.DONT_REMOVE: setIcon(InstallIcon); break; 66cdf0e10cSrcweir case PackageDescription.IGNORE: setIcon(InstalledIcon); break; 67cdf0e10cSrcweir case PackageDescription.INSTALL_SOME: setIcon(DontKnowIcon); break; 68cdf0e10cSrcweir case PackageDescription.REMOVE_SOME: setIcon(DontKnowIcon); break; 69cdf0e10cSrcweir case PackageDescription.DONT_INSTALL: setIcon(DontInstallIcon); break; 70cdf0e10cSrcweir case PackageDescription.REMOVE: setIcon(RemoveIcon); break; 71cdf0e10cSrcweir default: setIcon(InstalledIcon); break; 72cdf0e10cSrcweir } 73cdf0e10cSrcweir } 74cdf0e10cSrcweir 75cdf0e10cSrcweir if (sel) { 76cdf0e10cSrcweir setBackground(super.getBackgroundSelectionColor()); 77cdf0e10cSrcweir setForeground(textSelectionColor); 78cdf0e10cSrcweir } else { 79cdf0e10cSrcweir setBackground(super.getBackgroundNonSelectionColor()); 80cdf0e10cSrcweir setForeground(textSelectionColor); 81cdf0e10cSrcweir } 82cdf0e10cSrcweir 83cdf0e10cSrcweir return this; 84cdf0e10cSrcweir } 85cdf0e10cSrcweir } 86