/** * Initialize GUI. * * @param queryResult */ private void initGUI(IQueryResult queryResult) { this.setLayout(new RiverLayout(5, 5)); currentBreadCrumbName = null; breadCrumbsAL = new BreadCrumbActionListener(this); hyperlinkAL = new HyperlinlActionListener(this); associatedDataAL = new AssociatedDataActionListener(this); /* * The breadcrumb panel should be common to all cards, and hence should * not be part of any card. */ String key = this.panelCount + "#" + edu.wustl.cab2b.common.util.Utility.getDisplayName(queryResult.getOutputEntity()); this.m_vBreadCrumbs.add(key); this.m_breadCrumbPanel = new Cab2bPanel(); this.m_breadCrumbPanel.setLayout(new CardLayout()); BreadcrumbPanel breadCrumbPanel = new BreadcrumbPanel(breadCrumbsAL, m_vBreadCrumbs, this.viewPanel); currentBreadCrumbName = breadCrumbPanel.getCurrentBreadCrumbName(); this.m_breadCrumbPanel.add(breadCrumbPanel, "" + this.panelCount); // Check if you got only one record JXPanel simpleSearchResultPanel = ResultPanelFactory.getResultPanel(this, queryResult, null, null); /* * Initialize the panel that will house all cards, and add the first * card. */ this.m_resultsPanel = new Cab2bPanel(); this.m_resultsPanel.setLayout(new CardLayout()); this.m_resultsPanel.add(simpleSearchResultPanel, "" + this.panelCount); /* Add the main result panel to the current panel. */ this.add("hfill", this.m_breadCrumbPanel); this.add("br vfill hfill", this.m_resultsPanel); }
public void actionPerformed(ActionEvent evt) { logger.debug("bread crumbs ActionListener : " + evt.getActionCommand()); Cab2bHyperlink hyperlink = (Cab2bHyperlink) evt.getSource(); /* * Get the user object for the hyperlink. This contains the whole * string. */ String hyperlinkText = (String) hyperlink.getUserObject(); int i; for (i = 0; i < m_vBreadCrumbs.size(); i++) { String breadCrumbValue = (String) m_vBreadCrumbs.get(i); if (breadCrumbValue.trim().equals(hyperlinkText.trim())) { break; } } panelCount = i++; for (int j = i; j < m_vBreadCrumbs.size(); j++) { m_vBreadCrumbs.remove(j--); m_resultsPanel.remove(i); } /* * Get the number from the hyperlink text and use that to show the * panel. */ String strIndex = hyperlinkText.substring(0, hyperlinkText.indexOf('#')); breadCrumbPanel.showPanel(strIndex); BreadcrumbPanel breadcrumbPanel = new BreadcrumbPanel( breadCrumbPanel.getBreadCrumbsAL(), m_vBreadCrumbs, this.breadCrumbPanel.viewPanel); currentBreadCrumbName = breadcrumbPanel.getCurrentBreadCrumbName(); this.breadCrumbPanel.addBreadCrumbPanel(breadcrumbPanel, strIndex); this.breadCrumbPanel.showBreadcrumbPanel(strIndex); }