Esempio n. 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$
    }
  }
Esempio n. 2
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();
                    }
                  }
                });
          }
        });
  }