List of usage examples for javax.swing JList setListData
public void setListData(final Vector<? extends E> listData)
ListModel
from a Vector
and calls setModel with this model. From source file:org.mindswap.swoop.renderer.entity.ConciseFormatEntityRenderer.java
/** * Method that handles the Add* operation when the user clicks on the * corresponding hyperlink in the Concise Format Pane (eg. Add SuperClass) * It calls the appropriate PopupAdd* Java Class depending on the type of add operation * @param hLink - code representing type of Add operation * @return/*from w w w .j a v a 2 s .c om*/ * @throws OWLException */ public List handleAddLink(String hLink) throws OWLException { OWLOntology ontology = reasoner.getOntology(); // remove the prefixed "<" if (hLink.startsWith("<")) hLink = hLink.substring(1, hLink.length()); else System.out.println("hyperlink error: " + hLink); // new rules addition if (hLink.equals("AddRULE")) { PopupAddRule test = new PopupAddRule(swoopModel, displayedEntity); test.show(); } if (hLink.equals("AddA-ANN")) { // add annotation PopupAddAnnotation popup = new PopupAddAnnotation(swoopModel, false); popup.setLocation(200, 200); popup.show(); return new ArrayList(); } if (hLink.equals("AddATTRIB")) { // add property attribute - Functional etc JList attribList = new JList(); //attribList.setFont(new Font("Tahoma", Font.PLAIN, 10)); List attribs = new ArrayList(); OWLProperty prop = (OWLProperty) swoopModel.getSelectedEntity(); if (!prop.isFunctional(reasoner.getOntologies())) attribs.add("Functional"); if (prop instanceof OWLObjectProperty) { if (!((OWLObjectProperty) prop).isInverseFunctional(reasoner.getOntologies())) attribs.add("Inverse Functional"); if (!((OWLObjectProperty) prop).isTransitive(reasoner.getOntologies())) attribs.add("Transitive"); if (!((OWLObjectProperty) prop).isSymmetric(reasoner.getOntologies())) attribs.add("Symmetric"); } if (attribs.size() == 0) { JOptionPane.showMessageDialog(null, "Property already has all possible attributes", "Unable to Add", JOptionPane.INFORMATION_MESSAGE); return new ArrayList(); } attribList.setListData(attribs.toArray()); int attr = JOptionPane.showConfirmDialog(null, new JScrollPane(attribList), "Specify Property Attribute:", JOptionPane.YES_NO_OPTION); if (attr == 0) { OntologyChange change = null; String sel = attribList.getSelectedValue().toString(); if (sel.equals("Functional")) change = new SetFunctional(ontology, prop, true, null); else if (sel.equals("Inverse Functional")) change = new SetInverseFunctional(ontology, (OWLObjectProperty) prop, true, null); else if (sel.equals("Transitive")) change = new SetTransitive(ontology, (OWLObjectProperty) prop, true, null); else if (sel.equals("Symmetric")) change = new SetSymmetric(ontology, (OWLObjectProperty) prop, true, null); swoopModel.addUncommittedChange(change); } return new ArrayList(); } if (hLink.startsWith("AddC")) { // popup Add Class Frame String type = hLink.substring(hLink.indexOf("-") + 1, hLink.length()); PopupAddClass popup = new PopupAddClass(reasoner, type, swoopModel); popup.setLocation(200, 200); popup.show(); return popup.changes; } if (hLink.startsWith("AddP")) { // popup Add Property Frame boolean DP = true, OP = true; if (hLink.startsWith("AddP-INSO")) DP = false; if (hLink.startsWith("AddP-INSD")) OP = false; String type = hLink.substring(hLink.indexOf("-") + 1, hLink.length()); PopupAddProperty popup = new PopupAddProperty(reasoner, type, swoopModel, DP, OP); popup.setLocation(200, 200); popup.show(); return popup.changes; } if (hLink.startsWith("AddI-SAM") || hLink.startsWith("AddI-DIF") || hLink.startsWith("AddI-ONE") || hLink.startsWith("AddI-INS")) { // popup Add Individual Frame String type = hLink.substring(hLink.indexOf("-") + 1, hLink.length()); PopupAddIndividual popup = new PopupAddIndividual(reasoner, type, swoopModel); popup.setLocation(200, 200); popup.show(); return popup.changes; } if (hLink.startsWith("AddV")) { // add value for property String hash = hLink.substring(hLink.indexOf(":") + 1, hLink.length()); OWLProperty prop = (OWLProperty) OWLDescHash.get(hash); //*********************************************************** //changed for Econnections //*********************************************************** OWLEntity entit = swoopModel.getSelectedEntity(); if (prop instanceof OWLObjectProperty) { if (((OWLObjectProperty) prop).isLink()) { URI u = ((OWLObjectProperty) prop).getLinkTarget(); OWLOntology foreignOnto = swoopModel.getOntology(u); reasoner.setOntology(foreignOnto); swoopModel.setSelectedOntology(foreignOnto); } } PopupAddValue popup = new PopupAddValue(reasoner, swoopModel, prop); popup.setLocation(200, 200); popup.show(); if (prop instanceof OWLObjectProperty) { if (((OWLObjectProperty) prop).isLink()) { reasoner.setOntology(ontology); swoopModel.setSelectedOntology(ontology); swoopModel.setSelectedEntity(entit); } } return popup.changes; } return null; }
From source file:se.trixon.toolbox.alphatrans.AlphatransTopComponent.java
private void filter(String filter, JList list) { ArrayList<String> filtered = new ArrayList<>(); for (String charSet : mCharSets) { if (charSet.toLowerCase().contains(filter.toLowerCase())) { filtered.add(charSet);/*from w w w. j ava2s .c o m*/ } } list.setListData(filtered.toArray()); }
From source file:uk.ac.ebi.demo.picr.swing.PICRBLASTDemo.java
public PICRBLASTDemo() { //set general layout setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); add(Box.createVerticalStrut(5)); //create components JPanel row1 = new JPanel(); row1.setLayout(new BoxLayout(row1, BoxLayout.X_AXIS)); row1.add(Box.createHorizontalStrut(5)); row1.setBorder(BorderFactory.createTitledBorder("")); row1.add(new JLabel("Fragment:")); row1.add(Box.createHorizontalStrut(10)); final JTextArea sequenceArea = new JTextArea(5, 40); sequenceArea.setMaximumSize(sequenceArea.getPreferredSize()); row1.add(Box.createHorizontalStrut(10)); row1.add(sequenceArea);/*from w ww .j a v a 2s.co m*/ row1.add(Box.createHorizontalGlue()); JPanel row2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); row2.setBorder(BorderFactory.createTitledBorder("Target Databases")); final JList databaseList = new JList(); JScrollPane listScroller = new JScrollPane(databaseList); listScroller.setMaximumSize(new Dimension(100, 10)); JButton loadDBButton = new JButton("Load Databases"); row2.add(listScroller); row2.add(loadDBButton); JPanel row3 = new JPanel(new FlowLayout(FlowLayout.LEFT)); JCheckBox onlyActiveCheckBox = new JCheckBox("Only Active"); onlyActiveCheckBox.setSelected(true); row3.add(new JLabel("Options: ")); row3.add(onlyActiveCheckBox); add(row1); add(row2); add(row3); final String[] columns = new String[] { "Database", "Accession", "Version", "Taxon ID" }; final JTable dataTable = new JTable(new Object[0][0], columns); dataTable.setShowGrid(true); add(new JScrollPane(dataTable)); JPanel buttonPanel = new JPanel(); JButton mapAccessionButton = new JButton("Generate Mapping!"); buttonPanel.add(mapAccessionButton); add(buttonPanel); //create listeners! //update boolean flag in communication class onlyActiveCheckBox.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { client.setOnlyActive(((JCheckBox) e.getSource()).isSelected()); } }); //performs mapping call and updates interface with results mapAccessionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { if (!"".equals(sequenceArea.getText())) { //TODO filters and database are hardcoded here. They should be added to the input panel at a later revision. java.util.List<UPEntry> entries = client.performBlastMapping(sequenceArea.getText(), databaseList.getSelectedValues(), "90", "", "IDENTITY", "UniprotKB", "", false, new BlastParameter()); //compute size of array if (entries != null) { int size = 0; for (UPEntry entry : entries) { for (CrossReference xref : entry.getIdenticalCrossReferences()) { size++; } for (CrossReference xref : entry.getLogicalCrossReferences()) { size++; } } if (size > 0) { final Object[][] data = new Object[size][4]; int i = 0; for (UPEntry entry : entries) { for (CrossReference xref : entry.getIdenticalCrossReferences()) { data[i][0] = xref.getDatabaseName(); data[i][1] = xref.getAccession(); data[i][2] = xref.getAccessionVersion(); data[i][3] = xref.getTaxonId(); i++; } for (CrossReference xref : entry.getLogicalCrossReferences()) { data[i][0] = xref.getDatabaseName(); data[i][1] = xref.getAccession(); data[i][2] = xref.getAccessionVersion(); data[i][3] = xref.getTaxonId(); i++; } } //refresh DefaultTableModel dataModel = new DefaultTableModel(); dataModel.setDataVector(data, columns); dataTable.setModel(dataModel); System.out.println("update done"); } else { JOptionPane.showMessageDialog(null, "No Mappind data found."); } } else { JOptionPane.showMessageDialog(null, "No Mappind data found."); } } else { JOptionPane.showMessageDialog(null, "You must enter a valid FASTA sequence to map."); } } catch (SOAPFaultException soapEx) { JOptionPane.showMessageDialog(null, "A SOAP Error occurred."); soapEx.printStackTrace(); } } }); //loads list of mapping databases from communication class loadDBButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { java.util.List<String> databases = client.loadDatabases(); if (databases != null && databases.size() > 0) { databaseList.setListData(databases.toArray()); System.out.println("database refresh done"); } else { JOptionPane.showMessageDialog(null, "No Databases Loaded!."); } } catch (SOAPFaultException soapEx) { JOptionPane.showMessageDialog(null, "A SOAP Error occurred."); soapEx.printStackTrace(); } } }); }