All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.actelion.research.gui.dock.TreeLeaf Maven / Gradle / Ivy

There is a newer version: 2024.11.2
Show newest version
package com.actelion.research.gui.dock;

import com.actelion.research.gui.hidpi.HiDPIHelper;

import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;

public class TreeLeaf extends TreeElement implements ChangeListener {
	private JDockingPanel   mDockingPanel;
	private Dockable		mVisibleDockable;
	private String		  mStateTitle;
	private boolean		 mIsAutomatedStateChange;

	/**
	 * Constructor to create a leaf element with a visible component on the screen.
	 * @param dockable the first Dockable of this TreeLeaf
	 * @param dockingPanel
	 * @param isDragging
	 */
	public TreeLeaf(Dockable dockable, JDockingPanel dockingPanel, boolean isDragging) {
		mComponent = dockable;
		mVisibleDockable = dockable;
		mDockingPanel = dockingPanel;

		if (!isDragging)
			mDockingPanel.visibilityChanged(dockable, true);
		}
 
	public void stateChanged(ChangeEvent e) {
		if (mComponent instanceof JTabbedPane) {
			JTabbedPane tabbedPane = (JTabbedPane)e.getSource();
			if (mVisibleDockable != tabbedPane.getSelectedComponent()) {
				Dockable deselected = mVisibleDockable;
				mVisibleDockable = (Dockable)tabbedPane.getSelectedComponent();

				if (!mIsAutomatedStateChange) {
					mDockingPanel.visibilityChanged(deselected, false);
					mDockingPanel.visibilityChanged(mVisibleDockable, true);
					mDockingPanel.fireDockableSelected(mVisibleDockable);
					}

				mDockingPanel.selectDockable(mVisibleDockable);
				}
			}
		// if after removal of second last tab component the JTabbedPane was removed
		else if (mComponent instanceof Dockable) {
			Dockable deselected = mVisibleDockable;
			mVisibleDockable = (Dockable)mComponent;

			if (!mIsAutomatedStateChange) {
				mDockingPanel.visibilityChanged(deselected, false);
				mDockingPanel.visibilityChanged(mVisibleDockable, true);
				}
			mDockingPanel.selectDockable(mVisibleDockable);
			}
		}

	public boolean isSelected() {
		if (mComponent instanceof JTabbedPane) {
			JTabbedPane tabbedPane = (JTabbedPane)mComponent;
			for (int i=0; i stateInfoList, String firstDockableState) {
		if (mStateTitle == null) {
			if (mComponent instanceof JTabbedPane) {
				JTabbedPane tabbedPane = (JTabbedPane)mComponent;
				for (int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy