@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(); }
/** 成员搜索 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(""); } }); }
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; }
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); }
/** 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); } }); }
/** * 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); }