示例#1
0
  public void addClass() {

    int varNo = listObject.getSize();
    int opNo = listMethod.getSize();

    ClassDiagData cDD = new ClassDiagData();

    cDD.setClassName(className.getText());

    for (int i = 0; i < varNo; i++) {

      cDD.addInstanceVar(
          listObject
              .get(i)
              .toString()); // Create new data input 'template' and populate with use inputted data
    }

    for (int i = 0; i < opNo; i++) {
      cDD.addMethod(
          listMethod
              .get(i)
              .toString()); // Create new data input 'template' and populate with use inputted data
    }

    cDD.setAccessModifier("+");

    ClassDiag e =
        new ClassDiag(x, y, varNo, opNo); // Create a new class object and set the details of it
    e.setData(cDD); // Set the associated data with from the cDD.

    canvasPanel.addDrawable(e);
    canvasPanel.repaint();
    canvasPanel.setStatus("Class Created Successfully");
  }
示例#2
0
 private static Object objectOf(DefaultListModel listModel, Object objectName) {
   if (objectName instanceof String) {
     String name = (String) objectName;
     Object o;
     for (int i = listModel.size(); --i >= 0;)
       if (!((o = listModel.get(i)) instanceof String)
           && o.toString().equals(name))
         return listModel.get(i);
   }
   return objectName;
 }
  private void applyChanges() {
    boolean changedFieldSet = false; // Watch if we need to rebuild entry editors

    // First remove the mappings for fields that have been deleted.
    // If these were re-added, they will be added below, so it doesn't
    // cause any harm to remove them here.
    for (Iterator<String> i = removedFields.iterator(); i.hasNext(); ) {
      String fieldName = i.next();
      metaData.remove(Globals.SELECTOR_META_PREFIX + fieldName);
      changedFieldSet = true;
    }

    // Cycle through all fields that we have created listmodels for:
    loop:
    for (Iterator<String> i = wordListModels.keySet().iterator(); i.hasNext(); ) {
      // For each field name, store the values:
      String fieldName = i.next();
      if ((fieldName == null) || FIELD_FIRST_LINE.equals(fieldName)) continue loop;
      DefaultListModel lm = wordListModels.get(fieldName);
      int start = 0;
      // Avoid storing the <new word> marker if it is there:
      if (lm.size() > 0)
        while ((start < lm.size()) && (lm.get(start)).equals(WORD_FIRSTLINE_TEXT)) start++;
      Vector<String> data = metaData.getData(Globals.SELECTOR_META_PREFIX + fieldName);
      boolean newField = false;
      if (data == null) {
        newField = true;
        data = new Vector<String>();
        changedFieldSet = true;

      } else data.clear();
      for (int wrd = start; wrd < lm.size(); wrd++) {
        String word = (String) lm.get(wrd);
        data.add(word);
      }
      if (newField) metaData.putData(Globals.SELECTOR_META_PREFIX + fieldName, data);
    }

    // System.out.println("TODO: remove metadata for removed selector field.");
    panel.markNonUndoableBaseChanged();

    // Update all selectors in the current BasePanel.
    if (changedFieldSet) {
      panel.rebuildAllEntryEditors();
    } else {
      panel.updateAllContentSelectors();
    }
    panel.addContentSelectorValuesToAutoCompleters();
  }
 public List<BufferedImage> getExamples() {
   List<BufferedImage> list = new ArrayList<BufferedImage>();
   for (int i = 0; i < model.size(); i++) {
     Example example = (Example) model.get(i);
     list.add(example.getBufferedImage());
   }
   return list;
 }
 private int findPos(DefaultListModel lm, String item) {
   for (int i = 0; i < lm.size(); i++) {
     String s = (String) lm.get(i);
     if (item.compareToIgnoreCase(s) < 0) { // item precedes s
       return i;
     }
   }
   return lm.size();
 }
示例#6
0
 void syncLists() {
   JList list = webPanels[1 - panelIndex].instanceList;
   DefaultListModel model1 = (DefaultListModel) instanceList.getModel();
   DefaultListModel model2 = (DefaultListModel) list.getModel();
   model2.clear();
   int n = model1.getSize();
   for (int i = 0; i < n; i++)
     model2.addElement(model1.get(i));
   list.setSelectedIndices(new int[] {});
   enableButtons(instanceList);
   webPanels[1 - panelIndex].enableButtons(list);
 }
示例#7
0
 public LinkedList<String> getSourcePaths(boolean includeTestSource) {
   LinkedList<String> paths = new LinkedList<String>();
   int size = dir.getSize();
   for (int i = -1; ++i < size; ) {
     File item = (File) dir.get(i);
     if (!includeTestSource) {
       if (testSources.contains(item)) continue;
     }
     if (item.isDirectory()) {
       paths.add(item.toString());
     }
   }
   return paths;
 }
  /**
   * Removes a <tt>ConfigurationForm</tt> from this list.
   *
   * @param configForm The <tt>ConfigurationForm</tt> to remove.
   */
  public void removeConfigForm(ConfigurationForm configForm) {
    DefaultListModel listModel = (DefaultListModel) configList.getModel();

    for (int count = listModel.getSize(), i = count - 1; i >= 0; i--) {
      ConfigurationForm form = (ConfigurationForm) listModel.get(i);

      if (form.equals(configForm)) {
        listModel.remove(i);
        /*
         * TODO We may just consider not allowing duplicates on addition
         * and then break here.
         */
      }
    }
  }
  /**
   * Adds a new <tt>ConfigurationForm</tt> to this list.
   *
   * @param configForm The <tt>ConfigurationForm</tt> to add.
   */
  public void addConfigForm(ConfigurationForm configForm) {
    if (configForm == null) throw new IllegalArgumentException("configForm");

    DefaultListModel listModel = (DefaultListModel) configList.getModel();

    int i = 0;
    int count = listModel.getSize();
    int configFormIndex = configForm.getIndex();
    for (; i < count; i++) {
      ConfigurationForm form = (ConfigurationForm) listModel.get(i);

      if (configFormIndex < form.getIndex()) break;
    }
    listModel.add(i, configForm);
  }
示例#10
0
 /** @return A java exec compatible string of all jars on the classpath */
 public String getClasspath(boolean includeTestSource, String cpSep) {
   int size = dir.getSize();
   StringBuilder b = new StringBuilder();
   String prefix = "";
   for (int i = 0; i < size; i++) {
     File item = (File) dir.get(i);
     if (!includeTestSource) {
       if (testSources.contains(item)) continue;
     }
     if (item.isFile()) {
       b.append(prefix + item);
       prefix = cpSep;
     }
   }
   return b.toString();
 }
示例#11
0
  public void actionPerformed(ActionEvent e) {

    if (e.getSource() == remoteAppletPath) {//apparently no events are fired to reach this, maybe "enter" does it
      String path = remoteAppletPath.getText();
      WebExport.setAppletPath(path, true);
      return;
    }

    if (e.getSource() == localAppletPath) {//apparently no events are fired to reach this, maybe "enter" does it
      String path = localAppletPath.getText();
      WebExport.setAppletPath(path, false);
      return;
    }

    //Handle open button action.
    if (e.getSource() == addInstanceButton) {
      //make dialog to get name for instance
      //create an instance with this name.  Each instance is just a container for a string with the Jmol state
      //which contains the full information on the file that is loaded and manipulations done.
      String label = (instanceList.getSelectedIndices().length != 1 ? ""
          : getInstanceName(-1));
      String name = JOptionPane.showInputDialog(
          GT._("Give the occurrence of Jmol a name:"), label);
      if (name == null)
        return;
      //need to get the script...
      String script = viewer.getStateInfo();
      if (script == null) {
        LogPanel.log("Error trying to get Jmol State within pop_in_Jmol.");
      }
      DefaultListModel listModel = (DefaultListModel) instanceList.getModel();
      int width = 300;
      int height = 300;
      if (appletSizeSpinnerH != null) {
        width = ((SpinnerNumberModel) (appletSizeSpinnerW.getModel()))
            .getNumber().intValue();
        height = ((SpinnerNumberModel) (appletSizeSpinnerH.getModel()))
            .getNumber().intValue();
      }
      JmolInstance instance = new JmolInstance(viewer, name, script, width, height);
      if (instance == null) {
        LogPanel
            .log(GT._("Error creating new instance containing script(s) and image."));
      }

      int i;
      for (i = instanceList.getModel().getSize(); --i >= 0;)
        if (getInstanceName(i).equals(instance.name))
          break;
      if (i < 0) {
        i = listModel.getSize();
        listModel.addElement(instance);
        LogPanel.log(GT._("added Instance {0}", instance.name));
      } else {
        listModel.setElementAt(instance, i);
        LogPanel.log(GT._("updated Instance {0}", instance.name));
      }
      instanceList.setSelectedIndex(i);
      syncLists();
      return;
    }

    if (e.getSource() == deleteInstanceButton) {
      DefaultListModel listModel = (DefaultListModel) instanceList.getModel();
      //find out which are selected and remove them.
      int[] todelete = instanceList.getSelectedIndices();
      int nDeleted = 0;
      for (int i = 0; i < todelete.length; i++){
        JmolInstance instance = (JmolInstance) listModel.get(todelete[i]);
        try {
          instance.delete();
        } catch (IOException err) {
          LogPanel.log(err.getMessage());
        }
        listModel.remove(todelete[i] - nDeleted++);
      }
      syncLists();
      return;
    }

    if (e.getSource() == showInstanceButton) {
      DefaultListModel listModel = (DefaultListModel) instanceList.getModel();
      //find out which are selected and remove them.
      int[] list = instanceList.getSelectedIndices();
      if (list.length != 1)
        return;
      JmolInstance instance = (JmolInstance) listModel.get(list[0]);
      viewer.evalStringQuiet(")" + instance.script); //leading paren disabled history
      return;
    }

    if (e.getSource() == saveButton) {
      fc.setDialogTitle(GT._("Select a directory to create or an HTML file to save"));
      int returnVal = fc.showSaveDialog(this);
      if (returnVal != JFileChooser.APPROVE_OPTION)
        return;
      File file = fc.getSelectedFile();
      boolean retVal = true;
      try {
        String path = remoteAppletPath.getText();
        WebExport.setAppletPath(path, true);
        path = localAppletPath.getText();
        WebExport.setAppletPath(path, false);
        String authorName = pageAuthorName.getText();
        WebExport.setWebPageAuthor(authorName);
        retVal = fileWriter(file, instanceList);
      } catch (IOException IOe) {
        LogPanel.log(IOe.getMessage());
      }
      if (!retVal) {
        LogPanel.log(GT._("Call to FileWriter unsuccessful."));
      }
    }
    if (e.getSource() == helpButton){
      HelpDialog webExportHelp = new HelpDialog(WebExport.getFrame(), 
          WebExport.getHtmlResource(this, panelName + "_instructions"));
      webExportHelp.setVisible(true);
      webExportHelp.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    }
  }
 private void newWordAction() {
   if ((wordListModel.size() == 0) || !wordListModel.get(0).equals(WORD_FIRSTLINE_TEXT))
     wordListModel.add(0, WORD_FIRSTLINE_TEXT);
   wordList.setSelectedIndex(0);
   wPane.getVerticalScrollBar().setValue(0);
 }