Package workbench

Source Code of workbench.Control

package workbench;

import java.awt.Component;
import java.awt.Container;

import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JTextArea;

import workbench.ui.DiagramPanel;
import workbench.ui.Gui;

public class Control {

  private final Gui gui;
 
  public Control(Gui gui) {
    this.gui = gui;
   
    final JTextArea input = (JTextArea)find("Input");
    final JMenu menu = (JMenu)find("FileMenu");
    final DiagramPanel diagram = ((DiagramPanel)find("Diagram"));
    final JTextArea kappa = ((JTextArea)find("Kappa"));
    final JComboBox selection = ((JComboBox)find("ParserSelection"));
   
    new ChangeManagement(input, diagram, kappa, selection);
    new FileManagement(menu, input, (JLabel)find("Filename"));
  }


  private Component find(String name){
    return findComponentByName(gui, name);
  }
 
  private Component findComponentByName(Component component, String name) {
    if (component.getName() == name)
      return component;
    if (component instanceof Container){
      Container c = (Container)component;
     
      for (Component i : c.getComponents()){
        Component r = findComponentByName(i, name);
        if (r != null)
          return r;
      }
    }
    return null;
  }
}
TOP

Related Classes of workbench.Control

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.