List of usage examples for java.awt.event MouseEvent getClickCount
public int getClickCount()
From source file:org.yccheok.jstock.gui.MainFrame.java
private MouseAdapter getMyJXStatusBarExchangeRateLabelMouseAdapter() { return new MouseAdapter() { @Override// w ww .jav a 2s .co m public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { // Popup dialog to select currency exchange option. OptionsJDialog optionsJDialog = new OptionsJDialog(MainFrame.this, true); optionsJDialog.setLocationRelativeTo(MainFrame.this); optionsJDialog.set(jStockOptions); optionsJDialog.select(GUIBundle.getString("OptionsJPanel_Wealth")); optionsJDialog.setVisible(true); } } }; }
From source file:org.yccheok.jstock.gui.MainFrame.java
private MouseAdapter getMyJXStatusBarCountryLabelMouseAdapter() { return new MouseAdapter() { @Override/* ww w. j a va 2 s.c o m*/ public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { CountryJDialog countryJDialog = new CountryJDialog(MainFrame.this, true); countryJDialog.setLocationRelativeTo(MainFrame.this); countryJDialog.setCountry(jStockOptions.getCountry()); countryJDialog.setVisible(true); final Country country = countryJDialog.getCountry(); changeCountry(country); } } }; }
From source file:org.yccheok.jstock.gui.MainFrame.java
private MouseAdapter getDynamicChartMouseAdapter() { return new MouseAdapter() { @Override//from w w w.j a v a 2 s . c o m public void mouseClicked(MouseEvent e) { if (e.getClickCount() >= 2) { final Stock stock = getSelectedStock(); if (stock == null) { return; } final DynamicChart dynamicChart = MainFrame.this.dynamicCharts.get(stock.code); if (dynamicChart == null) { return; } Symbol symbol = null; // Use local variable to ensure thread safety. final StockInfoDatabase stock_info_database = MainFrame.this.stockInfoDatabase; // Is the database ready? if (stock_info_database != null) { // Possible null if we are trying to get index history. symbol = stock_info_database.codeToSymbol(stock.code); } final String template = GUIBundle.getString("MainFrame_IntradayMovementTemplate"); final String message = MessageFormat.format(template, symbol == null ? stock.symbol : symbol); dynamicChart.showNewJDialog(MainFrame.this, message); } } // Shall we provide visualize mouse move over effect, so that user // knows this is a clickable component? /* private final LineBorder lineBorder = new LineBorder(Color.WHITE); private Border oldBorder = null; @Override public void mouseEntered(MouseEvent e) { JPanel jPanel = (JPanel)e.getComponent(); Border old = jPanel.getBorder(); if (old != lineBorder) { oldBorder = old; } jPanel.setBorder(lineBorder); } @Override public void mouseExited(MouseEvent e) { JPanel jPanel = (JPanel)e.getComponent(); jPanel.setBorder(oldBorder); } */ }; }
From source file:org.yccheok.jstock.gui.MainFrame.java
private MouseAdapter getMyJXStatusBarImageLabelMouseAdapter() { return new MouseAdapter() { @Override//from w ww.ja v a 2s . c om public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { // Make sure no other task is running. // Use local variable to be thread safe. final DatabaseTask task = MainFrame.this.databaseTask; if (task != null) { if (task.isDone() == true) { // Task is done. But, does it success? boolean success = false; // Some developers suggest that check for isCancelled before calling get // to avoid CancellationException. Others suggest that just perform catch // on all Exceptions. I will do it both. if (task.isCancelled() == false) { try { success = task.get(); } catch (InterruptedException ex) { log.error(null, ex); } catch (ExecutionException ex) { log.error(null, ex); } catch (CancellationException ex) { log.error(null, ex); } } if (success == false) { // Fail. Automatically reload database for user. Need not to prompt them message. // As, they do not have any database right now. MainFrame.this.initDatabase(true); } else { final int result = JOptionPane.showConfirmDialog(MainFrame.this, MessagesBundle.getString("question_message_perform_server_reconnecting"), MessagesBundle.getString("question_title_perform_server_reconnecting"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.YES_OPTION) { MainFrame.this.initDatabase(false); } } } else { // There is task still running. Ask user whether he wants // to stop it. final int result = JOptionPane.showConfirmDialog(MainFrame.this, MessagesBundle.getString("question_message_cancel_server_reconnecting"), MessagesBundle.getString("question_title_cancel_server_reconnecting"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.YES_OPTION) { synchronized (MainFrame.this.databaseTaskMonitor) { MainFrame.this.databaseTask.cancel(true); MainFrame.this.databaseTask = null; } setStatusBar(false, GUIBundle.getString("MainFrame_NetworkError")); statusBar.setImageIcon(getImageIcon("/images/16x16/network-error.png"), java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui") .getString("MainFrame_DoubleClickedToTryAgain")); } } } else { // User cancels databaseTask explicitly. (Cancel while // JStock is fetching database from server). Let's read // from disk. initDatabase(true); } } } }; }
From source file:com.pianobakery.complsa.MainGui.java
public MainGui() { $$$setupUI$$$();/*from w w w . j av a 2 s. com*/ runtimeParameters(); trainCorp = new HashMap<String, File>(); trainSentModels = new HashMap<String, File>(); indexFilesModel = new HashMap<String, File>(); searchCorpusModel = new HashMap<String, File>(); selDocdirContent = new ArrayList<File>(); langModelsText.setText("None"); posIndRadiusTextField.setEnabled(false); //Disable all Components as long as wDir is not set. enableUIElements(false); ButtonGroup selSearchGroup = new ButtonGroup(); selSearchGroup.add(searchSearchCorpRadioButton); selSearchGroup.add(searchTopCorpRadioButton); ButtonGroup searchSelGroup = new ButtonGroup(); searchSelGroup.add(selTextRadioButton); searchSelGroup.add(selDocRadioButton); //licenseKeyGUI = new LicenseKeyGUI(frame, true); //Added to get the docSearchTable the focus when opening the Reader without selecting something so up down button will work frame.addWindowFocusListener(new WindowAdapter() { public void windowGainedFocus(WindowEvent e) { docSearchResTable.requestFocusInWindow(); } }); frame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke('S', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), "CTRL + S"); frame.getRootPane().getActionMap().put("CTRL + S", runSearch()); frame.addWindowListener(new WindowAdapter() { public void windowOpened(WindowEvent evt) { formWindowOpened(evt); } }); //Needs to get a white background in the termtableview (only in windows) termTablePane.getViewport().setBackground(Color.WHITE); //Project Page //Project Folder newFolderButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { newFolderMethod(); } }); selectFolderButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectFolderMethod(); } }); //Download Language Models downloadModelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { downloadModelMethod(); } }); //Add-Remove Topic Corpus addTopicCorpusButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { addTopicCorpusMethod(); } }); selectTrainCorp.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { frame.setTitle("Selected Training Corpus: " + selectTrainCorp.getSelectedItem() + " and " + "Sel. Search Corpus: " + searchCorpComboBox.getSelectedItem()); algTextField.setText("Knowledge Corpus: " + selectTrainCorp.getSelectedItem()); try { updateIndexFileFolder(); } catch (IOException e1) { e1.printStackTrace(); } } }); removeTopicCorpusButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) throws ArrayIndexOutOfBoundsException { removeTopicCorpusMethod(); } }); //Update and remove Index updateIndexButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateIndexMethod(); } }); removeIndexButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeIndexMethod(); } }); //Train Semantic trainCorpButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { trainCorpMethod(); } }); indexTypeComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (indexTypeComboBox.getSelectedIndex() == 2) { logger.debug("Enable indexType Combo with Index: " + indexTypeComboBox.getSelectedIndex()); posIndRadiusTextField.setEnabled(true); return; } logger.debug("Disable indexType Combo with Index: " + indexTypeComboBox.getSelectedIndex()); posIndRadiusTextField.setEnabled(false); } }); //Import and remove Search Corpora impSearchCorpButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { impSearchCorpMethod(); } }); searchCorpComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { frame.setTitle("Selected Training Corpus: " + selectTrainCorp.getSelectedItem() + " and " + "Sel. Search Corpus: " + searchCorpComboBox.getSelectedItem()); } }); removeSearchCorpButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) throws ArrayIndexOutOfBoundsException { removeSearchCorpMethod(); } }); //Search Page //Choose Index Type selectIndexTypeComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (searchModelList.isEmpty()) { return; } if (searchModelList.get(selectIndexTypeComboBox.getSelectedItem()) == null) { return; } List<String> theList = searchModelList.get(selectIndexTypeComboBox.getSelectedItem().toString()); selectTermweightComboBox.removeAllItems(); for (String aTFItem : theList) { selectTermweightComboBox.addItem(aTFItem); } getSelectedSearchModelFiles(); } }); selectTermweightComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (searchModelList.isEmpty()) { return; } if (searchModelList.get(selectIndexTypeComboBox.getSelectedItem()) == null) { return; } getSelectedSearchModelFiles(); } }); //Select Search Type selTextRadioButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectDocumentButton.setEnabled(false); searchTextArea.setEnabled(true); //searchDocValue.setText("nothing selected"); } }); selDocRadioButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectDocumentButton.setEnabled(true); searchTextArea.setText(null); searchTextArea.setEnabled(false); } }); selectDocumentButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { importSearchFile(); openSearchDocumentButton.setEnabled(true); } }); openSearchDocumentButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (searchDocReader == null) { searchDocReader = getReaderLater(null, maingui); searchDocReader.setSearchTerms(getSelectedTermTableWords()); } else if (!searchDocReader.getFrameVisible()) { searchDocReader.setFrameVisible(true); searchDocReader.setSearchTerms(getSelectedTermTableWords()); } searchDocReader.setDocumentText(searchFileString); searchDocReader.setSelFullDocLabel(searchDocValue.toString()); searchDocReader.setViewPane(2); searchDocReader.disableComponents(); searchDocReader.setSearchTerms(getSelectedTermTableWords()); } }); //Search Button searchButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { searchMethod(); } }); //Table Listeners docSearchResTable.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent me) { JTable table = (JTable) me.getSource(); Point p = me.getPoint(); int row = docSearchResTable.rowAtPoint(p); if (docSearchResModel == null || docSearchResModel.getRowCount() == 0 || docSearchResModel.getDocFile(0).getFileName().equals(emptyTable)) { return; } switch (me.getClickCount()) { case 1: if (row == -1) { break; } if (docSearchResTable.getRowCount() > 0) { logger.debug("Single click Doc: " + ((DocSearchModel) docSearchResTable.getModel()) .getDocSearchFile(row).getFile().toString()); fillMetaDataField( ((DocSearchModel) docSearchResTable.getModel()).getDocSearchFile(row).getFile()); if (reader != null) { reader.setSearchTerms(getSelectedTermTableWords()); } if (searchDocReader != null) { searchDocReader.setSearchTerms(getSelectedTermTableWords()); } setSelReaderContent(); setDocReaderContent(0); if (reader != null) { reader.setSearchTerms(getSelectedTermTableWords()); } if (searchDocReader != null) { searchDocReader.setSearchTerms(getSelectedTermTableWords()); } } break; case 2: if (row == -1) { break; } if (docSearchResTable.getRowCount() > 0) { logger.debug("Double click Doc: " + ((DocSearchModel) docSearchResTable.getModel()) .getDocSearchFile(row).getFile().toString()); fillMetaDataField( ((DocSearchModel) docSearchResTable.getModel()).getDocSearchFile(row).getFile()); if (reader == null) { reader = getReaderLater((DocSearchModel) docSearchResTable.getModel(), maingui); reader.setSearchTerms(getSelectedTermTableWords()); } else if (!reader.getFrameVisible()) { reader.setFrameVisible(true); reader.setSearchTerms(getSelectedTermTableWords()); } setSelReaderContent(); setDocReaderContent(0); if (reader != null) { reader.setSearchTerms(getSelectedTermTableWords()); } if (searchDocReader != null) { searchDocReader.setSearchTerms(getSelectedTermTableWords()); } } break; } } }); termSearchResTable.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent me) { JTable table = (JTable) me.getSource(); Point p = me.getPoint(); int row = docSearchResTable.rowAtPoint(p); if (termSearchResTable.getModel() == null || termSearchResTable.getRowCount() == 0 || termSearchResTable.getModel().getValueAt(row, 1).equals(emptyTable)) { return; } switch (me.getClickCount()) { case 1: logger.debug("Single click Term: " + termSearchResTable.getModel().getValueAt(row, 1)); logger.debug("Selected Terms: " + Arrays.toString(getSelectedTermTableWords())); if (reader != null) { reader.setSearchTerms(getSelectedTermTableWords()); } if (searchDocReader != null) { searchDocReader.setSearchTerms(getSelectedTermTableWords()); } break; case 2: logger.debug("Double click Term: " + termSearchResTable.getModel().getValueAt(row, 1)); if (reader != null) { reader.setSearchTerms(getSelectedTermTableWords()); } if (searchDocReader != null) { searchDocReader.setSearchTerms(getSelectedTermTableWords()); } break; } } }); docSearchResTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent event) { if (docSearchResModel == null || docSearchResModel.getRowCount() == 0 || docSearchResModel.getDocFile(0).getFileName().equals(emptyTable)) { return; } if (docSearchResTable.getSelectedRow() > -1) { // print first column value from selected row logger.debug("KeyboardSelection: " + ((DocSearchModel) docSearchResTable.getModel()) .getDocSearchFile( docSearchResTable.convertRowIndexToModel(docSearchResTable.getSelectedRow())) .getFile().toString()); fillMetaDataField(((DocSearchModel) docSearchResTable.getModel()) .getDocSearchFile( docSearchResTable.convertRowIndexToModel(docSearchResTable.getSelectedRow())) .getFile()); setSelReaderContent(); setDocReaderContent(0); if (reader != null) { reader.setSearchTerms(getSelectedTermTableWords()); } if (searchDocReader != null) { searchDocReader.setSearchTerms(getSelectedTermTableWords()); } } } }); termSearchResTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (termSearchResTable.getModel() == null || termSearchResTable.getRowCount() == 0 || termSearchResTable.getModel().getValueAt(0, 1).equals(emptyTable)) { return; } if (termSearchResTable.getSelectedRow() > -1) { // print first column value from selected row if (reader != null) { reader.setSearchTerms(getSelectedTermTableWords()); } if (searchDocReader != null) { searchDocReader.setSearchTerms(getSelectedTermTableWords()); } } } }); }
From source file:org.nuclos.client.ui.collect.CollectController.java
/** * alternative entry point: view search result (in Results tab) * @precondition this.isSearchPanelAvailable() * * @deprecated Move to ResultController. *//*w w w .ja v a 2s. c o m*/ public final void runViewResults(final ICollectableListOfValues clctlovSource) throws CommonBusinessException { // remove mouse listener for double click in table: final JTable tbl = this.getResultTable(); tbl.removeMouseListener(this.getMouseListenerForTableDoubleClick()); // add alternative mouse listener for foreign key lookup: foreignKeyMouseListenerForTableDoubleClick = new MouseAdapter() { @Override public void mouseClicked(MouseEvent ev) { if (SwingUtilities.isLeftMouseButton(ev) && ev.getClickCount() == 2) { try { final Collectable clctSelected = CollectController.this.getCompleteSelectedCollectable(); // TODO assert clctSelected != null ? if (clctSelected != null) { clctlovSource.acceptLookedUpCollectable(clctSelected); // remove the mouse listener after it has done its job: // tbl.removeMouseListener(this); // TODO may whatever mouselistener was installed should be removed from the table in "close()" // Note that Controller.close() is called implicitly here: getTab().dispose(); } } catch (Exception ex) { Errors.getInstance().showExceptionDialog(getTab(), ex); } } } }; tbl.addMouseListener(foreignKeyMouseListenerForTableDoubleClick); if (!this.isSearchPanelAvailable()) { throw new IllegalStateException("this.isSearchPanelAvailable()"); } this.setCollectableSearchConditionInSearchPanel(clctlovSource.getCollectableSearchCondition()); this.selectTab(); getResultController().getSearchResultStrategy().cmdSearch(); this.getCollectPanel().setTabbedPaneEnabledAt(CollectState.OUTERSTATE_DETAILS, false); this.getCollectPanel().setTabbedPaneEnabledAt(CollectState.OUTERSTATE_SEARCH, false); }
From source file:org.nuclos.client.ui.collect.CollectController.java
/** * alternative entry point: lookup a <code>Collectable</code> (in a foreign entity). *//*w w w . j a v a 2s .c o m*/ public void runLookupCollectable(final ICollectableListOfValues clctlovSource) throws CommonBusinessException { // show the internal frame in the front of the modal layer: final MainFrameTab ifrm = this.getTab(); ifrm.setVisible(true); if (!clctlovSource.isSearchComponent()) { String label = getSpringLocaleDelegate().getMessage("CollectController.41", "Auswahl bernehmen"); String description = getSpringLocaleDelegate().getMessage("CollectController.42", "Findet die bernahme in einem Unterformular statt werden mittels Mehrfachauswahl zustzliche Datenstze im Unterformular erzeugt."); if (clctlovSource instanceof CollectableListOfValues) { final CollectableListOfValues clov = (CollectableListOfValues) clctlovSource; if (clov.getValueListProvider() instanceof DatasourceBasedCollectableFieldsProvider) { ss.setValueListProviderDatasource( ((DatasourceBasedCollectableFieldsProvider) clov.getValueListProvider()) .getDatasourceVO()); ss.setValueListProviderDatasourceParameter( ((DatasourceBasedCollectableFieldsProvider) clov.getValueListProvider()) .getValueListParameter()); } else if (clov .getValueListProvider() instanceof CollectableFieldsProviderCache.CachingCollectableFieldsProvider) { CollectableFieldsProvider delegate = ((CollectableFieldsProviderCache.CachingCollectableFieldsProvider) clov .getValueListProvider()).getDelegate(); if (delegate instanceof DatasourceBasedCollectableFieldsProvider) { ss.setValueListProviderDatasource( ((DatasourceBasedCollectableFieldsProvider) delegate).getDatasourceVO()); ss.setValueListProviderDatasourceParameter( ((DatasourceBasedCollectableFieldsProvider) delegate).getValueListParameter()); } } } else if (clctlovSource instanceof EntityListOfValues) { label = getSpringLocaleDelegate().getMessage("CollectController.lookup.generation", "Objekte ausw\u00e4hlen"); description = getSpringLocaleDelegate().getMessage( "CollectController.lookup.generation.description", "Parameterobjekte fr die Objektgenerierung ausw\u00e4hlen."); } final JMenuItem miPopupApplySelection = new JMenuItem(label); miPopupApplySelection.setToolTipText(description); getResultPanel().popupmenuRow.removeAll();//.addSeparator(); getResultPanel().popupmenuRow.add(miPopupApplySelection); miPopupApplySelection.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { acceptLookedUpCollectable(clctlovSource); getTab().dispose(); } }); } // remove mouse listener for double click in table: getResultPanel().removeDoubleClickMouseListener(this.getMouseListenerForTableDoubleClick()); // add alternative mouse listener for foreign key lookup: foreignKeyMouseListenerForTableDoubleClick = new MouseAdapter() { @Override public void mouseClicked(MouseEvent ev) { if (SwingUtilities.isLeftMouseButton(ev) && ev.getClickCount() == 2) { int iRow = getResultTable().rowAtPoint(ev.getPoint()); if (iRow >= 0 && iRow < getResultTable().getRowCount()) { getResultTable().getSelectionModel().setSelectionInterval(iRow, iRow); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { acceptLookedUpCollectable(clctlovSource); getTab().dispose(); } }); } } } }; getResultPanel().addDoubleClickMouseListener(foreignKeyMouseListenerForTableDoubleClick); // @see NUCLOS-432 //getResultTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); getResultTable().getActionMap().put(KeyBindingProvider.EDIT_2.getKey(), new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { acceptLookedUpCollectable(clctlovSource); getTab().dispose(); } }); if (this.isSearchPanelAvailable()) { if (ss.getValueListProviderDatasource() != null) { this.runViewAll(); } else { this.runSearch(); } } else { this.runViewAll(); } final Boolean modalLookup = (Boolean) clctlovSource .getProperty(ICollectableListOfValues.PROPERTY_MODAL_LOOKUP); if (Boolean.TRUE.equals(modalLookup)) { JDialog d = new JDialog(Main.getInstance().getMainFrame(), ifrm.getTitle(), true); FrameUtils.externalizeIntoWindow(ifrm, d); d.pack(); d.setVisible(true); } }
From source file:org.yccheok.jstock.gui.JStock.java
private MouseAdapter getMyJXStatusBarExchangeRateLabelMouseAdapter() { return new MouseAdapter() { @Override/* ww w.ja v a 2 s . c o m*/ public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { // Popup dialog to select currency exchange option. OptionsJDialog optionsJDialog = new OptionsJDialog(JStock.this, true); optionsJDialog.setLocationRelativeTo(JStock.this); optionsJDialog.set(jStockOptions); optionsJDialog.select(GUIBundle.getString("OptionsJPanel_Wealth")); optionsJDialog.setVisible(true); } } }; }
From source file:org.yccheok.jstock.gui.JStock.java
private MouseAdapter getMyJXStatusBarCountryLabelMouseAdapter() { return new MouseAdapter() { @Override// ww w .j av a 2s. c o m public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { CountryJDialog countryJDialog = new CountryJDialog(JStock.this, true); countryJDialog.setLocationRelativeTo(JStock.this); countryJDialog.setCountry(jStockOptions.getCountry()); countryJDialog.setVisible(true); final Country country = countryJDialog.getCountry(); changeCountry(country); } } }; }
From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryBldrPane.java
/** * @param parentList// ww w. j a v a 2s. c o m */ protected void fillNextList(final JList parentList) { if (processingLists) { return; } processingLists = true; final int curInx = listBoxList.indexOf(parentList); if (curInx > -1) { int startSize = listBoxPanel.getComponentCount(); for (int i = curInx + 1; i < listBoxList.size(); i++) { listBoxPanel.remove(spList.get(i)); } int removed = startSize - listBoxPanel.getComponentCount(); for (int i = 0; i < removed; i++) { tableTreeList.remove(tableTreeList.size() - 1); } } else { listBoxPanel.removeAll(); tableTreeList.clear(); } QryListRendererIFace item = (QryListRendererIFace) parentList.getSelectedValue(); if (item instanceof ExpandableQRI) { JList newList; DefaultListModel model; JScrollPane sp; if (curInx == listBoxList.size() - 1) { newList = new JList(model = new DefaultListModel()); newList.addMouseListener(new MouseAdapter() { /* (non-Javadoc) * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) */ @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { if (currentInx != -1) { JList list = (JList) e.getSource(); QryListRendererIFace qriFace = (QryListRendererIFace) list.getSelectedValue(); if (BaseQRI.class.isAssignableFrom(qriFace.getClass())) { BaseQRI qri = (BaseQRI) qriFace; if (qri.isInUse()) { //remove the field for (QueryFieldPanel qfp : QueryBldrPane.this.queryFieldItems) { FieldQRI fqri = qfp.getFieldQRI(); if (fqri == qri || (fqri instanceof RelQRI && fqri.getTable() == qri)) { boolean clearIt = qfp.getSchemaItem() != null; QueryBldrPane.this.removeQueryFieldItem(qfp); if (clearIt) { qfp.setField(null, null); } break; } } } else { // add the field try { FieldQRI fieldQRI = buildFieldQRI(qri); if (fieldQRI == null) { throw new Exception("null FieldQRI"); } SpQueryField qf = new SpQueryField(); qf.initialize(); qf.setFieldName(fieldQRI.getFieldName()); qf.setStringId(fieldQRI.getStringId()); query.addReference(qf, "fields"); if (!isExportMapping) { addQueryFieldItem(fieldQRI, qf, false); } else { addNewMapping(fieldQRI, qf, null, false); } } catch (Exception ex) { log.error(ex); UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance() .capture(QueryBldrPane.class, ex); return; } } } } } } }); newList.setCellRenderer(qryRenderer); listBoxList.add(newList); sp = new JScrollPane(newList, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); JLabel colHeader = UIHelper.createLabel(item.getTitle()); colHeader.setHorizontalAlignment(SwingConstants.CENTER); colHeader.setBackground(listBoxPanel.getBackground()); colHeader.setOpaque(true); sp.setColumnHeaderView(colHeader); spList.add(sp); newList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { fillNextList(listBoxList.get(curInx + 1)); } } }); } else { newList = listBoxList.get(curInx + 1); model = (DefaultListModel) newList.getModel(); sp = spList.get(curInx + 1); JLabel colHeaderLbl = (JLabel) sp.getColumnHeader().getComponent(0); if (item instanceof TableQRI) { colHeaderLbl.setText(((TableQRI) item).getTitle()); } else { colHeaderLbl.setText(getResourceString("QueryBldrPane.QueryFields")); } } createNewList((TableQRI) item, model); listBoxPanel.remove(addBtn); listBoxPanel.add(sp); tableTreeList.add(((ExpandableQRI) item).getTableTree()); listBoxPanel.add(addBtn); currentInx = -1; } else { listBoxPanel.add(addBtn); } SwingUtilities.invokeLater(new Runnable() { public void run() { updateAddBtnState(); // Is all this really necessary listBoxPanel.validate(); listBoxPanel.repaint(); scrollPane.validate(); scrollPane.invalidate(); scrollPane.doLayout(); scrollPane.repaint(); validate(); invalidate(); doLayout(); repaint(); UIRegistry.forceTopFrameRepaint(); } }); processingLists = false; currentInx = curInx; }