コード例 #1
4
 /** Listener to handle button actions */
 public void actionPerformed(ActionEvent e) {
   // Check if the user changed the service filter option
   if (e.getSource() == service_box) {
     service_list.setEnabled(service_box.isSelected());
     service_list.clearSelection();
     remove_service_button.setEnabled(false);
     add_service_field.setEnabled(service_box.isSelected());
     add_service_field.setText("");
     add_service_button.setEnabled(false);
   }
   // Check if the user pressed the add service button
   if ((e.getSource() == add_service_button) || (e.getSource() == add_service_field)) {
     String text = add_service_field.getText();
     if ((text != null) && (text.length() > 0)) {
       service_data.addElement(text);
       service_list.setListData(service_data);
     }
     add_service_field.setText("");
     add_service_field.requestFocus();
   }
   // Check if the user pressed the remove service button
   if (e.getSource() == remove_service_button) {
     Object[] sels = service_list.getSelectedValues();
     for (int i = 0; i < sels.length; i++) {
       service_data.removeElement(sels[i]);
     }
     service_list.setListData(service_data);
     service_list.clearSelection();
   }
 }
コード例 #2
0
 /** Constructor */
 public SOAPMonitorFilter() {
   // By default, exclude NotificationService and
   // EventViewerService messages
   filter_exclude_list = new Vector();
   filter_exclude_list.addElement("NotificationService");
   filter_exclude_list.addElement("EventViewerService");
 }
コード例 #3
0
 /** Remove all messages from the table (but leave "most recent") */
 public void clearAll() {
   int last_row = data.size() - 1;
   if (last_row > 0) {
     data.removeAllElements();
     SOAPMonitorData soap = new SOAPMonitorData(null, null, null);
     data.addElement(soap);
     if (filter_data != null) {
       filter_data.removeAllElements();
       filter_data.addElement(soap);
     }
     fireTableDataChanged();
   }
 }
コード例 #4
0
 /** Add data to the table as a new row */
 public void addData(SOAPMonitorData soap) {
   int row = data.size();
   data.addElement(soap);
   if (filter_data != null) {
     if (filterMatch(soap)) {
       row = filter_data.size();
       filter_data.addElement(soap);
       fireTableRowsInserted(row, row);
     }
   } else {
     fireTableRowsInserted(row, row);
   }
 }
コード例 #5
0
ファイル: ChefTable.java プロジェクト: cks5015804/tortugades
 // add new Chef
 public void add(Chef chef) {
   _entries.addElement(chef);
   int index = _entries.size() - 1;
   _chefsByName.put(chef.getName(), new Integer(index));
   // tell TableView to update
   fireTableRowsInserted(index, index);
   fireTableRowsUpdated(index, index);
 }
コード例 #6
0
 /** Constructor */
 public SOAPMonitorTableModel() {
   data = new Vector();
   // Add "most recent" entry to top of table
   SOAPMonitorData soap = new SOAPMonitorData(null, null, null);
   data.addElement(soap);
   filter_include = null;
   filter_exclude = null;
   filter_active = false;
   filter_complete = false;
   filter_data = null;
   // By default, exclude NotificationService and
   // EventViewerService messages
   filter_exclude = new Vector();
   filter_exclude.addElement("NotificationService");
   filter_exclude.addElement("EventViewerService");
   filter_data = new Vector();
   filter_data.addElement(soap);
 }
コード例 #7
0
 /** Update a message */
 public void updateData(SOAPMonitorData soap) {
   int row;
   if (filter_data == null) {
     // No filter, so just fire table updated
     row = data.indexOf(soap);
     if (row != -1) {
       fireTableRowsUpdated(row, row);
     }
   } else {
     // Check if the row was being displayed
     row = filter_data.indexOf(soap);
     if (row == -1) {
       // Row was not displayed, so check for if it
       // now needs to be displayed
       if (filterMatch(soap)) {
         int index = -1;
         row = data.indexOf(soap) + 1;
         while ((row < data.size()) && (index == -1)) {
           index = filter_data.indexOf(data.elementAt(row));
           if (index != -1) {
             // Insert at this location
             filter_data.add(index, soap);
           }
           row++;
         }
         if (index == -1) {
           // Insert at end
           index = filter_data.size();
           filter_data.addElement(soap);
         }
         fireTableRowsInserted(index, index);
       }
     } else {
       // Row was displayed, so check if it needs to
       // be updated or removed
       if (filterMatch(soap)) {
         fireTableRowsUpdated(row, row);
       } else {
         filter_data.remove(soap);
         fireTableRowsDeleted(row, row);
       }
     }
   }
 }
コード例 #8
0
 /** Refilter the list of messages */
 public void applyFilter() {
   // Re-filter using new criteria
   filter_data = null;
   if ((filter_include != null)
       || (filter_exclude != null)
       || filter_active
       || filter_complete) {
     filter_data = new Vector();
     Enumeration e = data.elements();
     SOAPMonitorData soap;
     while (e.hasMoreElements()) {
       soap = (SOAPMonitorData) e.nextElement();
       if (filterMatch(soap)) {
         filter_data.addElement(soap);
       }
     }
   }
   fireTableDataChanged();
 }
コード例 #9
0
 public void add(SkeletonProperty prop) {
   m_props.addElement(prop);
   fireTableRowsInserted(m_props.size() - 1, m_props.size());
   fireTableStructureChanged();
 }
コード例 #10
0
 /** Reflow XML */
 public void doFormat() {
   Vector parts = new Vector();
   char[] chars = original.toCharArray();
   int index = 0;
   int first = 0;
   String part = null;
   while (index < chars.length) {
     // Check for start of tag
     if (chars[index] == '<') {
       // Did we have data before this tag?
       if (first < index) {
         part = new String(chars, first, index - first);
         part = part.trim();
         // Save non-whitespace data
         if (part.length() > 0) {
           parts.addElement(part);
         }
       }
       // Save the start of tag
       first = index;
     }
     // Check for end of tag
     if (chars[index] == '>') {
       // Save the tag
       part = new String(chars, first, index - first + 1);
       parts.addElement(part);
       first = index + 1;
     }
     // Check for end of line
     if ((chars[index] == '\n') || (chars[index] == '\r')) {
       // Was there data on this line?
       if (first < index) {
         part = new String(chars, first, index - first);
         part = part.trim();
         // Save non-whitespace data
         if (part.length() > 0) {
           parts.addElement(part);
         }
       }
       first = index + 1;
     }
     index++;
   }
   // Reflow as XML
   StringBuffer buf = new StringBuffer();
   Object[] list = parts.toArray();
   int indent = 0;
   int pad = 0;
   index = 0;
   while (index < list.length) {
     part = (String) list[index];
     if (buf.length() == 0) {
       // Just add first tag (should be XML header)
       buf.append(part);
     } else {
       // All other parts need to start on a new line
       buf.append('\n');
       // If we're at an end tag then decrease indent
       if (part.startsWith("</")) {
         indent--;
       }
       // Add any indent
       for (pad = 0; pad < indent; pad++) {
         buf.append("  ");
       }
       // Add the tag or data
       buf.append(part);
       // If this is a start tag then increase indent
       if (part.startsWith("<") && !part.startsWith("</") && !part.endsWith("/>")) {
         indent++;
         // Check for special <tag>data</tag> case
         if ((index + 2) < list.length) {
           part = (String) list[index + 2];
           if (part.startsWith("</")) {
             part = (String) list[index + 1];
             if (!part.startsWith("<")) {
               buf.append(part);
               part = (String) list[index + 2];
               buf.append(part);
               index = index + 2;
               indent--;
             }
           }
         }
       }
     }
     index++;
   }
   formatted = new String(buf);
 }
コード例 #11
0
 /** Add a page to the notebook */
 private void addPage(SOAPMonitorPage pg) {
   tabbed_pane.addTab("  " + pg.getHost() + "  ", pg);
   pages.addElement(pg);
 }
コード例 #12
0
 /** Highlights the value at the given index. */
 public void highlight(int index) {
   highlightIndex.addElement(new Integer(index));
   repaint();
 }
コード例 #13
0
 /** Registers the given ErrorEventListener as a listener to this GUI. */
 public void addErrorListener(ErrorEventListener listener) {
   errorEventListeners.addElement(listener);
 }
コード例 #14
0
 /** Registers the given ComputerPartEventListener as a listener to this GUI. */
 public void addListener(ComputerPartEventListener listener) {
   listeners.addElement(listener);
 }
コード例 #15
0
    /** Runs this thread. */
    public void run() {
      CommonFileChooser file_chooser = new CommonFileChooser();
      file_chooser.setDialogTitle("Choose a directory.");
      file_chooser.setMultiSelectionEnabled(false);
      file_chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

      if (file_chooser.showSaveDialog(pane) == JFileChooser.APPROVE_OPTION) {
        try {
          File directory = file_chooser.getSelectedFile();
          directory.mkdirs();

          // Outputs the variability XML file.

          String path = FileManager.unitePath(directory.getAbsolutePath(), "package.xml");
          File file = new File(path);
          if (file.exists()) {
            String message = "Overwrite to " + file.getPath() + " ?";
            if (0
                != JOptionPane.showConfirmDialog(
                    pane, message, "Confirmation", JOptionPane.YES_NO_OPTION)) {
              return;
            }
          }

          XmlVariabilityHolder holder = new XmlVariabilityHolder();

          Variability[] records = getSelectedRecords();
          for (int i = 0; i < records.length; i++) {
            XmlVariability variability = new XmlVariability(records[i]);
            holder.addVariability(variability);
          }

          holder.write(file);

          // Copies the report XML document files.

          Hashtable hash_xml = new Hashtable();

          for (int i = 0; i < records.length; i++) {
            XmlMagRecord[] mag_records = records[i].getMagnitudeRecords();
            for (int j = 0; j < mag_records.length; j++)
              hash_xml.put(mag_records[j].getImageXmlPath(), this);
          }

          Vector failed_list = new Vector();

          Enumeration keys = hash_xml.keys();
          while (keys.hasMoreElements()) {
            String xml_path = (String) keys.nextElement();
            try {
              File src_file = desktop.getFileManager().newFile(xml_path);
              File dst_file =
                  new File(FileManager.unitePath(directory.getAbsolutePath(), xml_path));
              if (dst_file.exists() == false) FileManager.copy(src_file, dst_file);
            } catch (Exception exception) {
              failed_list.addElement(xml_path);
            }
          }

          if (failed_list.size() > 0) {
            String header = "Failed to copy the following XML files:";
            MessagesDialog dialog = new MessagesDialog(header, failed_list);
            dialog.show(pane, "Error", JOptionPane.ERROR_MESSAGE);
          }

          // Copies the image files.

          failed_list = new Vector();

          keys = hash_xml.keys();
          while (keys.hasMoreElements()) {
            path = (String) keys.nextElement();
            try {
              XmlInformation info =
                  XmlReport.readInformation(desktop.getFileManager().newFile(path));
              path = info.getImage().getContent();

              File src_file = desktop.getFileManager().newFile(path);
              File dst_file = new File(FileManager.unitePath(directory.getAbsolutePath(), path));
              if (dst_file.exists() == false) FileManager.copy(src_file, dst_file);
            } catch (Exception exception) {
              failed_list.addElement(path);
            }
          }

          if (failed_list.size() > 0) {
            String header = "Failed to copy the following image files:";
            MessagesDialog dialog = new MessagesDialog(header, failed_list);
            dialog.show(pane, "Error", JOptionPane.ERROR_MESSAGE);
          }

          // Creates the sub catalog database.

          try {
            DiskFileSystem file_system =
                new DiskFileSystem(
                    new File(
                        directory.getAbsolutePath(),
                        net.aerith.misao.pixy.Properties.getDatabaseDirectoryName()));
            CatalogDBManager new_manager = new GlobalDBManager(file_system).getCatalogDBManager();

            Hashtable hash_stars = new Hashtable();
            for (int i = 0; i < records.length; i++) {
              CatalogStar star = records[i].getStar();

              CatalogDBReader reader =
                  new CatalogDBReader(desktop.getDBManager().getCatalogDBManager());
              StarList list = reader.read(star.getCoor(), 0.5);
              for (int j = 0; j < list.size(); j++) {
                CatalogStar s = (CatalogStar) list.elementAt(j);
                hash_stars.put(s.getOutputString(), s);
              }
            }

            keys = hash_stars.keys();
            while (keys.hasMoreElements()) {
              String string = (String) keys.nextElement();
              CatalogStar star = (CatalogStar) hash_stars.get(string);
              new_manager.addElement(star);
            }
          } catch (Exception exception) {
            String message = "Failed to create sub catalog database.";
            JOptionPane.showMessageDialog(pane, message, "Error", JOptionPane.ERROR_MESSAGE);
          }

          String message = "Completed.";
          JOptionPane.showMessageDialog(pane, message);
        } catch (IOException exception) {
          String message = "Failed.";
          JOptionPane.showMessageDialog(pane, message, "Error", JOptionPane.ERROR_MESSAGE);
        }
      }
    }