コード例 #1
0
ファイル: FreewayBz.java プロジェクト: amicom/my-project
      public FreewayBZPanel() {
        super("ins 0, wrap 2", "[][grow,fill]", "");
        final String lang = System.getProperty("user.language");
        String usertext_finddata;
        String usertext_uid;
        if ("de".equalsIgnoreCase(lang)) {
          usertext_finddata = "Klicke hier um deine User-ID und PIN zu sehen:";
          usertext_uid = "User-ID (muss 9-stellig sein)";
        } else {
          usertext_finddata = "Click here to find your User-ID/PIN:";
          usertext_uid = "User-ID: (must be 9 digis)";
        }
        add(new JLabel(usertext_finddata));
        add(new JLink("https://www.freeway.bz/account"));
        add(idLabel = new JLabel(usertext_uid));
        add(
            this.name =
                new ExtTextField() {

                  @Override
                  public void onChanged() {
                    if (notifier != null) {
                      notifier.onNotify();
                    }
                  }
                });

        name.setHelpText(IDHELP);

        add(new JLabel("PIN:"));
        add(
            this.pass =
                new ExtPasswordField() {

                  @Override
                  public void onChanged() {
                    if (notifier != null) {
                      notifier.onNotify();
                    }
                  }
                },
            "");
        pass.setHelpText(PINHELP);
      }
コード例 #2
0
  @Override
  public JComponent layoutDialogContent() {
    final Collection<LazyHostPlugin> allPLugins = HostPluginController.getInstance().list();
    // Filter - only premium plugins should be here
    final java.util.List<LazyHostPlugin> plugins = new ArrayList<LazyHostPlugin>();
    for (LazyHostPlugin lhp : allPLugins) {
      if (lhp.isPremium()) {
        plugins.add(lhp);
      }
    }
    if (plugins.size() == 0) {
      throw new RuntimeException("No Plugins Loaded Exception");
      // final HostPluginWrapper[] array = plugins.toArray(new
      // HostPluginWrapper[plugins.size()]);
    }
    filter =
        new ExtTextField() {
          private static final long serialVersionUID = 1L;

          @Override
          protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D) g;
            Composite comp = g2.getComposite();
            g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f));
            new AbstractIcon(IconKey.ICON_SEARCH, 16).paintIcon(this, g2, 3, 3);
            g2.setComposite(comp);
          }
        };
    filter.addFocusListener(
        new FocusListener() {
          @Override
          public void focusLost(FocusEvent e) {}

          @Override
          public void focusGained(FocusEvent e) {
            filter.selectAll();
          }
        });
    filter.setHelpText("Search Plugins");
    filter.addKeyListener(
        new KeyListener() {
          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {}

          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DOWN) {
              hoster.onKeyDown();
            }
            if (e.getKeyCode() == KeyEvent.VK_UP) {
              hoster.onKeyUp();
            }
          }
        });
    // filterText.setOpaque(false);
    // filterText.putClientProperty("Synthetica.opaque", Boolean.FALSE);
    // filterText.setBorder(null);
    filter.setBorder(
        BorderFactory.createCompoundBorder(
            filter.getBorder(), BorderFactory.createEmptyBorder(0, 20, 0, 0)));
    hoster =
        new HosterChooserTable(plugins) {
          @Override
          protected void processEvent(AWTEvent e) {
            if (e instanceof KeyEvent) {
              if (((KeyEvent) e).getKeyCode() == KeyEvent.VK_TAB) {
                content.dispatchEvent(e);
                return;
              }
            }
            super.processEvent(e);
          }

          @Override
          protected boolean processKeyBinding(
              KeyStroke stroke, KeyEvent evt, int condition, boolean pressed) {
            return super.processKeyBinding(stroke, evt, condition, pressed);
          }

          public void valueChanged(javax.swing.event.ListSelectionEvent e) {
            super.valueChanged(e);
            if (e.getValueIsAdjusting() || getModel().isTableSelectionClearing()) {
              return;
            }
            try {
              scrollToSelection(0);
              final PluginForHost plg = getSelectedPlugin().newInstance(cl);
              if (plg != null
                  && (lazyHostPlugin == null || !lazyHostPlugin.equals(plg.getLazyP()))) {
                final PluginForHost ret = updatePanel(plg);
                if (ret != null) {
                  lazyHostPlugin = ret.getLazyP();
                }
              }
            } catch (UpdateRequiredClassNotFoundException e1) {
              e1.printStackTrace();
            }
          }
        };
    filter
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              private DelayedRunnable delayedRefresh =
                  new DelayedRunnable(200, 1000) {
                    String lastText = null;

                    @Override
                    public String getID() {
                      return "AddAccountDialog";
                    }

                    @Override
                    public void delayedrun() {
                      new EDTRunner() {
                        @Override
                        protected void runInEDT() {
                          final String text = filter.getText();
                          if (!StringUtils.equals(lastText, text)) {
                            lastText = text;
                            hoster.refresh(text);
                          }
                        }
                      }.waitForEDT();
                    }
                  };

              @Override
              public void removeUpdate(DocumentEvent e) {
                delayedRefresh.resetAndStart();
              }

              @Override
              public void insertUpdate(DocumentEvent e) {
                delayedRefresh.resetAndStart();
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                delayedRefresh.resetAndStart();
              }
            });
    link = new JButton(new AbstractIcon(IconKey.ICON_MONEY, 16));
    link.setText(_GUI.T.gui_menu_action_premium_buy_name());
    link.setToolTipText(_GUI.T.gui_menu_action_premium_buy_name());
    link.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            try {
              final PluginForHost plugin = hoster.getSelectedPlugin().newInstance(cl);
              if (plugin != null) {
                StatsManager.I().openAfflink(plugin, null, "accountmanager/table");
              }
            } catch (UpdateRequiredClassNotFoundException e1) {
              e1.printStackTrace();
            }
          }
        });
    link.setFocusable(false);
    content = new JPanel(new MigLayout("ins 0, wrap 1", "[grow,fill]"));
    content.add(
        header(_GUI.T.AddAccountDialog_layoutDialogContent_choosehoster_()),
        "gapleft 15,spanx,pushx,growx");
    content.add(filter, "gapleft 32,pushx,growx");
    JScrollPane sp;
    content.add(sp = new JScrollPane(hoster), "gapleft 32,pushy,growy");
    sp.setFocusable(false);
    sp.getVerticalScrollBar().setFocusable(false);
    sp.getViewport().setFocusable(false);
    content.add(link, "height 20!,gapleft 32");
    content.add(
        header2 = header(_GUI.T.AddAccountDialog_layoutDialogContent_enterlogininfo()),
        "gapleft 15,spanx,pushx,growx,gaptop 15");
    final LazyHostPlugin lazyp;
    if (this.plugin != null) {
      lazyp = plugin.getLazyP();
    } else {
      lazyp = HostPluginController.getInstance().get(getPreselectedHoster());
    }
    if (lazyp != null) {
      hoster.setSelectedPlugin(lazyp);
    }
    getDialog()
        .addWindowFocusListener(
            new WindowFocusListener() {
              @Override
              public void windowLostFocus(final WindowEvent windowevent) {
                // TODO Auto-generated method stub
              }

              @Override
              public void windowGainedFocus(final WindowEvent windowevent) {
                final Component focusOwner = getDialog().getFocusOwner();
                if (focusOwner != null) {
                  // dialog component has already focus...
                  return;
                }
                /* we only want to force focus on first window open */
                getDialog().removeWindowFocusListener(this);
                focusFirstInputComponent();
              }
            });
    getDialog().setMinimumSize(new Dimension(400, 300));
    return content;
  }