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

net.alantea.swing.tree.TreeDialog Maven / Gradle / Ivy

package net.alantea.swing.tree;

import java.awt.Composite;
import java.awt.Frame;
import java.util.LinkedList;
import java.util.List;

import javax.swing.JDialog;

import net.alantea.liteprops.ChangeListener;

@SuppressWarnings("serial")
public abstract class TreeDialog extends JDialog
{
   Object treeRoot;
//   private JTree treeViewer;
   Object selected;
@SuppressWarnings("rawtypes")
//   private JButton okButton;
   List listeners = new LinkedList<>();

   protected TreeDialog(Frame parentShell, Object root)
   {
   }

   protected void setHeader()
   {
      // for subclasses
   }
   
   public void addListener(ChangeListener listener)
   {
      if (!listeners.contains(listener))
      {
         listeners.add(listener);
      }
   }
   
   public void removeListener(ChangeListener listener)
   {
      if (listeners.contains(listener))
      {
         listeners.remove(listener);
      }
   }

   @SuppressWarnings("unchecked")
   protected  void fireChanged(T oldValue, T newValue)
   {
      for (ChangeListener listener : listeners)
      {
         listener.changed(oldValue, newValue);
      }
   }

   public abstract ITreeContentProvider getTreeContentProvider();
      
   protected abstract boolean validateSelection(Object selection);
   
   public Object getSelected()
   {
      return selected;
   }

   protected void createButtonsForButtonBar (Composite parent)
   {
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy