Package com.dci.intellij.dbn.browser.ui

Source Code of com.dci.intellij.dbn.browser.ui.ModuleListCellRenderer

package com.dci.intellij.dbn.browser.ui;

import com.dci.intellij.dbn.browser.model.BrowserTreeNode;
import com.dci.intellij.dbn.connection.ModuleConnectionBundle;
import com.dci.intellij.dbn.connection.ProjectConnectionBundle;
import com.intellij.ui.ColoredListCellRenderer;
import com.intellij.ui.SimpleTextAttributes;

import javax.swing.JList;

public class ModuleListCellRenderer extends ColoredListCellRenderer {

    protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
        BrowserTreeNode treeNode = (BrowserTreeNode) value;
        setIcon(treeNode.getIcon(0));

        String displayName;
        if (treeNode instanceof ModuleConnectionBundle) {
            ModuleConnectionBundle connectionManager = (ModuleConnectionBundle) treeNode;
            displayName = connectionManager.getModule().getName();
        } else if (treeNode instanceof ProjectConnectionBundle) {
            displayName = "PROJECT";
        } else {
            displayName = treeNode.getPresentableText();
        }

        append(displayName, SimpleTextAttributes.REGULAR_ATTRIBUTES);
    }
}
TOP

Related Classes of com.dci.intellij.dbn.browser.ui.ModuleListCellRenderer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.