Exemple #1
0
  /** 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();
            }
          }
        });
  }
  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;
    }
  }
  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;
  }
  // 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);
  }
  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;
  }
  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() {}
        });
  }
  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;
  }
Exemple #8
0
 /**
  * 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;
 }
  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;
  }
Exemple #10
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);
            }
          });
    }
Exemple #11
0
  /**
   * Constructs new calendar with the specified selected date.
   *
   * @param date selected date
   */
  public WebCalendar(final Date date) {
    super(true);

    this.date = date != null ? new Date(date.getTime()) : null;
    this.shownDate = date != null ? new Date(date.getTime()) : new Date();

    setDrawFocus(true);
    setRound(StyleConstants.smallRound);
    setLayout(new BorderLayout(0, 0));
    putClientProperty(SwingUtils.HANDLES_ENABLE_STATE, true);

    // Main layout
    final WebPanel centerPanel = new WebPanel();
    centerPanel.setOpaque(false);
    add(centerPanel, BorderLayout.CENTER);

    // Header panel
    final WebPanel header = new WebPanel();
    header.setOpaque(false);
    add(header, BorderLayout.NORTH);

    previousSkip = WebButton.createIconWebButton(previousSkipIcon, StyleConstants.smallRound, true);
    previousSkip.setDrawFocus(false);
    previousSkip.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            changeYear(-1);
          }
        });

    previous = WebButton.createIconWebButton(previousIcon, StyleConstants.smallRound, true);
    previous.setDrawFocus(false);
    previous.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            changeMonth(-1);
          }
        });

    final WebPanel leftHeader = new WebPanel(new BorderLayout());
    leftHeader.setOpaque(false);
    leftHeader.add(previousSkip, BorderLayout.WEST);
    leftHeader.add(previous, BorderLayout.EAST);
    header.add(leftHeader, BorderLayout.WEST);

    titlePanel = new ComponentTransition(createTitleLabel());
    titlePanel.setOpaque(false);
    titlePanel.setTransitionEffect(new FadeTransitionEffect());
    titlePanel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(final MouseEvent e) {
            if (SwingUtilities.isLeftMouseButton(e)) {
              setShownDate(new Date());
            }
          }
        });
    header.add(titlePanel, BorderLayout.CENTER);

    next = WebButton.createIconWebButton(nextIcon, StyleConstants.smallRound, true);
    next.setDrawFocus(false);
    next.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            changeMonth(1);
          }
        });

    nextSkip = WebButton.createIconWebButton(nextSkipIcon, StyleConstants.smallRound, true);
    nextSkip.setDrawFocus(false);
    nextSkip.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            changeYear(1);
          }
        });

    final WebPanel rightHeader = new WebPanel(new BorderLayout());
    rightHeader.setOpaque(false);
    rightHeader.add(next, BorderLayout.WEST);
    rightHeader.add(nextSkip, BorderLayout.EAST);
    header.add(rightHeader, BorderLayout.EAST);

    // Week days
    weekHeaders = new WebPanel();
    weekHeaders.setUndecorated(false);
    weekHeaders.setDrawSides(true, false, true, false);
    weekHeaders.setShadeWidth(0);
    weekHeaders.setOpaque(false);
    weekHeaders.setMargin(
        StyleConstants.shadeWidth,
        StyleConstants.shadeWidth - 1,
        StyleConstants.shadeWidth + 1,
        StyleConstants.shadeWidth - 1);
    weekHeaders.setLayout(
        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.PREFERRED}
            }));
    centerPanel.add(weekHeaders, BorderLayout.NORTH);
    updateWeekHeaders();

    // Month days
    monthDays = createMonthPanel();
    updateMonth(monthDays);
    monthDaysTransition = new ComponentTransition(monthDays);
    monthDaysTransition.setOpaque(false);
    monthDaysTransition.addTransitionListener(
        new TransitionAdapter() {
          @Override
          public void transitionFinished() {
            requestFocusToSelected();
          }
        });
    centerPanel.add(monthDaysTransition, BorderLayout.CENTER);
  }
Exemple #12
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;
  }
Exemple #13
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));
    }