Ejemplo n.º 1
0
  @Inject
  public FileDetailsCtrl(FileNavigationState navState) {
    this.navState = navState;
    this.navState.selectedFileProperty().addListener(new SelectedFileListener());

    listFiles = FXCollections.observableList(new ArrayList<>());
    fileDetails = FXCollections.observableList(new ArrayList<>());

    fileGrid.setCellHeight(80);
    fileGrid.setCellWidth(100);

    fileGrid.getItems().addAll(listFiles);
    fileDetailsList.getItems().addAll(fileDetails);
  }
Ejemplo n.º 2
0
/** Created by bradley on 27/03/15. */
public class Team extends Item {
  private final ObservableList<Allocation> allocations = FXCollections.observableArrayList();
  private final StringProperty shortName;
  private final StringProperty description;
  private final ObjectProperty<Person> productOwner = new SimpleObjectProperty<>();
  private final ObjectProperty<Person> scrumMaster = new SimpleObjectProperty<>();
  private final ObservableList<Person> teamMembers =
      FXCollections.observableArrayList(
          person -> new Observable[] {person.shortNameProperty(), person.teamProperty()});
  private final ObservableList<Person> devTeam =
      FXCollections.observableArrayList(
          person -> new Observable[] {person.shortNameProperty(), person.teamProperty()});

  /** No-args constructor for JavaBeans(TM) compliance. Use at your own risk. */
  public Team() {
    shortName = new SimpleStringProperty("");
    description = new SimpleStringProperty("");
  }

  public Team(String shortName, String description, List<Person> teamMembers) {
    this.shortName = new SimpleStringProperty(shortName);
    this.description = new SimpleStringProperty(description);
    this.teamMembers.addAll(teamMembers);
  }

  /** @return a string array of the searchable fields for a model object */
  @Override
  public List<SearchableField> getSearchableStrings() {
    List<SearchableField> searchString = new ArrayList<>();
    searchString.addAll(
        Arrays.asList(
            new SearchableField("Short Name", getShortName()),
            new SearchableField("Description", getDescription())));
    searchString.add(new SearchableField("Members", Utilities.commaSeparatedValues(teamMembers)));
    if (productOwnerProperty().get() != null)
      searchString.add(new SearchableField("PO", getProductOwner().getShortName()));
    if (scrumMasterProperty().get() != null)
      searchString.add(new SearchableField("SM", getScrumMaster().getShortName()));
    return searchString;
  }

  @Override
  public StringProperty shortNameProperty() {
    return shortName;
  }

  public StringProperty descriptionProperty() {
    return description;
  }

  public ObjectProperty<Person> productOwnerProperty() {
    return productOwner;
  }

  public ObjectProperty<Person> scrumMasterProperty() {
    return scrumMaster;
  }

  @Override
  public String getShortName() {
    return shortName.get();
  }

  public void setShortName(String shortName) {
    this.shortName.set(shortName);
  }

  public ObservableList<Person> observableTeamMembers() {
    return teamMembers;
  }

  public List<Person> getTeamMembers() {
    List<Person> list = new ArrayList<>();
    list.addAll(teamMembers);
    return list;
  }

  public void setTeamMembers(List<Person> teamMembers) {
    this.teamMembers.clear();
    this.teamMembers.addAll(teamMembers);
  }

  public String getDescription() {
    return description.get();
  }

  public void setDescription(String description) {
    this.description.set(description);
  }

  public Person getProductOwner() {
    return productOwner.get();
  }

  public void setProductOwner(Person productOwner) {
    this.productOwner.set(productOwner);
  }

  public Person getScrumMaster() {
    return scrumMaster.get();
  }

  public void setScrumMaster(Person scrumMaster) {
    this.scrumMaster.set(scrumMaster);
  }

  public ObservableList<Person> observableDevTeam() {
    return devTeam;
  }

  public List<Person> getDevTeam() {
    List<Person> list = new ArrayList<>();
    list.addAll(devTeam);
    return list;
  }

  public void setDevTeam(List<Person> devTeam) {
    this.devTeam.clear();
    this.devTeam.addAll(devTeam);
  }

  public List<Allocation> getAllocations() {
    final ArrayList<Allocation> allocations1 = new ArrayList<>();
    allocations1.addAll(allocations);
    return allocations1;
    //        return Collections.unmodifiableList(allocations);
  }

  public void setAllocations(List<Allocation> allocations) {
    this.allocations.setAll(allocations);
  }

  public ObservableList<Allocation> observableAllocations() {
    return allocations;
  }

  @Override
  public String toString() {
    final StringBuilder sb = new StringBuilder();
    sb.append("Team{" + getShortName());
    sb.append(", description=" + getDescription());
    sb.append(", productOwner=");
    if (getProductOwner() != null) {
      sb.append(getProductOwner().getShortName());
    }
    sb.append(", scrumMaster=");
    if (getScrumMaster() != null) {
      sb.append(getScrumMaster().getShortName());
    }
    sb.append(", teamMembers=" + Utilities.commaSeparatedValues(observableTeamMembers()));
    sb.append(", devTeam=" + Utilities.commaSeparatedValues(observableDevTeam()));
    sb.append('}');
    return sb.toString();
  }

  @Override
  public void initBoundPropertySupport() {
    bps.addPropertyChangeSupportFor(shortName);
    bps.addPropertyChangeSupportFor(description);
    bps.addPropertyChangeSupportFor(productOwner);
    bps.addPropertyChangeSupportFor(scrumMaster);
    bps.addPropertyChangeSupportFor(teamMembers);
    bps.addPropertyChangeSupportFor(devTeam);
    bps.addPropertyChangeSupportFor(allocations);
  }
}
/**
 * FXML Controller class
 *
 * @author Mostafa Ali <*****@*****.**>
 */
public class InteractionsListController extends VBox {

  // Logger
  private static final Logger logger = LogManager.getLogger();

  @FXML private TableView<InteractionState> InteractionTableView;
  @FXML private TableColumn<InteractionState, String> InteractionTableColumn;
  @FXML private TableColumn CheckTableColumn;

  CheckBox cb = new CheckBox();
  ObservableList<InteractionState> interactions = FXCollections.observableArrayList();

  public InteractionsListController() {
    logger.entry();
    FXMLLoader fxmlLoader =
        new FXMLLoader(getClass().getResource("/fxml/customcontrol/InteractionsList.fxml"));
    fxmlLoader.setController(this);
    fxmlLoader.setRoot(this);
    try {
      fxmlLoader.load();

    } catch (IOException ex) {
      logger.log(Level.FATAL, ex.getMessage(), ex);
    }
    logger.exit();
  }

  public void setFddObjectModel(FddObjectModel fddObjectModel) {
    logger.entry();
    if (fddObjectModel != null) {
      fddObjectModel
          .getInteractionClasses()
          .values()
          .stream()
          .forEach(
              (value) -> {
                interactions.add(new InteractionState(value));
              });
      InteractionTableView.setItems(interactions);
      interactions.forEach(
          (interaction) -> {
            interaction
                .onProperty()
                .addListener(
                    (observable, oldValue, newValue) -> {
                      if (!newValue) {
                        cb.setSelected(false);
                      } else if (interactions.stream().allMatch(a -> a.isOn())) {
                        cb.setSelected(true);
                      }
                    });
          });
      InteractionTableColumn.setCellValueFactory(new PropertyValueFactory<>("interactionName"));
      CheckTableColumn.setCellValueFactory(
          new Callback<
              TableColumn.CellDataFeatures<InteractionState, Boolean>, ObservableValue<Boolean>>() {
            @Override
            public ObservableValue<Boolean> call(
                TableColumn.CellDataFeatures<InteractionState, Boolean> param) {
              return param.getValue().onProperty();
            }
          });

      CheckTableColumn.setCellFactory(CheckBoxTableCell.forTableColumn(CheckTableColumn));
      cb.setUserData(CheckTableColumn);
      cb.setOnAction(
          (ActionEvent event) -> {
            CheckBox cb1 = (CheckBox) event.getSource();
            TableColumn tc = (TableColumn) cb1.getUserData();
            InteractionTableView.getItems()
                .stream()
                .forEach(
                    (item) -> {
                      item.setOn(cb1.isSelected());
                    });
          });
      CheckTableColumn.setGraphic(cb);
    }
    logger.exit();
  }

  public List<InteractionClassFDD> getInteractions() {
    return interactions
        .stream()
        .filter(a -> a.isOn())
        .map(a -> a.interaction)
        .collect(Collectors.toList());
  }

  public static class InteractionState {

    private final ReadOnlyStringWrapper interactionName = new ReadOnlyStringWrapper();
    private final BooleanProperty on = new SimpleBooleanProperty();
    private final InteractionClassFDD interaction;

    public InteractionState(InteractionClassFDD interaction) {
      this.interaction = interaction;
      interactionName.set(interaction.getFullName());
    }

    public String getInteractionName() {
      return interactionName.get();
    }

    public ReadOnlyStringProperty interactionNameProperty() {
      return interactionName.getReadOnlyProperty();
    }

    public boolean isOn() {
      return on.get();
    }

    public void setOn(boolean value) {
      on.set(value);
    }

    public BooleanProperty onProperty() {
      return on;
    }

    @Override
    public String toString() {
      return interaction.getFullName();
    }
  }
}
Ejemplo n.º 4
0
  public TeamViewModel() {
    createValidators();

    ListProperty<Person> peopleInOrganisation = new SimpleListProperty<>();
    peopleInOrganisation.bind(
        Bindings.createObjectBinding(
            () -> {
              if (organisationProperty().get() != null) {
                return organisationProperty().get().getPeople();
              } else {
                return FXCollections.observableArrayList();
              }
            },
            organisationProperty()));

    ListProperty<Team> teamsInOrganisation = new SimpleListProperty<>();
    teamsInOrganisation.bind(
        Bindings.createObjectBinding(
            () -> {
              if (organisationProperty().get() != null) {
                return organisationProperty().get().getTeams();
              } else {
                return FXCollections.observableArrayList();
              }
            },
            organisationProperty()));

    ListProperty<Person> peopleInTeams = new SimpleListProperty<>();
    peopleInTeams.bind(
        Bindings.createObjectBinding(
            () -> {
              return teamsInOrganisation
                  .stream()
                  .flatMap(team -> team.observableTeamMembers().stream()) // TODO listen
                  .collect(GoatCollectors.toObservableList());
            },
            teamsInOrganisation));

    eligibleTeamMembers = new SimpleListProperty<>();
    eligibleTeamMembers.bind(
        Bindings.createObjectBinding(
            () -> {
              return peopleInOrganisation
                  .stream()
                  .filter(
                      person ->
                          !peopleInTeams.contains(person) // no team in model
                              || person.getTeam() == modelWrapper.get()) // this team in model
                  .collect(GoatCollectors.toObservableList());
            },
            peopleInOrganisation,
            peopleInTeams));

    eligibleDevs = new SimpleListProperty<>();
    eligibleDevs.bind(
        Bindings.createObjectBinding(
            () -> {
              return teamMembersProperty()
                  .get()
                  .stream() // is in team
                  .filter(
                      person ->
                          !person.equals(productOwnerProperty().get()) // not PO
                              && !person.equals(scrumMasterProperty().get())) // not SM
                  .collect(GoatCollectors.toObservableList());
            },
            teamMembersProperty(),
            productOwnerProperty(),
            scrumMasterProperty()));

    teamMembersProperty()
        .addListener(
            (ListChangeListener.Change<? extends Person> change) -> {
              change.next();
              List<? extends Person> removed = change.getRemoved();
              devTeamProperty().removeAll(removed);
              if (removed.contains(productOwnerProperty().get())) {
                productOwnerProperty().set(null);
              }
              if (removed.contains(scrumMasterProperty().get())) {
                scrumMasterProperty().set(null);
              }
            });
  }