Exemplo n.º 1
0
  public FileTreePane() {
    loadDynamicComponentFxml(FileTreePane.class, this);
    rootFileTreeItem = new RootFileTreeItem(this);

    // The root here is *not* the real root of the file system and should be hidden, because
    // (1) we might want to have 'virtual' visible roots like "Home", "Desktop", "Drives" and
    // (2) even if we displayed only the real file system without any shortcuts like "Desktop",
    // we'd still have multiple roots on a crappy pseudo-OS like Windows still having these shitty
    // drive letters.
    treeTableView.setShowRoot(false);
    treeTableView.setRoot(rootFileTreeItem);
    treeTableView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    treeTableView
        .getSelectionModel()
        .selectedItemProperty()
        .addListener(
            (ChangeListener<TreeItem<FileTreeItem<?>>>)
                (observable, o, n) -> updateSelectedFiles());
    treeTableView
        .getSelectionModel()
        .getSelectedItems()
        .addListener((InvalidationListener) observable -> updateSelectedFiles());

    selectedFiles.addListener(selectedFilesChangeListener);
    showHiddenFilesCheckBox.selectedProperty().bindBidirectional(showHiddenFilesProperty);

    // TODO remove the following line - preferably replace by proper, use-case-dependent management!
    selectedFiles.add(IOUtil.getUserHome());
    updateDisable();
  }
  @Test
  public void testAddOnModeratorSetListener() throws Exception {

    instance.onUserJoinedChannel(DEFAULT_CHANNEL_NAME, chatUser1);

    ObservableSet<String> moderatorInChannels =
        instance
            .getChatUsersForChannel(DEFAULT_CHANNEL_NAME)
            .get(chatUser1.getUsername())
            .getModeratorInChannels();

    assertThat(moderatorInChannels, empty());

    instance.onModeratorSet(DEFAULT_CHANNEL_NAME, chatUser1.getUsername());

    assertThat(moderatorInChannels, hasSize(1));
    assertThat(moderatorInChannels.iterator().next(), is(DEFAULT_CHANNEL_NAME));
  }
Exemplo n.º 3
0
  /**
   * Remove a buyer from the registry as they exit the market
   *
   * @param buyer buyer exiting the market
   */
  public void deregisterBuyer(EconomicAgent buyer) {
    boolean isNew = buyers.remove(buyer);
    assert isNew; // make sure it wasn't there before!

    if (MacroII.hasGUI()) {
      // todo logtodo

      network.removeAgent(buyer);
    }
  }
Exemplo n.º 4
0
  /**
   * Remove a seller from the registry as they exit the market
   *
   * @param seller seller exiting the market
   */
  public void deregisterSeller(EconomicAgent seller) {
    boolean isNew = sellers.remove(seller);
    assert isNew; // make sure it wasn't there before!

    if (MacroII.hasGUI()) {
      // todo logtodo

      // remove agent to the network
      network.removeAgent(seller);
    }
  }
Exemplo n.º 5
0
  /**
   * Add a buyer to the registry as they enter the market
   *
   * @param buyer buyer entering the market
   */
  public void registerBuyer(EconomicAgent buyer) {
    boolean isNew = buyers.add(buyer); // addSalesDepartmentListener it to the set
    assert isNew; // make sure it wasn't there before!

    // record it, if necessary
    if (MacroII.hasGUI()) {
      // todo logtodo

      network.addAgent(buyer);
    }
  }
Exemplo n.º 6
0
  private void updateSelectedFiles() {
    assertFxApplicationThread();

    if (updatingSelectedFiles) return;

    updatingSelectedFiles = true;
    try {
      final ObservableList<TreeItem<FileTreeItem<?>>> selectedItems =
          treeTableView.getSelectionModel().getSelectedItems();
      final Set<File> newSelectedFiles = new HashSet<File>(selectedItems.size());
      for (final TreeItem<FileTreeItem<?>> selectedItem : selectedItems) {
        final FileTreeItem<?> fileTreeItem =
            selectedItem == null
                ? null
                : selectedItem.getValue(); // strange but true: it can be null
        if (fileTreeItem instanceof FileFileTreeItem)
          newSelectedFiles.add(((FileFileTreeItem) fileTreeItem).getFile());
      }
      selectedFiles.retainAll(newSelectedFiles);
      selectedFiles.addAll(newSelectedFiles);
    } finally {
      updatingSelectedFiles = false;
    }
  }
Exemplo n.º 7
0
 public void removeListenerFromBuyerSet(
     SetChangeListener<? super EconomicAgent> setChangeListener) {
   buyers.removeListener(setChangeListener);
 }
Exemplo n.º 8
0
 public void addListenerToBuyerSet(SetChangeListener<? super EconomicAgent> setChangeListener) {
   buyers.addListener(setChangeListener);
 }
Exemplo n.º 9
0
 @Test
 public void mirroredSet() throws Exception {
   ObservableSet<String> source = FXCollections.observableSet();
   source.add("alpha");
   source.add("beta");
   ObservableSet<String> dest = ObservableMirrors.mirrorSet(source, gate);
   assertEquals(0, gate.getTaskQueueSize());
   assertEquals(2, dest.size());
   source.add("delta");
   assertEquals(1, gate.getTaskQueueSize());
   assertEquals(2, dest.size());
   gate.waitAndRun();
   assertEquals(0, gate.getTaskQueueSize());
   assertEquals(3, dest.size());
   source.removeAll(ImmutableList.of("alpha", "beta"));
   assertEquals(2, gate.getTaskQueueSize());
   gate.waitAndRun();
   gate.waitAndRun();
   assertEquals(1, dest.size());
   assertTrue(dest.contains("delta"));
 }