コード例 #1
0
ファイル: ManFrame.java プロジェクト: chriscasola/cs3041
 /**
  * Method required by ChangeListener interface. This method is called when the tab panel or slider
  * change
  */
 @Override
 public void stateChanged(ChangeEvent ce) {
   if (ce.getSource()
       instanceof JSlider) { // the slider changed, so notify the currently displayed ManPage
     JSlider slider = (JSlider) ce.getSource();
     if (!slider.getValueIsAdjusting()) {
       ISliderUpdated currentManPage = (ISliderUpdated) tabPanel.getSelectedComponent();
       currentManPage.sliderChanged(slider);
     }
   } else if (ce.getSource()
       instanceof TabPane) { // the active tab changed, so update the state of the slider
     TabPane tabPanel = (TabPane) ce.getSource();
     if (tabPanel.getTabCount() > 0) {
       switch (((ManPage) tabPanel.getSelectedComponent()).getHelpLevel()) {
         case DETAIL:
           toolbarPanel.getHelpLevelSlider().setValue(3);
           break;
         case SUMMARY:
           toolbarPanel.getHelpLevelSlider().setValue(2);
           break;
         case TOPIC:
           toolbarPanel.getHelpLevelSlider().setValue(1);
           break;
         default:
           break;
       }
     }
   }
 }
コード例 #2
0
ファイル: TabPanel.java プロジェクト: Gael/gwt-bootstrap
  private void add(TabPane child) {

    if (child.isCreateTabLink()) {
      TabLink tabLink = new TabLink(child);
      tabs.add(tabLink);
    }
    tabContent.add(child);
  }
コード例 #3
0
ファイル: TabService.java プロジェクト: jaredmorgs/AsciidocFX
  public void addImageTab(Path imagePath) {

    TabPane previewTabPane = controller.getPreviewTabPane();

    ImageTab tab = new ImageTab();
    tab.setPath(imagePath);
    tab.setText(imagePath.getFileName().toString());

    if (previewTabPane.getTabs().contains(tab)) {
      previewTabPane.getSelectionModel().select(tab);
      return;
    }

    Image image = new Image(IOHelper.pathToUrl(imagePath));
    ImageView imageView = new ImageView(image);
    imageView.setPreserveRatio(true);

    imageView.setFitWidth(previewTabPane.getWidth());

    previewTabPane
        .widthProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              imageView.setFitWidth(previewTabPane.getWidth());
            });

    Tooltip tip = new Tooltip(imagePath.toString());
    Tooltip.install(tab.getGraphic(), tip);

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
    scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
    scrollPane.setContent(imageView);
    scrollPane.addEventFilter(
        ScrollEvent.SCROLL,
        e -> {
          if (e.isControlDown() && e.getDeltaY() > 0) {
            // zoom in
            imageView.setFitWidth(imageView.getFitWidth() + 16.0);
          } else if (e.isControlDown() && e.getDeltaY() < 0) {
            // zoom out
            imageView.setFitWidth(imageView.getFitWidth() - 16.0);
          }
        });

    tab.setContent(scrollPane);

    TabPane tabPane = previewTabPane;
    tabPane.getTabs().add(tab);
    tabPane.getSelectionModel().select(tab);
  }
コード例 #4
0
ファイル: WebKitBrowser.java プロジェクト: sumitlakra/BurpKit
  private void createStatusBar() {
    statusBar = new StatusBar();
    statusBar.setText("Alerts");

    Button alertsButton = new Button();
    alertsButton.textProperty().bind(numberOfAlerts);
    alertsButton.setBackground(
        new Background(new BackgroundFill(Color.ORANGE, new CornerRadii(2), new Insets(4))));
    alertsButton.setOnAction(
        event -> {
          isDetailNodeVisible.setValue(true);
          detailPane.getSelectionModel().select(0);
        });

    statusBar.getLeftItems().add(alertsButton);
    statusBar.progressProperty().bind(webEngine.getLoadWorker().progressProperty());
  }
コード例 #5
0
ファイル: TabService.java プロジェクト: jaredmorgs/AsciidocFX
 public void initializeTabChangeListener(TabPane tabPane) {
   ReadOnlyObjectProperty<Tab> itemProperty = tabPane.getSelectionModel().selectedItemProperty();
   itemProperty.addListener(
       (observable, oldValue, selectedTab) -> {
         if (Objects.isNull(selectedTab)) return;
         threadService.runActionLater(
             () -> {
               EditorPane editorPane = ((MyTab) selectedTab).getEditorPane();
               if (Objects.nonNull(editorPane)) {
                 try {
                   editorPane.rerender();
                   editorPane.focus();
                 } catch (Exception e) {
                   logger.error("Problem occured after changing tab {}", selectedTab, e);
                 }
               }
             });
       });
 }
コード例 #6
0
ファイル: TabService.java プロジェクト: jaredmorgs/AsciidocFX
  public MyTab createTab() {

    MyTab tab =
        new MyTab() {
          @Override
          public ButtonType close() {
            if (Objects.nonNull(this.getPath()))
              closedPaths.add(Optional.ofNullable(current.currentTab().getPath()));

            ButtonType closeType = super.close();

            Platform.runLater(
                () -> {
                  ObservableList<Tab> tabs = controller.getTabPane().getTabs();
                  if (tabs.isEmpty()) {
                    controller.newDoc(null);
                  }
                });

            return closeType;
          }
        };

    tab.setOnCloseRequest(
        event -> {
          event.consume();
          tab.close();
        });

    MenuItem menuItem0 = new MenuItem("Close");
    menuItem0.setOnAction(
        actionEvent -> {
          tab.close();
        });

    MenuItem menuItem1 = new MenuItem("Close All");
    menuItem1.setOnAction(
        actionEvent -> {
          ObservableList<Tab> tabs = controller.getTabPane().getTabs();
          ObservableList<Tab> clonedTabs = FXCollections.observableArrayList(tabs);
          if (clonedTabs.size() > 0) {
            clonedTabs.forEach(
                (closedTab) -> {
                  MyTab myTab = (MyTab) closedTab;
                  myTab.close();
                });
          }
        });

    MenuItem menuItem2 = new MenuItem("Close Others");
    menuItem2.setOnAction(
        actionEvent -> {
          ObservableList<Tab> blackList = FXCollections.observableArrayList();
          blackList.addAll(controller.getTabPane().getTabs());

          blackList.remove(tab);

          blackList.forEach(
              t -> {
                MyTab closeTab = (MyTab) t;
                closeTab.close();
              });
        });
    //
    //        MenuItem menuItem3 = new MenuItem("Close Unmodified");
    //        menuItem3.setOnAction(actionEvent -> {
    //
    //            ObservableList<Tab> clonedTabs = FXCollections.observableArrayList();
    //            clonedTabs.addAll(controller.getTabPane().getTabs());
    //
    //
    //            for (Tab clonedTab : clonedTabs) {
    //                MyTab myTab = (MyTab) clonedTab;
    //                if (!myTab.getTabText().contains(" *"))
    //                    threadService.runActionLater(()->{
    //                        myTab.close();
    //                    });
    //            }
    //        });

    MenuItem menuItem4 = new MenuItem("Select Next Tab");
    menuItem4.setOnAction(
        actionEvent -> {
          TabPane tabPane = controller.getTabPane();
          if (tabPane.getSelectionModel().isSelected(tabPane.getTabs().size() - 1))
            tabPane.getSelectionModel().selectFirst();
          else tabPane.getSelectionModel().selectNext();
        });

    MenuItem menuItem5 = new MenuItem("Select Previous Tab");
    menuItem5.setOnAction(
        actionEvent -> {
          SingleSelectionModel<Tab> selectionModel = controller.getTabPane().getSelectionModel();
          if (selectionModel.isSelected(0)) selectionModel.selectLast();
          else selectionModel.selectPrevious();
        });

    MenuItem menuItem6 = new MenuItem("Reopen Closed Tab");
    menuItem6.setOnAction(
        actionEvent -> {
          if (closedPaths.size() > 0) {
            int index = closedPaths.size() - 1;
            closedPaths.get(index).filter(pathResolver::isAsciidoc).ifPresent(this::addTab);
            closedPaths.get(index).filter(pathResolver::isMarkdown).ifPresent(this::addTab);
            closedPaths.get(index).filter(pathResolver::isImage).ifPresent(this::addImageTab);
            closedPaths.remove(index);
          }
        });

    MenuItem menuItem7 = new MenuItem("Open File Location");

    menuItem7.setOnAction(
        event -> {
          current
              .currentPath()
              .ifPresent(
                  path -> {
                    controller
                        .getHostServices()
                        .showDocument(path.getParent().toUri().toASCIIString());
                  });
        });

    MenuItem menuItem8 = new MenuItem("New File");
    menuItem8.setOnAction(controller::newDoc);

    MenuItem gotoWorkdir = new MenuItem("Go to Workdir");
    gotoWorkdir.setOnAction(
        event -> {
          current.currentPath().map(Path::getParent).ifPresent(directoryService::changeWorkigDir);
        });

    ContextMenu contextMenu = new ContextMenu();
    contextMenu
        .getItems()
        .addAll(
            menuItem0,
            menuItem1,
            menuItem2,
            new SeparatorMenuItem(),
            menuItem4,
            menuItem5,
            menuItem6,
            new SeparatorMenuItem(),
            gotoWorkdir,
            new SeparatorMenuItem(),
            menuItem7,
            menuItem8);

    tab.contextMenuProperty().setValue(contextMenu);
    Label label = tab.getLabel();

    label.setOnMouseClicked(
        mouseEvent -> {
          if (mouseEvent.getButton().equals(MouseButton.SECONDARY)) {
            tab.select();
          } else if (mouseEvent.getClickCount() > 1) {
            controller.adjustSplitPane();
          }
        });

    return tab;
  }
コード例 #7
0
ファイル: TabService.java プロジェクト: jaredmorgs/AsciidocFX
  public void addTab(Path path, Runnable... runnables) {

    ObservableList<String> recentFiles = controller.getRecentFilesList();
    if (Files.notExists(path)) {
      recentFiles.remove(path.toString());
      return;
    }

    ObservableList<Tab> tabs = controller.getTabPane().getTabs();
    for (Tab tab : tabs) {
      MyTab myTab = (MyTab) tab;
      Path currentPath = myTab.getPath();
      if (Objects.nonNull(currentPath))
        if (currentPath.equals(path)) {
          myTab.select(); // Select already added tab
          return;
        }
    }

    AnchorPane anchorPane = new AnchorPane();
    EditorPane editorPane = webviewService.createWebView();

    MyTab tab = createTab();
    tab.setEditorPane(editorPane);
    tab.setTabText(path.getFileName().toString());

    editorPane.confirmHandler(
        param -> {
          if ("command:ready".equals(param)) {
            JSObject window = editorPane.getWindow();
            window.setMember("afx", controller);
            window.call("updateOptions", new Object[] {});
            Map<String, String> shortCuts = controller.getShortCuts();
            Set<String> keySet = shortCuts.keySet();
            for (String key : keySet) {
              window.call("addNewCommand", new Object[] {key, shortCuts.get(key)});
            }
            if (Objects.isNull(path)) return true;
            threadService.runTaskLater(
                () -> {
                  String content = IOHelper.readFile(path);
                  threadService.runActionLater(
                      () -> {
                        window.call("changeEditorMode", path.toUri().toString());
                        window.call("setInitialized");
                        window.call("setEditorValue", new Object[] {content});
                        for (Runnable runnable : runnables) {
                          runnable.run();
                        }
                      });
                });
          }
          return false;
        });

    threadService.runActionLater(
        () -> {
          TabPane tabPane = controller.getTabPane();
          tabPane.getTabs().add(tab);
          tab.select();
        });

    Node editorVBox = editorService.createEditorVBox(editorPane, tab);
    controller.fitToParent(editorVBox);

    anchorPane.getChildren().add(editorVBox);
    tab.setContent(anchorPane);
    tab.setPath(path);

    Tooltip tip = new Tooltip(path.toString());
    Tooltip.install(tab.getGraphic(), tip);

    recentFiles.remove(path.toString());
    recentFiles.add(0, path.toString());

    editorPane.focus();
  }
コード例 #8
0
ファイル: WebKitBrowser.java プロジェクト: sumitlakra/BurpKit
  private void createDetailPane() {
    detailPane = new TabPane();

    javaScriptConsoleTab = new JavaScriptConsoleTab(webEngine);
    addErrorListener(javaScriptConsoleTab::handleError);
    addAlertListener(javaScriptConsoleTab::handleAlert);

    crossSiteScriptingTrackerTab = new CrossSiteScriptingTrackerTab(webEngine);
    addAlertListener(crossSiteScriptingTrackerTab::handleAlert);

    pageResourcesTab = new PageResourcesTab(webEngine);

    Tab javaScriptEditorTab = new Tab("BurpScript IDE");
    javaScriptEditorTab
        .selectedProperty()
        .addListener(
            (observable, oldValue, newValue) -> {
              if (newValue) masterDetailPane.setDividerPositions(0.5);
            });
    JavaScriptEditor javaScriptEditor = new JavaScriptEditor(webEngine, controller, false);
    javaScriptEditor.setJavaScriptConsoleTab(javaScriptConsoleTab);
    javaScriptEditorTab.setContent(javaScriptEditor);

    Tab trafficBrowserTab = new Tab("Network");
    trafficBrowser = new TrafficBrowser();
    trafficBrowserTab.setContent(trafficBrowser);

    Debugger debugger = webEngine.impl_getDebugger();
    debugger.setEnabled(true);
    debugger.sendMessage("{\"id\": 1, \"method\":\"Network.enable\"}");
    debugger.setMessageCallback(
        new Callback<String, Void>() {

          ConcurrentHashMap<String, Traffic> trafficState = new ConcurrentHashMap<>();

          @Override
          public Void call(String param) {
            JsonParser parser = new JsonParser();
            JsonObject object = parser.parse(param).getAsJsonObject();

            String method = object.get("method").getAsString();
            JsonObject params = object.getAsJsonObject("params");
            JsonObject request = params.getAsJsonObject("request");
            JsonObject response = params.getAsJsonObject("response");
            String requestId = params.get("requestId").getAsString();

            Instant timeStamp;
            JsonElement epochObject = params.get("timestamp");
            if (epochObject != null) {
              double epoch = epochObject.getAsDouble();
              timeStamp =
                  Instant.ofEpochSecond(
                      (long) Math.floor(epoch), (long) (epoch * 1000000000 % 1000000000));
            } else {
              timeStamp = Instant.now();
            }

            Traffic traffic = null;

            switch (method) {
              case "Network.requestWillBeSent":
                URL url = null;
                String urlString = request.get("url").getAsString();

                try {
                  url = new URL(urlString);
                } catch (MalformedURLException e) {
                  //                            e.printStackTrace();
                }
                trafficState.put(
                    requestId,
                    new Traffic(
                        (url == null) ? urlString : url.getFile(),
                        timeStamp,
                        (url == null) ? "" : url.getHost(),
                        request.get("method").getAsString(),
                        params.get("documentURL").getAsString()));
                break;
              case "Network.responseReceived":
                traffic = trafficState.get(requestId);
                JsonObject headers = response.getAsJsonObject("headers");
                JsonElement contentType = headers.get("Content-Type");
                JsonElement contentLength = headers.get("Content-Length");
                traffic.setType((contentType == null) ? "" : contentType.getAsString());
                JsonElement requestLine = headers.get("");
                if (requestLine != null) {
                  String[] requestLineParts = requestLine.getAsString().split(" ", 3);
                  traffic.setStatusCode(new Integer(requestLineParts[1]));
                  traffic.setStatusText(requestLineParts[2]);
                  traffic.setSize((contentLength == null) ? "0" : contentLength.getAsString());
                } else {
                  traffic.setStatusCode(200);
                  traffic.setStatusText("OK");
                  traffic.setSize("0");
                }
                break;
              case "Network.loadingFinished":
                traffic = trafficState.get(requestId);
                traffic.setEndTime(timeStamp);
                trafficBrowser.getTraffic().add(traffic);
                trafficState.remove(requestId);
                if (traffic.getEndTime().isAfter(trafficBrowser.getEndTime())) {
                  trafficBrowser.setEndTime(traffic.getEndTime());
                }
            }
            return null;
          }
        });

    detailPane
        .getTabs()
        .addAll(
            javaScriptConsoleTab,
            crossSiteScriptingTrackerTab,
            pageResourcesTab,
            trafficBrowserTab,
            javaScriptEditorTab
            //                new ImagesTab(webEngine)
            );

    detailPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);
  }
コード例 #9
0
  /**
   * Called after the controls have been parsed from the XML. Sets up logic and components that
   * could not be set up using the GUI builder.
   */
  @Override
  public void initialize(URL url, ResourceBundle rb) {

    // the transformedTrajectory provides a view of the trajectory that reflects the selected
    // transformedTrajectory
    transformedTrajectory =
        new Cacheable<double[][]>() {
          private int eachKthPoint;
          private int embeddingDimension, embeddingDelay;
          private double noiseRatio;

          private int getSubsampleLength() {
            int prefixLength = (int) (subsampleLengthSlider.getValue() * trajectory[0].length);
            // per started block of k elements, one output element will be generated
            int k = getEachKthPoint();
            // full blocks + 1 block if there is a fractional block
            return prefixLength / k + (prefixLength % k > 0 ? 1 : 0);
          }

          @Override
          public synchronized boolean isValid() {
            if (cachedValue == null) return false;
            if (eachKthPoint != getEachKthPoint()) return false;
            // any embedding dimension <= 0 signifies that no embedding should be used, thus the
            // actual dimension does not matter
            if (getEmbeddingDimension() > 0 && (embeddingDimension != getEmbeddingDimension()))
              return false;
            // for an embedding dimension of <= 1, the delay is insignificant
            if (getEmbeddingDimension() > 1 && (embeddingDelay != getEmbeddingDelay()))
              return false;
            if (getNoiseRatio() != noiseRatio) return false;
            return trajectory == null
                || cachedValue == null
                || getSubsampleLength() == cachedValue[0].length;
          }

          @Override
          public synchronized void recompute() {
            if (trajectory == null) cachedValue = null;
            else {
              // create an empty array with the desired number of dimensions
              cachedValue = new double[trajectory.length][];
              eachKthPoint = getEachKthPoint();

              // crop to sampling size
              int newLength = getSubsampleLength();
              for (int dimIdx = 0; dimIdx < trajectory.length; dimIdx++) {
                cachedValue[dimIdx] =
                    new double[newLength]; // Arrays.copyOf(trajectory[dimIdx], newLength);
                for (int i = 0, t = 0; i < newLength; i++, t += eachKthPoint) {
                  cachedValue[dimIdx][i] = trajectory[dimIdx][t];
                }
              }

              int dim = getEmbeddingDimension();
              int tau = getEmbeddingDelay();
              double noiseRatio = getNoiseRatio();

              if (dim > 0 && tau > 0) {
                cachedValue = PhaseSpaceReconstructed.embed(cachedValue[0], dim, tau);
              }

              cachedValue = TimeSeriesGenerator.addNoise(cachedValue, 0.05, noiseRatio);

              this.noiseRatio = noiseRatio;
              this.embeddingDimension = dim;
              this.embeddingDelay = tau;
            }
          }
        };

    // sync recurrence threshold slider and text field
    Bindings.bindBidirectional(
        recurrenceThresholdTextField.textProperty(),
        recurrenceThresholdSlider.valueProperty(),
        DecimalFormat.getInstance());
    // sync GUI and model recurrence threshold
    Bindings.bindBidirectional(
        recurrenceThresholdTextField.textProperty(),
        recurrenceThresholdProperty(),
        DecimalFormat.getInstance());

    // sync GUI and model embedding parameters
    Bindings.bindBidirectional(
        embeddingDimensionTextField.textProperty(),
        embeddingDimensionProperty(),
        DecimalFormat.getIntegerInstance());
    Bindings.bindBidirectional(
        embeddingDelayTextField.textProperty(),
        embeddingDelayProperty(),
        DecimalFormat.getIntegerInstance());

    // sync GUI and noise parameter
    Bindings.bindBidirectional(noiseSlider.valueProperty(), noiseRatioProperty());

    Bindings.bindBidirectional(
        eachKthPointTextField.textProperty(),
        eachKthPointProperty(),
        DecimalFormat.getIntegerInstance());

    // enable the compute button only if the auto-update checkbox is not on.
    computeRPButton.disableProperty().bind(sliderAutoUpdate.selectedProperty());

    // recompute RP on parameter changes
    subsampleLengthSlider.valueProperty().addListener(this::parametersChanged);
    eachKthPointTextField
        .textProperty()
        .addListener(
            (obs, ov, nv) -> {
              parametersChanged(null, null, null);
            });
    recurrenceThresholdProperty().addListener(this::parametersChanged);
    embeddingDimensionProperty().addListener(this::parametersChanged);
    embeddingDelayProperty().addListener(this::parametersChanged);
    noiseRatioProperty().addListener(this::parametersChanged);

    // Make CRT controls update the computation
    // size of the CRT histogram
    crtLimit
        .textProperty()
        .addListener(
            new ChangeListener<String>() {
              @Override
              public void changed(
                  ObservableValue<? extends String> observable, String oldValue, String newValue) {
                parametersChanged(null, Integer.parseInt(oldValue), Integer.parseInt(newValue));
              }
            });
    // CRT log scale option
    logScaleCheckBox
        .selectedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean oldValue,
                  Boolean newValue) {
                if (oldValue != newValue) parametersChanged(null, 0, 0);
              }
            });

    // make the CRT image use all the available vertical space
    crtImageView.fitWidthProperty().bind(crtTabPane.widthProperty().subtract(20));
    crtImageView.fitHeightProperty().bind(crtTabPane.heightProperty());

    // swap the data of the line length histogram upon selecting another line type
    lineLengthTypeSelector.setItems(
        FXCollections.observableArrayList(
            "DIAGONAL",
            "VERTICAL",
            "WHITE_VERTICAL",
            "ORTHOGONAL")); // DRQA.LineType.DIAGONAL, DRQA.LineType.VERTICAL,
                            // DRQA.LineType.WHITE_VERTICAL, DRQA.LineType.ORTHOGONAL
    lineLengthTypeSelector
        .getSelectionModel()
        .selectedIndexProperty()
        .addListener(this::updateLineLengthHistogram);
    lineLengthTypeSelector.getSelectionModel().select(0);

    distanceDistributionSelector.setItems(FXCollections.observableArrayList("SUBSEQ", "PAIRWISE"));
    distanceDistributionSelector
        .getSelectionModel()
        .selectedIndexProperty()
        .addListener((obs, ov, nv) -> updateDistanceDistributionChart());
    distanceDistributionSelector.getSelectionModel().select(0);

    useDRQA
        .selectedProperty()
        .addListener(
            (obs, ov, nv) ->
                updateLineLengthHistogram(
                    null, null, lineLengthTypeSelector.getSelectionModel().getSelectedIndex()));
  }