Пример #1
1
    @Override
    public void run() {
      while (true) {
        if (istWindows()) aktuell = holeLaufwerkeWindows();
        else aktuell = holeLaufwerkeUnix();

        if (initial.size() != aktuell.size()) {
          if (!initial.containsAll(aktuell)) {
            neuesLaufwerk = holePathVonNeuemLaufwerk(initial, aktuell);
            textArea.append("Neues Laufwerk endeckt:  " + neuesLaufwerk + System.lineSeparator());
            this.initial = (ArrayList<Path>) aktuell.clone();
            neuesLaufwerkDialog();

          } else {
            this.initial = (ArrayList<Path>) aktuell.clone();
            textArea.append("Laufwerk wurde entfernt" + System.lineSeparator());
          }
        }

        try {
          Thread.sleep(5000);
        } catch (InterruptedException e) {
          System.out.println("Laufwerksprüfung wird abgebrochen");
        }
      }
    }
Пример #2
1
  private void updateTemplateFromEditor(PrintfTemplate template) {
    ArrayList params = new ArrayList();
    String format = null;
    int text_length = editorPane.getDocument().getLength();
    try {
      format = editorPane.getDocument().getText(0, text_length);
    } catch (BadLocationException ex1) {
    }
    Element section_el = editorPane.getDocument().getDefaultRootElement();
    // Get number of paragraphs.
    int num_para = section_el.getElementCount();
    for (int p_count = 0; p_count < num_para; p_count++) {
      Element para_el = section_el.getElement(p_count);
      // Enumerate the content elements
      int num_cont = para_el.getElementCount();
      for (int c_count = 0; c_count < num_cont; c_count++) {
        Element content_el = para_el.getElement(c_count);
        AttributeSet attr = content_el.getAttributes();
        // Get the name of the style applied to this content element; may be null
        String sn = (String) attr.getAttribute(StyleConstants.NameAttribute);
        // Check if style name match
        if (sn != null && sn.startsWith("Parameter")) {
          // we extract the label.
          JLabel l = (JLabel) StyleConstants.getComponent(attr);
          if (l != null) {
            params.add(l.getName());
          }
        }
      }
    }

    template.setFormat(format);
    template.setTokens(params);
  }
Пример #3
0
 /**
  * Method to ignore all incoming messages from a user
  *
  * @param i the user to ignore
  * @param quite if true will not show confirmation
  * @return true on succes, false on failure
  */
 private boolean ignore(String i, boolean quiet) {
   if (username.equals(i) || i.equals("server") || admins.contains(i)) {
     if (!quiet) {
       error("can't ignore that person");
     }
     return false;
   }
   if (!users.contains(i)) {
     if (!quiet) {
       error("user does not exists");
     }
     return false;
   }
   if (ignores.contains(i)) {
     if (!quiet) {
       error("already ignoring user");
     }
     return false;
   }
   ignores.add(i);
   updateList();
   if (!quiet) {
     serverMessage("ignoring " + i);
   }
   return true;
 }
Пример #4
0
 /**
  * Returns all editors.
  *
  * @return editors
  */
 EditorArea[] editors() {
   final ArrayList<EditorArea> edits = new ArrayList<EditorArea>();
   for (final Component c : tabs.getComponents()) {
     if (c instanceof EditorArea) edits.add((EditorArea) c);
   }
   return edits.toArray(new EditorArea[edits.size()]);
 }
 public Object[] getChildElements() {
   Object[] elements = new Object[myChildElements.size()];
   for (int i = 0; i < myChildElements.size(); i++) {
     elements[i] = myChildElements.get(i).myElement;
   }
   return elements;
 }
 public void bringToFront(Figure figure) {
   if (children.remove(figure)) {
     children.add(figure);
     needsSorting = true;
     fireAreaInvalidated(figure.getDrawingArea());
   }
 }
 public void sendToBack(Figure figure) {
   if (children.remove(figure)) {
     children.add(0, figure);
     needsSorting = true;
     fireAreaInvalidated(figure.getDrawingArea());
   }
 }
 public Figure basicRemoveChild(int index) {
   Figure figure = children.get(index);
   children.remove(index);
   quadTree.remove(figure);
   figure.removeFigureListener(figureHandler);
   needsSorting = true;
   return figure;
 }
 InstanceListModel(ASDGrammar grammar, String word) {
   ArrayList instanceList = grammar.lookupWord(word);
   for (Iterator it = instanceList.iterator(); it.hasNext(); ) {
     ASDGrammarNode n = (ASDGrammarNode) it.next();
     String instance = (String) n.instance();
     this.addElement(instance);
   }
 }
Пример #10
0
  /** Loads the icons for the tile patterns list. */
  private void loadIcons() {

    tilePatternIcons.clear();

    for (TilePattern tilePattern : tileset.getTilePatterns()) {
      tilePatternIcons.add(new TilePatternIcon(tilePattern, tileset));
    }
  }
Пример #11
0
 /**
  * adds a new user to the interal list of users
  *
  * @param un the name of the user to be added
  */
 public void userAdd(String un) {
   if (!users.contains(un)) {
     users.add(un);
     updateList();
     if (!un.equals(username) && showUserStatus)
       serverMessage(un + " has joined " + server.channel);
   }
 }
Пример #12
0
    public void valueChanged(ListSelectionEvent evt) {
      if (!evt.getValueIsAdjusting()) {
        JFileChooser chooser = getFileChooser();
        FileSystemView fsv = chooser.getFileSystemView();
        JList list = (JList) evt.getSource();

        int fsm = chooser.getFileSelectionMode();
        boolean useSetDirectory = usesSingleFilePane && (fsm == JFileChooser.FILES_ONLY);

        if (chooser.isMultiSelectionEnabled()) {
          File[] files = null;
          Object[] objects = list.getSelectedValues();
          if (objects != null) {
            if (objects.length == 1
                && ((File) objects[0]).isDirectory()
                && chooser.isTraversable(((File) objects[0]))
                && (useSetDirectory || !fsv.isFileSystem(((File) objects[0])))) {
              setDirectorySelected(true);
              setDirectory(((File) objects[0]));
            } else {
              ArrayList<File> fList = new ArrayList<File>(objects.length);
              for (Object object : objects) {
                File f = (File) object;
                boolean isDir = f.isDirectory();
                if ((chooser.isFileSelectionEnabled() && !isDir)
                    || (chooser.isDirectorySelectionEnabled() && fsv.isFileSystem(f) && isDir)) {
                  fList.add(f);
                }
              }
              if (fList.size() > 0) {
                files = fList.toArray(new File[fList.size()]);
              }
              setDirectorySelected(false);
            }
          }
          chooser.setSelectedFiles(files);
        } else {
          File file = (File) list.getSelectedValue();
          if (file != null
              && file.isDirectory()
              && chooser.isTraversable(file)
              && (useSetDirectory || !fsv.isFileSystem(file))) {

            setDirectorySelected(true);
            setDirectory(file);
            if (usesSingleFilePane) {
              chooser.setSelectedFile(null);
            }
          } else {
            setDirectorySelected(false);
            if (file != null) {
              chooser.setSelectedFile(file);
            }
          }
        }
      }
    }
Пример #13
0
  public ArrayList<String> getNewFoe(int race, int name) {
    ArrayList<String> foeDes = new ArrayList<>();
    int index = 0;
    switch (race) {
      case 1:
        index = characters.indexOf("Gnome");
        break;

      case 2:
        index = characters.indexOf("Halfling");
        break;

      case 3:
        index = characters.indexOf("Goblin");
        break;

      case 4:
        index = characters.indexOf("Human");
        break;

      case 5:
        index = characters.indexOf("Dwarf");
        break;

      case 6:
        index = characters.indexOf("Elf");
        break;

      case 7:
        index = characters.indexOf("Orc");
        break;

      case 8:
        index = characters.indexOf("Troll");
        break;

      default:
        System.out.println("Couldn't generate characters");
        System.exit(1);
        break;
    }
    String temp = characters.substring(index);
    // need to remove an extra line if female because of file format
    if (name > 10) {
      index = temp.indexOf("\n");
      temp = temp.substring(index + 1);
    }
    for (; name > 0; name--) {
      index = temp.indexOf("\n");
      temp = temp.substring(index + 1);
    }
    index = temp.indexOf(" ");
    foeDes.add(temp.substring(0, index));
    foeDes.add(temp.substring(index + 1, temp.indexOf("\n")));
    return foeDes;
  }
Пример #14
0
 /**
  * constructor
  *
  * @param values list of values, ArrayList
  */
 public MPopButton(ArrayList values) {
   this();
   for (int i = 0; i < values.size(); i++) {
     JMenuItem item = popup.add((String) values.get(i));
     item.addActionListener(popActionListener);
     popup.add(item);
   }
   m_aListValues = values;
   setDefaultText();
 } // MPopButton()
 public Object getChild(Object parent, int index) {
   ArrayList<Field> fields = ((Variable) parent).getFields();
   Field f = (Field) fields.get(index);
   Object parentValue = ((Variable) parent).getValue();
   try {
     return new Variable(f.getType(), f.getName(), f.get(parentValue));
   } catch (IllegalAccessException e) {
     return null;
   }
 }
Пример #16
0
 private ArrayList<Path> holeLaufwerkeUnix() {
   ArrayList<Path> laufwerksRoot = new ArrayList<>();
   for (FileStore store : FileSystems.getDefault().getFileStores()) {
     if (store.name().contains("/dev/sd")) {
       laufwerksRoot.add(
           Paths.get(store.toString().substring(0, store.toString().indexOf(' '))));
     }
   }
   return laufwerksRoot;
 }
Пример #17
0
    private ArrayList<Path> holeLaufwerkeWindows() {
      ArrayList<Path> laufwerksRoot = new ArrayList<>();

      Iterable<Path> rootDirectories = FileSystems.getDefault().getRootDirectories();

      for (Path path : rootDirectories) {
        laufwerksRoot.add(path.getRoot());
      }
      return laufwerksRoot;
    }
Пример #18
0
 // returns 0: diary 1: diary start time
 public ArrayList<String> getDiary() {
   ArrayList<String> info = new ArrayList<>();
   int index = game.indexOf("Time:");
   info.add(game.substring(0, index));
   game = game.substring(index);
   index = game.indexOf("\n");
   info.add(game.substring(6, index));
   game = game.substring(index + 1);
   return info;
 }
Пример #19
0
 /** The only richer format supported is the file list flavor */
 protected Object getRicherData(DataFlavor flavor) {
   if (DataFlavor.javaFileListFlavor.equals(flavor)) {
     ArrayList<Object> files = new ArrayList<Object>();
     for (Object file : this.fileData) {
       files.add(file);
     }
     return files;
   }
   return null;
 }
 /** Implementation note: Sorting can not be done for orphaned children. */
 public java.util.List<Figure> sort(Collection<Figure> c) {
   ensureSorted();
   ArrayList<Figure> sorted = new ArrayList<Figure>(c.size());
   for (Figure f : children) {
     if (c.contains(f)) {
       sorted.add(f);
     }
   }
   return sorted;
 }
Пример #21
0
 /** cleans up a connection by removing all user from all maintained lists */
 public void close() {
   error("Connection to server was lost");
   admin = false;
   users.clear();
   afks.clear();
   ignores.clear();
   admins.clear();
   channels.clear();
   cboChannels.removeAllItems();
   updateList();
 }
Пример #22
0
 public ArrayList<String> getNewTres(int race, boolean raceTres, int tresNum) {
   ArrayList<String> tresDes = new ArrayList<>();
   String temp = treasures;
   int index;
   for (; tresNum > 0; tresNum--) {
     index = temp.indexOf("\n");
     temp = temp.substring(index + 1);
   }
   index = temp.indexOf(":");
   tresDes.add(temp.substring(0, index));
   tresDes.add(temp.substring(index + 2, temp.indexOf("\n")));
   return tresDes;
 }
Пример #23
0
 public ArrayList<String> getNewWep(int race, boolean raceWep, int wepNum) {
   ArrayList<String> wepDes = new ArrayList<>();
   String temp = weapons;
   int index;
   for (; wepNum > 0; wepNum--) {
     index = temp.indexOf("\n");
     temp = temp.substring(index + 1);
   }
   index = temp.indexOf(":");
   wepDes.add(temp.substring(0, index));
   wepDes.add(temp.substring(index + 2, temp.indexOf("\n")));
   return wepDes;
 }
Пример #24
0
 public boolean hasMorePaths() {
   if (game.indexOf("Path") == 0) {
     path = new ArrayList<>();
     // extract name & description
     int index = game.indexOf("\n");
     String info = game.substring(5, index);
     game = game.substring(index + 1);
     index = info.indexOf(":");
     path.add(info.substring(0, index));
     path.add(info.substring(index + 2));
     return true;
   }
   return false;
 }
Пример #25
0
 @Override
 public void mouseClicked(MouseEvent e) {
   ArrayList list = getSelectedMessages();
   if (list.size() == 0) {
     deleteBut.setVisible(false);
     restoreBut.setVisible(false);
   } else {
     deleteBut.setVisible(true);
     if (Home.titlePan.getTitle().equals("Trash")) {
       restoreBut.setVisible(true);
       System.out.println("Here inside");
     }
   }
 }
Пример #26
0
  /**
   * Gets the list of selected records.
   *
   * @return the list of selected records.
   */
  public Variability[] getSelectedRecords() {
    ArrayList list = new ArrayList();

    int check_column = getCheckColumn();
    for (int i = 0; i < model.getRowCount(); i++) {
      if (((Boolean) getValueAt(i, check_column)).booleanValue()) {
        Variability record = (Variability) record_list.elementAt(index.get(i));
        list.add(record);
      }
    }

    Variability[] records = new Variability[list.size()];
    return (Variability[]) list.toArray(records);
  }
 WordListModel(ASDGrammar grammar) {
   Set entrySet = grammar.lexicon().entrySet();
   ArrayList words = new ArrayList(entrySet.size());
   for (Iterator it = entrySet.iterator(); it.hasNext(); ) {
     Map.Entry e = (Map.Entry) it.next();
     String word = (String) e.getKey();
     words.add(word);
   }
   Object[] wordArray = words.toArray();
   if (words.size() > 1)
     //       Arrays.sort(wordArray);
     Arrays.sort(wordArray, new WordComparator());
   for (int j = 0; j < wordArray.length; j++) {
     this.addElement((String) wordArray[j]);
   }
 }
Пример #28
0
 public boolean hasMoreWeps() {
   if (game.indexOf("Weapon") == 0) {
     wep = new ArrayList<>();
     // extract name & description
     int index = game.indexOf("\n");
     String info = game.substring(7, index);
     game = game.substring(index + 1);
     index = info.indexOf(":");
     wep.add(info.substring(0, index));
     wep.add(info.substring(index + 2, info.indexOf("Force:") - 1));
     // extract force
     wep.add(info.substring(info.lastIndexOf(":") + 2).trim());
     return true;
   }
   return false;
 }
Пример #29
0
 public boolean hasMoreTres() {
   if (game.indexOf("Treasure") == 0) {
     tres = new ArrayList<>();
     // extract name & description
     int index = game.indexOf("\n");
     String info = game.substring(9, index);
     game = game.substring(index + 1);
     index = info.indexOf(":");
     tres.add(info.substring(0, index));
     tres.add(info.substring(index + 2, info.indexOf("Value:") - 1));
     // extract value
     tres.add(info.substring(info.lastIndexOf(":") + 2).trim());
     return true;
   }
   return false;
 }
Пример #30
-8
 public ArrayList getSelectedMessages() {
   ArrayList list = new ArrayList();
   for (int i = 0; i < table.getRowCount(); i++) {
     if (((Boolean) table.getValueAt(i, 0)) == true) {
       list.add(msgID[i]);
     }
   }
   return list;
 }