List of usage examples for javax.swing.event ListSelectionListener ListSelectionListener
ListSelectionListener
From source file:com.codecrate.shard.ui.view.ObjectManagerView.java
private EventSelectionModel getSelectionModel() { if (null == selectionModel) { selectionModel = new EventSelectionModel(getSortedObjects()); selectionModel.setSelectionMode(EventSelectionModel.MULTIPLE_INTERVAL_SELECTION); selectionModel.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { deleteCommand.setEnabled(isDeleteCommandEnabled()); propertiesCommand.setEnabled(isPropertiesCommandEnabled()); }//from w w w . ja va 2 s .c o m }); } return selectionModel; }
From source file:com.eviware.soapui.impl.wsdl.monitor.SoapMonitor.java
private JComponent buildLog() { tableModel = new MonitorLogTableModel(); logTable = new JXTable(1, 2); logTable.setColumnControlVisible(true); logTable.setModel(tableModel);/*from ww w . j a v a 2 s .com*/ logTable.setHorizontalScrollEnabled(true); logTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); operationFilter = new PatternFilter(".*", 0, 4); operationFilter.setAcceptNull(true); interfaceFilter = new PatternFilter(".*", 0, 3); interfaceFilter.setAcceptNull(true); targetHostFilter = new PatternFilter(".*", 0, 2); targetHostFilter.setAcceptNull(true); requestHostFilter = new PatternFilter(".*", 0, 1); requestHostFilter.setAcceptNull(true); Filter[] filters = new Filter[] { requestHostFilter, targetHostFilter, interfaceFilter, operationFilter }; FilterPipeline pipeline = new FilterPipeline(filters); logTable.setFilters(pipeline); ListSelectionModel sel = logTable.getSelectionModel(); sel.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { int row = logTable.getSelectedRow(); if (row == -1) { // requestXmlDocument.setXml( null ); // responseXmlDocument.setXml( null ); requestModelItem.setMessageExchange(null); } else { WsdlMonitorMessageExchange exchange = tableModel.getMessageExchangeAt(row); requestModelItem.setMessageExchange(exchange); // responseModelItem.setMessageExchange( exchange ); // requestXmlDocument.setXml( exchange.getRequestContent() ); // responseXmlDocument.setXml( exchange.getResponseContent() ); } addToMockServiceButton.setEnabled(row != -1); addToTestCaseButton.setEnabled(row != -1); // addToRestTestCaseButton.setEnabled( row != -1 ); createRequestButton.setEnabled(row != -1); } }); JPanel tablePane = new JPanel(); tablePane.setLayout(new BorderLayout()); toolbar.addGlue(); tablePane.add(buildFilterBar(), BorderLayout.NORTH); tablePane.add(new JScrollPane(logTable), BorderLayout.CENTER); return tablePane; }
From source file:edu.ku.brc.specify.tools.schemalocale.FieldItemPanel.java
/** * //from ww w. j ava2 s. c o m */ public void buildUI() { setIgnoreChanges(true); fieldsList = createList(fieldsModel); fieldsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { getAllDataFromUI(); fieldSelected(); } } }); fieldsList.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { super.focusLost(e); //lastIndex = fieldsList.getSelectedIndex(); } }); fieldDescText.addKeyListener(new LengthWatcher(255)); // setting min and pref sizes to some bogus values so that textarea shrinks with dialog fieldNameText.addKeyListener(new LengthWatcher(64)); CellConstraints cc = new CellConstraints(); int y = 1; JScrollPane fldsp = UIHelper.createScrollPane(fieldsList); // LocalizableNameDescIFace PanelBuilder pb = new PanelBuilder(new FormLayout("max(200px;p),4px,p,2px,p,10px,p,2px,p,f:p:g", (includeHiddenUI ? "p,2px," : "") + (isDBSchema ? "p,2px,p,2px," : "") + (includeFormatAndAutoNumUI ? "p,2px,p,2px," : "") + "p,2px,p,2px,p,2px,p,2px,p,2px,p,2px,f:p:g"), this); pb.add(fldsp, cc.xywh(1, y, 1, 7 + (isDBSchema ? 4 : 0))); pb.add(fieldNameLbl = createI18NFormLabel("SL_LABEL", SwingConstants.RIGHT), cc.xy(3, y)); pb.add(fieldNameText, cc.xywh(5, y, 6, 1)); y += 2; if (includeHiddenUI) { pb.add(fieldHideChk, cc.xy(5, y)); y += 2; } pb.add(fieldDescLbl = createI18NFormLabel("SL_DESC", SwingConstants.RIGHT), cc.xy(3, y)); JScrollPane sp = new JScrollPane(fieldDescText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); pb.add(sp, cc.xywh(5, y, 6, 1)); y += 2; fieldDescText.setLineWrap(true); fieldDescText.setWrapStyleWord(true); if (isDBSchema) { fieldTypeTxt = createLabel(""); fieldLengthTxt = createLabel(""); pb.add(fieldTypeLbl = createI18NFormLabel("SL_TYPE", SwingConstants.RIGHT), cc.xy(3, y)); pb.add(fieldTypeTxt, cc.xy(5, y)); pb.add(fieldReqChk = createCheckBox(getResourceString("SL_REQ")), cc.xy(9, y)); y += 2; pb.add(fieldLengthLbl = createI18NFormLabel("SL_LENGTH", SwingConstants.RIGHT), cc.xy(3, y)); pb.add(fieldLengthTxt, cc.xy(5, y)); y += 2; fieldTypeTxt.setBackground(Color.WHITE); fieldLengthTxt.setBackground(Color.WHITE); fieldTypeTxt.setOpaque(true); fieldLengthTxt.setOpaque(true); } if (includeFormatAndAutoNumUI) { PanelBuilder inner = new PanelBuilder(new FormLayout("p,2px,p", "p")); formatSwitcherCombo = createComboBox(); fmtCardLayout = new CardLayout(); formatterPanel = new JPanel(fmtCardLayout); pb.add(formatLbl = createI18NFormLabel("SL_FMTTYPE", SwingConstants.RIGHT), cc.xy(3, y)); inner.add(formatSwitcherCombo, cc.xy(1, 1)); inner.add(formatterPanel, cc.xy(3, 1)); pb.add(inner.getPanel(), cc.xywh(5, y, 6, 1)); y += 2; ActionListener switchAL = new ActionListener() { public void actionPerformed(ActionEvent e) { String item = (String) formatSwitcherCombo.getSelectedItem(); if (item != null) { fmtCardLayout.show(formatterPanel, item); webLinkCombo.setEnabled(item.equals(SL_WEBLINK)); if (formatSwitcherCombo.getSelectedIndex() == 0) { if (webLinkCombo.getModel().getSize() > 0) { webLinkCombo.setSelectedIndex(0); } if (formatCombo.getModel().getSize() > 0) { formatCombo.setSelectedIndex(0); } if (pickListCBX.getModel().getSize() > 0) { pickListCBX.setSelectedIndex(0); } } } } }; formatSwitcherCombo.addActionListener(switchAL); formatterPanel.add(SL_NONE, new JPanel()); //-------------------------- // UIFieldFormatter //-------------------------- inner = new PanelBuilder(new FormLayout("max(p;150px),2px,min", "p")); formatCombo = createComboBox(new DefaultComboBoxModel()); formatMoreBtn = createButton(ELIPSES); inner.add(formatCombo, cc.xy(1, 1)); inner.add(formatMoreBtn, cc.xy(3, 1)); formatMoreBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { UIFormatterListEdtDlg dlg = new UIFormatterListEdtDlg((Frame) UIRegistry.getTopWindow(), fieldInfo, true, schemaPanel.getUiFieldFormatterMgrCache()); dlg.setVisible(true); if (!dlg.isCancelled() && dlg.hasChanged()) { //schemaPanel.setHasChanged(true); formHasChanged(); //fillFormatBox(dlg.getSelectedFormat()); setSelectedFieldFormatter(dlg.getSelectedFormat()); } } }); formatterPanel.add(SL_FORMAT, inner.getPanel()); ActionListener changed = new ActionListener() { public void actionPerformed(ActionEvent e) { formHasChanged(); boolean hasFormat = formatCombo.getSelectedIndex() > 0; webLinkCombo.setEnabled(!hasFormat); if (hasFormat) { webLinkCombo.setSelectedIndex(webLinkCombo.getModel().getSize() > 0 ? 0 : -1); pickListCBX.setSelectedIndex(pickListCBX.getModel().getSize() > 0 ? 0 : -1); } } }; formatCombo.addActionListener(changed); //-------------------------- // WebLinks //-------------------------- webLinkMoreBtn = createButton(ELIPSES); webLinkMoreBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { WebLinkDef selectedWL = (WebLinkDef) webLinkCombo.getSelectedItem(); WebLinkConfigDlg dlg = webLinkMgrCache.editWebLinks(tableInfo, false); if (dlg.getBtnPressed() == CustomDialog.OK_BTN) { fillWebLinkBox(); formHasChanged(); if (selectedWL != null && !selectedWL.getName().equals(SL_WEBLINK)) { dlg.setWebLink(selectedWL.getName()); } if (dlg.getBtnPressed() == CustomDialog.OK_BTN) { setSelectedWebLink(dlg.getSelectedItem()); } } } }); inner = new PanelBuilder(new FormLayout("max(p;150px),2px,min", "p")); webLinkCombo = createComboBox(); DefaultComboBoxModel model = (DefaultComboBoxModel) webLinkCombo.getModel(); model.addElement(webLinkDefNone); webLinkCombo.setSelectedIndex(0); inner.add(webLinkCombo, cc.xy(1, 1)); inner.add(webLinkMoreBtn, cc.xy(3, 1)); ActionListener wlchanged = new ActionListener() { public void actionPerformed(ActionEvent e) { formHasChanged(); boolean hasWL = webLinkCombo.getSelectedIndex() > 0; webLinkCombo.setEnabled(hasWL); if (hasWL) { formatCombo.setSelectedIndex(formatCombo.getModel().getSize() > 0 ? 0 : -1); pickListCBX.setSelectedIndex(pickListCBX.getModel().getSize() > 0 ? 0 : -1); } } }; webLinkCombo.addActionListener(wlchanged); formatterPanel.add(SL_WEBLINK, inner.getPanel()); } //-------------------------- // PickList //-------------------------- pickListCBX = createComboBox(new DefaultComboBoxModel()); pickListCBX.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { formHasChanged(); if (formatCombo != null && pickListCBX.getSelectedIndex() > 0) { formatCombo.setSelectedIndex(formatCombo.getModel().getSize() > 0 ? 0 : -1); webLinkCombo.setSelectedIndex(webLinkCombo.getModel().getSize() > 0 ? 0 : -1); } } }); pickListMoreBtn = createButton(ELIPSES); pickListMoreBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { LocalizableItemIFace currentField = prevField; prevField = getSelectedFieldItem(); PickList selectedItem = (PickList) pickListCBX.getSelectedItem(); PickListEditorDlg dlg = new PickListEditorDlg( localizableIO.hasUpdatablePickLists() ? null : localizableIO, true, true); dlg.setTableInfo(tableInfo); dlg.setFieldInfo(fieldInfo); dlg.createUI(); dlg.setSize(400, 500); dlg.setVisible(true); if (!dlg.isCancelled()) { if (dlg.hasChanged()) { hasChanged = true; Vector<PickList> list = dlg.getNewPickLists(); DefaultComboBoxModel plCbxModel = (DefaultComboBoxModel) pickListCBX.getModel(); for (int i = 0; i < plCbxModel.getSize(); i++) { list.add((PickList) plCbxModel.getElementAt(i)); } Collections.sort(list); plCbxModel.removeAllElements(); plCbxModel.addElement(pickListNone); int inx = -1; int i = 0; for (PickList pl : list) { plCbxModel.addElement(pl); if (inx == -1 && selectedItem != null && ((selectedItem.getId() != null && pl.getId() != null && selectedItem.getId().equals(pl.getId())) || (selectedItem.getName() != null && pl.getName() != null && selectedItem.getName().equals(pl.getName())))) { inx = i; } i++; } pickListCBX.setSelectedIndex(inx + 1); } } prevField = currentField; } }); if (includeFormatAndAutoNumUI) { PanelBuilder inner = new PanelBuilder(new FormLayout("max(p;150px),2px,min", "p")); inner.add(pickListCBX, cc.xy(1, 1)); inner.add(pickListMoreBtn, cc.xy(3, 1)); formatterPanel.add(SL_PICKLIST, inner.getPanel()); } else { pb.add(pickListLbl = createI18NFormLabel(SL_PICKLIST, SwingConstants.RIGHT), cc.xy(3, y)); pb.add(pickListCBX, cc.xy(5, y)); pb.add(pickListMoreBtn, cc.xy(7, y)); y += 2; } nxtBtn = createI18NButton("SL_NEXT"); nxtEmptyBtn = createI18NButton("SL_NEXT_EMPTY"); fldSpellChkBtn = createI18NButton("SL_SPELL_CHECK"); //JPanel bbp = ButtonBarFactory.buildCenteredBar(adjustButtonArray(new JButton[] {nxtEmptyBtn, nxtBtn, fldSpellChkBtn})); //bbp.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); //pb.add(bbp, cc.xywh(3, y, 8, 1)); nxtBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { next(); } }); nxtEmptyBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { nextEmpty(); } }); fldSpellChkBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (checker != null) { checker.spellCheck(fieldDescText); checker.spellCheck(fieldNameText); } } }); fieldHideChk.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { formHasChanged(); } }); fieldReqChk.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { formHasChanged(); } }); DocumentListener dl = new DocumentAdaptor() { @Override protected void changed(DocumentEvent e) { formHasChanged(); } }; fieldNameText.getDocument().addDocumentListener(dl); fieldDescText.getDocument().addDocumentListener(dl); /* if (formatTxt != null) { formatTxt.getDocument().addDocumentListener(dl); } */ SchemaI18NService.getInstance().checkCurrentLocaleMenu(); enableUIControls(false); setIgnoreChanges(false); }
From source file:it.cnr.icar.eric.client.ui.swing.RegistryObjectsTable.java
@SuppressWarnings("unchecked") private void addRenderers() { try {//from w w w.j a va 2 s . co m setDefaultRenderer(Class.forName("java.lang.Object"), new JBDefaultTableCellRenderer()); setDefaultRenderer(Class.forName("java.util.Collection"), new CollectionRenderer()); final JList<Object> list = new JList<Object>(); list.setVisibleRowCount(3); list.setOpaque(true); list.setCellRenderer(new ListDefaultRenderer()); list.addListSelectionListener(new ListSelectionListener() { @SuppressWarnings({ "static-access", "unused" }) public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { Object obj = list.getSelectedValue(); obj = RegistryObjectsTable.this.convertValue(obj); if (obj instanceof URL) { HyperLinker.displayURL(obj.toString()); } else if (obj instanceof String) { //Check if URL is valid URL _url = null; try { _url = new URL(obj.toString()); HyperLinker.displayURL(obj.toString()); } catch (MalformedURLException exc) { //No need to do anything. It is normal for text to not be a URL _url = null; } } } } }); JScrollPane listPane = new JScrollPane(list); setDefaultEditor(Class.forName("java.util.Collection"), new JBDefaultCellEditor(listPane)); HyperLinkLabel hyperLinkLabel = new HyperLinkLabel(); hyperLinkLabel.setHorizontalAlignment(SwingConstants.TRAILING); setDefaultEditor(Class.forName("java.lang.Object"), new JBDefaultCellEditor(hyperLinkLabel)); } catch (ClassNotFoundException e) { return; } }
From source file:edu.ku.brc.af.ui.forms.IconViewObj.java
/** * /* www. j a v a 2 s . c om*/ */ protected void initMainComp() { if (isEditing) { String delTTStr = ResultSetController.createTooltip("DeleteRecordTT", view.getObjTitle()); String edtTTStr = ResultSetController.createTooltip("EditRecordTT", view.getObjTitle()); String newTTStr = ResultSetController.createTooltip("NewRecordTT", view.getObjTitle()); editBtn = UIHelper.createIconBtnTT("EditForm", IconManager.IconSize.Std16, edtTTStr, false, null); newBtn = UIHelper.createIconBtnTT("CreateObj", IconManager.IconSize.Std16, newTTStr, false, null); delBtn = UIHelper.createIconBtnTT("DeleteRecord", IconManager.IconSize.Std16, delTTStr, false, null); validationInfoBtn = FormViewObj.createValidationIndicator(mainComp, getValidator()); editBtn.setEnabled(false); delBtn.setEnabled(false); newBtn.setEnabled(true); } else { String srchTTStr = ResultSetController.createTooltip("ShowRecordInfoTT", view.getObjTitle()); viewBtn = UIHelper.createIconBtnTT("InfoIcon", IconManager.IconSize.Std16, srchTTStr, false, null); viewBtn.setEnabled(false); } altViewsList = new Vector<AltViewIFace>(); switcherUI = FormViewObj.createMenuSwitcherPanel(mvParent, view, altView, altViewsList, mainComp, cellName, dataClass); Dimension maxSize = Thumbnailer.getInstance().getMaxSize(); iconTray = new OrderedIconTray(IconTray.SINGLE_ROW, maxSize.width, maxSize.height); iconTray.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equalsIgnoreCase("item order")) { rootHasChanged(); } } }); iconTray.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 1) { updateEnableUI(); } else if (e.getClickCount() > 1) { doDoubleClick(); } } @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { showContextMenu(e); } } }); iconTray.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { updateEnableUI(); } } }); if (isEditing) { addActionListenerToEditButton(); addActionListenerToNewButton(); addActionListenerToDeleteButton(); IconViewTransferHandler ivth = new IconViewTransferHandler(this); iconTray.setTransferHandler(ivth); } else { addActionListenerToViewButton(); } mainComp = new RestrictablePanel(); mainComp.setLayout(new BorderLayout()); if (mvParent == null) { mainComp.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); } boolean isAbove = mvParent.getSeparator() != null; int defCnt = (isEditing ? 3 : 1) + (switcherUI != null ? 1 : 0) + (validationInfoBtn != null ? 1 : 0); String colDef = (isAbove ? "1px," : "f:1px:g,") + UIHelper.createDuplicateJGoodiesDef("p", "1px", defCnt); PanelBuilder builder = new PanelBuilder(new FormLayout(colDef, "p")); CellConstraints cc = new CellConstraints(); int x = 2; if (isEditing) { builder.add(editBtn, cc.xy(x, 1)); x += 2; builder.add(newBtn, cc.xy(x, 1)); x += 2; builder.add(delBtn, cc.xy(x, 1)); x += 2; if (validationInfoBtn != null) // is null when genrating form images { builder.add(validationInfoBtn, cc.xy(x, 1)); x += 2; } } else { builder.add(viewBtn, cc.xy(x, 1)); x += 2; } if (switcherUI != null) { builder.add(switcherUI, cc.xy(x, 1)); x += 2; } if (isAbove) { sepController = builder.getPanel(); } else { southPanel = builder.getPanel(); mainComp.add(southPanel, BorderLayout.SOUTH); } mainComp.add(iconTray, BorderLayout.CENTER); }
From source file:search2go.UIFrame.java
public UIFrame() throws IOException, ParseException { topLevels = new TopLevelGTermSet[] { CCs, MFs, BPs }; this.addWindowListener(new WindowAdapter() { @Override/*from w ww . j a va 2 s. c om*/ public void windowClosing(WindowEvent et) { try { if (os.isWindows()) { Runtime.getRuntime().exec("cmd /C TaskKill -IM blastx.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM blastn.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM blastp.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM python.exe -F"); } else { Runtime.getRuntime().exec("killAll -KILL blastx"); Runtime.getRuntime().exec("killAll -KILL blastn"); Runtime.getRuntime().exec("killAll -KILL blastp"); Runtime.getRuntime().exec("killAll -KILL python"); } } catch (IOException ex) { System.out.println("Error closing child processes"); } } }); initComponents(); txtBlastOutput.getDocument().addDocumentListener(new BufferEnforcer(txtBlastOutput)); txtFullOutput.getDocument().addDocumentListener(new BufferEnforcer(txtFullOutput)); txtMapOutput.getDocument().addDocumentListener(new BufferEnforcer(txtMapOutput)); ((DefaultCaret) txtBlastOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); ((DefaultCaret) txtMapOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); ((DefaultCaret) txtFullOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); webSaveMenu = new JPopupMenu(); JMenuItem saveWeb = new JMenuItem(); saveWeb.setText("Save"); saveWeb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { webSaveDialogue.showSaveDialog(pnlChartHolder); File saveFile = webSaveDialogue.getSelectedFile(); if (!saveFile.getPath().contains(".png")) saveFile = new File(saveFile.getPath() + ".png"); try { BufferedImage webChartImage = new BufferedImage(pnlChartHolder.getWidth(), pnlChartHolder.getHeight(), BufferedImage.TYPE_INT_RGB); pnlChartHolder.print(webChartImage.getGraphics()); ImageIO.write(webChartImage, "png", saveFile); } catch (Exception ex) { javax.swing.JOptionPane.showMessageDialog(pnlChartHolder, "Error saving chart. Please try again."); } } }); webSaveMenu.add(saveWeb); pnlChartHolder.add(webSaveMenu); pnlChartHolder.setLayout(new java.awt.BorderLayout()); try { currentProj = Workspace.open(new Path("Search2GO_Data")); chkDoCCs.setState(currentProj.willDoCC()); chkDoBPs.setState(currentProj.willDoBP()); chkDoMFs.setState(currentProj.willDoMF()); txtQuery.setText(currentProj.getQueryPath()); txtQueryFP.setText(currentProj.getQueryPath()); txtDatabase.setText(currentProj.getPathToDB()); txtDatabaseFP.setText(currentProj.getPathToDB()); txtThreads.setValue(currentProj.getThreadNo()); txtThreadsFP.setValue(currentProj.getThreadNo()); cbxNXP.setSelectedIndex(currentProj.getBlastTypeIndex()); cbxNXPFP.setSelectedIndex(currentProj.getBlastTypeIndex()); cbxDBID.setSelectedIndex(currentProj.getSelectedDBIndex()); cbxDBIDFP.setSelectedIndex(currentProj.getSelectedDBIndex()); txtBitScore.setValue(currentProj.getBitScoreThreshold()); txtBitScoreFP.setValue(currentProj.getBitScoreThreshold()); txtBlastE.setValue(currentProj.getEThreshold()); txtMapE.setValue(currentProj.getEThreshold()); txtEFP.setValue(currentProj.getEThreshold()); } catch (FileNotFoundException e) { currentProj = Workspace.create(new Path("Search2GO_Data")); chkDoCCs.setState(currentProj.willDoCC()); chkDoBPs.setState(currentProj.willDoBP()); chkDoMFs.setState(currentProj.willDoMF()); } this.setTitle("Search2GO " + currentProj.getPath().toString()); GTermTableModel = new DefaultTableModel(); GTermTableModel.setColumnCount(2); GTermTableModel.setColumnIdentifiers(new String[] { "GO ID", "Frequency" }); ListSelectionModel GTermSelector = tblGOFreq.getSelectionModel(); GTermSelector.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (tblGOFreq.getSelectedRow() > -1) { DefaultListModel emptyModel = new DefaultListModel(); lstQueries.setModel(emptyModel); txtTermInfo.setText(""); String selectedID = (String) tblGOFreq.getValueAt(tblGOFreq.getSelectedRow(), 0); JTextArea tempHolderInfo = new JTextArea(); JTextArea tempHolderQueries = new JTextArea(); if (tblGOFreq.getSelectedRow() != -1) { ResetGTermInfoGetter(tempHolderInfo, tempHolderQueries); gTermInfoGetter.getProcess(0).addParameter("id", selectedID.substring(0, selectedID.indexOf("["))); gTermInfoGetter.getProcess(1).addParameter("id", selectedID.substring(0, selectedID.indexOf("["))); GTerm currentGTerm = gTerms.getGTerm(selectedID.substring(0, selectedID.indexOf("["))); gTermInfoGetter.getProcess(1).addParameter("db", currentGTerm.getTopLevel().getCode()); gTermInfoGetter.setTail(new ProcessSequenceEnd() { @Override public void run() { tempHolderInfo.setText("id: " + selectedID + "\n" + tempHolderInfo.getText()); txtTermInfo.setText(tempHolderInfo.getText()); DefaultListModel queryList = new DefaultListModel(); for (String str : tempHolderQueries.getText().split(";")) { queryList.addElement(str.replaceAll("Query: ", "")); } lstQueries.setModel(queryList); prgIdentification.setIndeterminate(false); } }); try { gTermInfoGetter.start(); prgIdentification.setIndeterminate(true); } catch (IOException ex) { Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex); } } } } } }); lstQueries.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting() && !e.toString().contains("invalid") && lstQueries.getSelectedValue() != null) { JTextArea tempHolder = new JTextArea(); ProcessSequence fetchLocusSequence = new ProcessSequence(new ProcessSequenceEnd() { @Override public void run() { if (txtTermInfo.getText().contains("Score")) { txtTermInfo.setText( txtTermInfo.getText().substring(0, txtTermInfo.getText().indexOf("Score"))); } txtTermInfo.append(tempHolder.getText()); prgIdentification.setIndeterminate(false); } }); Path fetchLocusPath = new Path("Processes"); fetchLocusPath.append("fetchLocus.py"); Process fetchLocus = new Process(tempHolder); fetchLocus.setScriptCommand(fetchLocusPath.toEscString()); fetchLocus.addParameter("dir", currentProj.getPath().toEscString()); fetchLocus.addParameter("q", new ParameterString(lstQueries.getSelectedValue().replace("\n", "")).toString()); String selectedID = (String) tblGOFreq.getValueAt(tblGOFreq.getSelectedRow(), 0); GTerm currentGTerm = gTerms.getGTerm(selectedID.substring(0, selectedID.indexOf("["))); fetchLocus.addParameter("db", currentGTerm.getTopLevel().getCode()); fetchLocus.addParameter("id", currentGTerm.getID()); fetchLocusSequence.addProcess(fetchLocus); try { fetchLocusSequence.start(); prgIdentification.setIndeterminate(true); } catch (IOException ex) { Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex); } } } }); DocumentListener filterListener = new DocumentListener() { private void anyUpdate() { gTerms.getFilter().setFilterString(txtSearchTerms.getText()); if (!txtMinFreqFilter.getText().equals("")) gTerms.getFilter().setMinFreq(Integer.parseInt(txtMinFreqFilter.getText())); else gTerms.getFilter().setMinFreq(0); if (!txtMaxFreqFilter.getText().equals("")) gTerms.getFilter().setMaxFreq(Integer.parseInt(txtMaxFreqFilter.getText())); else gTerms.getFilter().setMaxFreq(-1); fillIdentTable(gTerms.stringFilter(), false); } @Override public void insertUpdate(DocumentEvent e) { anyUpdate(); } @Override public void removeUpdate(DocumentEvent e) { anyUpdate(); } @Override public void changedUpdate(DocumentEvent e) { anyUpdate(); } }; txtSearchTerms.getDocument().addDocumentListener(filterListener); txtMinFreqFilter.getDocument().addDocumentListener(filterListener); txtMaxFreqFilter.getDocument().addDocumentListener(filterListener); NumberFormat numberMask = NumberFormat.getIntegerInstance(); numberMask.setGroupingUsed(false); NumberFormatter numberMasker = new NumberFormatter(numberMask); NumberFormatter numberMaskerAndBlank = new NumberFormatter(numberMask) { @Override public Object stringToValue(String s) throws ParseException { if (s == null || s.length() == 0) return null; return super.stringToValue(s); } }; DefaultFormatterFactory numberMaskFactory = new DefaultFormatterFactory(numberMasker); DefaultFormatterFactory numberMaskAndBlankFactory = new DefaultFormatterFactory(numberMaskerAndBlank); txtThreads.setFormatterFactory(numberMaskFactory); txtThreadsFP.setFormatterFactory(numberMaskFactory); txtBitScore.setFormatterFactory(numberMaskAndBlankFactory); txtBitScoreFP.setFormatterFactory(numberMaskAndBlankFactory); txtMinFreqFilter.setFormatterFactory(numberMaskFactory); txtMaxFreqFilter.setFormatterFactory(numberMaskFactory); txtBlastE.setFormatterFactory(numberMaskAndBlankFactory); txtMapE.setFormatterFactory(numberMaskAndBlankFactory); txtEFP.setFormatterFactory(numberMaskAndBlankFactory); blastButton = new StopButton(btnBlast); mapButton = new StopButton(btnMapIDs); identButton = new StopButton(btnGTermIdent); fullButton = new StopButton(btnProcessFP); if (currentProj.getStage() >= 2) identify(false); }
From source file:com.mirth.connect.client.ui.SettingsPanelMap.java
private void initComponents() { setBackground(Color.WHITE);//from w ww. ja v a 2s . co m setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); setLayout(new MigLayout("insets 12, fill")); configurationMapTable = new MirthTable(); configurationMapTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); configurationMapTable.getTableHeader().setReorderingAllowed(false); configurationMapTable.setSortable(false); configurationMapTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); configurationMapTable .setModel(new RefreshTableModel(new String[][] {}, new String[] { "Key", "Value", "Comment" })); TableCellEditor cellEditor = new TextFieldCellEditor() { @Override protected boolean valueChanged(String value) { PlatformUI.MIRTH_FRAME.setSaveEnabled(true); return true; } }; configurationMapTable.getColumnExt("Key").setCellEditor(cellEditor); configurationMapTable.getColumnExt("Value").setCellEditor(cellEditor); configurationMapTable.getColumnExt("Comment").setCellEditor(cellEditor); configurationMapTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { int selectedRow; if (configurationMapTable.isEditing()) { selectedRow = configurationMapTable.getEditingRow(); } else { selectedRow = configurationMapTable.getSelectedRow(); } removeButton.setEnabled(selectedRow != -1); } }); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { configurationMapTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } configurationMapScrollPane = new JScrollPane(); configurationMapScrollPane.setViewportView(configurationMapTable); addButton = new MirthButton("Add"); addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ((RefreshTableModel) configurationMapTable.getModel()).addRow(new String[] { "", "" }); if (configurationMapTable.getRowCount() == 1) { configurationMapTable.setRowSelectionInterval(0, 0); } PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } }); removeButton = new MirthButton("Remove"); removeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (configurationMapTable.getSelectedModelIndex() != -1 && !configurationMapTable.isEditing()) { Integer selectedModelIndex = configurationMapTable.getSelectedModelIndex(); RefreshTableModel model = (RefreshTableModel) configurationMapTable.getModel(); int newViewIndex = configurationMapTable.convertRowIndexToView(selectedModelIndex); if (newViewIndex == (model.getRowCount() - 1)) { newViewIndex--; } // must set lastModelRow to -1 so that when setting the new // row selection below the old data won't try to be saved. model.removeRow(selectedModelIndex); if (model.getRowCount() != 0) { configurationMapTable.setRowSelectionInterval(newViewIndex, newViewIndex); } PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } } }); configurationMapPanel = new JPanel(); configurationMapPanel.setBackground(Color.WHITE); configurationMapPanel.setLayout(new MigLayout("fill, flowy, insets 0", "[grow][]", "grow")); configurationMapPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( javax.swing.BorderFactory.createMatteBorder(1, 0, 0, 0, new java.awt.Color(204, 204, 204)), "Configuration Map", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11))); // NOI18N configurationMapPanel.add(configurationMapScrollPane, "grow, wrap"); configurationMapPanel.add(addButton, "growx, aligny top, split"); configurationMapPanel.add(removeButton, "growx, aligny top"); add(configurationMapPanel, "grow, height 100px:100%:100%, wrap"); }
From source file:com.android.tools.idea.structure.MavenDependencyLookupDialog.java
public MavenDependencyLookupDialog(@NotNull Project project, @Nullable Module module) { super(project, true); myAndroidModule = module != null && AndroidFacet.getInstance(module) != null; myProgressIcon.suspend();//from w w w . j av a2 s .co m mySearchField.setButtonIcon(AllIcons.Actions.Menu_find); mySearchField.getButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { startSearch(); } }); mySearchTextField = mySearchField.getTextField(); mySearchTextField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (!isValidCoordinateSelected()) { startSearch(); } else { close(OK_EXIT_CODE); } } }); boolean isPreviewVersion = false; if (module != null) { AndroidFacet facet = AndroidFacet.getInstance(module); if (facet != null) { IdeaAndroidProject androidProject = facet.getIdeaAndroidProject(); if (androidProject != null) { ApiVersion minSdkVersion = androidProject.getSelectedVariant().getMergedFlavor() .getMinSdkVersion(); if (minSdkVersion != null) { isPreviewVersion = new AndroidVersion(minSdkVersion.getApiLevel(), minSdkVersion.getCodename()).isPreview(); } } } } RepositoryUrlManager manager = RepositoryUrlManager.get(); for (String libraryId : RepositoryUrlManager.EXTRAS_REPOSITORY.keySet()) { String libraryCoordinate = manager.getLibraryCoordinate(libraryId, null, isPreviewVersion); if (libraryCoordinate != null) { Artifact artifact = Artifact.fromCoordinate(libraryCoordinate, libraryId); if (artifact != null) { myShownItems.add(artifact); } } } myShownItems.addAll(COMMON_LIBRARIES); myResultList.setModel(new CollectionComboBoxModel(myShownItems, null)); myResultList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent listSelectionEvent) { Artifact value = (Artifact) myResultList.getSelectedValue(); if (value != null) { mySearchTextField.setText(value.getCoordinates()); } } }); myResultList.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent mouseEvent) { if (mouseEvent.getClickCount() == 2 && isValidCoordinateSelected()) { close(OK_EXIT_CODE); } } }); init(); }
From source file:com.android.tools.idea.gradle.structure.editors.MavenDependencyLookupDialog.java
public MavenDependencyLookupDialog(@NotNull Project project, @Nullable Module module) { super(project, true); myAndroidModule = module != null && AndroidFacet.getInstance(module) != null; myProgressIcon.suspend();//www . ja va 2s.c o m mySearchField.setButtonIcon(AllIcons.Actions.Menu_find); mySearchField.getButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { startSearch(); } }); mySearchTextField = mySearchField.getTextField(); mySearchTextField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (StringUtil.isEmpty(mySearchField.getText())) { return; } if (!isValidCoordinateSelected()) { startSearch(); } else { close(OK_EXIT_CODE); } } }); boolean preview = false; if (module != null) { AndroidFacet facet = AndroidFacet.getInstance(module); if (facet != null) { AndroidModuleModel androidModel = AndroidModuleModel.get(facet); if (androidModel != null) { ApiVersion minSdkVersion = androidModel.getSelectedVariant().getMergedFlavor() .getMinSdkVersion(); if (minSdkVersion != null) { preview = new AndroidVersion(minSdkVersion.getApiLevel(), minSdkVersion.getCodename()) .isPreview(); } } } } RepositoryUrlManager manager = RepositoryUrlManager.get(); for (SupportLibrary library : SupportLibrary.values()) { String libraryCoordinate = manager.getLibraryStringCoordinate(library, true); if (libraryCoordinate != null) { Artifact artifact = Artifact.fromCoordinate(libraryCoordinate); if (artifact != null) { myAndroidSdkLibraries.add(libraryCoordinate); myShownItems.add(artifact); } } } myShownItems.addAll(COMMON_LIBRARIES); myResultList.setModel(new CollectionComboBoxModel(myShownItems, null)); myResultList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent listSelectionEvent) { Artifact value = (Artifact) myResultList.getSelectedValue(); if (value != null) { mySearchTextField.setText(value.getCoordinates()); } } }); myResultList.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent mouseEvent) { if (mouseEvent.getClickCount() == 2 && isValidCoordinateSelected()) { close(OK_EXIT_CODE); } } }); myOKAction = new OkAction() { @Override protected void doAction(ActionEvent e) { String text = mySearchField.getText(); if (text != null && !hasVersion(text) && isKnownLocalLibrary(text)) { // If it's a known library that doesn't exist in the local repository, we don't display the version for it. Add it back so that // final string is a valid gradle coordinate. mySearchField.setText(text + ':' + REVISION_ANY); } super.doAction(e); } }; init(); }
From source file:com.android.tools.idea.structure.gradle.MavenDependencyLookupDialog.java
public MavenDependencyLookupDialog(@NotNull Project project, @Nullable Module module) { super(project, true); myAndroidModule = module != null && AndroidFacet.getInstance(module) != null; myProgressIcon.suspend();// ww w . ja va 2s . com mySearchField.setButtonIcon(AllIcons.Actions.Menu_find); mySearchField.getButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { startSearch(); } }); mySearchTextField = mySearchField.getTextField(); mySearchTextField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (StringUtil.isEmpty(mySearchField.getText())) { return; } if (!isValidCoordinateSelected()) { startSearch(); } else { close(OK_EXIT_CODE); } } }); boolean preview = false; if (module != null) { AndroidFacet facet = AndroidFacet.getInstance(module); if (facet != null) { IdeaAndroidProject androidProject = facet.getIdeaAndroidProject(); if (androidProject != null) { ApiVersion minSdkVersion = androidProject.getSelectedVariant().getMergedFlavor() .getMinSdkVersion(); if (minSdkVersion != null) { preview = new AndroidVersion(minSdkVersion.getApiLevel(), minSdkVersion.getCodename()) .isPreview(); } } } } RepositoryUrlManager manager = RepositoryUrlManager.get(); for (String libraryId : RepositoryUrlManager.EXTRAS_REPOSITORY.keySet()) { String libraryCoordinate = manager.getLibraryCoordinate(libraryId, null, preview); if (libraryCoordinate != null) { Artifact artifact = Artifact.fromCoordinate(libraryCoordinate, libraryId); if (artifact != null) { myAndroidSdkLibraries.add(libraryCoordinate); myShownItems.add(artifact); } } } myShownItems.addAll(COMMON_LIBRARIES); myResultList.setModel(new CollectionComboBoxModel(myShownItems, null)); myResultList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent listSelectionEvent) { Artifact value = (Artifact) myResultList.getSelectedValue(); if (value != null) { mySearchTextField.setText(value.getCoordinates()); } } }); myResultList.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent mouseEvent) { if (mouseEvent.getClickCount() == 2 && isValidCoordinateSelected()) { close(OK_EXIT_CODE); } } }); myOKAction = new OkAction() { @Override protected void doAction(ActionEvent e) { String text = mySearchField.getText(); if (text != null && !hasVersion(text) && RepositoryUrlManager.EXTRAS_REPOSITORY.containsKey(getArtifact(text))) { // If it's a known library that doesn't exist in the local repository, we don't display the version for it. Add it back so that // final string is a valid gradle coordinate. mySearchField.setText(text + ':' + REVISION_ANY); } super.doAction(e); } }; init(); }