Пример #1
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());
  }
Пример #2
0
 /**
  * Creates and returns title label.
  *
  * @return created title label
  */
 protected WebLabel createTitleLabel() {
   titleLabel = new WebLabel(titleFormat.format(shownDate));
   titleLabel.setBoldFont();
   titleLabel.setDrawShade(true);
   titleLabel.setHorizontalAlignment(WebLabel.CENTER);
   titleLabel.setVerticalAlignment(WebLabel.CENTER);
   return titleLabel;
 }
  // 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);
  }
 /** Updates renderer elements view. */
 public void updateFilesView() {
   if (isTilesView()) {
     nameLabel.setHorizontalAlignment(JLabel.LEADING);
     fileList.setFixedCellWidth(tileCellSize.width);
     fileList.setFixedCellHeight(tileCellSize.height);
   } else {
     nameLabel.setHorizontalAlignment(JLabel.CENTER);
     fileList.setFixedCellWidth(iconCellSize.width);
     fileList.setFixedCellHeight(iconCellSize.height);
   }
 }
Пример #5
0
  @SuppressWarnings("rawtypes")
  private void createBorder() {
    DashedBorderPainter dbp = new DashedBorderPainter();
    dbp.setColor(new Color(221, 20, 20));
    dbp.setWidth(2);
    dbp.setDashPhase(3);
    borderLabel.setPainter(dbp);

    app.add(borderLabel);

    borderLabel.setBounds(255, 245, 210, 60);
  }
Пример #6
0
 private static Component createMark(final WebLookAndFeelDemo owner, final Example example) {
   final FeatureState fs = example.getFeatureState();
   ImageIcon fsIcon = fs.getIcon();
   final WebLabel featureState = new WebLabel(fsIcon);
   TooltipManager.setTooltip(featureState, fsIcon, fs.getDescription(), TooltipWay.up);
   featureState.addMouseListener(
       new MouseAdapter() {
         @Override
         public void mousePressed(MouseEvent e) {
           owner.showLegend(featureState, fs);
         }
       });
   return new CenterPanel(featureState, true, true);
 }
Пример #7
0
  public IMChatListElement(Icon icon, String title, WebButton removeBtn) {
    this.removeBtn = removeBtn;

    // 图片和标题
    WebLabel titleLabel = new WebLabel(title, icon);
    titleLabel.setMargin(0, 0, 0, 4);
    titleLabel.setAlignmentX(WebLabel.LEFT_ALIGNMENT);
    titleLabel.setOpaque(false);
    titleLabel.setForeground(Color.WHITE);
    this.add(titleLabel, BorderLayout.CENTER);
    this.add(removeBtn, BorderLayout.LINE_END);

    setPainter(new ChatListElementPainter());
  }
Пример #8
0
  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;
  }
Пример #9
0
    private void initComponent() {
      // 小于一天就显示时间,否则就显示日期
      String time = DATE_FORMAT.format(msg.getDate());
      if (System.currentTimeMillis() - msg.getDate().getTime() < 24 * 3600 * 1000) {
        time = TIME_FORMAT.format(msg.getDate());
      }
      infoLabl = new WebLabel(msg.getSender().getNickname() + " " + time);
      infoLabl.setForeground(new Color(70, 160, 220));
      infoLabl.setMargin(5);
      contnetPane = new RichTextPane();
      contnetPane.setRichItems(msg.getContents());
      contnetPane.setEditable(false);

      add(infoLabl, BorderLayout.PAGE_START);
      add(contnetPane, BorderLayout.CENTER);
    }
Пример #10
0
 void setEnabled(boolean enabled, boolean isMember) {
   mTextArea.setEnabled(enabled);
   Color textBG = enabled ? Color.WHITE : Color.LIGHT_GRAY;
   mTextArea.setBackground(textBG);
   mOverlay.setBackground(textBG);
   mOverlayLabel.setText(isMember ? Tr.tr("You are not a member of this group") : "");
 }
Пример #11
0
  private void reloadMembers() {
    GroupMemberListModel model = (GroupMemberListModel) listModels.get(namedObject.getEntity());

    List<? extends QQStranger> members = getMembers();

    if (model == null) {
      model = new GroupMemberListModel(new UserListComparator());
      for (QQStranger m : members) {
        model.addElement(new UserListElement(new UIUser(m)));

        // 下载头像, 只下载一次,后面是手动更新
        if (isLoadFace) {
          IMEventService events = getContext().getSerivce(IMService.Type.EVENT);
          events.broadcast(new IMEvent(IMEventType.USER_FACE_REQUEST, m));
        }
      }
      listModels.put(namedObject.getEntity(), model);
    }

    model.sort(); // 根据状态排序
    membersCount.setText("Members (" + getOnlineCount(members) + "/" + members.size() + ")");
    if (model != memberList.getModel()) {
      memberList.setModel(model);
    }
    model.updateAll();
    // 停止进度条
    progressOverlay.setShowLoad(false);
  }
Пример #12
0
 public void setPageInfo(int count) {
   if (currentPage == 0) {
     currentPage = count;
   }
   totalPage = count;
   pageTotal.setText(currentPage + " / " + totalPage + " page");
 }
Пример #13
0
  /** 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();
  }
Пример #14
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;
    }
  }
Пример #15
0
  private Component createNameLabel(DetailsDecoration detail) {

    if (detail instanceof JComponentDetailsDecoration) {
      Component c = createComponentNameLabel((JComponentDetailsDecoration) detail);
      if (c != null) {
        c.setForeground(detail.isVisible() ? Color.BLACK : Color.lightGray);
        return c;
      }
    }

    WebLabel label = new WebLabel(StringUtils.capitalize(detail.getName()), JLabel.TRAILING);

    label.setDrawShade(true);
    SwingUtils.changeFontSize(label, -1);

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

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

    if (StringUtils.isNotEmpty(detail.getDescription())) {
      String description =
          "<html><body width=\"300px\">" + detail.getDescription() + "</body></html>";
      TooltipManager.setTooltip(label, description, TooltipWay.down, 0);
    }

    if (!StringUtils.isEmpty(detail.getDescriptionLink())) {
      DetailsWebLinkLabel webLabel = new DetailsWebLinkLabel("", JLabel.TRAILING);
      webLabel.setIcon(IconNames.INFO_ICON);
      webLabel.setLink(detail.getDescriptionLink(), false);
      TooltipManager.setTooltip(webLabel, detail.getDescriptionLink(), TooltipWay.down, 0);
      return new GroupPanel(GroupingType.fillFirst, 5, webLabel, label);
    }

    label.setForeground(detail.isVisible() ? Color.BLACK : Color.lightGray);
    return label;
  }
Пример #16
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("");
          }
        });
  }
Пример #17
0
  public void BuildComponents() {
    pawnEdit.setDrawShade(true);
    pawnEdit.setShadeColor(new Color(221, 20, 20));

    TooltipManager.addTooltip(RRButton, "Clears map of all raiders");
    TooltipManager.addTooltip(
        CRButton, "Converts all raiders to colonists. This is unstable use at own risk");
    TooltipManager.addTooltip(CEButton, "Not completed, minimal features implemented");

    createBorder();
    app.add(pawnEdit);
    app.add(RRButton);
    app.add(CRButton);
    app.add(CEButton);

    pawnEdit.setBounds(260, 225, 80, 25);
    RRButton.setBounds(260, 250, 100, 25);
    CRButton.setBounds(360, 250, 100, 25);
    CEButton.setBounds(260, 275, 140, 25);

    RRButton.addActionListener(rrl);
    CRButton.addActionListener(crl);
    CEButton.addActionListener(cel);
  }
Пример #18
0
  @Override
  public void changed(float totalRest, float totalWork) {
    txtHoursOfRest24Hrs.setText(Float.toString(totalRest));
    txtHoursOfWork24Hrs.setText(Float.toString(totalWork));

    Calendar cal = Calendar.getInstance();
    cal.setTime(currentDate);

    int month = cal.get(Calendar.MONTH);

    StringBuilder sb = new StringBuilder();
    sb.append("<html><ul>");

    if (currentCrew != null) {

      try {

        EntryTime time = new EntryTime();
        time.setSchedule(timeSheet.getSchedule());

        double totalWorkHours = 24 - time.getTotalRestHours();

        errorReportEntry = new ErrorReportEntry();
        errorReportEntry.setEntryDate(getDate(currentDate));
        errorReportEntry.setCrew(currentCrew);

        errorReportEntry.setRestIn24hours(time.getTotalRestHours());
        errorReportEntry.setWorkIn24hours(totalWorkHours);

        if (time.getTotalRestHours() < 10) {
          sb.append("<li>Total period of REST > 10 Hours</li>");

          errorReportEntry.setRestGreater10hrs(true);
        }

        if (totalWorkHours > 14) {
          sb.append("<li>Total period of WORK &lt; 14 Hours</li>");

          errorReportEntry.setWorkLess14hrs(true);
        }

        errorReport = new ErrorReport(currentCrew, null, month, cal.get(Calendar.YEAR));
        errorReport.generateReport();

        if (errorReport.getEntryTimeList().size() >= cal.get(Calendar.DAY_OF_MONTH) - 1) {
          errorReport
              .getEntryTimeList()
              .get(cal.get(Calendar.DAY_OF_MONTH) - 1)
              .setSchedule(timeSheet.getSchedule());
          errorReport.refresh();
        }

        if (errorReport.getContainMoreThan2RestPeriods(cal.get(Calendar.DAY_OF_MONTH)) == true) {
          sb.append("<li>Total number of REST periods are more than 2</li>");

          errorReportEntry.setTotalRestPeriods(
              errorReport.getRestPeriodCounter(cal.get(Calendar.DAY_OF_MONTH)));
        }

        if (!errorReport.contain6HourContinuousRest(cal.get(Calendar.DAY_OF_MONTH))) {
          sb.append("<li>At least one period of rest must be of 6 hours in length</li>");

          errorReportEntry.setOneRestPeriod6hrs(true);
        }

        double restHoursIn24Hours = errorReport.get24HourRestHours(cal.get(Calendar.DAY_OF_MONTH));
        if (restHoursIn24Hours < 10) {
          sb.append("<li>Any 24-hour Total Period of REST &gt; 10 Hours</li>");

          errorReportEntry.setAnyRest24hours(restHoursIn24Hours);

          errorReportEntry.setTotalRest24hrsGreater10hrs(true);
        }

        double restHoursIn7Days = errorReport.get7DayRestHours(cal.get(Calendar.DAY_OF_MONTH));
        if (restHoursIn7Days < 77) {
          sb.append("<li>Any 7-days Total Period of REST &gt; 77 Hours</li>");

          errorReportEntry.setRest7days(restHoursIn7Days);

          errorReportEntry.setTotalRest7daysGreater77hrs(true);
        }

        double last3DayTotalRestHours =
            errorReport.getLast3DayTotalRestHours(cal.get(Calendar.DAY_OF_MONTH));
        if (last3DayTotalRestHours < 36) {
          sb.append("<li>Rest hours in last 3 days are &lt; 36 Hours</li>");
        }
        errorReportEntry.setRestHour3daysGreater36hrs(last3DayTotalRestHours);

      } catch (Exception e) {
      }
    }

    sb.append("</ul></html>");

    lblNonConformities.setText(sb.toString());
    lblNonConformities.repaint();
  }
  /**
   * Constructs cell renderer for the specified file list.
   *
   * @param fileList file list in which this cell renderer is used
   */
  public WebFileListCellRenderer(final WebFileList fileList) {
    super();

    this.fileList = fileList;

    iconLabel = new WebLabel();
    iconLabel.setHorizontalAlignment(JLabel.CENTER);
    iconLabel.setPreferredSize(new Dimension(imageSide, imageSide));

    nameLabel = new WebLabel();
    nameLabel.setFont(nameLabel.getFont().deriveFont(Font.PLAIN));
    nameLabel.setForeground(Color.BLACK);
    nameLabel.setVerticalAlignment(JLabel.CENTER);

    descriptionLabel = new WebLabel(WebLabel.LEADING);
    descriptionLabel.setFont(descriptionLabel.getFont().deriveFont(Font.PLAIN));
    descriptionLabel.setForeground(Color.GRAY);

    sizeLabel = new WebLabel(WebLabel.LEADING);
    sizeLabel.setFont(sizeLabel.getFont().deriveFont(Font.PLAIN));
    sizeLabel.setForeground(new Color(49, 77, 179));

    setLayout(new FileCellLayout());
    add(iconLabel);
    add(nameLabel);
    add(descriptionLabel);
    add(sizeLabel);

    fileList.addPropertyChangeListener(
        WebLookAndFeel.COMPONENT_ENABLED_PROPERTY,
        new PropertyChangeListener() {
          @Override
          public void propertyChange(final PropertyChangeEvent evt) {
            final boolean enabled = fileList.isEnabled();
            iconLabel.setEnabled(enabled);
            nameLabel.setEnabled(enabled);
            descriptionLabel.setEnabled(enabled);
            sizeLabel.setEnabled(enabled);
          }
        });

    fileList.addPropertyChangeListener(
        WebLookAndFeel.COMPONENT_ORIENTATION_PROPERTY,
        new PropertyChangeListener() {
          @Override
          public void propertyChange(final PropertyChangeEvent evt) {
            final ComponentOrientation orientation = fileList.getComponentOrientation();
            nameLabel.setComponentOrientation(orientation);
            descriptionLabel.setComponentOrientation(orientation);
            sizeLabel.setComponentOrientation(orientation);
          }
        });

    updateFilesView();
  }
  /**
   * Returns list cell renderer component.
   *
   * @param list tree
   * @param value cell value
   * @param index cell index
   * @param isSelected whether cell is selected or not
   * @param cellHasFocus whether cell has focus or not
   * @return cell renderer component
   */
  @Override
  public Component getListCellRendererComponent(
      final JList list,
      final Object value,
      final int index,
      final boolean isSelected,
      final boolean cellHasFocus) {
    super.getListCellRendererComponent(list, "", index, isSelected, cellHasFocus);

    final FileElement element = (FileElement) value;
    final File file = element.getFile();

    // Proper margin
    setMargin(isTilesView() ? tileCellMargin : iconCellMargin);

    // Renderer icon
    String imageSize = null;
    if (iconLabel.isEnabled()) {
      // Thumbnail loading
      synchronized (thumbnailsLock) {
        if (!element.isThumbnailQueued() && !element.isDisabledThumbnailQueued()) {
          queueThumbnailLoad(element, false);
        }
      }

      // Image thumbnail
      final ImageIcon thumbnail = element.getEnabledThumbnail();
      iconLabel.setIcon(thumbnail);

      // Image description
      if (thumbnail != null) {
        imageSize = thumbnail.getDescription();
      }
    } else {
      // Disabled thumbnail loading
      synchronized (thumbnailsLock) {
        if (!element.isDisabledThumbnailQueued()) {
          queueThumbnailLoad(element, true);
        }
      }

      // Image disabled thumbnail
      iconLabel.setDisabledIcon(element.getDisabledThumbnail());
    }

    // Updating file description elements
    if (fileList.getEditedCell() != index) {
      // Settings description
      final FileDescription fileDescription = FileUtils.getFileDescription(file, imageSize);
      nameLabel.setText(fileDescription.getName());

      // Updating tile view additional description
      if (isTilesView()) {
        descriptionLabel.setText(fileDescription.getDescription());

        // Updating size label
        if (fileDescription.getSize() != null) {
          sizeLabel.setText(fileDescription.getSize());
        } else {
          sizeLabel.setText(null);
        }
      } else {
        descriptionLabel.setText(null);
        sizeLabel.setText(null);
      }
    } else {
      nameLabel.setText(null);
      descriptionLabel.setText(null);
      sizeLabel.setText(null);
    }

    return this;
  }
Пример #21
0
 private void updateFileName() {
   fileName.setIcon(getDisplayIcon(file));
   fileName.setText(getDisplayName(file));
 }
 public void setHorizontalTextPosition(int textPosition) {
   horizontalTextPositionSet = true;
   super.setHorizontalTextPosition(textPosition);
 }
Пример #23
0
    /** 初始化组件 */
    private void initComponent() {
      WebLabel netSettingLbl = new WebLabel("Network Setting");
      WebLabel typeLbl = new WebLabel("Type:");
      WebLabel addressLbl = new WebLabel("Address:");
      WebLabel portLbl = new WebLabel("Port:");
      WebLabel usernameLbl = new WebLabel("Username:"******"Password:"******"Domain:");

      typeCbx = new WebComboBox();
      typeCbx.addItem("None");
      typeCbx.addItem("Http");
      typeCbx.addItem("Socks5");
      typeCbx.addItem("Browser");
      typeCbx.setDrawFocus(false);

      // field
      addressFld = new WebTextField();
      portFld = new WebTextField();
      usernameFld = new WebTextField();
      passwordFld = new WebTextField();
      domainFld = new WebTextField();

      // label margin
      netSettingLbl.setMargin(15);
      Insets insets = new Insets(5, 5, 5, 5);
      typeLbl.setMargin(5, 37, 5, 5);
      addressLbl.setMargin(5, 14, 5, 5);
      portLbl.setMargin(5, 27, 5, 5);
      usernameLbl.setMargin(insets);
      passwordLbl.setMargin(insets);
      domainLbl.setMargin(insets);

      // size
      Dimension d1 = new Dimension(80, 30);
      Dimension d2 = new Dimension(100, 30);
      Dimension d3 = new Dimension(50, 30);

      // field properties
      typeCbx.setPreferredSize(d1);
      usernameFld.setPreferredSize(d1);
      addressFld.setPreferredSize(d2);
      passwordFld.setPreferredSize(d2);
      portFld.setPreferredSize(d3);
      domainFld.setPreferredSize(d3);

      // group panel
      GroupPanel g1 =
          new GroupPanel(true, typeLbl, typeCbx, addressLbl, addressFld, portLbl, portFld);
      GroupPanel g2 =
          new GroupPanel(
              true, usernameLbl, usernameFld, passwordLbl, passwordFld, domainLbl, domainFld);
      g1.setPreferredSize(new Dimension(this.getWidth(), 30));

      // test button
      Dimension dBtn = new Dimension(80, 30);
      WebButton testBtn = new WebButton("Test");
      WebButton okBtn = new WebButton("OK");
      WebButton cancelBtn = new WebButton("Cancel");
      // size
      testBtn.setPreferredSize(dBtn);
      okBtn.setPreferredSize(dBtn);
      cancelBtn.setPreferredSize(dBtn);
      // action
      testBtn.setAction(view.getActionService().getActionMap(this).get("processTestAction"));
      okBtn.setAction(view.getActionService().getActionMap(this).get("processOKAction"));
      cancelBtn.setAction(view.getActionService().getActionMap(this).get("processCancelAction"));
      // reset text
      testBtn.setText("Test");
      okBtn.setText("OK");
      cancelBtn.setText("Cancel");

      // layout panel
      WebPanel testPl = new WebPanel();
      testPl.add(testBtn, BorderLayout.LINE_END);
      testPl.setOpaque(false);
      testPl.setMargin(20, 0, 5, 30);
      WebPanel confimBtnPl = new WebPanel();
      confimBtnPl.add(new GroupPanel(true, okBtn, cancelBtn), BorderLayout.LINE_END);
      confimBtnPl.setMargin(10, 0, 5, 30);
      confimBtnPl.setOpaque(false);

      // add to content
      add(new GroupPanel(false, netSettingLbl, g1, g2, testPl, confimBtnPl));
    }
Пример #24
0
  public WebFilePlate(File file, boolean decorated) {
    super(decorated);

    this.file = file;

    // setDrawFocus ( true );
    setMargin(0, 3, 0, 0);

    TableLayout tableLayout =
        new TableLayout(
            new double[][] {{TableLayout.FILL, TableLayout.PREFERRED}, {TableLayout.PREFERRED}});
    tableLayout.setHGap(0);
    tableLayout.setVGap(0);
    setLayout(tableLayout);

    // Displayed file name
    fileName = new WebLabel();
    fileName.setMargin(0, 0, 0, showRemoveButton ? 1 : 0);
    add(fileName, "0,0");

    // Updating current file name
    updateFileName();

    // Adding remove button if needed
    if (showRemoveButton) {
      add(getRemoveButton(), "1,0");
    }

    // Adding appear listener
    addAncestorListener(
        new AncestorAdapter() {
          @Override
          public void ancestorAdded(AncestorEvent event) {
            if (animator != null && animator.isRunning()) {
              animator.stop();
            }
            if (animate) {
              animator =
                  new WebTimer(
                      "WebFilePlate.fadeInTimer",
                      StyleConstants.animationDelay,
                      new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                          opacity += 0.1f;
                          if (opacity < 1f) {
                            WebFilePlate.this.repaint();
                          } else {
                            opacity = 1f;
                            WebFilePlate.this.repaint();
                            animator.stop();
                          }
                        }
                      });
              animator.start();
            } else {
              opacity = 1f;
              WebFilePlate.this.repaint();
            }
          }
        });
  }
Пример #25
0
 /** Updates title label text. */
 protected void updateTitleLabel() {
   titleLabel.setText(titleFormat.format(shownDate));
 }
Пример #26
0
    /** 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);
            }
          });
    }
Пример #27
0
  private WebButton createSettings() {
    WebButton settings =
        new WebButton(new ImageIcon(SourceViewer.class.getResource("icons/settings.png")));
    settings.setDrawFocus(false);
    settings.setRolloverDecoratedOnly(true);

    WebButtonPopup wbp = new WebButtonPopup(settings, PopupWay.downLeft);

    WebPanel popupContent = new WebPanel(new VerticalFlowLayout(5, 5));
    popupContent.setMargin(5);
    popupContent.setOpaque(false);
    wbp.setContent(popupContent);

    theme = new WebComboBox(EditorTheme.values());
    theme.registerSettings(SETTINGS_PREFIX + "theme", 0);
    theme.setRenderer(
        new WebComboBoxCellRenderer(theme) {
          @Override
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            EditorTheme editorTheme = (EditorTheme) value;
            WebComboBoxElement renderer =
                (WebComboBoxElement)
                    super.getListCellRendererComponent(
                        list, value, index, isSelected, cellHasFocus);
            renderer.setIcon(editorTheme.getIcon());
            renderer.setText(editorTheme.getName());
            return renderer;
          }
        });
    theme.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            synchronized (activeEditorsLock) {
              final String themeName = theme.getSelectedItem().toString().toLowerCase();
              for (Map.Entry<JarEntry, RSyntaxTextArea> entry : activeEditors.entrySet()) {
                loadTheme(themeName, entry.getValue());
              }
            }
          }
        });
    popupContent.add(theme);

    allowCodeFolding = new WebToggleButton(loadEditorIcon("allowCodeFolding"));
    allowCodeFolding.registerSettings(SETTINGS_PREFIX + "allowCodeFolding", false);
    allowCodeFolding.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            synchronized (activeEditorsLock) {
              for (Map.Entry<JarEntry, RSyntaxTextArea> entry : activeEditors.entrySet()) {
                entry.getValue().setCodeFoldingEnabled(allowCodeFolding.isSelected());
              }
            }
          }
        });
    final WebLabel allowCodeFoldingLabel = new WebLabel("Allow code folding");
    allowCodeFoldingLabel.setDrawShade(true);
    allowCodeFoldingLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            if (SwingUtils.isLeftMouseButton(e)) {
              allowCodeFolding.requestFocusInWindow();
              allowCodeFolding.doClick();
            }
          }
        });
    popupContent.add(new GroupPanel(5, allowCodeFolding, allowCodeFoldingLabel));

    paintTabLines = new WebToggleButton(loadEditorIcon("paintTabLines"));
    paintTabLines.registerSettings(SETTINGS_PREFIX + "paintTabLines", false);
    paintTabLines.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            synchronized (activeEditorsLock) {
              for (Map.Entry<JarEntry, RSyntaxTextArea> entry : activeEditors.entrySet()) {
                entry.getValue().setPaintTabLines(paintTabLines.isSelected());
              }
            }
          }
        });
    final WebLabel paintTabLinesLabel = new WebLabel("Paint tab lines");
    paintTabLinesLabel.setDrawShade(true);
    paintTabLinesLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            if (SwingUtils.isLeftMouseButton(e)) {
              paintTabLines.requestFocusInWindow();
              paintTabLines.doClick();
            }
          }
        });
    popupContent.add(new GroupPanel(5, paintTabLines, paintTabLinesLabel));

    showWhitespaces = new WebToggleButton(loadEditorIcon("showWhitespaces"));
    showWhitespaces.registerSettings(SETTINGS_PREFIX + "showWhitespaces", false);
    showWhitespaces.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            synchronized (activeEditorsLock) {
              for (Map.Entry<JarEntry, RSyntaxTextArea> entry : activeEditors.entrySet()) {
                entry.getValue().setWhitespaceVisible(showWhitespaces.isSelected());
              }
            }
          }
        });
    final WebLabel showWhitespacesLabel = new WebLabel("Show whitespaces");
    showWhitespacesLabel.setDrawShade(true);
    showWhitespacesLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            if (SwingUtils.isLeftMouseButton(e)) {
              showWhitespaces.requestFocusInWindow();
              showWhitespaces.doClick();
            }
          }
        });
    popupContent.add(new GroupPanel(5, showWhitespaces, showWhitespacesLabel));

    showEol = new WebToggleButton(loadEditorIcon("showEol"));
    showEol.registerSettings(SETTINGS_PREFIX + "showEol", false);
    showEol.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            synchronized (activeEditorsLock) {
              for (Map.Entry<JarEntry, RSyntaxTextArea> entry : activeEditors.entrySet()) {
                entry.getValue().setEOLMarkersVisible(showEol.isSelected());
              }
            }
          }
        });
    final WebLabel showEolLabel = new WebLabel("Show end of line");
    showEolLabel.setDrawShade(true);
    showEolLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            if (SwingUtils.isLeftMouseButton(e)) {
              showEol.requestFocusInWindow();
              showEol.doClick();
            }
          }
        });
    popupContent.add(new GroupPanel(5, showEol, showEolLabel));

    return settings;
  }