示例#1
0
  void handleScanFiles(JTextField field, String[] extensions) {
    String[] dataFiles = scanDataFolderForFilesByType(extensions);
    if (dataFiles == null || dataFiles.length == 0) return;

    String[] oldFileList = field.getText().trim().split(",");
    ArrayList<String> newFileList = new ArrayList<String>();
    for (String c : oldFileList) {
      c = c.trim();
      if (!c.equals("") && newFileList.indexOf(c) == -1) // TODO check exists() here?
      {
        newFileList.add(c);
      }
    }
    for (String c : dataFiles) {
      c = c.trim();
      if (!c.equals("") && newFileList.indexOf(c) == -1) {
        newFileList.add(c);
      }
    }
    Collections.sort(newFileList);
    String finalFileList = "";
    int i = 0;
    for (String s : newFileList) {
      finalFileList += (i > 0 ? ", " : "") + s;
      i++;
    }
    field.setText(finalFileList);
  }
示例#2
0
  private void parseDirective(String directive) {
    if (directive == null) {
      System.err.println("Directive is null.");
      return;
    }

    String[] pair = directive.split("=");
    if (pair == null || pair.length != 2) {
      System.err.println("Unable to parse directive: \"" + directive + "\" Ignored.");
      return;
    }

    String key = pair[0].trim(), value = pair[1].trim();

    // clean these, might have too much whitespace around commas
    if (validKeys.indexOf(key) == FONT || validKeys.indexOf(key) == PRELOAD) {
      value = value.replaceAll("[\\s]*,[\\s]*", ",");
    }

    if (validKeys.indexOf(key) == -1) {
      System.err.println("Directive key not recognized: \"" + key + "\" Ignored.");
      return;
    }
    if (value.equals("")) {
      System.err.println("Directive value empty. Ignored.");
      return;
    }

    value = value.replaceAll("^\"|\"$", "").replaceAll("^'|'$", "");

    // System.out.println( key + " = " + value );

    boolean v;
    switch (validKeys.indexOf(key)) {
      case CRISP:
        v = value.toLowerCase().equals("true");
        crispBox.setSelected(v);
        break;
      case FONT:
        fontField.setText(value);
        break;
      case GLOBAL_KEY_EVENTS:
        v = value.toLowerCase().equals("true");
        globalKeyEventsBox.setSelected(v);
        break;
      case PAUSE_ON_BLUR:
        v = value.toLowerCase().equals("true");
        pauseOnBlurBox.setSelected(v);
        break;
      case PRELOAD:
        preloadField.setText(value);
        break;
      case TRANSPARENT:
        v = value.toLowerCase().equals("true");
        // transparentBox.setSelected(v);
        break;
    }
  }
示例#3
0
 /**
  * removes a user from the user list
  *
  * @param un the name of the user to be removed
  */
 public void userDel(String un) {
   users.remove(users.indexOf(un));
   if (ignores.contains(un)) {
     ignores.remove(ignores.indexOf(un));
   }
   if (afks.contains(un)) {
     afks.remove(afks.indexOf(un));
   }
   if (admins.contains(un)) {
     admins.remove(admins.indexOf(un));
   }
   updateList();
   serverMessage(un + " has left " + server.channel);
   privates.serverMessage(un, un + " has left");
 }
示例#4
0
 /**
  * changes the name of a user, updating list of admins, afks, ignoes, and master user list
  *
  * @param on old username
  * @param nn new username
  */
 public void rename(String on, String nn) {
   if (admins.contains(on)) {
     admins.remove(admins.indexOf(on));
     admins.add(nn);
   }
   if (afks.contains(on)) {
     afks.remove(afks.indexOf(on));
     afks.add(nn);
   }
   if (ignores.contains(on)) {
     ignores.remove(ignores.indexOf(on));
     ignores.add(nn);
   }
   users.remove(on);
   users.add(nn);
   updateList();
   serverMessage(on + " renamed to " + nn);
 }
示例#5
0
  // Mutators
  public void vote(String candidate) {
    // update the array of votes to reflect the user selection
    int index = _candidates.indexOf(candidate);
    if (index != -1) {
      _votes[index]++;
      System.out.println("Voted for: " + _candidates.get(index));
      System.out.println("Current votes: " + _votes[index]);

    } else {
      System.out.println("No vote");
    }
  }
  private ProgressIndicatorEx removeFromMaps(@NotNull InlineProgressIndicator progress) {
    final ProgressIndicatorEx original = myInline2Original.get(progress);

    myInline2Original.remove(progress);

    myOriginal2Inlines.remove(original, progress);
    if (myOriginal2Inlines.get(original) == null) {
      final int originalIndex = myOriginals.indexOf(original);
      myOriginals.remove(originalIndex);
      myInfos.remove(originalIndex);
    }

    return original;
  }
示例#7
0
  String[] scanDataFolderForFilesByType(String[] extensions) {
    ArrayList files = new ArrayList();
    File dataFolder = editor.getSketch().getDataFolder();

    if (!dataFolder.exists()) return null; // TODO no folder present .. warn?

    for (String ext : extensions) {
      String[] found = listFiles(dataFolder, true, ext);
      if (found == null || found.length == 0) continue;

      for (String f : found) {
        if (files.indexOf(f) == -1) files.add(f);
      }
    }

    return (String[]) files.toArray(new String[0]);
  }
示例#8
0
 // Accessors
 public int getIndex(String candidate) {
   return _candidates.indexOf(candidate);
 }
 public int indexOf(Figure figure) {
   return children.indexOf(figure);
 }
示例#10
0
 public void setEnabled(String strTxt, boolean bEnabled) {
   if (m_aListValues != null && m_aListValues.contains(strTxt)) {
     setEnabled(m_aListValues.indexOf(strTxt), bEnabled);
   }
 }