/** * public MutableStatusBar(String s1, String s2, String s3) { super(); status_1 = new JLabel(s1); * status_2 = new JLabel(s2); status_3 = new JLabel(s3); this.init(); }. */ protected void init() { this.setLayout(new GridBagLayout()); this.setBorder(BorderFactory.createEmptyBorder(3, 2, 1, 1)); final GridBagConstraints constraints = new GridBagConstraints(); // status_1.setHorizontalAlignment(JLabel.CENTER); status_1.setBorder( new CompoundBorder( new SoftBevelBorder(SoftBevelBorder.LOWERED), new EmptyBorder(0, 2, 0, 2))); status_1.setPreferredSize(new Dimension(180, 16)); status_2.setBorder( new CompoundBorder( new SoftBevelBorder(SoftBevelBorder.LOWERED), new EmptyBorder(0, 2, 0, 2))); status_2.setPreferredSize(new Dimension(200, 16)); status_3.setBorder( new CompoundBorder( new SoftBevelBorder(SoftBevelBorder.LOWERED), new EmptyBorder(0, 2, 0, 2))); status_3.setPreferredSize(new Dimension(300, 16)); greenStatusIcon = new MutableImageLabel(resource.getIcon("green_off.gif"), resource.getIcon("green_on.gif")); greenStatusIcon.setBorder(new EmptyBorder(2, 2, 2, 1)); redStatusIcon = new MutableImageLabel(resource.getIcon("red_off.gif"), resource.getIcon("red_on.gif")); redStatusIcon.setBorder(new EmptyBorder(2, 1, 2, 3)); // ===================================================================== constraints.insets = new Insets(0, 0, 0, 4); constraints.anchor = GridBagConstraints.EAST; constraints.fill = GridBagConstraints.VERTICAL; constraints.weightx = 1.0; constraints.weighty = 1.0; constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; this.add(status_1, constraints); constraints.weightx = 0.0; constraints.gridx++; this.add(status_2, constraints); constraints.gridx = 2; this.add(status_3, constraints); constraints.gridx++; if (greenStatusIcon != null) { this.add(greenStatusIcon, constraints); } constraints.insets = new Insets(0, 0, 0, 0); constraints.gridx++; if (redStatusIcon != null) { this.add(redStatusIcon, constraints); } }
public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); if (node == null) { return; } Object userObject = node.getUserObject(); if (userObject instanceof TopicInfo) { TopicInfo topicInfo = (TopicInfo) userObject; try { if (topicInfo.subtopicCount > 0) { htmlPane.setText( "<div style='font-family:Verdana,Tahoma;font-size:10px;'>Please choose a topic</div>"); return; } URL helpFileUrl = ResourceManager.getHelpFileUrl(topicInfo.id); if (helpFileUrl == null) { throw new RuntimeException(); } String content = CommonUtil.readStringFromUrl(helpFileUrl); content = "<html><body style=\"font-family:Verdana,Tahoma;font-size:10px;\">" + "<h2>" + topicInfo.title + "</h2>" + content + "</body></html>"; ((HTMLDocument) htmlPane.getDocument()).setBase(helpFileUrl); htmlPane.setText(content); htmlPane.setCaretPosition(0); } catch (Exception e1) { htmlPane.setText( "<div style='color:#FF0000;font-family:Verdana,Tahoma;font-size:10px;'>Cannot read help for \"" + topicInfo.title + "\"!</div>"); } } }
/** Constructor - creates layout. */ public HelpFrame() { setTitle("Web-Harvest Help"); setIconImage(((ImageIcon) ResourceManager.HELP32_ICON).getImage()); this.topNode = new DefaultMutableTreeNode(); this.treeModel = new DefaultTreeModel(this.topNode); try { String helpContent = CommonUtil.readStringFromUrl(ResourceManager.getHelpContentUrl()); XmlNode xmlNode = XmlParser.parse(new InputSource(new StringReader(helpContent))); createNodes(topNode, xmlNode); } catch (Exception e) { e.printStackTrace(); GuiUtils.showErrorMessage("Error reading help content!"); } tree = new JTree(topNode); tree.setRootVisible(false); tree.setShowsRootHandles(true); tree.setBorder(new EmptyBorder(5, 5, 5, 5)); tree.setCellRenderer( new DefaultTreeCellRenderer() { public Component getTreeCellRendererComponent( JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) super.getTreeCellRendererComponent( tree, value, sel, expanded, leaf, row, hasFocus); if (value instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode) value; Object userObject = defaultMutableTreeNode.getUserObject(); if (userObject instanceof TopicInfo) { TopicInfo topicInfo = (TopicInfo) userObject; renderer.setIcon( topicInfo.subtopicCount == 0 ? ResourceManager.HELPTOPIC_ICON : ResourceManager.HELPDIR_ICON); } } return renderer; } }); tree.addTreeSelectionListener(this); htmlPane = new JEditorPane(); htmlPane.setEditable(false); htmlPane.setContentType("text/html"); htmlPane.setEditorKit(new HTMLEditorKit()); htmlPane.setBorder(new EmptyBorder(5, 5, 5, 5)); JSplitPane splitPane = new ProportionalSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setResizeWeight(0.0d); splitPane.setBorder(null); JScrollPane treeScrollPane = new WHScrollPane(tree); treeScrollPane.getViewport().setBackground(Color.white); treeScrollPane.setBackground(Color.white); splitPane.setLeftComponent(treeScrollPane); splitPane.setRightComponent(new WHScrollPane(htmlPane)); splitPane.setDividerLocation(0.3d); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.add(splitPane, BorderLayout.CENTER); pack(); }
FilterByErrorAction() { super("", ResourceManager.getIcon16x16("error-mark")); }
FilterByTimeAction() { super("", ResourceManager.getIcon16x16("filter")); }
/** * DOCUMENT ME! * * @version $Revision$, $Date$ */ public class MutableStatusBar extends JPanel { // ~ Static fields/initializers --------------------------------------------- protected static final Logger logger = Logger.getLogger(MutableStatusBar.class); private static final ResourceManager resource = ResourceManager.getManager(); // ~ Instance fields -------------------------------------------------------- private JLabel status_1; private JLabel status_2; private JLabel status_3; private MutableImageLabel greenStatusIcon; private MutableImageLabel redStatusIcon; // ~ Constructors ----------------------------------------------------------- /** Creates a new MutableStatusBar object. */ public MutableStatusBar() { super(); status_1 = new JLabel(""); // NOI18N status_2 = new JLabel(""); // NOI18N status_3 = new JLabel(""); // NOI18N this.init(); } // ~ Methods ---------------------------------------------------------------- /** * public MutableStatusBar(String s1, String s2, String s3) { super(); status_1 = new JLabel(s1); * status_2 = new JLabel(s2); status_3 = new JLabel(s3); this.init(); }. */ protected void init() { this.setLayout(new GridBagLayout()); this.setBorder(BorderFactory.createEmptyBorder(3, 2, 1, 1)); final GridBagConstraints constraints = new GridBagConstraints(); // status_1.setHorizontalAlignment(JLabel.CENTER); status_1.setBorder( new CompoundBorder( new SoftBevelBorder(SoftBevelBorder.LOWERED), new EmptyBorder(0, 2, 0, 2))); status_1.setPreferredSize(new Dimension(180, 16)); status_2.setBorder( new CompoundBorder( new SoftBevelBorder(SoftBevelBorder.LOWERED), new EmptyBorder(0, 2, 0, 2))); status_2.setPreferredSize(new Dimension(200, 16)); status_3.setBorder( new CompoundBorder( new SoftBevelBorder(SoftBevelBorder.LOWERED), new EmptyBorder(0, 2, 0, 2))); status_3.setPreferredSize(new Dimension(300, 16)); greenStatusIcon = new MutableImageLabel(resource.getIcon("green_off.gif"), resource.getIcon("green_on.gif")); greenStatusIcon.setBorder(new EmptyBorder(2, 2, 2, 1)); redStatusIcon = new MutableImageLabel(resource.getIcon("red_off.gif"), resource.getIcon("red_on.gif")); redStatusIcon.setBorder(new EmptyBorder(2, 1, 2, 3)); // ===================================================================== constraints.insets = new Insets(0, 0, 0, 4); constraints.anchor = GridBagConstraints.EAST; constraints.fill = GridBagConstraints.VERTICAL; constraints.weightx = 1.0; constraints.weighty = 1.0; constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; this.add(status_1, constraints); constraints.weightx = 0.0; constraints.gridx++; this.add(status_2, constraints); constraints.gridx = 2; this.add(status_3, constraints); constraints.gridx++; if (greenStatusIcon != null) { this.add(greenStatusIcon, constraints); } constraints.insets = new Insets(0, 0, 0, 0); constraints.gridx++; if (redStatusIcon != null) { this.add(redStatusIcon, constraints); } } /** * DOCUMENT ME! * * @param statusMessage DOCUMENT ME! * @param messagePosition DOCUMENT ME! */ public void setStatusMessage(final String statusMessage, final int messagePosition) { // if(logger.isDebugEnabled())logger.debug("setStatusMessage: '" + statusMessage + "' @position: // '" + // messagePosition + "'"); switch (messagePosition) { case Status.MESSAGE_IGNORE: { break; } case Status.MESSAGE_POSITION_1: { status_1.setText(statusMessage); break; } case Status.MESSAGE_POSITION_2: { status_2.setText(statusMessage); break; } case Status.MESSAGE_POSITION_3: { status_3.setText(statusMessage); break; } } } /** * DOCUMENT ME! * * @param greenIconStatus DOCUMENT ME! */ public void setGreenIconStatus(final int greenIconStatus) { // if(logger.isDebugEnabled())logger.debug("setGreenIconStatus: '" + greenIconStatus + "'"); switch (greenIconStatus) { case Status.ICON_IGNORE: { break; } case Status.ICON_ACTIVATED: { greenStatusIcon.switchOn(true); break; } case Status.ICON_DEACTIVATED: { greenStatusIcon.switchOff(true); break; } case Status.ICON_BLINKING: { greenStatusIcon.blink(500); break; } default: { greenStatusIcon.switchOff(true); } } } /** * DOCUMENT ME! * * @param redIconStatus DOCUMENT ME! */ public void setRedIconStatus(final int redIconStatus) { // if(logger.isDebugEnabled())logger.debug("setRedIconStatus: '" + redIconStatus + "'"); switch (redIconStatus) { case Status.ICON_IGNORE: { break; } case Status.ICON_ACTIVATED: { redStatusIcon.switchOn(true); break; } case Status.ICON_DEACTIVATED: { redStatusIcon.switchOff(true); break; } case Status.ICON_BLINKING: { redStatusIcon.blink(500); break; } default: { redStatusIcon.switchOn(true); } } } /** * DOCUMENT ME! * * @param status DOCUMENT ME! */ public void setStatus(final Status status) { this.setStatusMessage(status.getStatusMessage(), status.getMessagePosition()); this.setRedIconStatus(status.getRedIconState()); this.setGreenIconStatus(status.getGreenIconState()); } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public boolean isGreenStatusIconBlinking() { return greenStatusIcon.isBlinking(); } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public boolean isRedStatusIconBlinking() { return redStatusIcon.isBlinking(); } }