Пример #1
0
  public MainView(MainModel m) {

    model = m;

    /** ********* Begin: Initialize components **************** */

    // create menu bar
    menuBar = new JMenuBar();

    // create file menu
    fileMenu = new JMenu("File");
    loadConfigItem = new JMenuItem("Load Parameters...");
    loadConfigItem.setAccelerator(KeyStroke.getKeyStroke("ctrl L"));
    saveConfigItem = new JMenuItem("Save Parameters...");
    saveConfigItem.setAccelerator(KeyStroke.getKeyStroke("ctrl S"));
    saveGraphItem = new JMenuItem("Save Graph...");
    saveGraphItem.setAccelerator(KeyStroke.getKeyStroke("ctrl G"));
    preferencesItem = new JMenuItem("Preferences...");
    preferencesItem.setAccelerator(KeyStroke.getKeyStroke("ctrl P"));
    exitItem = new JMenuItem("Exit");
    exitItem.setAccelerator(KeyStroke.getKeyStroke("ctrl Q"));
    fileMenu.add(loadConfigItem);
    fileMenu.add(saveConfigItem);
    fileMenu.addSeparator();
    fileMenu.add(saveGraphItem);
    fileMenu.addSeparator();
    fileMenu.add(preferencesItem);
    fileMenu.addSeparator();
    fileMenu.add(exitItem);

    //		// create table menu
    Database db = model.populateTableList();
    if (db == null) {
      // TODO: do something
    } else {
      model.setDb(db);
      // TODO: do other stuff here
    }

    // create tools menu
    toolsMenu = new JMenu("Tools");
    runItem = new JMenuItem("Run Query");
    runItem.setAccelerator(KeyStroke.getKeyStroke("ctrl R"));
    advancedItem = new JMenuItem("Advanced Query");
    // TODO: add accelerator
    forceItem = new JMenuItem("Force Requery");
    forceItem.setAccelerator(KeyStroke.getKeyStroke("ctrl Y"));
    diffItem = new JMenuItem("Run Diff...");
    diffItem.setAccelerator(KeyStroke.getKeyStroke("ctrl I"));
    exportDataItem = new JMenuItem("Export Data...");
    exportDataItem.setAccelerator(KeyStroke.getKeyStroke("ctrl E"));
    displayDbs = new JMenuItem("Display Tables...");
    displayReplacementFields = new JMenuItem("Display Replacement Fields...");
    displayDefaultLabels = new JMenuItem("Display Default Labels...");
    toolsMenu.add(runItem);
    toolsMenu.add(advancedItem);
    toolsMenu.add(forceItem);
    toolsMenu.add(diffItem);
    // toolsMenu.add(preferencesItem);
    toolsMenu.add(exportDataItem);
    toolsMenu.addSeparator();
    toolsMenu.add(displayDbs);
    toolsMenu.add(displayReplacementFields);
    toolsMenu.add(displayDefaultLabels);

    // create help menu
    helpMenu = new JMenu("Help");
    describeTableItem = new JMenuItem("Describe Table");
    describeTableItem.setAccelerator(KeyStroke.getKeyStroke("ctrl T"));
    helpItem = new JMenuItem("Help Contents");
    helpItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            new HelpView();
          }
        });
    helpMenu.add(describeTableItem);
    helpMenu.add(helpItem);

    // add menus to menu bar
    menuBar.add(fileMenu);
    menuBar.add(toolsMenu);
    menuBar.add(helpMenu);

    // create main content panel
    allContent = new JPanel();

    // fetch info to populate parameter fields
    Vector<String> colNum = model.getTableColumnNamesNum();
    Vector<String> colAll = model.getTableColumnNamesAll();

    // setup history panel
    history = new HistoryView();

    // setup parameter panel
    params = new ParameterView(this, colNum, colAll);
    Dimension dim = params.getSavedWindowSize();
    if (dim != null) {
      preferred_height = (int) dim.getHeight();
      preferred_width = (int) dim.getWidth();
    }
    preferencesItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            new AdvancedOptions(params);
          }
        });

    // setup graph panel
    graph = new GraphView(this, params);

    JSplitPane splitPaneRight = new JSplitPane(JSplitPane.VERTICAL_SPLIT, graph, history);
    splitPaneRight.setOneTouchExpandable(true);
    splitPaneRight.setDividerLocation((int) (preferred_height * 0.7));
    graph.setMinimumSize(
        new Dimension((int) (0.5 * preferred_width), (int) (0.5 * preferred_height)));

    JSplitPane splitPaneLeft = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, params, splitPaneRight);
    splitPaneLeft.setOneTouchExpandable(true);
    splitPaneLeft.setDividerLocation(333);
    params.setMinimumSize(new Dimension((int) (.2 * preferred_width), (preferred_height)));

    /** ********* End: Initialize components **************** */

    /** ********* Start: Layout components **************** */
    allContent.setPreferredSize(new Dimension(preferred_width, preferred_height));

    // initialize layout
    GridBagLayout gridbag = new GridBagLayout();
    allContent.setLayout(gridbag);
    GridBagConstraints c = new GridBagConstraints();

    // layout parameter panel
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 1;
    allContent.add(splitPaneLeft, c);

    // set menu bar and add panel to the content pane
    setJMenuBar(menuBar);
    setContentPane(allContent);

    /** ********* End: Layout components **************** */
    setTitle(version);
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    pack();

    if (db == null) {
      appendToHistory("Please specify a database to use (Tools > Display Tables)\n");
    }

    gridbag = null;
    c = null;
    splitPaneRight = null;
    splitPaneLeft = null;
    colNum = null;
  }
Пример #2
0
 public void setComboFields(
     Vector<String> tableColumnNamesNum, Vector<String> tableColumnNamesAll) {
   params.setComboFields(tableColumnNamesNum, tableColumnNamesAll);
   params.setShouldLoadTopUsed(true);
 }
Пример #3
0
 public void setShouldLoadTopUsed(boolean b) {
   params.setShouldLoadTopUsed(true);
 }
Пример #4
0
 public void run() {
   params.hitRunButton();
 }
Пример #5
0
 public String getYMin() {
   return params.getYMin();
 }
Пример #6
0
 public String getYLabel() {
   return params.getYLabel();
 }
Пример #7
0
 public String getXMax() {
   return params.getXMax();
 }
Пример #8
0
 public String getGraphTitle() {
   return params.getGraphTitle();
 }