public void actionPerformed(ActionEvent actionEvent) { Cab2bHyperlink hyperlink = (Cab2bHyperlink) actionEvent.getSource(); /* Get the user object associated with that source. */ final HyperLinkUserObject hyperLinkUserObject = (HyperLinkUserObject) hyperlink.getUserObject(); IQuery tempQuery = null; AbstractAssociatedDataPanel linkContainer = (AbstractAssociatedDataPanel) hyperlink.getParent(); try { tempQuery = linkContainer.getQuery((hyperLinkUserObject.getAssociation())); } catch (RemoteException e) { CommonUtils.handleException(e, breadCrumbPanel, true, true, true, false); } final IQuery query = tempQuery; breadCrumbText = Utility.getDisplayName(hyperLinkUserObject.getTargetEntity()); /* Get result by executing the Query in a worker thread. */ CustomSwingWorker swingWorker = new CustomSwingWorker((JXPanel) breadCrumbPanel, SimpleSearchResultBreadCrumbPanel.this) { IQueryResult queryResult = null; protected void doNonUILogic() throws Exception { queryResult = CommonUtils.executeQuery((ICab2bQuery) query); } protected void doUIUpdateLogic() throws RuntimeException { /* * Get attributes and set in map, for later when the user is * navigating, and for now directly set it. */ IAssociation association = hyperLinkUserObject.getAssociation(); IDataRow parentDataRow = hyperLinkUserObject.getParentDataRow(); currentBreadCrumbName = breadCrumbText; JXPanel resultPanel = ResultPanelFactory.getResultPanel( breadCrumbPanel, queryResult, parentDataRow, association); addToPanel(resultPanel, breadCrumbText); } }; if (query != null) { swingWorker.start(); } else { addToPanel(ResultPanelFactory.getNoResultFoundPopup(breadCrumbText), breadCrumbText); } }
public void actionPerformed(ActionEvent evt) { Cab2bHyperlink<JPageElement> hyperlink = (Cab2bHyperlink<JPageElement>) evt.getSource(); String hyperlinkText = hyperlink.getText(); JPageElement jPageElement = hyperlink.getUserObject(); PageElement pageElement = jPageElement.getPageElement(); /* Get the data row corresponding to the clicked element. */ Vector recordListUserObject = (Vector) pageElement.getUserObject(); DataRow dataRow = (DataRow) recordListUserObject.get(0); IRecord record = (IRecord) recordListUserObject.get(1); ViewSearchResultsSimplePanel currentPanel = (ViewSearchResultsSimplePanel) m_resultsPanel.getComponent(panelCount); /* * Refresh the breadcrumb vector, and pass that instance onto a new * instance of the breadcrumb panel. */ int currentCount = ++panelCount; m_vBreadCrumbs.add(currentCount + "#" + hyperlinkText); BreadcrumbPanel breadcrumbPanel = new BreadcrumbPanel(getBreadCrumbsAL(), m_vBreadCrumbs, this.searchPanel.viewPanel); currentBreadCrumbName = hyperlinkText; JXPanel detailsPanel = ResultPanelFactory.getSearchResultPanel( searchPanel, record, dataRow, currentPanel.getIncomingAssociationCollection(), currentPanel.getIntraModelAssociationCollection()); addBreadCrumbPanel(breadcrumbPanel, "" + currentCount); showBreadcrumbPanel("" + currentCount); addPanel(detailsPanel, "" + currentCount); showPanel("" + currentCount); }
/** * 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); }