Exemple #1
0
  protected void showView() {
    boolean done = false;

    synchronized (okToProc) {
      if (okToProc.get()) {
        if (frame != null) {
          generateViewImage(viewList.get(viewInx));
          frame.dispose();
        }

        viewInx++;

        ViewIFace view = viewList.get(viewInx);
        System.out.println(view.getName());

        if (!view.getViewSetName().equals("Editor")) // $NON-NLS-1$
        {
          Object data = null;
          try {
            ViewDefIFace viewDef = view.getAltViews().get(0).getViewDef();
            if (!(viewDef.getDataGettable()
                instanceof edu.ku.brc.af.ui.forms.DataGetterForHashMap)) {
              Class<?> dataCls = Class.forName(viewDef.getClassName());
              if (dataCls != null) {
                System.err.println(dataCls);
                data = dataCls.newInstance();
                if (data instanceof FormDataObjIFace) {
                  ((FormDataObjIFace) data).initialize();
                }
              }
            }
          } catch (Exception ex) {
          }

          if (data instanceof Discipline) {
            ((Discipline) data).setType("fish");
          }
          FormPane formPane =
              new FormPane(
                  view.getName(),
                  null,
                  null,
                  view.getName(),
                  "edit",
                  data,
                  MultiView.IS_NEW_OBJECT | MultiView.HIDE_SAVE_BTN,
                  true); //$NON-NLS-1$
          frame = new JFrame();
          frame.setFocusable(false);
          frame.setContentPane(formPane);
          frame.setSize(1024, 768);
          frame.setVisible(true);

          frame.setLocation(0, 0);

          Dimension size = frame.getContentPane().getPreferredSize();
          size.height += 40;
          size.width += 30;
          frame.setSize(size);

          String str = String.format("%d of %d", viewInx + 1, viewList.size());
          System.out.println(str); // $NON-NLS-1$
          getStatusBar().setText(str); // $NON-NLS-1$

        } else if (frame != null) {
          frame.setVisible(false);
          frame.dispose();
          frame = null;
        }

        if (viewInx < viewList.size() - 1) {
          SwingUtilities.invokeLater(
              new Runnable() {
                @Override
                public void run() {
                  try {
                    Thread.sleep(500);
                  } catch (Exception ex) {
                    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                    edu.ku.brc.exceptions.ExceptionTracker.getInstance()
                        .capture(FormDisplayer.class, ex);
                  }
                  showView();
                }
              });
        } else {
          done = true;
        }
      } else {
        done = true;
      }
    }

    if (done) {
      if (cancelDlg != null) cancelDlg.setVisible(false);
      if (frame != null) {
        frame.setVisible(false);
        frame.dispose();
      }

      createIndexFile();

      getStatusBar().setText("Done"); // $NON-NLS-1$
    }
  }
  /* (non-Javadoc)
   * @see edu.ku.brc.ui.CustomDialog#createUI()
   */
  @Override
  public void createUI() {
    super.createUI();

    CellConstraints cc = new CellConstraints();

    // table info
    PanelBuilder tblInfoPB =
        new PanelBuilder(new FormLayout("p,p:g", "p") /*, new FormDebugPanel()*/);
    JLabel tableTitleLbl =
        createI18NFormLabel(
            "FmtListEditorBase." + (baseInfo instanceof DBTableInfo ? "TABLE" : "FIELD"));
    JLabel tableTitleValueLbl = createLabel(baseInfo.getTitle());
    tableTitleValueLbl.setBackground(Color.WHITE);
    tableTitleValueLbl.setOpaque(true);

    tblInfoPB.add(tableTitleLbl, cc.xy(1, 1));
    tblInfoPB.add(tableTitleValueLbl, cc.xy(2, 1));

    // add available data object formatters
    createList();

    ActionListener addAL =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            addItem();
          }
        };

    ActionListener delAL =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            deleteSelectedItem();
          }
        };

    ActionListener edtAL =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            editItem(list.getSelectedValue(), false);
          }
        };

    ActionListener defAL =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setDefaultItem();
          }
        };

    String[] toolTipKeys = getDEDAToolTipKeys();

    // delete button
    dedaPanel =
        new DefEditDeleteAddPanel(
            defAL,
            edtAL,
            delAL,
            addAL,
            toolTipKeys[0],
            toolTipKeys[1],
            toolTipKeys[2],
            toolTipKeys[3]);
    dedaPanel.getAddBtn().setEnabled(true);

    PanelBuilder pb =
        new PanelBuilder(new FormLayout("f:max(250px;p):g", "p,6px,f:max(250px;p):g,2px,p"));

    // lay out components on main panel
    int y = 1; // leave first row blank
    pb.add(tblInfoPB.getPanel(), cc.xy(1, y));
    y += 2;

    pb.add(UIHelper.createScrollPane(list), cc.xy(1, y));
    y += 2;

    pb.add(dedaPanel, cc.xy(1, y));
    y += 2;

    pb.setDefaultDialogBorder();

    contentPanel = pb.getPanel();
    mainPanel.add(contentPanel, BorderLayout.CENTER);

    updateUIEnabled();

    pack();
  }
Exemple #3
0
  public void generateFormImages() {
    if (setup()) {
      createFormImagesIndexFile();
    }

    int userChoice =
        JOptionPane.showConfirmDialog(
            getTopWindow(),
            getResourceString("FormDisplayer.CHOOSE_VIEWLIST"), // $NON-NLS-1$
            getResourceString("FormDisplayer.CHOOSE_VIEWLIST_TITLE"), // $NON-NLS-1$
            JOptionPane.YES_NO_OPTION);

    doAll = userChoice == JOptionPane.YES_OPTION ? true : false;

    if (setup()) {

      SpecifyAppContextMgr appContext = (SpecifyAppContextMgr) AppContextMgr.getInstance();

      viewList = doAll ? appContext.getEntirelyAllViews() : appContext.getAllViews();
      SwingUtilities.invokeLater(
          new Runnable() {

            /* (non-Javadoc)
             * @see java.lang.Runnable#run()
             */
            public void run() {
              showView();
            }
          });
    }

    JButton stopBtn = UIHelper.createButton("Stop Generating Images");
    PanelBuilder pb = new PanelBuilder(new FormLayout("p", "p"));
    pb.add(stopBtn, (new CellConstraints()).xy(1, 1));
    pb.setDefaultDialogBorder();
    cancelDlg =
        new CustomDialog(
            (Frame) null, "Stop Image Generation", false, CustomDialog.OK_BTN, pb.getPanel());
    cancelDlg.setOkLabel(getResourceString("CLOSE"));

    cancelDlg.setAlwaysOnTop(true);
    cancelDlg.setVisible(true);

    // Insets    screenInsets =
    // Toolkit.getDefaultToolkit().getScreenInsets(cancelDlg.getGraphicsConfiguration());;
    Rectangle screenRect = cancelDlg.getGraphicsConfiguration().getBounds();
    int y = screenRect.height - (cancelDlg.getSize().height * 2);
    cancelDlg.setLocation(screenRect.x, y);

    stopBtn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    synchronized (okToProc) {
                      okToProc.set(false);
                      viewInx = viewList.size();
                    }
                  }
                });
          }
        });
  }