コード例 #1
0
  void confirmSubscription(ViewEvent.SubscriptionRequest event) {
    final Contact contact = event.contact;

    WebPanel panel = panel(Tr.tr("Authorization request"), contact);

    String expl = Tr.tr("When accepting, this contact will be able to see your online status.");
    panel.add(textArea(expl));

    WebNotificationPopup popup =
        NotificationManager.showNotification(
            panel,
            NotificationOption.accept,
            NotificationOption.decline,
            NotificationOption.cancel);
    popup.setClickToClose(false);
    popup.addNotificationListener(
        new NotificationListener() {
          @Override
          public void optionSelected(NotificationOption option) {
            switch (option) {
              case accept:
                mView.getControl().sendSubscriptionResponse(contact, true);
                break;
              case decline:
                mView.getControl().sendSubscriptionResponse(contact, false);
            }
          }

          @Override
          public void accepted() {}

          @Override
          public void closed() {}
        });
  }
コード例 #2
0
ファイル: DetailsBox.java プロジェクト: gitools/gitools
 public void drawUpdating() {
   WebPanel container = getContainer();
   container.removeAll();
   container.setLayout(new HorizontalLayout());
   container.add(updatingPanel);
   container.repaint();
 }
コード例 #3
0
  void confirmContactDeletion(final Contact contact) {
    WebPanel panel = panel(Tr.tr("Contact was deleted on server"), contact);

    String expl =
        Tr.tr("Remove this contact from your contact list?") + "\n" + View.REMOVE_CONTACT_NOTE;
    panel.add(textArea(expl));

    WebNotificationPopup popup =
        NotificationManager.showNotification(
            panel, NotificationOption.yes, NotificationOption.no, NotificationOption.cancel);
    popup.setClickToClose(false);
    popup.addNotificationListener(
        new NotificationListener() {
          @Override
          public void optionSelected(NotificationOption option) {
            switch (option) {
              case yes:
                mView.getControl().deleteContact(contact);
            }
          }

          @Override
          public void accepted() {}

          @Override
          public void closed() {}
        });
  }
コード例 #4
0
ファイル: WebNotification.java プロジェクト: Zauther/weblaf
 /** Updates visible notification options. */
 protected void updateOptions() {
   if (options != null && options.size() > 0) {
     for (final NotificationOption option : options) {
       final WebButton optionButton = new WebButton("");
       optionButton.setLanguage(option.getLanguageKey());
       optionButton.addActionListener(
           new ActionListener() {
             @Override
             public void actionPerformed(final ActionEvent e) {
               fireOptionSelected(option);
               if (closeOnOptionSelection) {
                 acceptAndHide();
               }
             }
           });
       optionsPanel.add(optionButton);
     }
     if (!contains(southPanel)) {
       add(southPanel, BorderLayout.SOUTH);
     }
   } else {
     optionsPanel.removeAll();
     if (contains(southPanel)) {
       remove(southPanel);
     }
   }
   revalidate();
 }
コード例 #5
0
  private static Component createDescription(Example example, ExampleGroup group) {
    Color foreground = group.getPreferredForeground();

    WebLabel titleLabel = new WebLabel(example.getTitle(), JLabel.TRAILING);
    titleLabel.setDrawShade(true);
    titleLabel.setForeground(foreground);
    if (foreground.equals(Color.WHITE)) {
      titleLabel.setShadeColor(Color.BLACK);
    }

    if (example.getDescription() == null) {
      return titleLabel;
    } else {
      WebLabel descriptionLabel = new WebLabel(example.getDescription(), WebLabel.TRAILING);
      descriptionLabel.setForeground(Color.GRAY);
      SwingUtils.changeFontSize(descriptionLabel, -1);

      WebPanel vertical =
          new WebPanel(new VerticalFlowLayout(VerticalFlowLayout.MIDDLE, 0, 0, true, false));
      vertical.setOpaque(false);
      vertical.add(titleLabel);
      vertical.add(descriptionLabel);

      return vertical;
    }
  }
コード例 #6
0
  /** 初始化窗口显示 */
  private void initView() {
    setSize(240, 500);
    // setAlwaysOnTop(true);

    IMTitleComponent title = getIMTitleComponent();
    title.setShowMinimizeButton(false);
    title.setShowMaximizeButton(false);

    memberList = new WebList();
    memberList.setCellRenderer(new GroupMemberListCellRenderer());
    WebScrollPane listScroll =
        new WebScrollPane(memberList) {

          {
            setHorizontalScrollBarPolicy(WebScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
            setBorder(null);
            setMargin(0);
            setShadeWidth(0);
            setRound(0);
            setDrawBorder(false);
          }
        };

    content = new WebPanel();
    content.add(listScroll, BorderLayout.CENTER);
    WebPanel rootContent = new WebPanel();
    rootContent.add(title, BorderLayout.PAGE_START);
    rootContent.add(content, BorderLayout.CENTER);
    setContentPanel(rootContent);
  }
コード例 #7
0
  void showPasswordDialog(boolean wasWrong) {
    WebPanel passPanel = new WebPanel();
    WebLabel passLabel = new WebLabel(Tr.tr("Please enter your key password:"******"Wrong password"));
      wrongLabel.setForeground(Color.RED);
      passPanel.add(wrongLabel, BorderLayout.SOUTH);
    }
    WebOptionPane passPane =
        new WebOptionPane(
            passPanel, WebOptionPane.QUESTION_MESSAGE, WebOptionPane.OK_CANCEL_OPTION);
    JDialog dialog = passPane.createDialog(mMainFrame, Tr.tr("Enter password"));
    dialog.setModal(true);
    dialog.addWindowFocusListener(
        new WindowAdapter() {
          @Override
          public void windowGainedFocus(WindowEvent e) {
            passField.requestFocusInWindow();
          }
        });
    // blocking
    dialog.setVisible(true);

    Object value = passPane.getValue();
    if (value != null && value.equals(WebOptionPane.OK_OPTION))
      mControl.connect(passField.getPassword());
  }
コード例 #8
0
  // TODO not used
  private void showNotification() {
    final WebDialog dialog = new WebDialog();
    dialog.setUndecorated(true);
    dialog.setBackground(Color.BLACK);
    dialog.setBackground(StyleConstants.transparent);

    WebNotificationPopup popup = new WebNotificationPopup(PopupStyle.dark);
    popup.setIcon(Utils.getIcon("kontalk_small.png"));
    popup.setMargin(View.MARGIN_DEFAULT);
    popup.setDisplayTime(6000);
    popup.addNotificationListener(
        new NotificationListener() {
          @Override
          public void optionSelected(NotificationOption option) {}

          @Override
          public void accepted() {}

          @Override
          public void closed() {
            dialog.dispose();
          }
        });

    // content
    WebPanel panel = new WebPanel();
    panel.setMargin(View.MARGIN_DEFAULT);
    panel.setOpaque(false);
    WebLabel title = new WebLabel("A new Message!");
    title.setFontSize(View.FONT_SIZE_BIG);
    title.setForeground(Color.WHITE);
    panel.add(title, BorderLayout.NORTH);
    String text = "this is some message, and some longer text was added";
    WebLabel message = new WebLabel(text);
    message.setForeground(Color.WHITE);
    panel.add(message, BorderLayout.CENTER);
    popup.setContent(panel);

    // popup.packPopup();
    dialog.setSize(popup.getPreferredSize());

    // set position on screen
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gd.getDefaultConfiguration();
    Rectangle screenBounds = gc.getBounds();
    // get height of the task bar
    // doesn't work on all environments
    // Insets toolHeight = toolkit.getScreenInsets(popup.getGraphicsConfiguration());
    int toolHeight = 40;
    dialog.setLocation(
        screenBounds.width - dialog.getWidth() - 10,
        screenBounds.height - toolHeight - dialog.getHeight());

    dialog.setVisible(true);
    NotificationManager.showNotification(dialog, popup);
  }
コード例 #9
0
    AddUserDialog() {
      this.setTitle(Tr.tr("Add New Contact"));
      // this.setSize(400, 280);
      this.setResizable(false);
      this.setModal(true);

      GroupPanel groupPanel = new GroupPanel(10, false);
      groupPanel.setMargin(5);

      // editable fields
      WebPanel namePanel = new WebPanel();
      namePanel.setLayout(new BorderLayout(10, 5));
      namePanel.add(new WebLabel(Tr.tr("Display Name:")), BorderLayout.WEST);
      mNameField = new WebTextField();
      namePanel.add(mNameField, BorderLayout.CENTER);
      groupPanel.add(namePanel);
      groupPanel.add(new WebSeparator(true, true));

      mEncryptionBox = new WebCheckBox(Tr.tr("Encryption"));
      mEncryptionBox.setAnimated(false);
      mEncryptionBox.setSelected(true);
      groupPanel.add(mEncryptionBox);
      groupPanel.add(new WebSeparator(true, true));

      groupPanel.add(new WebLabel("JID:"));
      mJIDField = new WebTextField(38);
      groupPanel.add(mJIDField);
      groupPanel.add(new WebSeparator(true, true));

      this.add(groupPanel, BorderLayout.CENTER);

      // buttons
      WebButton cancelButton = new WebButton(Tr.tr("Cancel"));
      cancelButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              AddUserDialog.this.dispose();
            }
          });
      final WebButton saveButton = new WebButton(Tr.tr("Save"));
      saveButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              AddUserDialog.this.saveUser();
              AddUserDialog.this.dispose();
            }
          });

      GroupPanel buttonPanel = new GroupPanel(2, cancelButton, saveButton);
      buttonPanel.setLayout(new FlowLayout(FlowLayout.TRAILING));
      this.add(buttonPanel, BorderLayout.SOUTH);

      this.pack();
    }
コード例 #10
0
ファイル: StatusBar.java プロジェクト: hihihippp/conexp-ng
 /** Creates the status bar. */
 public StatusBar() {
   setLayout(new BorderLayout());
   setPreferredSize(new Dimension(100, 20));
   panel = new WebPanel();
   BoxLayout boxLayout = new BoxLayout(panel, BoxLayout.LINE_AXIS);
   panel.setLayout(boxLayout);
   panel.add(Box.createHorizontalGlue());
   add(panel, BorderLayout.CENTER);
   setVisible(false);
 }
コード例 #11
0
ファイル: WebNotification.java プロジェクト: Zauther/weblaf
  /** Initializes various notification popup settings. */
  protected void initializeNotificationPopup() {
    setAlwaysOnTop(true);
    setWindowOpaque(false);
    setCloseOnOuterAction(false);
    setLayout(new BorderLayout(15, 5));

    iconImage = new WebImage();
    westPanel = new AlignPanel(iconImage, SwingConstants.CENTER, SwingConstants.CENTER);
    updateIcon();

    contentPanel = new WebPanel();
    contentPanel.setOpaque(false);
    centerPanel = new AlignPanel(contentPanel, SwingConstants.CENTER, SwingConstants.CENTER);
    updateContent();

    optionsPanel = new WebPanel(new HorizontalFlowLayout(4, false));
    optionsPanel.setOpaque(false);
    southPanel = new AlignPanel(optionsPanel, SwingConstants.RIGHT, SwingConstants.CENTER);
    updateOptions();

    addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(final MouseEvent e) {
            if (clickToClose) {
              if (SwingUtils.isLeftMouseButton(e)) {
                acceptAndHide();
              } else {
                hidePopup();
              }
            }
          }
        });
    addPopupListener(
        new PopupAdapter() {
          @Override
          public void popupWillBeOpened() {
            accepted = false;
          }

          @Override
          public void popupOpened() {
            startDelayedClose();
          }

          @Override
          public void popupWillBeClosed() {
            if (accepted) {
              fireAccepted();
            } else {
              fireClosed();
            }
          }
        });
  }
コード例 #12
0
ファイル: UIMsgHistoryModule.java プロジェクト: himcc/iqq
  /** content */
  private void intiContent() {
    IMTitleComponent title = getIMTitleComponent();
    title.setShowMinimizeButton(false);
    title.setShowMaximizeButton(false);

    content = new MsgHistoryPanel(this);
    WebPanel rootContent = new WebPanel();
    rootContent.add(title, BorderLayout.PAGE_START);
    rootContent.add(content, BorderLayout.CENTER);
    setContentPanel(rootContent);
    changeSkin(new ColorBackgroundPainter(Color.LIGHT_GRAY));
  }
コード例 #13
0
 private void showAboutDialog() {
   WebPanel aboutPanel = new WebPanel(new GridLayout(0, 1, 5, 5));
   aboutPanel.add(new WebLabel("Kontalk Java Client v" + Kontalk.VERSION));
   WebLinkLabel linkLabel = new WebLinkLabel();
   linkLabel.setLink("http://www.kontalk.org");
   linkLabel.setText(Tr.tr("Visit kontalk.org"));
   aboutPanel.add(linkLabel);
   WebLabel soundLabel = new WebLabel(Tr.tr("Notification sound by") + " FxProSound");
   aboutPanel.add(soundLabel);
   Icon icon = Utils.getIcon("kontalk.png");
   WebOptionPane.showMessageDialog(
       this, aboutPanel, Tr.tr("About"), WebOptionPane.INFORMATION_MESSAGE, icon);
 }
コード例 #14
0
  private static Component createPreview(WebLookAndFeelDemo owner, Example example) {
    WebPanel previewPanel = new WebPanel();
    previewPanel.setOpaque(false);
    previewPanel.setLayout(
        new TableLayout(
            new double[][] {
              {example.isFillWidth() ? TableLayout.FILL : TableLayout.PREFERRED},
              {TableLayout.FILL, TableLayout.PREFERRED, TableLayout.FILL}
            }));

    previewPanel.add(example.getPreview(owner), "0,1");

    return previewPanel;
  }
コード例 #15
0
  /** 成员搜索 content */
  private void initSeacher() {
    final WebPanel headerPl = new WebPanel();
    membersCount = new WebLabel("Members (0/0)");
    membersCount.setMargin(0, 5, 0, 0);
    WebButton searcherBtn =
        WebButton.createIconWebButton(
            IMImageUtil.getScaledInstance(SkinUtils.getImageIcon("searchNormal"), 18, 18),
            StyleConstants.smallRound,
            true);
    final WebTextField seacherTxt = new WebTextField("Find a contact...");
    seacherTxt.setForeground(Color.LIGHT_GRAY);
    seacherTxt.setVisible(false);
    headerPl.add(membersCount, BorderLayout.CENTER);
    headerPl.add(searcherBtn, BorderLayout.LINE_END);
    headerPl.add(seacherTxt, BorderLayout.PAGE_END);

    progressOverlay = new WebProgressOverlay();
    progressOverlay.setComponent(headerPl);
    content.add(progressOverlay, BorderLayout.PAGE_START);
    searcherBtn.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (!seacherTxt.isVisible()) {
              seacherTxt.setVisible(true);
              headerPl.revalidate();
              headerPl.repaint();
            } else if (seacherTxt.isVisible()) {
              seacherTxt.setVisible(false);
              headerPl.revalidate();
              headerPl.repaint();
            }
          }
        });
    seacherTxt.addFocusListener(
        new FocusListener() {

          @Override
          public void focusLost(FocusEvent e) {
            seacherTxt.setText("Find a contact...");
          }

          @Override
          public void focusGained(FocusEvent e) {
            seacherTxt.setText("");
          }
        });
  }
コード例 #16
0
ファイル: DetailsBox.java プロジェクト: gitools/gitools
  private Component createValueLabel(DetailsDecoration property, int maxLength) {

    String value = property.getFormatedValue();
    boolean abbreviate = (value.length() > maxLength);
    String abbreviatedValue;

    if (value.matches("[0-9\\.]+e-?[0-9]+")) {
      value =
          "<html><body>" + value.replaceAll("e(-?[0-9]+)", "·10<sup>$1</sup>") + "</body></html>";
    }

    if (abbreviate) {
      abbreviatedValue = StringUtils.abbreviate(value, maxLength);
    } else {
      abbreviatedValue = value;
    }

    WebLabel label;
    if (StringUtils.isEmpty(property.getValueLink())) {
      label = new WebLabel(abbreviatedValue);
    } else {
      DetailsWebLinkLabel webLabel = new DetailsWebLinkLabel(abbreviatedValue);
      webLabel.setLink(property.getValueLink(), false);
      label = webLabel;
    }

    SwingUtils.changeFontSize(label, -1);

    if (abbreviate) {
      TooltipManager.setTooltip(label, value, TooltipWay.down, 0);
    }

    label.setCursor(new Cursor(Cursor.HAND_CURSOR));
    label.addMouseListener(new PropertyMouseListener(property));

    if (property.isSelected()) {
      SwingUtils.setBoldFont(label);
    }

    if (property.getBgColor() != null) {
      WebPanel colorBox = new WebPanel();
      colorBox.setPreferredSize(new Dimension(15, 15));
      colorBox.setBackground(property.getBgColor());
      return new GroupPanel(4, colorBox, label);
    }

    label.setForeground(property.isVisible() ? Color.BLACK : Color.lightGray);
    return label;
  }
コード例 #17
0
ファイル: WebNotification.java プロジェクト: Zauther/weblaf
 /** Updates visible notification content. */
 protected void updateContent() {
   if (content != null) {
     contentPanel.removeAll();
     contentPanel.add(content);
     if (!contains(centerPanel)) {
       add(centerPanel, BorderLayout.CENTER);
     }
   } else {
     contentPanel.removeAll();
     if (contains(centerPanel)) {
       remove(centerPanel);
     }
   }
   revalidate();
 }
コード例 #18
0
  void showPresenceError(Contact contact, RosterHandler.Error error) {
    WebPanel panel = panel(Tr.tr("Contact error"), contact);

    panel.add(new WebLabel(Tr.tr("Error:")).setBoldFont());
    String errorText = Tr.tr(error.toString());
    switch (error) {
      case SERVER_NOT_FOUND:
        errorText = Tr.tr("Server not found");
        break;
    }

    panel.add(textArea(errorText));

    NotificationManager.showNotification(panel, NotificationOption.cancel);
  }
コード例 #19
0
ファイル: StatusBar.java プロジェクト: hihihippp/conexp-ng
 /**
  * Creates a progress bar and returns the id with which it is saved.
  *
  * @return id of progress bar
  */
 public long startCalculation() {
   WebProgressBar pb = new WebProgressBar();
   pb.setStringPainted(true);
   panel.add(pb);
   progressBarMap.put(id, pb);
   return id++;
 }
コード例 #20
0
  private void confirmNewKey(final Contact contact, final PGPUtils.PGPCoderKey key) {
    WebPanel panel = new GroupPanel(GAP_DEFAULT, false);
    panel.setOpaque(false);

    panel.add(new WebLabel(Tr.tr("Received new key for contact")).setBoldFont());
    panel.add(new WebSeparator(true, true));

    panel.add(new WebLabel(Tr.tr("Contact:")));
    String contactText = Utils.name(contact) + " " + Utils.jid(contact.getJID(), 30, true);
    panel.add(new WebLabel(contactText).setBoldFont());

    panel.add(new WebLabel(Tr.tr("Key fingerprint:")));
    WebTextArea fpArea = Utils.createFingerprintArea();
    fpArea.setText(Utils.fingerprint(key.fingerprint));
    panel.add(fpArea);

    String expl =
        Tr.tr(
            "When declining the key further communication to and from this contact will be blocked.");
    WebTextArea explArea = new WebTextArea(expl, 3, 30);
    explArea.setEditable(false);
    explArea.setLineWrap(true);
    explArea.setWrapStyleWord(true);
    panel.add(explArea);

    WebNotificationPopup popup =
        NotificationManager.showNotification(
            panel,
            NotificationOption.accept,
            NotificationOption.decline,
            NotificationOption.cancel);
    popup.setClickToClose(false);
    popup.addNotificationListener(
        new NotificationListener() {
          @Override
          public void optionSelected(NotificationOption option) {
            switch (option) {
              case accept:
                mControl.acceptKey(contact, key);
                break;
              case decline:
                mControl.declineKey(contact);
            }
          }

          @Override
          public void accepted() {}

          @Override
          public void closed() {}
        });
  }
コード例 #21
0
ファイル: WebCalendar.java プロジェクト: hackereye/weblaf
  /** Updates week headers. */
  protected void updateWeekHeaders() {
    weekHeaders.removeAll();
    for (int i = 1; i <= 7; i++) {
      final int day = startWeekFromSunday ? (i == 1 ? 7 : i - 1) : i;

      final WebLabel dayOfWeekLabel = new WebLabel();
      dayOfWeekLabel.setLanguage("weblaf.ex.calendar.dayOfWeek." + day);
      dayOfWeekLabel.setDrawShade(true);
      dayOfWeekLabel.setHorizontalAlignment(WebLabel.CENTER);
      dayOfWeekLabel.setFontSizeAndStyle(10, Font.BOLD);
      weekHeaders.add(dayOfWeekLabel, (i - 1) * 2 + ",0");

      if (i < 7) {
        weekHeaders.add(new WebSeparator(WebSeparator.VERTICAL), ((i - 1) * 2 + 1) + ",0");
      }
    }
    weekHeaders.revalidate();
  }
コード例 #22
0
ファイル: WebCalendar.java プロジェクト: hackereye/weblaf
 /**
  * Creates and returns month panel.
  *
  * @return created month panel
  */
 protected WebPanel createMonthPanel() {
   final WebPanel monthDays = new WebPanel();
   monthDays.setOpaque(false);
   monthDays.setMargin(
       StyleConstants.shadeWidth - 1,
       StyleConstants.shadeWidth - 1,
       StyleConstants.shadeWidth - 1,
       StyleConstants.shadeWidth - 1);
   final TableLayout layout =
       new TableLayout(
           new double[][] {
             {
               TableLayout.FILL,
               TableLayout.PREFERRED,
               TableLayout.FILL,
               TableLayout.PREFERRED,
               TableLayout.FILL,
               TableLayout.PREFERRED,
               TableLayout.FILL,
               TableLayout.PREFERRED,
               TableLayout.FILL,
               TableLayout.PREFERRED,
               TableLayout.FILL,
               TableLayout.PREFERRED,
               TableLayout.FILL
             },
             {
               TableLayout.FILL,
               TableLayout.FILL,
               TableLayout.FILL,
               TableLayout.FILL,
               TableLayout.FILL,
               TableLayout.FILL
             }
           });
   layout.setHGap(0);
   layout.setVGap(0);
   monthDays.setLayout(layout);
   return monthDays;
 }
コード例 #23
0
  private Component getGrid() {
    TableLayout layout =
        new TableLayout(
            new double[][] {
              {TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED},
              {TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}
            });
    layout.setHGap(5);
    layout.setVGap(5);

    WebPanel content = new WebPanel(layout);
    content.setOpaque(false);

    txtHoursOfRest24Hrs = new WebTextField(5);
    txtHoursOfWork24Hrs = new WebTextField(5);

    txtHoursOfRest24Hrs.setText(Float.toString(timeSheet.getTotalRest()));
    txtHoursOfWork24Hrs.setText(Float.toString(timeSheet.getTotalWork()));

    txtHoursOfRest24Hrs.setEnabled(false);
    txtHoursOfWork24Hrs.setEnabled(false);

    content.add(new WebLabel("Hours of rest in 24 hours period"), "0,1");
    content.add(txtHoursOfRest24Hrs, "1,1");

    content.add(new WebLabel("Hours of work in 24 hours period"), "0,2");
    content.add(txtHoursOfWork24Hrs, "1,2");

    return content;
  }
コード例 #24
0
  void confirmNewKey(final Contact contact, final PGPUtils.PGPCoderKey key) {
    WebPanel panel = panel(Tr.tr("Received new key for contact"), contact);

    panel.add(new WebLabel(Tr.tr("Key fingerprint:")));
    WebTextArea fpArea = Utils.createFingerprintArea();
    fpArea.setText(Utils.fingerprint(key.fingerprint));
    panel.add(fpArea);

    String expl =
        Tr.tr(
            "When declining the key further communication to and from this contact will be blocked.");
    panel.add(textArea(expl));

    WebNotificationPopup popup =
        NotificationManager.showNotification(
            panel,
            NotificationOption.accept,
            NotificationOption.decline,
            NotificationOption.cancel);
    popup.setClickToClose(false);
    popup.addNotificationListener(
        new NotificationListener() {
          @Override
          public void optionSelected(NotificationOption option) {
            switch (option) {
              case accept:
                mView.getControl().acceptKey(contact, key);
                break;
              case decline:
                mView.getControl().declineKey(contact);
            }
          }

          @Override
          public void accepted() {}

          @Override
          public void closed() {}
        });
  }
コード例 #25
0
  private static WebPanel panel(String title, Contact contact) {
    WebPanel panel = new GroupPanel(GAP_DEFAULT, false);
    panel.setOpaque(false);

    panel.add(new WebLabel(title).setBoldFont());
    panel.add(new WebSeparator(true, true));

    panel.add(new WebLabel(Tr.tr("Contact:")).setBoldFont());
    panel.add(new WebLabel(contactText(contact)));

    return panel;
  }
コード例 #26
0
  public static Component createGroupView(WebLookAndFeelDemo owner, ExampleGroup group) {
    // Creating group view
    Component exampleView;
    List<Example> examples = group.getGroupExamples();
    if (group.isSingleExample() && examples.size() == 1) {
      Example example = examples.get(0);
      exampleView = example.getPreview(owner);
    } else {
      final List<Component> preview = new ArrayList<Component>();

      final WebPanel groupPanel =
          new WebPanel() {
            @Override
            public void setEnabled(boolean enabled) {
              for (Component previewComponent : preview) {
                SwingUtils.setEnabledRecursively(previewComponent, enabled);
              }
              super.setEnabled(enabled);
            }
          };
      groupPanel.putClientProperty(SwingUtils.HANDLES_ENABLE_STATE, true);
      groupPanel.setOpaque(false);
      exampleView = groupPanel;

      int rowsAmount = examples.size() > 1 ? examples.size() * 2 - 1 : 1;
      double[] rows = new double[6 + rowsAmount];
      rows[0] = TableLayout.FILL;
      rows[1] = 20;
      rows[2] = TableLayout.PREFERRED;
      for (int i = 3; i < rows.length - 3; i++) {
        rows[i] = TableLayout.PREFERRED;
      }
      rows[rows.length - 3] = TableLayout.PREFERRED;
      rows[rows.length - 2] = 20;
      rows[rows.length - 1] = TableLayout.FILL;

      double[] columns = {
        20,
        1f - group.getContentPartSize(),
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        TableLayout.PREFERRED,
        group.getContentPartSize(),
        20
      };

      TableLayout groupLayout = new TableLayout(new double[][] {columns, rows});
      groupLayout.setHGap(4);
      groupLayout.setVGap(4);
      groupPanel.setLayout(groupLayout);

      groupPanel.add(
          group.modifySeparator(createVerticalSeparator()), "2,0,2," + (rows.length - 1));
      groupPanel.add(
          group.modifySeparator(createVerticalSeparator()), "4,0,4," + (rows.length - 1));
      groupPanel.add(
          group.modifySeparator(createVerticalSeparator()), "6,0,6," + (rows.length - 1));
      groupPanel.add(
          group.modifySeparator(createVerticalSeparator()), "8,0,8," + (rows.length - 1));

      groupPanel.add(
          group.modifySeparator(createHorizontalSeparator()), "0,2," + (columns.length - 1) + ",2");
      groupPanel.add(
          group.modifySeparator(createHorizontalSeparator()),
          "0," + (rows.length - 3) + "," + (columns.length - 1) + "," + (rows.length - 3));

      int row = 3;
      for (Example example : examples) {
        // Title & description
        groupPanel.add(createDescription(example, group), "1," + row);

        // Marks
        Component mark = createMark(owner, example);
        groupPanel.add(mark, "3," + row);

        // Source code
        Component source = createSourceButton(owner, example);
        groupPanel.add(source, "5," + row);

        // More usage examples
        Component usage = createPresentationButton(example);
        groupPanel.add(usage, "7," + row);

        SwingUtils.equalizeComponentsSize(mark, source, usage);

        // Preview
        Component previewComponent = createPreview(owner, example);
        groupPanel.add(previewComponent, "9," + row);
        preview.add(previewComponent);

        // Rows separator
        if (row > 3) {
          groupPanel.add(
              group.modifySeparator(createHorizontalSeparator()),
              "0," + (row - 1) + "," + (columns.length - 1) + "," + (row - 1),
              0);
        }

        row += 2;
      }
    }

    if (group.isShowWatermark()) {
      WebImage linkImage = new WebImage(logoIcon);
      linkImage.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

      TooltipManager.setTooltip(linkImage, linkIcon, "Library site", TooltipWay.trailing);

      linkImage.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
              WebUtils.browseSiteSafely(WebLookAndFeelDemo.WEBLAF_SITE);
            }
          });

      WebOverlay linkOverlay =
          new WebOverlay(exampleView, linkImage, WebOverlay.LEADING, WebOverlay.BOTTOM);
      linkOverlay.setOverlayMargin(15, 15, 15, 15);
      linkOverlay.setOpaque(false);

      exampleView = linkOverlay;
    }

    return exampleView;
  }
コード例 #27
0
 public void updatePainter() {
   super.setPainter(painter);
 }
コード例 #28
0
  /** Constructs new directory chooser panel. */
  public WebDirectoryChooserPanel() {
    super();

    // Panel settings
    setOpaque(true);

    // Controls pane
    final WebToolBar contolsToolbar = new WebToolBar(WebToolBar.HORIZONTAL);
    contolsToolbar.setToolbarStyle(ToolbarStyle.attached);
    contolsToolbar.setFloatable(false);

    folderUp = new WebButton(FOLDER_UP_ICON);
    folderUp.setLanguage("weblaf.ex.dirchooser.folderup");
    folderUp
        .addHotkey(WebDirectoryChooserPanel.this, Hotkey.ALT_UP)
        .setHotkeyDisplayWay(TooltipWay.down);
    folderUp.setRolloverDecoratedOnly(true);
    folderUp.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            if (selectedDirectory != null) {
              updateSelectedDirectory(selectedDirectory.getParentFile(), true, true);
            }
          }
        });
    contolsToolbar.add(folderUp);

    folderHome = new WebButton(FOLDER_HOME_ICON);
    folderHome.setLanguage("weblaf.ex.dirchooser.home");
    folderHome
        .addHotkey(WebDirectoryChooserPanel.this, Hotkey.ALT_H)
        .setHotkeyDisplayWay(TooltipWay.trailing);
    folderHome.setRolloverDecoratedOnly(true);
    folderHome.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            updateSelectedDirectory(FileUtils.getUserHome(), true, true);
          }
        });
    contolsToolbar.add(folderHome);

    contolsToolbar.addSeparator();

    for (final File file : FileTreeRootType.drives.getRoots()) {
      final WebButton root = new WebButton(FileUtils.getFileIcon(file));
      TooltipManager.setTooltip(root, FileUtils.getDisplayFileName(file));
      root.setRolloverDecoratedOnly(true);
      root.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent e) {
              updateSelectedDirectory(file, true, true);
            }
          });
      contolsToolbar.add(root);
    }

    refresh = new WebButton(REFRESH_ICON);
    refresh.setLanguage("weblaf.ex.dirchooser.refresh");
    refresh
        .addHotkey(WebDirectoryChooserPanel.this, Hotkey.F5)
        .setHotkeyDisplayWay(TooltipWay.leading);
    refresh.setRolloverDecoratedOnly(true);
    refresh.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            if (selectedDirectory != null) {
              fileTree.reloadChilds(selectedDirectory);
            } else {
              fileTree.reloadRootNode();
            }
          }
        });
    contolsToolbar.add(refresh, ToolbarLayout.END);

    folderNew = new WebButton(FOLDER_NEW_ICON);
    folderNew.setLanguage("weblaf.ex.dirchooser.newfolder");
    folderNew
        .addHotkey(WebDirectoryChooserPanel.this, Hotkey.CTRL_N)
        .setHotkeyDisplayWay(TooltipWay.down);
    folderNew.setRolloverDecoratedOnly(true);
    folderNew.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            if (selectedDirectory != null) {
              final String defaultName = LanguageManager.get("weblaf.ex.dirchooser.newfolder.name");
              final String freeName = FileUtils.getAvailableName(selectedDirectory, defaultName);
              final File file = new File(selectedDirectory, freeName);
              if (file.mkdir()) {
                // Updating filestree
                fileTree.addFile(selectedDirectory, file);

                // Editing added folder name
                fileTree.startEditingFile(file);
              } else {
                final String message =
                    LanguageManager.get("weblaf.ex.dirchooser.newfolder.error.text");
                final String title =
                    LanguageManager.get("weblaf.ex.dirchooser.newfolder.error.title");
                WebOptionPane.showMessageDialog(
                    WebDirectoryChooserPanel.this, message, title, WebOptionPane.ERROR_MESSAGE);
              }
            }
          }
        });
    contolsToolbar.add(folderNew, ToolbarLayout.END);

    remove = new WebButton(REMOVE_ICON);
    remove.setLanguage("weblaf.ex.dirchooser.delete");
    remove
        .addHotkey(WebDirectoryChooserPanel.this, Hotkey.DELETE)
        .setHotkeyDisplayWay(TooltipWay.down);
    remove.setRolloverDecoratedOnly(true);
    remove.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            final File file = fileTree.getSelectedFile();
            if (file == null) {
              return;
            }

            // Displaying delete confirmation
            final String message = LanguageManager.get("weblaf.ex.dirchooser.delete.confirm.text");
            final String title = LanguageManager.get("weblaf.ex.dirchooser.delete.confirm.title");
            final int confirm =
                WebOptionPane.showConfirmDialog(
                    WebDirectoryChooserPanel.this,
                    message,
                    title,
                    WebOptionPane.YES_NO_OPTION,
                    WebOptionPane.QUESTION_MESSAGE);

            // Proceed if delete was confirmed
            if (confirm == WebOptionPane.YES_OPTION) {
              // Retrieving index of deleted file node in parent node
              final FileTreeNode parentNode = fileTree.getSelectedNode().getParent();
              final int index = parentNode.indexOfFileChild(file);
              final int count = parentNode.getChildCount();

              // Removing file
              FileUtils.deleteFile(file);
              fileTree.removeFile(file);

              // Restoring selection
              fileTree.setSelectedNode(
                  count == 1
                      ? parentNode
                      : (index < count - 1
                          ? parentNode.getChildAt(index)
                          : parentNode.getChildAt(index - 1)));
            }
          }
        });
    contolsToolbar.add(remove, ToolbarLayout.END);

    // Path field
    webPathField = new WebPathField(selectedDirectory);
    webPathField.setFileFilter(filter);
    webPathField.addPathFieldListener(
        new PathFieldListener() {
          @Override
          public void directoryChanged(final File newDirectory) {
            updateSelectedDirectory(webPathField.getSelectedPath(), false, true);
          }
        });

    // Files tree
    fileTree = new WebFileTree(FileTreeRootType.drives);
    fileTree.setVisibleRowCount(15);
    fileTree.setFileFilter(filter);
    fileTree.setSelectedFile(selectedDirectory, true);
    fileTree.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    fileTree.setEditable(true);

    // Selected directory update
    fileTreeListener =
        new TreeSelectionListener() {
          @Override
          public void valueChanged(final TreeSelectionEvent e) {
            updateSelectedDirectory(fileTree.getSelectedFile(), true, false);
          }
        };
    fileTree.addTreeSelectionListener(fileTreeListener);

    // Toolbar update
    fileTree.addTreeSelectionListener(
        new TreeSelectionListener() {
          @Override
          public void valueChanged(final TreeSelectionEvent e) {
            updateToolbarControlsState();
          }
        });

    // Tree scroll
    final WebScrollPane treeScroll = new WebScrollPane(fileTree);
    treeScroll.setPreferredWidth(400);

    // Panel content
    setLayout(new BorderLayout(0, 3));
    add(contolsToolbar, BorderLayout.NORTH);
    final WebPanel panel = new WebPanel(new BorderLayout(0, 1));
    panel.setMargin(0, 3, 2, 3);
    panel.add(webPathField, BorderLayout.NORTH);
    panel.add(treeScroll, BorderLayout.CENTER);
    add(panel, BorderLayout.CENTER);

    updateSelectedDirectory(null, true, true);
    updateToolbarControlsState();
  }
コード例 #29
0
ファイル: StatusBar.java プロジェクト: hihihippp/conexp-ng
 /**
  * Removes the progress bar with given id.
  *
  * @param id id of progress bar to remove
  */
 public void endCalculation(Long id) {
   panel.remove(progressBarMap.remove(id));
   revalidate();
 }
コード例 #30
0
ファイル: UIMsgHistoryModule.java プロジェクト: himcc/iqq
    /** initialization */
    private void initComponent() {
      headerPl = new WebPanel();
      contentPl = new WebPanel();
      footerPl = new WebPanel();
      localMsgPl = new GroupPanel(false);
      onlineMsgPl = new GroupPanel(false);

      WebScrollPane localMsgScroll =
          new WebScrollPane(localMsgPl) {
            private static final long serialVersionUID = 1L;

            {
              setHorizontalScrollBarPolicy(WebScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
              setBorder(null);
              setMargin(0);
              setShadeWidth(0);
              setRound(0);
              setDrawBorder(false);
            }
          };

      /*
      WebScrollPane onlineMsgScroll = new WebScrollPane(onlineMsgPl) {
      	private static final long serialVersionUID = 1L;

      	{
      		setHorizontalScrollBarPolicy(WebScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
      		setBorder(null);
      		setMargin(0);
      		setShadeWidth(0);
      		setRound(0);
      		setDrawBorder(false);
      	}
      };
      WebTabbedPane msgTab = new WebTabbedPane();
      msgTab.add("Local", localMsgScroll);
      msgTab.add("Online", onlineMsgScroll);
      msgTab.setTabbedPaneStyle(TabbedPaneStyle.attached);
      msgTab.setTabStretchType(TabStretchType.always);
      msgTab.setOpaque(false);
      msgTab.setPainter(SkinUtils.getPainter(Type.NPICON, "transparent"));
      msgTab.setBackgroundAt(0, Color.WHITE);
      msgTab.setBackgroundAt(1, Color.WHITE);
      contentPl.add(msgTab);
      */
      contentPl.add(localMsgScroll);

      WebButton searcherBtn =
          WebButton.createIconWebButton(
              IMImageUtil.getScaledInstance(SkinUtils.getImageIcon("searchNormal"), 18, 18),
              StyleConstants.smallRound,
              true);
      WebButton pagePrev =
          WebButton.createIconWebButton(
              IMImageUtil.getScaledInstance(
                  SkinUtils.getImageIcon("chat/msghistory/arrow/left"), 18, 18),
              StyleConstants.smallRound,
              true);
      WebButton pageNext =
          WebButton.createIconWebButton(
              IMImageUtil.getScaledInstance(
                  SkinUtils.getImageIcon("chat/msghistory/arrow/right"), 18, 18),
              StyleConstants.smallRound,
              true);
      WebTextField pageFld = new WebTextField();
      pageFld.setPreferredSize(new Dimension(30, 20));
      pageTotal = new WebLabel("/0 Page");
      pageTotal.setForeground(Color.GRAY);

      footerPl.add(searcherBtn, BorderLayout.LINE_START);
      footerPl.add(new GroupPanel(true, pagePrev, pageTotal, pageNext), BorderLayout.LINE_END);
      footerPl.setOpaque(true);
      footerPl.setBackground(Color.LIGHT_GRAY);

      pagePrev.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
              if (currentPage == 1) {
                return;
              } else {
                currentPage--;
              }

              // 显示消息
              IMEvent imEvent = new IMEvent(IMEventType.MSG_HISTORY_FIND, namedObject.getEntity());
              imEvent.putData("start", firstKey);
              imEvent.putData("limit", limit);
              imEvent.putData("direct", "older");
              IMEventService events = getContext().getSerivce(IMService.Type.EVENT);
              events.broadcast(imEvent);
            }
          });
      pageNext.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
              if (currentPage == totalPage) {
                return;
              } else {
                currentPage++;
              }
              // 显示消息
              IMEvent imEvent = new IMEvent(IMEventType.MSG_HISTORY_FIND, namedObject.getEntity());
              imEvent.putData("start", lastKey);
              imEvent.putData("limit", limit);
              imEvent.putData("direct", "newer");
              IMEventService events = getContext().getSerivce(IMService.Type.EVENT);
              events.broadcast(imEvent);
            }
          });
    }