@Override
  public void addChartOptions(final XToolBar toolBar) {
    toolBar.add(new HelpIcon(Helps.PLAYER_STATS_CHART, true).rightBorder(5));

    toolBar.add(new XLabel(Settings.PLAYER_STATS_STAT.name + ":"));
    toolBar.add(statComboBox);

    toolBar.add(new XLabel(Settings.PLAYER_STATS_PRESENTATION.name + ":"));
    toolBar.add(presentationComboBox);

    toolBar.add(minsCheckBox);

    toolBar.add(gasCheckBox);

    toolBar.add(separateMinsGasCheckBox);
  }
Example #2
0
  /** Builds the GUI of the page. */
  private void buildGui() {
    final Box toolBarsBox = Box.createVerticalBox();
    addNorth(toolBarsBox);

    final XToolBar infoBar = new XToolBar();
    toolBarsBox.add(infoBar);
    infoBar.add(
        new XLabel(
                "<html>On this page you can view and install the available <b>Official</b> external modules."
                    + " <b><font color='red'>Restart is required when changes are made!</font></b></html>")
            .verticalBorder(5));
    infoBar.finalizeLayout();

    final ToolBarForTable toolBar = new ToolBarForTable(table);
    toolBarsBox.add(toolBar);
    toolBar.addSelectInfoLabel("Select a Module.");
    toolBar.addSelEnabledButton(enableUpdateAction);
    toolBar.addSeparator();
    toolBar.addSelEnabledButton(disableUpdateAction);
    toolBar.addSeparator();
    toolBar.add(new XLabel(LHelps.EXTERNAL_MODULES.title).leftBorder(20));
    toolBar.add(new HelpIcon(LHelps.EXTERNAL_MODULES).leftBorder(2));
    toolBar.addSeparator();
    toolBar.add(new XLabel(LHelps.OFFICIAL_EXTERNAL_MODULES.title));
    toolBar.add(new HelpIcon(LHelps.OFFICIAL_EXTERNAL_MODULES).leftBorder(2));
    toolBar.finalizeLayout();

    final Box viewsBox = Box.createVerticalBox();
    viewsBox.add(waitInfoWrapper);
    if (LEnv.APP_STARTED.get())
      waitInfoWrapper.setVisible(false); // App started, we surely have what we need
    else tableWrapperBox.setVisible(false);
    viewsBox.add(tableWrapperBox);
    addCenter(viewsBox);

    rebuildTable();
  }
Example #3
0
  @Override
  protected void buildGui() {
    XToolBar toolBar = new XToolBar();
    toolBarsBox.add(toolBar);

    toolBar.add(new XLabel("Data source:").verticalBorder(7));
    dataSourceComboBox.addActionListener(rebuilderListener);
    dataSourceComboBox.setMaximumRowCount(dataSourceComboBox.getItemCount());
    toolBar.add(dataSourceComboBox);

    toolBar.addSeparator();
    LGuiUtils.autoCreateDisabledImage(toolBar.add(saveAction));

    toolBar.addSeparator();
    toolBar.add(new XLabel("Line size:"));
    toolBar.add(hexLineSizeComboBox);
    toolBar.add(new XLabel(Settings.HEX_LINE_SIZE.viewHints.getSubsequentText()));

    toolBar.addSeparator();
    toolBar.add(new XLabel("Jump to pos:"));
    final XTextField jumpTextField = new XTextField(null, 6, true);
    jumpTextField.setValidator(
        new IValidator() {
          @Override
          public boolean validate(final String text) {
            final boolean result = validateLogic(text);
            if (!result) Sound.beepOnEmptyTxtSearchRslt();
            return result;
          }

          private boolean validateLogic(final String text) {
            if (text.isEmpty() || "0x".equals(text)) return true;
            try {
              final int pos =
                  text.startsWith("0x")
                      ? Integer.parseInt(text.substring(2), 16)
                      : Integer.parseInt(text);
              if (pos < 0 || pos >= data.length) return false;
              final int line = pos >> hexLineSizeComboBox.getSelectedItem().shiftCount;
              textList.setSelectedIndex(line);
              textList.scrollRectToVisible(textList.getCellBounds(line, line));
              return true;
            } catch (final NumberFormatException nfe) {
              return false;
            }
          }
        });
    jumpTextField.addActionListener(
        new ActionAdapter() {
          @Override
          public void actionPerformed(final ActionEvent event) {
            final String text = jumpTextField.getText();
            jumpTextField.setText(null);
            jumpTextField.setText(text);
          }
        });
    jumpTextField.setToolTipText(
        "<html>Enter a byte position to jump to, either decimal or hexa starting with <code>\"0x\"</code>.</html>");
    // Focus Jump field when pressing CTRL+J
    jumpTextField.registerFocusHotkey(
        this, KeyStroke.getKeyStroke(KeyEvent.VK_J, InputEvent.CTRL_MASK));
    toolBar.add(jumpTextField);

    toolBar.addSeparator();
    toolBar.add(dataSizeLabel);

    toolBar.finalizeLayout();

    super.buildGui();

    // Extend the original tool bar
    toolBar = this.toolBar;
    // Move the info component (currently the last) to the end
    final Component infoComp = toolBar.getComponent(toolBar.getComponentCount() - 1);
    toolBar.remove(toolBar.getComponentCount() - 1);
    // Insert tip to the text search, before the separator:
    toolBar.add(new TipIcon(Tips.BINARY_DATA_TEXT_SEARCH), toolBar.getComponentCount() - 1);
    // Add Hex searcher
    hexSearchComp.textField.setValidator(
        new IValidator() {
          @Override
          public boolean validate(String text) {
            text = text.replace(" ", ""); // Remove spaces
            // Check: length must be even, must contain only hex digits
            return (text.length() & 0x01) == 0 && text.matches("[\\da-f]*");
          }
        });
    hexSearchComp.textField.setToolTipText(
        "<html>Search hex data, for example <code>\"06 1f\"</html>");
    // Register CTRL+F for hex search (CTRL+S is taken by the other search component)
    // (CTRL+H is already used by JTextField!)
    hexSearchComp.registerFocusHotkey(
        this, KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_MASK));
    hexSearchComp.setSearcher(hexSearcher);
    toolBar.add(hexSearchComp);
    toolBar.addSeparator();
    toolBar.add(infoComp);
    toolBar.finalizeLayout();
  }