コード例 #1
0
 @Override
 protected final void updateItem(LocalFile item, boolean empty) {
   super.updateItem(item, empty);
   icon.set(null);
   title.setValue("");
   if (!empty) {
     icon.set(item.getIcon());
     title.setValue(item.getFileName());
   }
 }
コード例 #2
0
ファイル: ThemeManager.java プロジェクト: peteclarkez/jgnash
  static {
    preferences = Preferences.userNodeForPackage(ThemeManager.class);

    final StringProperty _baseColorProperty = new SimpleStringProperty();

    // restore the old value
    fontScaleProperty.set(preferences.getDouble(FONT_SIZE, 1));

    // Save the value when it changes
    fontScaleProperty.addListener(
        (observable, oldValue, newValue) -> {
          if (newValue != null) {
            preferences.putDouble(FONT_SIZE, newValue.doubleValue());
          }
        });

    baseColorProperty.setValue(Color.web(preferences.get(BASE_COLOR, DEFAULT_MODENA_BASE_COLOR)));

    // restore the old base color value
    switch (preferences.get(LAST, Application.STYLESHEET_MODENA)) {
      case Application.STYLESHEET_CASPIAN:
        baseColorProperty.setValue(
            Color.web(preferences.get(BASE_COLOR, DEFAULT_CASPIAN_BASE_COLOR)));
        break;
      case Application.STYLESHEET_MODENA:
        baseColorProperty.setValue(
            Color.web(preferences.get(BASE_COLOR, DEFAULT_MODENA_BASE_COLOR)));
        break;
      default:
        baseColorProperty.setValue(
            Color.web(preferences.get(BASE_COLOR, DEFAULT_MODENA_BASE_COLOR)));
    }

    _baseColorProperty.setValue(colorToHex(baseColorProperty.getValue()));

    // Save the value when it changes
    baseColorProperty.addListener(
        (observable, oldValue, newValue) -> {
          if (newValue != null) {
            preferences.put(BASE_COLOR, colorToHex(newValue));
            _baseColorProperty.setValue(colorToHex(newValue));
          }
        });

    // Create the binding format for the style / font size
    styleProperty =
        Bindings.format(
            "-fx-font-size: %1$.6fem; -fx-base:%2$s", fontScaleProperty, _baseColorProperty);
  }
コード例 #3
0
ファイル: PathTreeCell.java プロジェクト: Darksirion/GUI
 @Override
 public void commitEdit(PathItem pathItem) {
   // rename the file or directory
   if (editingPath != null) {
     try {
       Files.move(editingPath, pathItem.getPath());
     } catch (IOException ex) {
       cancelEdit();
       messageProp.setValue(String.format("Renaming %s filed", editingPath.getFileName()));
     }
   }
   super.commitEdit(pathItem);
 }
コード例 #4
0
  public RealNumberTextField() {
    super();
    this.textProperty()
        .addListener(
            (v, oldV, newValue) -> {
              getStyleClass().removeAll("validation-error");
              if (newValue == null || newValue.trim().isEmpty()) {
                realNumberTextProperty.setValue(null);
                realNumberIntegerProperty.setValue(null);

              } else {
                try {
                  newValue = newValue.trim().replace(",", ".");
                  realNumberIntegerProperty.setValue(
                      (int) (Double.parseDouble(newValue) * ApplicationConstants.RESOLUTION));
                  realNumberTextProperty.setValue(newValue);
                } catch (Exception e) {
                  getStyleClass().add("validation-error");
                  realNumberTextProperty.setValue(null);
                  realNumberIntegerProperty.setValue(null);
                }
              }
            });
  }
コード例 #5
0
ファイル: WebKitBrowser.java プロジェクト: sumitlakra/BurpKit
  private void handleAlert(WebEvent<String> event) {
    numberOfAlerts.setValue(Integer.toString(Integer.valueOf(numberOfAlerts.getValue()) + 1));
    String message = event.getData();

    /*
     * Handle all the external onAlert event handlers first.
     */
    for (EventHandler<WebEvent<String>> handler : alertListeners) handler.handle(event);

    /*
     * Finally display an alert box if the operator demands it.
     */
    if (showAlerts.getValue()) {
      dialog.title("JavaScript Alert").message(message).showInformation();
      resetParents();
    }
  }
コード例 #6
0
ファイル: WebKitBrowser.java プロジェクト: sumitlakra/BurpKit
  public void workerStateChanged(
      ObservableValue<? extends Worker.State> observable,
      Worker.State oldValue,
      Worker.State newValue) {
    if (newValue == Worker.State.READY || newValue == Worker.State.SCHEDULED) {
      if (trafficBrowser != null) {
        trafficBrowser.setStartTime(Instant.now());
        trafficBrowser.getTraffic().clear();
      }
      numberOfAlerts.setValue("0");
    } else if (newValue == Worker.State.SUCCEEDED) {
      JSObject result = (JSObject) webEngine.executeScript("window");

      result.setMember(
          "burpCallbacks",
          new BurpExtenderCallbacksBridge(webEngine, BurpExtender.getBurpExtenderCallbacks()));

      result.setMember("burpKit", javaScriptHelpers);

      //            result.setMember("locals", locals);
      //
      //            result.setMember("globals", globals);

      if (controller != null) {
        result.setMember("burpController", controller);
      }
    } else if (newValue == Worker.State.FAILED) {
      dialog
          .title("Navigation Failed")
          .message(webEngine.getLoadWorker().getException().getMessage())
          .showInformation();
      resetParents();
    } else if (newValue == Worker.State.CANCELLED) {
      dialog
          .title("Navigation Cancelled")
          .message(webEngine.getLoadWorker().getMessage())
          .showInformation();
      resetParents();
    }
  }
コード例 #7
0
ファイル: PathTreeCell.java プロジェクト: Darksirion/GUI
  public PathTreeCell(/*final Stage owner, */ final StringProperty messageProp) {
    this.messageProp = messageProp;
    MenuItem expandMenu = new MenuItem("Expand");
    expandMenu.setOnAction(
        (ActionEvent event) -> {
          getTreeItem().setExpanded(true);
        });
    MenuItem expandAllMenu = new MenuItem("Expand All");
    expandAllMenu.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent t) {
            expandTreeItem(getTreeItem());
          }

          private void expandTreeItem(TreeItem<PathItem> item) {
            if (item.isLeaf()) {
              return;
            }
            item.setExpanded(true);
            ObservableList<TreeItem<PathItem>> children = item.getChildren();
            children
                .stream()
                .filter(child -> (!child.isLeaf()))
                .forEach(child -> expandTreeItem(child));
          }
        });
    MenuItem addMenu = new MenuItem("Add Directory");
    addMenu.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent t) {
            Path newDir = createNewDirectory();
            if (newDir != null) {
              TreeItem<PathItem> addItem = PathTreeItem.createNode(new PathItem(newDir));
              getTreeItem().getChildren().add(addItem);
            }
          }

          private Path createNewDirectory() {
            Path newDir = null;
            while (true) {
              Path path = getTreeItem().getValue().getPath();
              newDir =
                  Paths.get(
                      path.toAbsolutePath().toString(),
                      "newDirectory" + String.valueOf(getItem().getCountNewDir()));
              try {
                Files.createDirectory(newDir);
                break;
              } catch (FileAlreadyExistsException ex) {
                continue;
              } catch (IOException ex) {
                cancelEdit();
                messageProp.setValue(
                    String.format("Creating directory(%s) failed", newDir.getFileName()));
                break;
              }
            }
            return newDir;
          }
        });
    MenuItem deleteMenu = new MenuItem("Delete");
    deleteMenu.setOnAction(
        (ActionEvent event) -> {
          ObjectProperty<TreeItem<PathItem>> prop = new SimpleObjectProperty<>();
          new ModalDialog(/*owner, */ getTreeItem(), prop);
          prop.addListener(
              (ObservableValue<? extends TreeItem<PathItem>> ov,
                  TreeItem<PathItem> oldItem,
                  TreeItem<PathItem> newItem) -> {
                try {
                  Files.walkFileTree(newItem.getValue().getPath(), new VisitorForDelete());
                  if (getTreeItem().getParent() == null) {
                    // when the root is deleted how to clear the TreeView???
                  } else {
                    getTreeItem().getParent().getChildren().remove(newItem);
                  }
                } catch (IOException ex) {
                  messageProp.setValue(
                      String.format(
                          "Deleting %s failed", newItem.getValue().getPath().getFileName()));
                }
              });
        });
    dirMenu.getItems().addAll(expandMenu, expandAllMenu, deleteMenu, addMenu);
    fileMenu.getItems().addAll(deleteMenu);
  }