예제 #1
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);
  }
예제 #2
0
  public SourceViewer(JarStructure jarStructure) {
    super();

    this.jarStructure = jarStructure;

    toolBar = new WebPanel(true, new ToolbarLayout());
    toolBar.setDrawSides(false, false, true, false);
    toolBar.setShadeWidth(0);
    add(toolBar, BorderLayout.NORTH);

    classPath = new WebBreadcrumb(false);
    classPath.setEncloseLastElement(true);
    classPath.setElementMargin(4, 6, 4, 6);
    classPath.setOpaque(false);
    toolBar.add(classPath, ToolbarLayout.FILL);

    toolBar.add(createClassSearch(), ToolbarLayout.END);
    toolBar.add(createSettings(), ToolbarLayout.END);

    viewTabbedPane = new ViewTabbedPane();
    viewTabbedPane.setTabbedPaneStyle(TabbedPaneStyle.attached);
    viewChangeListener =
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            updateClassPath(viewTabbedPane.getSelectedEntry(), false);
          }
        };
    viewTabbedPane.addChangeListener(viewChangeListener);
    viewTabbedPane.addViewListener(
        new ViewListener() {
          @Override
          public void viewOpened(JarEntry entry) {
            //
          }

          @Override
          public void viewClosed(JarEntry entry) {
            synchronized (activeEditorsLock) {
              // Removing opened editor
              activeEditors.remove(entry);
            }
            updateClassPath(viewTabbedPane.getSelectedEntry(), false);
          }
        });
    HotkeyManager.registerHotkey(
        viewTabbedPane,
        Hotkey.ALT_LEFT,
        new HotkeyRunnable() {
          @Override
          public void run(KeyEvent e) {
            final int tabCount = viewTabbedPane.getTabCount();
            if (tabCount > 0) {
              final int index = viewTabbedPane.getSelectedIndex();
              viewTabbedPane.setSelectedIndex(index > 0 ? index - 1 : tabCount - 1);
            }
          }
        });
    HotkeyManager.registerHotkey(
        viewTabbedPane,
        Hotkey.ALT_RIGHT,
        new HotkeyRunnable() {
          @Override
          public void run(KeyEvent e) {
            final int tabCount = viewTabbedPane.getTabCount();
            if (tabCount > 0) {
              final int index = viewTabbedPane.getSelectedIndex();
              viewTabbedPane.setSelectedIndex(index < tabCount - 1 ? index + 1 : 0);
            }
          }
        });
    add(viewTabbedPane, BorderLayout.CENTER);

    updateClassPath(null, false);
  }