Package com.dci.intellij.dbn.execution.method.ui

Source Code of com.dci.intellij.dbn.execution.method.ui.ObjectHierarchyPanel2

package com.dci.intellij.dbn.execution.method.ui;

import com.dci.intellij.dbn.object.common.DBObject;
import com.dci.intellij.dbn.connection.ConnectionHandler;

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;

public class ObjectHierarchyPanel2 extends JPanel {
    private DBObject object;

    public ObjectHierarchyPanel2(DBObject object) {
        super();
        this.object = object;
        this.setLayout(new BorderLayout());
        JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
        ConnectionHandler connectionHandler = object.getConnectionHandler();
        JLabel connectionLabel = new JLabel(
                connectionHandler.getName(),
                connectionHandler.getIcon(),
                SwingConstants.LEFT);
        add(connectionLabel);
        add(panel, BorderLayout.SOUTH );

        List<DBObject> chain = new ArrayList<DBObject>();
        while (object != null) {
            chain.add(0, object);
            object = object.getParentObject();
        }

        for (int i=0; i<chain.size(); i++) {
            object = chain.get(i);
            if ( i > 0) panel.add(new JLabel(" > "));

            JLabel objectLabel = new JLabel(object.getName(), object.getIcon(), SwingConstants.LEFT);
            if (object == this.object) {
                Font font = objectLabel.getFont().deriveFont(Font.BOLD);
                objectLabel.setFont(font);
            }
            panel.add(objectLabel);
        }
    }
}
TOP

Related Classes of com.dci.intellij.dbn.execution.method.ui.ObjectHierarchyPanel2

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.