Ejemplo n.º 1
4
  public void viewReport(String text, JTabbedPane pnl, int year) {

    sid = Integer.parseInt(text);
    if (text.equals("")) {
      JOptionPane.showMessageDialog(repstu, "Type the Student Id");
    } else {

      String rep_path = System.getProperty("user.dir") + "/reports/payment_stu.jrxml";
      Map<String, Object> params = new HashMap<String, Object>();

      params.put("sid", sid);
      params.put("year", "" + year);
      params.put("name", this.getName());
      params.put("datetime", this.getDateTime());

      try {

        JasperReport jreport = JasperCompileManager.compileReport(rep_path);
        JasperPrint jprint = JasperFillManager.fillReport(jreport, params, DB.getmyCon());

        JRViewer jview = new JRViewer(jprint);
        pnl.removeAll();
        pnl.add("Report", jview);

        jview.setZoomRatio((float) 0.9);
      } catch (Exception ex) {
        System.out.println("ERROR:" + ex);
      }
    }
  }
Ejemplo n.º 2
0
  private void updateTabBar(Vector vtThread) {
    pnlThread.removeAll();
    for (int iThreadIndex = 0; iThreadIndex < vtThread.size(); iThreadIndex++) {
      try {
        Vector vtThreadInfo = (Vector) vtThread.elementAt(iThreadIndex);
        PanelThreadMonitor mntTemp = new PanelThreadMonitor(channel);

        String strThreadID = (String) vtThreadInfo.elementAt(0);
        String strThreadName = (String) vtThreadInfo.elementAt(1);
        int iThreadStatus = Integer.parseInt((String) vtThreadInfo.elementAt(2));
        mntTemp.setThreadID(strThreadID);
        mntTemp.setThreadName(strThreadName);
        mntTemp.setThreadStatus(iThreadStatus);
        showResult(mntTemp.txtMonitor, (String) vtThreadInfo.elementAt(3));
        mntTemp.addPropertyChangeListener(this);

        pnlThread.add(strThreadName, mntTemp);
        mntTemp.updateStatus();
      } catch (Exception e) {
        e.printStackTrace();
        MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
      }
    }
    Skin.applySkin(this);
  }
Ejemplo n.º 3
0
 /**
  * Must be called to connect to an archive.
  *
  * @param archive the archive to mount.
  */
 protected void doMount(Archive archive) {
   this.archive = archive;
   archive.getRoot().mkdirs();
   logger = new DownloadLogger(archive);
   logger.clear();
   setTitle("Raccoon - " + archive.getRoot().getAbsolutePath());
   views.removeAll();
   if (archive.getAndroidId().length() == 0) {
     views.addTab("Archive setup", InitView.create(this, archive));
   } else {
     searchView = SearchView.create(this, archive);
     updates.setEnabled(true);
     views.addTab("Search", searchView);
     views.addChangeListener(searchView);
     search.setEnabled(true);
     downloads.setEnabled(true);
     downloadListScroll = new JScrollPane();
     downloadListScroll.setViewportView(downloadList);
     downloadListScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
     views.addTab("Downloads", downloadListScroll);
     Preferences prefs = Preferences.userNodeForPackage(getClass());
     prefs.put(LASTARCHIVE, archive.getRoot().getAbsolutePath());
     SwingUtilities.invokeLater(searchView);
   }
 }
Ejemplo n.º 4
0
  /** Removes all the components from the CytoPanel. */
  @Override
  public void removeAll() {
    // remove all tabs and components from JTabbedPane
    tabbedPane.removeAll();
    componentsById.clear();

    // send out a notification
    notifyListeners(NOTIFICATION_COMPONENT_REMOVED);
  }
 public void clear() {
   for (java.util.Enumeration<Editor> e = pageList.elements(); e.hasMoreElements(); )
     e.nextElement().clear();
   pageList.clear();
   tabbedPanel.removeAll();
   showFirstPage();
   updatePageCounterField(pageList.size());
   changed = false;
 }
Ejemplo n.º 6
0
 private void clearPanel() {
   tabbedPane.removeAll();
   tabbedToolPanel.removeAll();
   panes.clear();
   keys.clear();
   vpInfo.clear();
   toolList.clear();
   objList.clear();
   removeAllPushpinComp();
   for (int i = 0; i < nviews; i++) tp_paneInfo[i].clear();
 }
Ejemplo n.º 7
0
  public void viewWaitingPanel(ActiveGame active) {

    JPanel waitingPanel = new WaitingPanel(active);
    ((WaitingPanel) waitingPanel).setDomainFile(active.getDomainfile());
    tabPanel.removeAll();
    tabPanel.addTab("Waiting", waitingPanel);
    JPanel result = new ResultPanel();
    tabPanel.addTab("Result", result);

    // pack();
    this.setVisible(true);
  }
Ejemplo n.º 8
0
  public void viewStartPanel(GameType game) {

    JPanel startPanel = new StartGamePanel(game);

    tabPanel.removeAll();
    tabPanel.addTab("Start Game", startPanel);
    JPanel result = new ResultPanel();
    tabPanel.addTab("Result", result);

    // pack();
    this.setVisible(true);
  }
Ejemplo n.º 9
0
  public void viewHomePanel() {

    JPanel homePanel = new HomePanel();

    tabPanel.removeAll();
    tabPanel.addTab("Home", homePanel);
    JPanel result = new ResultPanel();
    tabPanel.addTab("Result", result);

    // pack();
    this.setVisible(true);
  }
Ejemplo n.º 10
0
  /* (non-Javadoc)
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(ActionEvent e) {
    Object o = e.getSource();
    if (o instanceof JMenuItem) {
      JMenuItem sender = (JMenuItem) o;
      String name = sender.getText();
      if (name.equals("close")) {
        tabbedPane.removeTabAt(tabbedPane.getSelectedIndex());
      } else if (name.equals("save")) {
        int index = tabbedPane.getSelectedIndex();
        Component c = tabbedPane.getComponent(index);
        Point p = c.getLocation();
        Component t = tabbedPane.getComponentAt(new Point(p.x + 20, p.y + 30));
        if (t instanceof TextView) {
          TextView text = (TextView) t;
          // String code = text.getText();
          // save the code
          // saveTab(code);
        }
        if (t instanceof HTMLTextView) {
          HTMLTextView text = (HTMLTextView) t;
          fileChooser.setSelectedFile(new File(text.node.getName()));
          int returnVal = fileChooser.showSaveDialog(this);

          if (returnVal == JFileChooser.APPROVE_OPTION) {
            File f = fileChooser.getSelectedFile();

            // save the code
            String fileType =
                f.getName().substring(f.getName().lastIndexOf("."), f.getName().length());
            if (fileType.indexOf("htm") != -1) {
              // save as html
              String code = text.getText();
              saveTab(code, f);
            } else if (fileType.indexOf("java") != -1) {
              // save as java
              String code = text.getUnModyfiedContent();
              saveTab(code, f);
            } else if (text.node.fileType.indexOf(FileTypes.MANIFEST) != -1
                || text.node.fileType.indexOf(FileTypes.MANIFEST2) != -1) {
              String code = text.getUnModyfiedContent();
              saveTab(code, f);
              System.out.println("Saved manifest");
            } else {
              System.out.println("FILETYPE UNKNOWN:" + text.node.fileType);
            }
          }
        }
      } else if (name.equals("close all")) {
        tabbedPane.removeAll();
      }
    }
  }
Ejemplo n.º 11
0
  public void setCurrentLayout(int newId) {

    if (newId >= nviews) return;

    tabbedPane.removeAll();
    tabbedToolPanel.removeAll();
    String key;
    String currValue;
    JComponent obj;
    PushpinIF pobj;
    clearPushpinComp();
    for (int i = 0; i < keys.size(); i++) {
      key = (String) keys.get(i);
      currValue = (String) tp_paneInfo[newId].get(key);
      obj = (JComponent) panes.get(key);
      pobj = null;
      if (currValue.equals("yes") && obj != null) {
        if (obj instanceof PushpinIF) {
          pobj = (PushpinIF) obj;
          pobj.setAvailable(true);
          if (!pobj.isOpen()) {
            if (!pobj.isPopup()) obj = null;
          }
        }
        if (obj != null) {
          if (key.equals("Locator")) key = getLocatorName();
          tabbedPane.addTab(key, null, obj, "");
        }
        // tabbedPane.addTab(key, null, (JComponent)panes.get(key), "");
      }
    }

    if (tabbedPane.getTabCount() < 1) {
      pinPanel.setAvailable(false);
      pinPanel.setStatus("close");
      // setVisible(false);
      return;
    }

    pinPanel.setAvailable(true);
    pinPanel.setStatus("open");
    if (tabbedPane.getTabCount() == 1) {
      tabbedToolPanel.add(tabbedPane.getComponentAt(0));
      // tabbedToolPanel.add(tabbedPane);
    } else {
      tabbedToolPanel.add(tabbedPane);
    }
    setSelectedTab(tp_selectedTab, selectedTabName);

    tabbedToolPanel.validate();
    // repaint();
  }
Ejemplo n.º 12
0
  public void release() {
    for (EditorView<T> view : views) {
      view.release();
      view.removePropertyChangeListener(this);
    }

    views.clear();

    inputTabs.removeChangeListener(inputTabsChangeListener);
    inputTabs.removeAll();

    inspectorPanel.release();
    document.release();
  }
  public void newFolderSelected(File dir) {
    tabbedPane.removeAll();
    editorPanels.clear();
    consoleTextArea.setText("");
    filesListModel.clear();

    for (SourceFile sf : SpeedyGrader.getInstance().getSourceFiles(dir)) {
      filesListModel.addElement(sf);
    }

    splitMainPane.setDividerLocation(.2);
    this.revalidate();
    this.repaint();
  }
Ejemplo n.º 14
0
  public void setPanel(int plotType) {

    this.plotType = plotType;
    tabbedPane.removeAll();
    String tabTitle = StatComboPanel.plotMap.get(plotType);
    tabbedPane.insertTab(tabTitle, null, new JScrollPane(mainPanel), null, 0);
    tabbedPane.addTab(app.getMenu("Graph"), new JScrollPane(graphPanel));
    showYSettings = true;

    switch (plotType) {
      case StatComboPanel.PLOT_HISTOGRAM:
        classesPanel.setVisible(true);
        histogramPanel.setVisible(true);
        graphPanel.setVisible(true);
        scatterplotPanel.setVisible(false);
        break;

      case StatComboPanel.PLOT_DOTPLOT:
      case StatComboPanel.PLOT_BOXPLOT:
      case StatComboPanel.PLOT_NORMALQUANTILE:
        tabbedPane.removeTabAt(0);
        showYSettings = true;
        classesPanel.setVisible(false);
        histogramPanel.setVisible(false);
        graphPanel.setVisible(true);
        scatterplotPanel.setVisible(false);
        break;

      case StatComboPanel.PLOT_SCATTERPLOT:
        showYSettings = true;
        classesPanel.setVisible(false);
        histogramPanel.setVisible(false);
        graphPanel.setVisible(true);
        scatterplotPanel.setVisible(true);
        break;

      case StatComboPanel.PLOT_RESIDUAL:
        tabbedPane.removeTabAt(0);
        showYSettings = true;
        classesPanel.setVisible(false);
        histogramPanel.setVisible(false);
        graphPanel.setVisible(true);
        scatterplotPanel.setVisible(false);
        break;
    }

    setLabels();
    updateGUI();
  }
Ejemplo n.º 15
0
  private void rebuildTabs() {

    rebuildingTabs = true;
    for (int i = 0; i < tabbedPane.getTabCount(); i++) {
      SheetPanel sheetPanel = (SheetPanel) tabbedPane.getComponentAt(i);
      sheetPanel.dispose();
    }
    tabbedPane.removeAll();
    Workbook workbook = manager.getWorkbook();
    for (Sheet sheet : workbook.getSheets()) {
      if (!sheet.isHidden()) {
        SheetPanel sheetPanel = new SheetPanel(manager, sheet);
        tabbedPane.add(sheet.getName(), sheetPanel);
      }
    }
    rebuildingTabs = false;
  }
Ejemplo n.º 16
0
  private synchronized void closeAll() {
    try {
      // Close all child window
      WindowManager.closeAll();

      // Remove all child component
      pnlThread.setVisible(false);
      pnlUser.setVisible(false);
      pnlThread.removeAll();
      clearAll(txtBoard);
      tblUser.setData(new Vector());
      Thread.sleep(500);
    } catch (Exception e) {
      e.printStackTrace();
      MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
    }
  }
  @Override
  public void valueChanged(ListSelectionEvent lse) {
    if (!lse.getValueIsAdjusting()) {
      boolean needsSave = false;
      for (EditorPanel ep : editorPanels) {
        if (ep.needsSave()) {
          needsSave = true;
        }
      }
      if (needsSave) {
        int i =
            JOptionPane.showConfirmDialog(
                this,
                "Would you like to save before switching files?",
                "Save?",
                JOptionPane.YES_NO_CANCEL_OPTION,
                JOptionPane.QUESTION_MESSAGE);
        switch (i) {
          case JOptionPane.YES_OPTION:
            for (EditorPanel ep : editorPanels) {
              ep.save();
            }
            break;
          case JOptionPane.NO_OPTION:
            break;
          case JOptionPane.CANCEL_OPTION:
          case JOptionPane.CLOSED_OPTION:
            return;
        }
      }
      tabbedPane.removeAll();
      editorPanels.clear();

      if (filesList.getSelectedValue() != null) {
        for (Entry<String, File> ents : filesList.getSelectedValue().getFileList().entrySet()) {
          EditorPanel ep = new EditorPanel(ents.getValue(), textFont);
          tabbedPane.addTab(ents.getKey(), ep);
          editorPanels.add(ep);
        }

        SpeedyGrader.getInstance().startComplieAndRun();
      }
    }
  }
Ejemplo n.º 18
0
  protected void updateTable() {
    AuditHasLinksPane mon = new AuditHasLinksPane();
    AuditHasLinksTab jAuditorLinksPane = new AuditHasLinksTab(mon);

    AuditPlanDao dt = null;
    String auditPlanID = null;
    String enterpriseID = null;
    try {
      dt = (AuditPlanDao) dataSource.getCurrentRecord();
      auditPlanID = dt.auditPlanID.getValue();
      enterpriseID = dt.fkEnterpriseID.getValue();
    } catch (DataSourceException ex) {

    }
    AuditHasLinksDao auditHasLinksDao = null;
    try {
      AuditHasLinks auditLinks =
          (AuditHasLinks)
              TmplEJBLocater.getInstance()
                  .getEJBRemote("pt.inescporto.siasoft.go.auditor.ejb.session.AuditHasLinks");
      try {
        auditHasLinksDao = auditLinks.getLinks(auditPlanID, enterpriseID);
      } catch (UserException ex) {
        ex.printStackTrace();
      } catch (RemoteException ex) {
        ex.printStackTrace();
      }
    } catch (NamingException ex) {
      ex.printStackTrace();
    }
    try {
      departList = (Hashtable<String, Vector>) auditHasLinksDao.departList;
      if (departList.containsKey(auditPlanID)) {
        Vector v = auditHasLinksDao.departList.get(auditPlanID);
        jAuditorLinksPane.refresh(v);
      }
      auditTab.removeAll();
      auditTab.add(jAuditorLinksPane.getAuditHasLinksPane(), 0);
      auditTab.setTitleAt(0, res.getString("label.activelinks"));
    } catch (Exception ex) {

    }
  }
Ejemplo n.º 19
0
  @Override
  public void setEntity(Entity entity) {

    jTabbedFrame.removeAll();

    currentEntity = entity;
    if (currentEntity == null) {
      setTitle("Property Viewer");
      return;
    }
    setTitle("Property Viewer - " + currentEntity.getInputName());

    ArrayList<ClassFields> cFields = getFields(entity);
    for (int i = 0; i < cFields.size(); i++) {
      // The properties in the current page
      ClassFields cf = cFields.get(i);
      PropertyTableModel mod = new PropertyTableModel(entity, cf.fields);
      PropertyTable tab = new PropertyTable(mod);
      JScrollPane scroll = new JScrollPane(tab);

      jTabbedFrame.addTab(cf.klass.getSimpleName(), scroll);
    }
  }
Ejemplo n.º 20
0
  /**
   * Update the display to show the information about the specified example.
   *
   * @param example the currently-selected example
   */
  private void display(Example example) {
    if (example == null) {
      tabbedPane.removeAll();
      runButton.setEnabled(false);
    } else {
      tabbedPane.removeAll();

      JEditorPane description = new JEditorPane();
      description.setContentType("text/html");
      description.setText(example.getDescription());
      description.setEditable(false);

      description.addHyperlinkListener(
          new HyperlinkListener() {

            @Override
            public void hyperlinkUpdate(HyperlinkEvent hle) {
              if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType())) {
                Desktop desktop = Desktop.getDesktop();

                try {
                  desktop.browse(hle.getURL().toURI());
                } catch (Exception ex) {
                  // unable to launch browser
                }
              }
            }
          });

      tabbedPane.addTab("Description", description);

      for (String resource : example.getResources()) {
        try {
          RSyntaxTextArea textArea = new RSyntaxTextArea(20, 60);

          if (resource.endsWith(".java")) {
            textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
          } else {
            textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE);
          }

          textArea.setCodeFoldingEnabled(true);
          textArea.setText(load(resource));
          textArea.setSelectionStart(0);
          textArea.setSelectionEnd(0);
          textArea.setEditable(false);
          RTextScrollPane sp = new RTextScrollPane(textArea);

          tabbedPane.addTab(new File(resource).getName(), sp);
        } catch (IOException ex) {
          ex.printStackTrace();
        }
      }

      if (example.getMainClass() == null) {
        runButton.setEnabled(false);
      } else {
        runButton.setEnabled(true);
      }
    }
  }
Ejemplo n.º 21
0
 public void viewConnectPanel() {
   JPanel connPanel = new ConnectPanel();
   tabPanel.removeAll();
   tabPanel.addTab("Connect To Server", connPanel);
 }
Ejemplo n.º 22
0
  public void removeAll() {
    int size = activeEditors.size();
    for (int i = size - 1; i >= 0; i--) remove(i);

    super.removeAll(); // XXX this really shouldn't be necessary.
  }
Ejemplo n.º 23
0
 /** Method for removing all current Panels */
 public void removeAllPanels() {
   pane.removeAll();
   objects.removeAll();
 }
  /**
   * Populate the tag conflict resolver with tags for each type of primitives
   *
   * @param tagsForNodes the tags belonging to nodes in the paste source
   * @param tagsForWays the tags belonging to way in the paste source
   * @param tagsForRelations the tags belonging to relations in the paste source
   * @param sourceStatistics histogram of tag source, number of primitives of each type in the
   *     source
   * @param targetStatistics histogram of paste targets, number of primitives of each type in the
   *     paste target
   */
  public void populate(
      TagCollection tagsForNodes,
      TagCollection tagsForWays,
      TagCollection tagsForRelations,
      Map<OsmPrimitiveType, Integer> sourceStatistics,
      Map<OsmPrimitiveType, Integer> targetStatistics) {
    tagsForNodes = (tagsForNodes == null) ? new TagCollection() : tagsForNodes;
    tagsForWays = (tagsForWays == null) ? new TagCollection() : tagsForWays;
    tagsForRelations = (tagsForRelations == null) ? new TagCollection() : tagsForRelations;
    if (tagsForNodes.isEmpty() && tagsForWays.isEmpty() && tagsForRelations.isEmpty()) {
      populate(null, null, null);
      return;
    }
    tpResolvers.removeAll();
    initResolver(OsmPrimitiveType.NODE, tagsForNodes, targetStatistics);
    initResolver(OsmPrimitiveType.WAY, tagsForWays, targetStatistics);
    initResolver(OsmPrimitiveType.RELATION, tagsForRelations, targetStatistics);

    pnlTagResolver.removeAll();
    pnlTagResolver.add(tpResolvers, BorderLayout.CENTER);
    mode = Mode.RESOLVING_TYPED_TAGCOLLECTIONS;
    validate();
    statisticsModel.reset();
    if (!tagsForNodes.isEmpty()) {
      StatisticsInfo info = new StatisticsInfo();
      info.numTags = tagsForNodes.getKeys().size();
      int numTargets =
          targetStatistics.get(OsmPrimitiveType.NODE) == null
              ? 0
              : targetStatistics.get(OsmPrimitiveType.NODE);
      if (numTargets > 0) {
        info.sourceInfo.put(OsmPrimitiveType.NODE, sourceStatistics.get(OsmPrimitiveType.NODE));
        info.targetInfo.put(OsmPrimitiveType.NODE, numTargets);
        statisticsModel.append(info);
      }
    }
    if (!tagsForWays.isEmpty()) {
      StatisticsInfo info = new StatisticsInfo();
      info.numTags = tagsForWays.getKeys().size();
      int numTargets =
          targetStatistics.get(OsmPrimitiveType.WAY) == null
              ? 0
              : targetStatistics.get(OsmPrimitiveType.WAY);
      if (numTargets > 0) {
        info.sourceInfo.put(OsmPrimitiveType.WAY, sourceStatistics.get(OsmPrimitiveType.WAY));
        info.targetInfo.put(OsmPrimitiveType.WAY, numTargets);
        statisticsModel.append(info);
      }
    }
    if (!tagsForRelations.isEmpty()) {
      StatisticsInfo info = new StatisticsInfo();
      info.numTags = tagsForRelations.getKeys().size();
      int numTargets =
          targetStatistics.get(OsmPrimitiveType.RELATION) == null
              ? 0
              : targetStatistics.get(OsmPrimitiveType.RELATION);
      if (numTargets > 0) {
        info.sourceInfo.put(
            OsmPrimitiveType.RELATION, sourceStatistics.get(OsmPrimitiveType.RELATION));
        info.targetInfo.put(OsmPrimitiveType.RELATION, numTargets);
        statisticsModel.append(info);
      }
    }

    for (int i = 0; i < getNumResolverTabs(); i++) {
      if (!getResolver(i).getModel().isResolvedCompletely()) {
        tpResolvers.setSelectedIndex(i);
        break;
      }
    }
  }
  @Override
  public void propertyChange(PropertyChangeEvent event) {
    System.out.println("ktos mnie zawolal: " + event);
    tabbedPane.removeAll();

    if (event.getNewValue() instanceof XmlDocument) {
      final XmlDocument xmlDocument = (XmlDocument) event.getNewValue();

      JPanel generalPanel = new JPanel();

      GridBagLayout gridBagLayout = new GridBagLayout();
      generalPanel.setAlignmentY(Component.TOP_ALIGNMENT);
      generalPanel.setLayout(gridBagLayout);

      GridBagConstraints c = new GridBagConstraints();
      c.fill = GridBagConstraints.HORIZONTAL;
      c.anchor = GridBagConstraints.LINE_START;
      c.gridx = 0;
      c.gridy = 0;
      c.weightx = 1;
      c.weighty = 0.3;
      generalPanel.add(new JLabel("Root element name: "), c);

      final JTextField rootElementName =
          new JTextField(
              xmlDocument.getRootElement() != null ? xmlDocument.getRootElement().getName() : "");
      rootElementName.addFocusListener(
          new FocusListener() {

            @Override
            public void focusGained(FocusEvent e) {}

            @Override
            public void focusLost(FocusEvent e) {
              xmlDocument.getRootElement().setName(rootElementName.getText());
            }
          });

      c.gridx = 1;
      c.gridy = 0;
      c.weightx = 1;
      c.weighty = 0.3;
      generalPanel.add(rootElementName, c);

      c.gridx = 0;
      c.gridy = 1;
      c.weightx = 1;
      c.weighty = 0.3;
      generalPanel.add(new JLabel("Encoding: "), c);

      final JTextField encoding =
          new JTextField(xmlDocument.getEncoding() != null ? xmlDocument.getEncoding() : "");
      encoding.addFocusListener(
          new FocusListener() {

            @Override
            public void focusGained(FocusEvent e) {}

            @Override
            public void focusLost(FocusEvent e) {
              xmlDocument.setEncoding(encoding.getText());
            }
          });

      c.gridx = 1;
      c.gridy = 1;
      c.weightx = 1;
      c.weighty = 0.3;
      generalPanel.add(encoding, c);

      c.gridx = 0;
      c.gridy = 2;
      c.weightx = 1;
      c.weighty = 0.3;
      generalPanel.add(new JLabel("Version: "), c);

      final JTextField version =
          new JTextField(xmlDocument.getVersion() != null ? xmlDocument.getVersion() : "");
      version.addFocusListener(
          new FocusListener() {

            @Override
            public void focusGained(FocusEvent e) {}

            @Override
            public void focusLost(FocusEvent e) {
              xmlDocument.setVersion(version.getText());
            }
          });

      c.gridx = 1;
      c.gridy = 2;
      c.weightx = 1;
      c.weighty = 0.3;
      generalPanel.add(version, c);

      c.gridx = 0;
      c.gridy = 3;
      c.gridwidth = 1;
      c.weighty = 1;
      generalPanel.add(new JPanel(), c);

      tabbedPane.addTab("General", null, generalPanel, "General options");

    } else if (event.getNewValue() instanceof XmlTag) {
      final XmlTag xmlTag = (XmlTag) event.getNewValue();
      JPanel generalPanel = new JPanel();

      GridBagLayout gridBagLayout = new GridBagLayout();
      generalPanel.setAlignmentY(Component.TOP_ALIGNMENT);
      generalPanel.setLayout(gridBagLayout);

      GridBagConstraints c = new GridBagConstraints();
      c.fill = GridBagConstraints.HORIZONTAL;
      c.anchor = GridBagConstraints.LINE_START;
      c.gridx = 0;
      c.gridy = 0;
      c.weightx = 1;
      c.weighty = 0.3;
      generalPanel.add(new JLabel("Tag name: "), c);

      final JTextField tagName = new JTextField(xmlTag.getName());
      tagName.addFocusListener(
          new FocusListener() {

            @Override
            public void focusGained(FocusEvent e) {}

            @Override
            public void focusLost(FocusEvent e) {
              xmlTag.setName(tagName.getText());
            }
          });

      c.gridx = 1;
      c.gridy = 0;
      c.weightx = 1;
      c.weighty = 0.3;
      generalPanel.add(tagName, c);

      c.gridx = 0;
      c.gridy = 1;
      c.gridwidth = 2;
      c.weighty = 1;
      generalPanel.add(new JPanel(), c);

      tabbedPane.addTab("General", null, generalPanel, "General options");

      AttributesModel attributesModel = new AttributesModel(xmlTag);

      JTable attributesTable = new JTable(attributesModel);
      TableColumn columnName = attributesTable.getColumn("Name");
      columnName.setWidth(140);
      TableColumn columnValue = attributesTable.getColumn("Value");
      columnValue.setWidth(140);
      JPanel attrPanel = new JPanel(new BorderLayout());
      attrPanel.add(attributesTable.getTableHeader(), BorderLayout.PAGE_START);
      JScrollPane scrollPane = new JScrollPane(attributesTable);
      attrPanel.add(scrollPane, BorderLayout.CENTER);

      Schema schema = xmlTag.getSchema();
      String path = xmlTag.getPath();

      AvailableAttributesFinder aaf = new AvailableAttributesFinder(schema.getContent());
      Map<String, Boolean> availableAttributes = aaf.getAvailableAttributesForNode(path);

      attributesTable.addMouseListener(
          new AttributeTableClickListener(
              attributesTable, true, xmlTag.getSchemaType(), availableAttributes));
      scrollPane.addMouseListener(
          new AttributeTableClickListener(
              attributesTable, false, xmlTag.getSchemaType(), availableAttributes));

      tabbedPane.addTab("Attributes", null, attrPanel, "Attributes of this element");
      String text = ((XmlTag) event.getNewValue()).toString(0);

      JPanel textPanel = new JPanel();
      textPanel.setLayout(new GridLayout(0, 1));
      JTextArea textArea = new JTextArea(text);
      textArea.setEditable(false);
      textPanel.add(textArea);

      tabbedPane.addTab("Text", null, textPanel, "The text in the element");
    } else if (event.getNewValue() instanceof mxCell && ((mxCell) event.getNewValue()).isEdge()) {
      mxCell cell = (mxCell) event.getNewValue();
      mxICell source = cell.getSource();
      mxICell target = cell.getTarget();
      if (source != null
          && target != null
          && source.getParent() != null
          && target.getParent() != null) {
        XmlTag sourceTag = (XmlTag) source.getParent().getValue();
        XmlTag targetTag = (XmlTag) target.getParent().getValue();

        System.out.println(sourceTag + " -> " + targetTag);

        JPanel generalPanel = new JPanel();

        GridBagLayout gridBagLayout = new GridBagLayout();
        generalPanel.setAlignmentY(Component.TOP_ALIGNMENT);
        generalPanel.setLayout(gridBagLayout);

        GridBagConstraints c = new GridBagConstraints();
        c.fill = GridBagConstraints.HORIZONTAL;
        c.anchor = GridBagConstraints.LINE_START;
        c.gridx = 0;
        c.gridy = 0;
        c.weightx = 1;
        c.weighty = 0.3;
        generalPanel.add(new JLabel("Source tag name: "), c);

        final JTextField sourceTagName =
            new JTextField(sourceTag.getName() != null ? sourceTag.getName() : "");
        sourceTagName.setEditable(false);

        c.gridx = 1;
        c.gridy = 0;
        c.weightx = 1;
        c.weighty = 0.3;
        generalPanel.add(sourceTagName, c);

        c.gridx = 0;
        c.gridy = 1;
        c.weightx = 1;
        c.weighty = 0.3;
        generalPanel.add(new JLabel("Target tag name: "), c);

        final JTextField targetTagName =
            new JTextField(targetTag.getName() != null ? targetTag.getName() : "");
        targetTagName.setEditable(false);

        c.gridx = 1;
        c.gridy = 1;
        c.weightx = 1;
        c.weighty = 0.3;
        generalPanel.add(targetTagName, c);

        c.gridx = 0;
        c.gridy = 2;
        c.gridwidth = 1;
        c.weighty = 1;
        generalPanel.add(new JPanel(), c);

        tabbedPane.addTab("General", null, generalPanel, "General options");
      }
    }
  }
Ejemplo n.º 26
0
  public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();

    if (cmd.equals("new")) {
      icons = new Hashtable[0];
      fields = new Hashtable[0];

      tabPane.removeAll();
      repaint();
    } else if (cmd.equals("open")) {
      JFileChooser chooser = new JFileChooser();
      FileFilter filter =
          new FileFilter() {
            public boolean accept(File f) {
              return f.getAbsolutePath().endsWith(".template") || f.isDirectory();
            }

            public String getDescription() {
              return "OME Notes Templates";
            }
          };

      chooser.setFileFilter(filter);

      int status = chooser.showOpenDialog(this);
      if (status == JFileChooser.APPROVE_OPTION) {
        String file = chooser.getSelectedFile().getAbsolutePath();
        try {
          Template t = new Template(file);

          TemplateTab[] tabs = t.getTabs();
          for (int i = 0; i < tabs.length; i++) {
            int rows = tabs[i].getRows();
            int cols = tabs[i].getColumns();
            if (cols == 0) cols = 1;
            if (rows == 0) rows = 1;

            addTab(tabs[i].getName(), rows, cols);
            tabPane.setSelectedIndex(i);

            for (int j = 0; j < tabs[i].getNumFields(); j++) {
              TemplateField f = tabs[i].getField(j);

              int x = f.getRow();
              int y = f.getColumn();
              if (x == -1) x = 1;
              if (y == -1) y = j + 1;

              Point p = new Point(x, y);
              DraggableIcon icon = (DraggableIcon) icons[i].get(p);

              icon.label = new JLabel(f.getName());

              JPanel panel = new JPanel();
              panel.add(f.getComponent());

              icon.setPanel(panel);
            }
          }
        } catch (Exception exc) {
          error("Failed to parse template", exc);
        }

        tabPane.setSelectedIndex(0);
      }
    } else if (cmd.equals("save")) {
      // build up the template from the components

      TemplateTab[] tabs = new TemplateTab[tabPane.getTabCount()];

      for (int i = 0; i < tabs.length; i++) {
        tabs[i] = new TemplateTab();
        tabs[i].setName(tabPane.getTitleAt(i));
        JComponent c = (JComponent) tabPane.getComponentAt(i);
        FormLayout layout = (FormLayout) c.getLayout();

        tabs[i].setRows(layout.getRowCount());
        tabs[i].setColumns(layout.getColumnCount());

        Object[] keys = icons[i].keySet().toArray();

        for (int j = 0; j < keys.length; j++) {
          Point p = (Point) keys[j];
          DraggableIcon icon = (DraggableIcon) icons[i].get(p);
          TemplateField f = (TemplateField) fields[i].get(p);

          if (icon.image != null) {
            Component[] components = icon.image.getComponents();
            JLabel label = icon.label;
            JComponent component = (JComponent) components[0];

            f.setComponent(component);

            for (int k = 0; k < COMPONENTS.length; k++) {
              if (component.getClass().equals(COMPONENTS[k])) {
                f.setType(COMPONENT_TYPES[k]);
                break;
              }
            }

            f.setRow(p.y);
            f.setColumn(p.x);
            f.setDefaultValue(TemplateTools.getComponentValue(component));

            tabs[i].addField(f);
          }
        }
      }

      Template t = new Template(tabs, null);

      // prompt for filename to save to
      if (currentFile == null) {
        JFileChooser chooser = new JFileChooser();

        FileFilter filter =
            new FileFilter() {
              public boolean accept(File f) {
                return true;
              }

              public String getDescription() {
                return "All files";
              }
            };

        chooser.setFileFilter(filter);

        int status = chooser.showSaveDialog(this);
        if (status == JFileChooser.APPROVE_OPTION) {
          currentFile = chooser.getSelectedFile().getAbsolutePath();
          if (currentFile == null) return;
        }
      }

      try {
        t.save(currentFile);
      } catch (IOException io) {
        error("Failed to save template", io);
      }
    } else if (cmd.equals("quit")) dispose();
    else if (cmd.equals("add row")) addRow();
    else if (cmd.equals("add col")) addColumn();
    else if (cmd.equals("prompt tab")) {
      // prompt for tab name
      JPopupMenu menu = new JPopupMenu();
      newTabName = new JTextField();
      newTabName.setPreferredSize(new Dimension(200, 25));
      menu.add(newTabName);
      JButton b = new JButton("OK");
      b.addActionListener(this);
      b.setActionCommand("new tab");
      menu.add(b);

      JComponent s = (JComponent) e.getSource();
      menu.show(s, s.getX(), s.getY());
      newTabName.grabFocus();
    } else if (cmd.equals("new tab")) {
      newTabName.getParent().setVisible(false);
      addTab(newTabName.getText(), 2, 2);
    } else if (cmd.equals("setName")) {
      JPopupMenu menu = (JPopupMenu) ((JComponent) e.getSource()).getParent();
      DraggableIcon icon = (DraggableIcon) menu.getInvoker();
      menu.setVisible(false);

      String text = ((JTextField) menu.getComponents()[0]).getText();

      Point p = new Point(icon.gridx, icon.gridy);
      int ndx = tabPane.getSelectedIndex();
      TemplateField f = (TemplateField) fields[ndx].get(p);
      f.setName(text);
      f.setNameMap(null);

      // set the name
      if (icon.label != null) icon.remove(icon.label);
      icon.remove(icon.image);
      icon.label = new JLabel(text);
      icon.add(icon.label);
      icon.add(icon.image);
      icon.getParent().repaint();
    } else if (cmd.equals("changeName")) {
      // prompt for new field name
      JPopupMenu menu = new JPopupMenu();
      JTextField field = new JTextField();
      field.setPreferredSize(new Dimension(200, 25));
      menu.add(field);
      JButton b = new JButton("OK");
      b.addActionListener(this);
      b.setActionCommand("setName");
      menu.add(b);
      menu.show(lastMenuComponent, lastMenuX, lastMenuY);
      field.grabFocus();
    } else if (cmd.equals("nameMap")) {
      JPopupMenu menu = (JPopupMenu) ((JComponent) e.getSource()).getParent();
      DraggableIcon icon = (DraggableIcon) menu.getInvoker();
      menu.setVisible(false);

      MappingWindow w = new MappingWindow(this, true);
      w.show(lastMenuComponent, lastMenuX, lastMenuY);
    } else if (cmd.equals("map")) {
      JPopupMenu menu = (JPopupMenu) ((JComponent) e.getSource()).getParent();
      DraggableIcon icon = (DraggableIcon) menu.getInvoker();
      menu.setVisible(false);

      MappingWindow w = new MappingWindow(this, false);
      w.show(lastMenuComponent, lastMenuX, lastMenuY);
    } else if (cmd.equals("repeat")) {
      JMenuItem item = (JMenuItem) e.getSource();
      DraggableIcon icon = (DraggableIcon) ((JPopupMenu) item.getParent()).getInvoker();
      TemplateField f = getField(icon);

      if (item.getText().equals("Repeat this field")) {
        item.setText("Don't repeat this field");
        f.setRepeated(true);
      } else {
        item.setText("Repeat this field");
        f.setRepeated(false);
      }
    } else if (cmd.equals("removeField")) {
      JPopupMenu menu = (JPopupMenu) ((JComponent) e.getSource()).getParent();
      DraggableIcon icon = (DraggableIcon) menu.getInvoker();
      menu.setVisible(false);

      int idx = tabPane.getSelectedIndex();
      Object[] keys = icons[idx].keySet().toArray();
      for (int i = 0; i < keys.length; i++) {
        if (icons[idx].get(keys[i]).equals(icon)) {
          icons[idx].remove(keys[i]);
          fields[idx].remove(keys[i]);
          break;
        }
      }

      icon.remove(icon.label);
      icon.remove(icon.image);
      tabPane.repaint();
    } else if (cmd.startsWith("removeRow")) {
      int row = Integer.parseInt(cmd.substring(cmd.indexOf(":") + 1));
      JPopupMenu menu = (JPopupMenu) ((JComponent) e.getSource()).getParent();
      menu.setVisible(false);

      JPanel pane = (JPanel) tabPane.getSelectedComponent();
      FormLayout layout = (FormLayout) pane.getLayout();

      int rows = layout.getRowCount();
      int cols = layout.getColumnCount();

      int idx = tabPane.getSelectedIndex();

      for (int i = 0; i < cols; i++) {
        pane.remove((JComponent) icons[idx].get(new Point(i + 1, row + 1)));
      }

      rekey(row, -1);
      layout.removeRow(row + 1);
      tabPane.repaint();
    } else if (cmd.startsWith("removeColumn")) {
      int col = Integer.parseInt(cmd.substring(cmd.indexOf(":") + 1));
      JPopupMenu menu = (JPopupMenu) ((JComponent) e.getSource()).getParent();
      menu.setVisible(false);

      JPanel pane = (JPanel) tabPane.getSelectedComponent();
      FormLayout layout = (FormLayout) pane.getLayout();

      int rows = layout.getRowCount();
      int cols = layout.getColumnCount();
      int idx = tabPane.getSelectedIndex();

      for (int i = 0; i < rows; i++) {
        pane.remove((JComponent) icons[idx].get(new Point(col + 1, i + 1)));
      }

      rekey(-1, col);
      layout.removeColumn(col + 1);
      tabPane.repaint();
    } else if (cmd.equals("removeTab")) {
      int ndx = tabPane.getSelectedIndex();
      tabPane.remove(ndx);

      Hashtable[] h = new Hashtable[icons.length - 1];
      Hashtable[] f = new Hashtable[fields.length - 1];

      System.arraycopy(icons, 0, h, 0, ndx);
      System.arraycopy(icons, ndx + 1, h, ndx, h.length - ndx);
      System.arraycopy(fields, 0, f, 0, ndx);
      System.arraycopy(fields, ndx + 1, f, ndx, f.length - ndx);

      icons = h;
      fields = f;
    } else if (cmd.equals("specifyChoices")) {
      JMenuItem item = (JMenuItem) e.getSource();
      DraggableIcon icon = (DraggableIcon) ((JPopupMenu) item.getParent()).getInvoker();
      TemplateField f = getField(icon);

      EnumWindow w = new EnumWindow(this, f.getEnums());
      w.show(lastMenuComponent, lastMenuX, lastMenuY);
    } else if (cmd.equals("setThumbSource")) {
      JPopupMenu menu = new JPopupMenu();
      ButtonGroup g = new ButtonGroup();

      JRadioButton dataset = new JRadioButton("Use thumbnail from dataset");
      dataset.setSelected(true);
      g.add(dataset);

      JRadioButton file = new JRadioButton("Use thumbnail from file:");
      g.add(file);

      menu.add(dataset);
      menu.add(file);

      JTextField field = new JTextField();
      field.setPreferredSize(new Dimension(200, 25));
      menu.add(field);

      JButton b = new JButton("OK");
      b.addActionListener(this);
      b.setActionCommand("applyThumbSource");
      menu.add(b);
      menu.show(lastMenuComponent, lastMenuX, lastMenuY);
    } else if (cmd.equals("applyThumbSource")) {
      JPopupMenu menu = (JPopupMenu) ((JComponent) e.getSource()).getParent();
      DraggableIcon icon = (DraggableIcon) menu.getInvoker();

      Component[] c = menu.getComponents();
      JRadioButton dataset = (JRadioButton) c[0];

      String text = null;

      if (!dataset.isSelected()) {
        JTextField t = (JTextField) c[2];
        text = t.getText();
        getField(icon).setValueMap(text);
      }

      menu.setVisible(false);

      if (text != null) {
        try {
          BufferedImageReader reader = new BufferedImageReader();
          reader.setId(text);
          BufferedImage thumb = reader.openThumbImage(0);
          JLabel label = (JLabel) icon.image.getComponents()[0];
          label.setIcon(new ImageIcon(thumb));
          reader.close();
        } catch (FormatException exc) {
          error("Failed to open thumbnail (" + text + ")", exc);
        } catch (IOException exc) {
          error("Failed to open thumbnail (" + text + ")", exc);
        }
      }
    } else if (cmd.equals("ok")) {
      // this event came from an instance of EnumWindow
      JPanel parent = (JPanel) ((JButton) e.getSource()).getParent();
      EnumWindow menu = (EnumWindow) parent.getParent();
      DraggableIcon icon = (DraggableIcon) menu.getInvoker();
      TemplateField f = getField(icon);
      menu.setVisible(false);

      String[] options = menu.getOptions();
      f.setEnums(options);

      JComboBox box = (JComboBox) icon.image.getComponents()[0];
      for (int i = 0; i < options.length; i++) box.addItem(options[i]);
      repaint();
    } else if (cmd.equals("chooseMapping")) {
      // this event came from an instance of MappingWindow
      JTabbedPane parent = (JTabbedPane) ((JButton) e.getSource()).getParent();
      MappingWindow menu = (MappingWindow) parent.getParent();
      DraggableIcon icon = (DraggableIcon) menu.getInvoker();
      TemplateField f = getField(icon);

      String omexmlMap = null;

      if (menu.nameMap) f.setNameMap(omexmlMap);
      else f.setValueMap(omexmlMap);
      menu.setVisible(false);
    }
  }
Ejemplo n.º 27
0
  public void setPanel(PlotType plotType) {

    tabbedPane.removeAll();
    this.setVisible(true);

    // add plot-specific tab
    String tabTitle = plotType.getTranslatedKey(loc);
    tabbedPane.insertTab(tabTitle, null, new JScrollPane(mainPanel), null, 0);
    classesPanel.setVisible(false);
    histogramPanel.setVisible(false);
    scatterplotPanel.setVisible(false);
    barChartPanel.setVisible(false);
    boxPlotPanel.setVisible(false);

    rbNormalized.setVisible(false);
    ckOverlayNormal.setVisible(false);
    ckShowHistogram.setVisible(false);
    ckCumulative.setVisible(false);
    ckOverlayPolygon.setVisible(false);

    // add graph tab
    tabbedPane.addTab(loc.getMenu("Graph"), new JScrollPane(graphPanel));
    graphPanel.setVisible(true);
    showYAxisSettings = true;

    // set visibility for plot-specific panels
    switch (plotType) {
      case HISTOGRAM:
        classesPanel.setVisible(true);
        histogramPanel.setVisible(true);
        rbNormalized.setVisible(true);
        ckOverlayNormal.setVisible(true);
        ckShowHistogram.setVisible(true);
        ckCumulative.setVisible(true);
        ckOverlayPolygon.setVisible(true);

        layoutHistogramPanel();

        break;

      case BOXPLOT:
      case MULTIBOXPLOT:
        boxPlotPanel.setVisible(true);
        break;

      case BARCHART:
        barChartPanel.setVisible(true);
        layoutBarChartPanel();
        break;

      case SCATTERPLOT:
        scatterplotPanel.setVisible(true);
        break;

        // graph tab only
      case DOTPLOT:
      case NORMALQUANTILE:
      case RESIDUAL:
        tabbedPane.removeTabAt(0);
        break;

      case STEMPLOT:
        this.setVisible(false);
        break;
    }

    setLabels();
    updateGUI();
  }
Ejemplo n.º 28
0
package com.ufgov.zc.client.component.ui;