示例#1
0
  @SuppressWarnings("serial")
  @Override
  public void setupToolBar() {
    getToolbar()
        .add(
            new WebLabel("Resting Hour Report Entry") {
              {
                setDrawShade(true);
                setMargin(10);
              }
            });

    getToolbar().addSeparator();

    WebButton btnSaveNext =
        WebButton.createIconWebButton(
            getIconsHelper().loadIcon("common/save_all_16x16.png"),
            StyleConstants.smallRound,
            true);
    btnSaveNext.putClientProperty("command", "saveAndNext");
    btnSaveNext.addActionListener(this);
    btnSaveNext.setToolTipText("Save and move to next date (CTRL + Shift + S)");

    getToolbar().add(btnSaveNext);

    HotkeyManager.registerHotkey(getOwner(), btnSaveNext, Hotkey.CTRL_SHIFT_S);

    super.setupToolBar();
  }
示例#2
0
 /** 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();
 }
示例#3
0
  @Override
  public void actionPerformed(ActionEvent e) {

    if (e.getSource() instanceof WebComboBox) {

      if (((WebComboBox) e.getSource()).getActionCommand().equals("crewSelectedChanged")) {
        if (cmbCrew.getSelectedItem() instanceof Crew) {

          autoSave();

          currentCrew = (Crew) cmbCrew.getSelectedItem();

          if (currentCrew != null) {

            // calendar = null;
            // calendar = new ExWebCalendar(currentDate, currentCrew.getSignOnDate());

            calendar.refresh(currentCrew.getSignOnDate());

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

          getSchedule(currentDate);
        }
      }

    } else {
      WebButton btnSource = (WebButton) e.getSource();

      if (btnSource.getClientProperty("command").equals("saveAndNext")) {

        if (currentCrew == null) {
          NotificationManager.showPopup(getOwner(), cmbCrew, new String[] {"Please select crew"});
          return;
        }

        // saveRestingHour();
        // calendar.moveToNext();
        // Calendar calNext = Calendar.getInstance();
        // calNext.setTime(currentDate);
        // calNext.add(Calendar.DAY_OF_MONTH, 1);

        // calendar.setDate(calNext.getTime());

      } else if (btnSource.getClientProperty("command").equals("new")) {

      } else if (btnSource.getClientProperty("command").equals("save")) {

        if (currentCrew == null) {
          NotificationManager.showPopup(getOwner(), cmbCrew, new String[] {"Please select crew"});
          return;
        }

        saveRestingHour();
      }
    }
  }
  /** Updates toolbar controls state. */
  protected void updateToolbarControlsState() {
    final File selectedFile = fileTree.getSelectedFile();

    folderUp.setEnabled(selectedFile != null && selectedFile.getParentFile() != null);

    folderNew.setEnabled(selectedFile != null && selectedFile.canWrite());
    remove.setEnabled(
        selectedFile != null && selectedFile.getParentFile() != null && selectedFile.canWrite());
  }
    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();
    }
  /** 成员搜索 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("");
          }
        });
  }
示例#7
0
  private WebButton getRemoveButton() {
    if (remove == null) {
      remove =
          WebButton.createIconWebButton(CROSS_ICON, StyleConstants.smallRound, 3, 2, true, false);
      remove.setFocusable(false);
      remove.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(final ActionEvent ae) {
              if (animator != null && animator.isRunning()) {
                animator.stop();
              }
              if (animate) {
                animator =
                    new WebTimer(
                        "WebFilePlate.fadeOutTimer",
                        StyleConstants.animationDelay,
                        new ActionListener() {
                          @Override
                          public void actionPerformed(ActionEvent e) {
                            opacity -= 0.1f;
                            if (opacity > 0f) {
                              WebFilePlate.this.repaint();
                            } else {
                              // Remove file plate
                              removeFromParent();

                              // Firing final close listeners
                              fireActionPerformed(ae);

                              // Stopping animation
                              animator.stop();
                            }
                          }
                        });
                animator.start();
              } else {
                // Remove file plate
                removeFromParent();
              }
            }
          });
    }
    return remove;
  }
示例#8
0
  private static Component createSourceButton(final WebLookAndFeelDemo owner, Example example) {
    final Class classType = example.getClass();

    WebButton sourceButton = WebButton.createIconWebButton(JarEntry.javaIcon);
    TooltipManager.setTooltip(
        sourceButton, JarEntry.javaIcon, ReflectUtils.getJavaClassName(classType), TooltipWay.up);
    sourceButton.setRolloverDecoratedOnly(true);
    sourceButton.setFocusable(false);

    sourceButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            owner.showSource(classType);
          }
        });

    return new CenterPanel(sourceButton, false, true);
  }
  @Override
  public Component getPreview(WebLookAndFeelDemo owner) {
    // Hotkey and Tooltip managers integration
    final WebButton tip = new WebButton("Tooltip with hotkey", loadIcon("web.png"));
    HotkeyManager.registerHotkey(
        owner, tip, Hotkey.CTRL_S, new ButtonHotkeyRunnable(tip, 50), TooltipWay.trailing);
    TooltipManager.setTooltip(tip, "Increase counter", TooltipWay.trailing, 0);
    tip.addActionListener(
        new ActionListener() {
          private int count = 0;

          @Override
          public void actionPerformed(ActionEvent e) {
            count++;
            tip.setText("Pressed " + count + (count == 1 ? " time" : " times"));
          }
        });

    return new GroupPanel(tip);
  }
  private void save() {
    if (!mSubjectField.getText().equals(mThread.getSubject())) {
      mThread.setSubject(mSubjectField.getText());
    }
    //        List<?> participants = mParticipantsList.getCheckedValues();
    //        Set<User> threadUser = new HashSet<>();
    //        for (Object o: participants) {
    //            threadUser.add(((UserElement) o).user);
    //        }
    //        mThread.setUser(threadUser);

    KonThread.ViewSettings newSettings;
    if (mColorOpt.isSelected()) newSettings = new KonThread.ViewSettings(mColor.getBottomBgColor());
    else if (mImgOpt.isSelected() && !mImgChooser.getSelectedFiles().isEmpty())
      newSettings =
          new KonThread.ViewSettings(mImgChooser.getSelectedFiles().get(0).getAbsolutePath());
    else newSettings = new KonThread.ViewSettings();

    if (!newSettings.equals(mThread.getViewSettings())) {
      mThread.setViewSettings(newSettings);
    }
  }
示例#11
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);
  }
示例#12
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));
    }
  /** 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();
  }
示例#14
0
    StatusDialog() {
      this.setTitle(Tr.tr("Status"));
      this.setResizable(false);
      this.setModal(true);

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

      String[] strings = mConf.getStringArray(Config.NET_STATUS_LIST);
      List<String> stats = new ArrayList<>(Arrays.<String>asList(strings));
      String currentStatus = "";
      if (!stats.isEmpty()) currentStatus = stats.remove(0);

      stats.remove("");

      groupPanel.add(new WebLabel(Tr.tr("Your current status:")));
      mStatusField = new WebTextField(currentStatus, 30);
      groupPanel.add(mStatusField);
      groupPanel.add(new WebSeparator(true, true));

      groupPanel.add(new WebLabel(Tr.tr("Previously used:")));
      mStatusList = new WebList(stats);
      mStatusList.setMultiplySelectionAllowed(false);
      mStatusList.addListSelectionListener(
          new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
              if (e.getValueIsAdjusting()) return;
              mStatusField.setText(mStatusList.getSelectedValue().toString());
            }
          });
      WebScrollPane listScrollPane = new ScrollPane(mStatusList);
      groupPanel.add(listScrollPane);
      this.add(groupPanel, BorderLayout.CENTER);

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

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

      this.pack();
    }
示例#15
0
  MainFrame(
      final View view,
      TableView<?, ?> userList,
      TableView<?, ?> threadList,
      Component content,
      Component searchPanel,
      Component statusBar) {
    mView = view;

    // general view + behaviour
    this.setTitle("Kontalk Java Client");
    this.setSize(mConf.getInt(Config.VIEW_FRAME_WIDTH), mConf.getInt(Config.VIEW_FRAME_HEIGHT));

    this.setIconImage(Utils.getImage("kontalk.png"));

    // closing behaviour
    this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    this.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            if (mConf.getBoolean(Config.MAIN_TRAY_CLOSE)
                && SystemTray.getSystemTray().getTrayIcons().length > 0)
              MainFrame.this.toggleState();
            else mView.callShutDown();
          }
        });

    // menu
    WebMenuBar menubar = new WebMenuBar();
    this.setJMenuBar(menubar);

    WebMenu konNetMenu = new WebMenu("KonNet");
    konNetMenu.setMnemonic(KeyEvent.VK_K);

    mConnectMenuItem = new WebMenuItem(Tr.tr("Connect"));
    mConnectMenuItem.setAccelerator(Hotkey.ALT_C);
    mConnectMenuItem.setToolTipText(Tr.tr("Connect to Server"));
    mConnectMenuItem.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            mView.callConnect();
          }
        });
    konNetMenu.add(mConnectMenuItem);

    mDisconnectMenuItem = new WebMenuItem(Tr.tr("Disconnect"));
    mDisconnectMenuItem.setAccelerator(Hotkey.ALT_D);
    mDisconnectMenuItem.setToolTipText(Tr.tr("Disconnect from Server"));
    mDisconnectMenuItem.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            mView.callDisconnect();
          }
        });
    konNetMenu.add(mDisconnectMenuItem);
    konNetMenu.addSeparator();

    WebMenuItem statusMenuItem = new WebMenuItem(Tr.tr("Set status"));
    statusMenuItem.setAccelerator(Hotkey.ALT_S);
    statusMenuItem.setToolTipText(Tr.tr("Set status text send to other user"));
    statusMenuItem.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            WebDialog statusDialog = new StatusDialog();
            statusDialog.setVisible(true);
          }
        });
    konNetMenu.add(statusMenuItem);
    konNetMenu.addSeparator();

    WebMenuItem exitMenuItem = new WebMenuItem(Tr.tr("Exit"));
    exitMenuItem.setAccelerator(Hotkey.ALT_E);
    exitMenuItem.setToolTipText(Tr.tr("Exit application"));
    exitMenuItem.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            mView.callShutDown();
          }
        });
    konNetMenu.add(exitMenuItem);

    menubar.add(konNetMenu);

    WebMenu optionsMenu = new WebMenu(Tr.tr("Options"));
    optionsMenu.setMnemonic(KeyEvent.VK_O);

    WebMenuItem conConfMenuItem = new WebMenuItem(Tr.tr("Preferences"));
    conConfMenuItem.setAccelerator(Hotkey.ALT_P);
    conConfMenuItem.setToolTipText(Tr.tr("Set application preferences"));
    conConfMenuItem.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            mView.showConfig();
          }
        });
    optionsMenu.add(conConfMenuItem);

    menubar.add(optionsMenu);

    WebMenu helpMenu = new WebMenu(Tr.tr("Help"));
    helpMenu.setMnemonic(KeyEvent.VK_H);

    WebMenuItem aboutMenuItem = new WebMenuItem(Tr.tr("About"));
    aboutMenuItem.setToolTipText(Tr.tr("About Kontalk"));
    aboutMenuItem.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            MainFrame.this.showAboutDialog();
          }
        });
    helpMenu.add(aboutMenuItem);

    menubar.add(helpMenu);

    // Layout...
    this.setLayout(new BorderLayout(5, 5));

    // ...left...
    WebPanel sidePanel = new WebPanel(false);
    sidePanel.add(searchPanel, BorderLayout.NORTH);
    mTabbedPane = new WebTabbedPane(WebTabbedPane.LEFT);
    WebButton newThreadButton = new WebButton(Tr.tr("New"));
    newThreadButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO new thread button
          }
        });
    // String threadOverlayText =
    //        Tr.t/r("No chats to display. You can create a new chat from your contacts");
    WebScrollPane threadPane = createTablePane(threadList, newThreadButton, "threadOverlayText");
    mTabbedPane.addTab("", threadPane);
    mTabbedPane.setTabComponentAt(Tab.THREADS.ordinal(), new WebVerticalLabel(Tr.tr("Chats")));

    WebButton newUserButton = new WebButton(Tr.tr("Add"));
    newUserButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            WebDialog addUserDialog = new AddUserDialog();
            addUserDialog.setVisible(true);
          }
        });
    // String userOverlayText = T/r.tr("No contacts to display. You have no friends ;(");
    WebScrollPane userPane = createTablePane(userList, newUserButton, "userOverlayText");
    mTabbedPane.addTab("", userPane);
    mTabbedPane.setTabComponentAt(Tab.USER.ordinal(), new WebVerticalLabel(Tr.tr("Contacts")));
    mTabbedPane.setPreferredSize(new Dimension(250, -1));
    mTabbedPane.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            mView.tabPaneChanged(Tab.values()[mTabbedPane.getSelectedIndex()]);
          }
        });

    sidePanel.add(mTabbedPane, BorderLayout.CENTER);
    this.add(sidePanel, BorderLayout.WEST);

    // ...right...
    this.add(content, BorderLayout.CENTER);

    // ...bottom
    this.add(statusBar, BorderLayout.SOUTH);
  }
示例#16
0
  private WebButton createClassSearch() {
    WebButton classSearch = new WebButton(classSearchIcon);
    classSearch.setDrawFocus(false);
    classSearch.setRolloverDecoratedOnly(true);
    classSearch.addHotkey(Hotkey.CTRL_N);
    classSearch.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            showClassSearchPopup();
          }
        });

    classSearchField = new WebTextField(20, false);
    classSearchField.setHideInputPromptOnFocus(false);
    classSearchField.setInputPrompt("Enter class name here...");
    HotkeyManager.registerHotkey(
        classSearchField,
        Hotkey.ESCAPE,
        new HotkeyRunnable() {
          @Override
          public void run(KeyEvent e) {
            hideClassSearchPopup();
          }
        });

    final WebImage leadingComponent = new WebImage(classSearchIcon);
    leadingComponent.setMargin(2);
    classSearchField.setLeadingComponent(leadingComponent);

    classSearchPopup = new WebPopup();
    classSearchPopup.setCloseOnFocusLoss(true);
    classSearchPopup.add(classSearchField);
    classSearchPopup.setDefaultFocusComponent(classSearchField);

    classSearchHintsPopup =
        new WebWindow(classSearchPopup) {
          @Override
          public Dimension getPreferredSize() {
            final Dimension ps = super.getPreferredSize();
            ps.width = Math.max(classSearchField.getWidth(), ps.width);
            return ps;
          }
        };
    classSearchHintsPopup.setFocusable(false);
    classSearchHintsPopup.setAlwaysOnTop(true);
    classSearchPopup.addFocusableChild(classSearchHintsPopup);

    classSearchHintsList = new WebList(new DefaultListModel());
    classSearchHintsList.setFocusable(false);
    classSearchHintsList.setRolloverSelectionEnabled(true);
    classSearchHintsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    classSearchHintsList.setCellRenderer(
        new WebListCellRenderer() {
          @Override
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            JarEntry entry = (JarEntry) value;
            WebListElement renderer =
                (WebListElement)
                    super.getListCellRendererComponent(
                        list, value, index, isSelected, cellHasFocus);
            renderer.setIcon(entry.getIcon());
            renderer.setText(entry.getName());
            return renderer;
          }
        });
    classSearchHintsList.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            if (SwingUtils.isLeftMouseButton(e)) {
              openSelectedHint();
            }
          }
        });

    HotkeyManager.registerHotkey(
        classSearchField,
        Hotkey.HOME,
        new HotkeyRunnable() {
          @Override
          public void run(KeyEvent e) {
            if (classSearchHintsList.getModelSize() > 0) {
              classSearchHintsList.setSelectedIndex(0);
            }
          }
        });
    HotkeyManager.registerHotkey(
        classSearchField,
        Hotkey.UP,
        new HotkeyRunnable() {
          @Override
          public void run(KeyEvent e) {
            if (classSearchHintsList.getModelSize() > 0) {
              int index = classSearchHintsList.getSelectedIndex();
              if (index > 0) {
                classSearchHintsList.setSelectedIndex(index - 1);
              } else {
                classSearchHintsList.setSelectedIndex(classSearchHintsList.getModelSize() - 1);
              }
            }
          }
        });
    HotkeyManager.registerHotkey(
        classSearchField,
        Hotkey.DOWN,
        new HotkeyRunnable() {
          @Override
          public void run(KeyEvent e) {
            if (classSearchHintsList.getModelSize() > 0) {
              int index = classSearchHintsList.getSelectedIndex();
              if (index < classSearchHintsList.getModelSize() - 1) {
                classSearchHintsList.setSelectedIndex(index + 1);
              } else {
                classSearchHintsList.setSelectedIndex(0);
              }
            }
          }
        });
    HotkeyManager.registerHotkey(
        classSearchField,
        Hotkey.END,
        new HotkeyRunnable() {
          @Override
          public void run(KeyEvent e) {
            if (classSearchHintsList.getModelSize() > 0) {
              classSearchHintsList.setSelectedIndex(classSearchHintsList.getModelSize() - 1);
            }
          }
        });
    HotkeyManager.registerHotkey(
        classSearchField,
        Hotkey.ENTER,
        new HotkeyRunnable() {
          @Override
          public void run(KeyEvent e) {
            openSelectedHint();
          }
        });

    WebScrollPane foundClassesScroll = new WebScrollPane(classSearchHintsList);
    foundClassesScroll.setShadeWidth(0);
    foundClassesScroll.setRound(0);
    classSearchHintsPopup.add(foundClassesScroll);

    classSearchPopup.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentMoved(ComponentEvent e) {
            updateHintsLocation();
          }

          @Override
          public void componentResized(ComponentEvent e) {
            updateHintsLocation();
          }
        });

    classSearchPopup.addPopupListener(
        new PopupAdapter() {
          @Override
          public void popupWillBeOpened() {
            lastSearchedText = null;
            lastFocusBeforeSearch = FocusManager.getFocusOwner();
          }

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

          @Override
          public void popupClosed() {
            hideHints();
            if (lastFocusBeforeSearch != null) {
              lastFocusBeforeSearch.requestFocusInWindow();
            }
          }
        });

    classSearchField.addCaretListener(
        new CaretListener() {
          @Override
          public void caretUpdate(CaretEvent e) {
            if (classSearchHintsDelay == null) {
              classSearchHintsDelay =
                  new WebTimer(
                      500,
                      new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                          updateHints();
                        }
                      });
              classSearchHintsDelay.setRepeats(false);
            }
            if (classSearchField.getText().trim().length() > 0) {
              classSearchHintsDelay.restart();
            } else {
              classSearchHintsDelay.stop();
              hideHints();
            }
          }
        });

    return classSearch;
  }
  ThreadDetails(final Component focusGainer, KonThread thread) {
    mThread = thread;

    GroupPanel groupPanel = new GroupPanel(View.GAP_BIG, false);
    groupPanel.setMargin(View.MARGIN_BIG);

    groupPanel.add(new WebLabel(Tr.tr("Edit Chat")).setBoldFont());
    groupPanel.add(new WebSeparator(true, true));

    // editable fields
    groupPanel.add(new WebLabel(Tr.tr("Subject:")));
    String subj = mThread.getSubject();
    mSubjectField = new WebTextField(subj, 22);
    mSubjectField.setInputPrompt(subj);
    mSubjectField.setHideInputPromptOnFocus(false);
    groupPanel.add(mSubjectField);
    groupPanel.add(new WebSeparator(true, true));

    final WebSlider colorSlider = new WebSlider(WebSlider.HORIZONTAL);

    groupPanel.add(new WebLabel(Tr.tr("Custom Background")));
    mColorOpt = new WebRadioButton(Tr.tr("Color:") + " ");
    Optional<Color> optBGColor = mThread.getViewSettings().getBGColor();
    mColorOpt.setSelected(optBGColor.isPresent());
    mColorOpt.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            colorSlider.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
          }
        });
    mColor = new WebButton();
    mColor.setMinimumHeight(25);
    Color oldColor = optBGColor.orElse(DEFAULT_BG);
    mColor.setBottomBgColor(oldColor);
    groupPanel.add(new GroupPanel(GroupingType.fillLast, mColorOpt, mColor));

    colorSlider.setMinimum(0);
    colorSlider.setMaximum(100);
    colorSlider.setPaintTicks(false);
    colorSlider.setPaintLabels(false);
    colorSlider.setEnabled(optBGColor.isPresent());
    final GradientData gradientData = GradientData.getDefaultValue();
    // TODO set location for color
    gradientData.getColor(0);
    colorSlider.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            float v = colorSlider.getValue() / (float) 100;
            Color c = gradientData.getColorForLocation(v);
            mColor.setBottomBgColor(c);
            mColor.repaint();
          }
        });
    groupPanel.add(colorSlider);

    mImgOpt = new WebRadioButton(Tr.tr("Image:") + " ");
    String imgPath = mThread.getViewSettings().getImagePath();
    mImgOpt.setSelected(!imgPath.isEmpty());
    mImgOpt.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            mImgChooser.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
            mImgChooser.getChooseButton().setEnabled(e.getStateChange() == ItemEvent.SELECTED);
          }
        });
    mImgChooser = Utils.createImageChooser(!imgPath.isEmpty(), imgPath);
    groupPanel.add(new GroupPanel(GroupingType.fillLast, mImgOpt, mImgChooser));
    UnselectableButtonGroup.group(mColorOpt, mImgOpt);
    groupPanel.add(new WebSeparator());

    //        groupPanel.add(new WebLabel(Tr.tr("Participants:")));
    //        mParticipantsList = new WebCheckBoxList();
    //        mParticipantsList.setVisibleRowCount(10);
    //        for (User oneUser : UserList.getInstance().getAll()) {
    //            boolean selected = mThread.getUser().contains(oneUser);
    //            mParticipantsList.getCheckBoxListModel().addCheckBoxElement(
    //                    new UserElement(oneUser),
    //                    selected);
    //        }
    final WebButton saveButton = new WebButton(Tr.tr("Save"));
    //        mParticipantsList.getModel().addListDataListener(new ListDataListener() {
    //            @Override
    //            public void intervalAdded(ListDataEvent e) {
    //            }
    //            @Override
    //            public void intervalRemoved(ListDataEvent e) {
    //            }
    //            @Override
    //            public void contentsChanged(ListDataEvent e) {
    //                saveButton.setEnabled(!mParticipantsList.getCheckedValues().isEmpty());
    //            }
    //        });
    //
    //        groupPanel.add(new WebScrollPane(mParticipantsList));
    //        groupPanel.add(new WebSeparator(true, true));

    this.add(groupPanel, BorderLayout.CENTER);

    saveButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            //                if (mParticipantsList.getCheckedValues().size() > 1) {
            //                        String infoText = Tr.t/r("More than one receiver not supported
            // (yet).");
            //                        WebOptionPane.showMessageDialog(ThreadListView.this,
            //                                infoText,
            //                                Tr.t/r("Sorry"),
            //                                WebOptionPane.INFORMATION_MESSAGE);
            //                    return;
            //                }
            ThreadDetails.this.save();

            // close popup
            focusGainer.requestFocus();
          }
        });
    // this.getRootPane().setDefaultButton(saveButton);

    GroupPanel buttonPanel = new GroupPanel(2, saveButton);
    buttonPanel.setLayout(new FlowLayout(FlowLayout.TRAILING));
    this.add(buttonPanel, BorderLayout.SOUTH);
  }
示例#18
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);
            }
          });
    }
示例#19
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;
  }
示例#20
0
  public WebColorChooserField(final Color color) {
    super();

    // Pipette color picker
    updatePipette();

    // Trailing color choose button
    colorButton = new WebButton(ImageUtils.createColorChooserIcon(color));
    colorButton.setFocusable(false);
    colorButton.setShadeWidth(0);
    colorButton.setMoveIconOnPress(false);
    colorButton.setRolloverDecoratedOnly(true);
    colorButton.setCursor(Cursor.getDefaultCursor());
    colorButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            showColorChooserPopup();
          }
        });
    setTrailingComponent(colorButton);

    // Actions
    addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(final ActionEvent e) {
            updateColorFromField();
          }
        });
    addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(final MouseEvent e) {
            if (isEnabled() && SwingUtilities.isRightMouseButton(e)) {
              showColorChooserPopup();
            }
          }
        });
    addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusLost(final FocusEvent e) {
            updateColorFromField();
          }
        });
    addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(final KeyEvent e) {
            if (isEnabled()) {
              if (Hotkey.ESCAPE.isTriggered(e)) {
                updateViewFromColor();
              } else if (Hotkey.DOWN.isTriggered(e)) {
                showColorChooserPopup();
              }
            }
          }
        });

    // Initial data
    setFieldType(ColorChooserFieldType.rgb);
    setColor(color);

    // Initial styling settings
    updateMargin();
    setHorizontalAlignment(CENTER);
  }
示例#21
0
 /** Private update methods */
 private void updateViewFromColor() {
   colorButton.setIcon(ImageUtils.createColorChooserIcon(color));
   updateText();
 }
示例#22
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);
  }