public ChatPrefs() {
   maxMessages = new SimpleIntegerProperty(500);
   zoom = new SimpleDoubleProperty(1);
   learnedAutoComplete = new SimpleBooleanProperty(false);
   previewImageUrls = new SimpleBooleanProperty(true);
   hideFoeMessages = new SimpleBooleanProperty(true);
   channelTabScrollPaneWidth = new SimpleIntegerProperty(250);
   userToColor = new SimpleMapProperty<>(FXCollections.observableHashMap());
   chatColorMode = new SimpleObjectProperty<>(CUSTOM);
 }
Beispiel #2
0
public class DefaultData {
  public static final Catalog BOOKS_CATALOG = new Catalog("Books");
  public static final Catalog CLOTHES_CATALOG = new Catalog("Clothes");
  public static final Product MESSIAH_BOOK =
      new Product(BOOKS_CATALOG, "Messiah Of Dune", "11/11/2000", 20, 15.00);
  public static final Product GONE_BOOK =
      new Product(BOOKS_CATALOG, "Gone with the Wind", "12/5/1995", 15, 12.00);
  public static final Product GARDEN_BOOK =
      new Product(BOOKS_CATALOG, "Garden of Rama", "1/1/2005", 5, 18.00);
  public static final Product PANTS = new Product(CLOTHES_CATALOG, "Pants", "11/1/2000", 20, 15.00);
  public static final Product SKIRTS =
      new Product(CLOTHES_CATALOG, "Skirts", "1/5/1995", 15, 12.00);
  public static final Product TSHIRTS =
      new Product(CLOTHES_CATALOG, "T-Shirts", "1/10/2005", 10, 22.00);
  public static final ObservableList<Catalog> CATALOG_LIST_DATA =
      FXCollections.observableArrayList(BOOKS_CATALOG, CLOTHES_CATALOG);
  public static final ObservableMap<Catalog, List<Product>> PRODUCT_LIST_DATA =
      FXCollections.observableHashMap();
  public static final List<String> DISPLAY_PRODUCT_FIELDS =
      Arrays.asList("Item Name", "Price", "Quantity Available", "Review");

  static {
    MESSIAH_BOOK.setDescription(
        "You saw how good Dune was. \nThis is Part 2 of this \nunforgettable trilogy.");
    GONE_BOOK.setDescription(
        "A moving classic that tells \na tale of love and \na tale of courage.");
    GARDEN_BOOK.setDescription("Highly acclaimed Book \nof Isaac Asimov. A real \nnail-biter.");
    PANTS.setDescription(
        "I've seen the Grand Canyon. I've camped \nat Yellowstone. But nothing on \nearth compares to the look and feel of \nthese pants.");
    SKIRTS.setDescription("Once this brand of skirts \nbecomes well-known, watch out!");
    TSHIRTS.setDescription("Can be worn by men or women. \nAlways in style.");

    PRODUCT_LIST_DATA.put(BOOKS_CATALOG, Arrays.asList(MESSIAH_BOOK, GONE_BOOK, GARDEN_BOOK));

    PRODUCT_LIST_DATA.put(CLOTHES_CATALOG, Arrays.asList(PANTS, SKIRTS, TSHIRTS));
  }
}
  @Before
  public void setUp() throws Exception {
    instance = new PircBotXChatService();
    instance.fafService = fafService;
    instance.userService = userService;
    instance.taskService = taskService;
    instance.i18n = i18n;
    instance.pircBotXFactory = pircBotXFactory;
    instance.preferencesService = preferencesService;
    instance.executorService = executorService;

    chatUser1 = new ChatUser("chatUser1", null);
    chatUser2 = new ChatUser("chatUser2", null);
    loggedInProperty = new SimpleBooleanProperty();

    botShutdownLatch = new CountDownLatch(1);

    userToColorProperty = new SimpleMapProperty<>(FXCollections.observableHashMap());
    chatColorMode = new SimpleObjectProperty<>(CUSTOM);

    when(userService.getUsername()).thenReturn(CHAT_USER_NAME);
    when(userService.getPassword()).thenReturn(CHAT_PASSWORD);
    when(userService.loggedInProperty()).thenReturn(loggedInProperty);

    when(user1.getNick()).thenReturn(chatUser1.getUsername());
    when(user1.getChannels()).thenReturn(ImmutableSortedSet.of(defaultChannel));
    when(user1.getUserLevels(defaultChannel)).thenReturn(ImmutableSortedSet.of(UserLevel.VOICE));

    when(user2.getNick()).thenReturn(chatUser2.getUsername());
    when(user2.getChannels()).thenReturn(ImmutableSortedSet.of(defaultChannel));
    when(user2.getUserLevels(defaultChannel)).thenReturn(ImmutableSortedSet.of(UserLevel.VOICE));

    when(defaultChannel.getName()).thenReturn(DEFAULT_CHANNEL_NAME);
    when(pircBotX.getConfiguration()).thenReturn(configuration);
    when(pircBotX.sendIRC()).thenReturn(outputIrc);
    when(pircBotX.getUserChannelDao()).thenReturn(userChannelDao);

    doAnswer(
            invocation -> {
              CompletableFuture<Object> future = new CompletableFuture<>();
              WaitForAsyncUtils.async(
                  () -> {
                    invocation.getArgumentAt(0, Task.class).run();
                    future.complete(null);
                  });
              return future;
            })
        .when(executorService)
        .submit(any(Task.class));

    botStartedFuture = new CompletableFuture<>();
    doAnswer(
            invocation -> {
              botStartedFuture.complete(true);
              botShutdownLatch.await();
              return null;
            })
        .when(pircBotX)
        .startBot();

    when(pircBotXFactory.createPircBotX(any())).thenReturn(pircBotX);
    when(configuration.getListenerManager()).thenReturn(listenerManager);

    instance.ircHost = LOOPBACK_ADDRESS.getHostAddress();
    instance.ircPort = IRC_SERVER_PORT;
    instance.defaultChannelName = DEFAULT_CHANNEL_NAME;
    instance.reconnectDelay = 100;

    when(preferencesService.getPreferences()).thenReturn(preferences);
    when(preferences.getChat()).thenReturn(chatPrefs);

    when(chatPrefs.userToColorProperty()).thenReturn(userToColorProperty);
    when(chatPrefs.chatColorModeProperty()).thenReturn(chatColorMode);

    instance.postConstruct();
  }
Beispiel #4
0
 /**
  * session scope bindings
  *
  * @return
  */
 public ObservableMap<String, Property<?>> getBindings() {
   if (bindings == null) {
     bindings = FXCollections.observableHashMap();
   }
   return bindings;
 }
@IDProperty("id")
@DefaultProperty("children")
public class Widget {
  private StringProperty id = new SimpleStringProperty();
  private StringProperty name = new SimpleStringProperty();
  private IntegerProperty number = new SimpleIntegerProperty();
  private ObservableList<Widget> children = FXCollections.observableArrayList();
  private ObservableSet<String> set = FXCollections.observableSet();
  private ObservableMap<String, Object> properties = FXCollections.observableHashMap();
  private BooleanProperty enabledProperty = new SimpleBooleanProperty(true);
  private ArrayList<String> styles = new ArrayList<String>();
  private ArrayList<String> values = new ArrayList<String>();
  private float[] ratios = new float[] {};
  private String[] names = new String[] {};

  public static final String ALIGNMENT_KEY = "alignment";
  public static final int TEN = 10;
  private EventHandler<ActionEvent> actionHandler;

  public Widget() {
    this(null);
  }

  public Widget(String name) {
    setName(name);
  }

  public String getId() {
    return id.get();
  }

  public void setId(String value) {
    id.set(value);
  }

  public StringProperty idProperty() {
    return id;
  }

  public String getName() {
    return name.get();
  }

  public void setName(String value) {
    name.set(value);
  }

  public StringProperty nameProperty() {
    return name;
  }

  public int getNumber() {
    return number.get();
  }

  public void setNumber(int value) {
    number.set(value);
  }

  public IntegerProperty numberProperty() {
    return number;
  }

  public ObservableList<Widget> getChildren() {
    return children;
  }

  public ObservableMap<String, Object> getProperties() {
    return properties;
  }

  public boolean isEnabled() {
    return enabledProperty.get();
  }

  public void setEnabled(boolean value) {
    enabledProperty.set(value);
  }

  public BooleanProperty enabledProperty() {
    return enabledProperty;
  }

  public List<String> getStyles() {
    return styles;
  }

  public List<String> getValues() {
    return values;
  }

  public void setValues(List<String> values) {
    if (values == null) {
      throw new IllegalArgumentException();
    }

    this.values = new ArrayList<String>();
    this.values.addAll(values);
  }

  public float[] getRatios() {
    return Arrays.copyOf(ratios, ratios.length);
  }

  public void setRatios(float[] ratios) {
    this.ratios = Arrays.copyOf(ratios, ratios.length);
  }

  public String[] getNames() {
    return Arrays.copyOf(names, names.length);
  }

  public void setNames(String[] names) {
    this.names = Arrays.copyOf(names, names.length);
  }

  public ObservableSet<String> getSet() {
    return set;
  }

  public static Alignment getAlignment(Widget widget) {
    return (Alignment) widget.getProperties().get(ALIGNMENT_KEY);
  }

  public static void setAlignment(Widget widget, Alignment alignment) {
    widget.getProperties().put(ALIGNMENT_KEY, alignment);
  }

  public final void setOnAction(EventHandler<ActionEvent> value) {
    actionHandler = value;
  }

  public final EventHandler<ActionEvent> getOnAction() {
    return actionHandler;
  }

  public final void fire() {
    actionHandler.handle(new ActionEvent());
  }
}