📄 sectionpanel.java
字号:
aj = new Ajax(); if(att.startsWith("seqset")) ok = aj.seqsetType(fc); else ok = aj.seqType(fc); } if(ok) { if(!mysettings.isCygwin()) { ajaxLength = aj.length; ajaxWeight = aj.weight; ajaxProtein = aj.protein; } if( (updateBeginEnd(inSeqAttr[h].getBegSeq(), inSeqAttr[h].getEndSeq())) && (!att.startsWith("seqset")) && (!att.startsWith("seqall")) ) { inSeqAttr[h].setBegSeq(1); inSeqAttr[h].setEndSeq(ajaxLength); } resolveDependents(nod,dep,sifc.getFileChosen(),varName); } else JOptionPane.showMessageDialog(sectionPane, "Sequence not found.\n" + "Check the sequence entered.", "Error Message", JOptionPane.ERROR_MESSAGE); } else if(fc!=null) //Ajax with SOAP { try { CallAjax ca = new CallAjax(fc,att,mysettings); if(ca.getStatus().equals("0") && ca.getLength() > 0) { ajaxLength = ca.getLength(); ajaxWeight = ca.getWeight(); ajaxProtein = ca.isProtein(); int seqLen = ca.getLength(); if( (updateBeginEnd(inSeqAttr[h].getBegSeq(), inSeqAttr[h].getEndSeq())) && (!att.startsWith("seqset")) && (!att.startsWith("seqall")) ) { inSeqAttr[h].setBegSeq(1); inSeqAttr[h].setEndSeq(seqLen); } resolveDependents(nod,dep,sifc.getFileChosen(),varName); } else { JOptionPane.showMessageDialog(sectionPane, "Sequence not found." + "\nCheck the sequence entered.", "Error Message", JOptionPane.ERROR_MESSAGE); }// System.out.println("PROPERTIES::: "+ca.getStatus()+" "+ajaxLength+" "+ajaxWeight); } catch (JembossSoapException eae) { System.out.println("Call to Ajax library failed"); } } f.setCursor(cdone);// resolveDependents(nod,dep,sifc.getFileChosen(),varName); } }); } else if(att.startsWith("list") || att.startsWith("select")) { double max = 1.; if(parseAcd.isMaxParamValue(nff)) max = Double.parseDouble(parseAcd.getMaxParam(nff)); if(max <= 1.0) { fieldOption[h].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String sel = ""; int index = fieldOption[h].getSelectedIndex(); if(att.startsWith("select")) sel = new String((new Integer(index+1)).toString()); else if(att.startsWith("list")) sel = new String(parseAcd.getListLabel(nff,index)); resolveDependents(nod,dep,sel,varName); } }); } } else if(att.startsWith("bool")) { checkBox[h].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String sel = ""; if(checkBox[h].isSelected()) sel = new String("true"); else sel = new String("false"); resolveDependents(nod,dep,sel,varName); } }); // resolve dependents as for is loaded in String sel = ""; if(checkBox[h].isSelected()) sel = new String("true"); else sel = new String("false"); resolveDependents(nod,dep,sel,varName); } } } /** * * Cygwin uses infoseq to get sequence length and type * and uses infoalign to get the sequence weight. * */ private boolean cygwinSeqAttr(String fc, String[] envp, String att) { String command = mysettings.getEmbossBin().concat( "infoseq -only -type -length -nohead -auto "+fc); RunEmbossApplication2 rea = new RunEmbossApplication2(command,envp,null); rea.waitFor(); String stdout = rea.getProcessStdout(); if(stdout.trim().equals("")) return false; StringTokenizer stok = new StringTokenizer(stdout,"\n "); if(stok.nextToken().trim().equalsIgnoreCase("P")) ajaxProtein = true; else ajaxProtein = false; ajaxLength = Integer.parseInt(stok.nextToken().trim()); if(att.startsWith("seqset")) { command = mysettings.getEmbossBin().concat( "infoalign -only -weight -nohead -out stdout -auto "+fc); rea = new RunEmbossApplication2(command,envp,null); rea.waitFor(); stok = new StringTokenizer(rea.getProcessStdout(),"\n"); ajaxWeight = 0.f; while(stok.hasMoreTokens()) ajaxWeight+= Float.parseFloat(stok.nextToken()); }// System.out.println(command+"\n"+rea.getProcessStdout()); return true; } /** * * Check sbeg and send values before updating in the * panel to avoid overriding user selection * @param s start * @param e end * @return true to automatically update * */ private boolean updateBeginEnd(String s, String e) { if( ((s!=null) && (!s.equals(""))) || ((e!=null) && (!e.equals(""))) ) { int n = JOptionPane.showConfirmDialog(f, "Overwrite the input sequence \n" + "start :" + s + "\n" + "end :" + e + "\n" + "values already set?", "Confirm", JOptionPane.YES_NO_OPTION); if(n == JOptionPane.NO_OPTION) return false; } return true; } /** * * Given an ACD variable and the value it takes, resolve any dependent * attribute values. * @param nod number of dependent values * @param dep[] dependents * @param textVal value of variable * @param varName variable name * */ private void resolveDependents(int nod, Dependent dep[], String textVal, String varName) { for(int i=0;i<nod;i++) { String exp = dep[i].getDependentExp(); int field = dep[i].getDependentField(); int param = dep[i].getDependentParam(); try { AcdVarResolve avr = new AcdVarResolve(exp,textVal,varName,parseAcd, numofFields,textf,textInt,textFloat,fieldOption, checkBox);// System.out.println(exp + "EXP ==> " + avr.getResult() + " " + textVal); exp = avr.getResult(); } catch(NullPointerException npe) { continue; } AcdFunResolve afr = new AcdFunResolve(exp); String result = afr.getResult(); String att = parseAcd.getParameterAttribute( dep[i].getDependentField(),0).toLowerCase(); String type = dep[i].getDependentType();// System.out.println(varName + " RES => " + result +" "+ type +" att "+ att// +" : "+ parseAcd.getParamValueStr(dep[i].getDependentField(),0)); int h = parseAcd.getGuiHandleNumber(field); // ACD changes: // required is now standard // optional is now additional if( (att.equals("list") || att.equals("select")) && (type.startsWith("stand") || type.startsWith("add")) ) // (type.startsWith("req") || type.startsWith("opt")) ) { double max = 1.; if(parseAcd.isMaxParamValue(field)) max = Double.parseDouble(parseAcd.getMaxParam(field)); if(max <= 1.0) { if(result.equals("false")) setShadingAndVisibility(fieldOption[h], false, field); else setShadingAndVisibility(fieldOption[h], true , field); } else { if(result.equals("false")) setShadingAndVisibility(multiOption[h], false, field); else setShadingAndVisibility(multiOption[h], true, field); } } else if(att.startsWith("datafile")|| att.startsWith("featout") || att.startsWith("string") || att.startsWith("seqout") || att.startsWith("outfile") || att.startsWith("matrix") || att.startsWith("infile") || att.startsWith("regexp") || att.startsWith("codon") || att.startsWith("dirlist") ) { if( (type.startsWith("add") || type.startsWith("stand")) && result.equals("false")) setShadingAndVisibility(textf[h], false, field); else if ( (type.startsWith("add") || type.startsWith("stand")) && result.equals("true")) setShadingAndVisibility(textf[h], true, field); if(type.startsWith("def")) { if(att.startsWith("matrix")) { Vector mat = BuildProgramMenu.getMatrices(); Enumeration en = mat.elements(); while(en.hasMoreElements()) { String m = (String)en.nextElement(); if(result.equalsIgnoreCase(m)) { textf[h].setText(m); break; } } } else textf[h].setText(result); } } else if(att.startsWith("int")) { if( (type.startsWith("add") || type.startsWith("stand")) && result.equals("false")) setShadingAndVisibility(textInt[h], false, field); else if ( (type.startsWith("add") || type.startsWith("stand")) && result.equals("true")) setShadingAndVisibility(textInt[h], true, field); if(type.startsWith("def")) textInt[h].setValue(Integer.parseInt(result)); } else if(att.startsWith("float")) { if( (type.startsWith("add") || type.startsWith("stand")) && result.equals("false")) setShadingAndVisibility(textFloat[h], false, field); else if ( (type.startsWith("add") || type.startsWith("stand")) && result.equals("true")) setShadingAndVisibility(textFloat[h], true, field); if(type.startsWith("def")) textFloat[h].setValue(Double.parseDouble(result)); } else if(att.startsWith("bool")) { if(type.startsWith("add") || type.startsWith("stand")) { if(result.equals("false")) setShadingAndVisibility(checkBox[h], false, field); else setShadingAndVisibility(checkBox[h], true, field); } else if(type.startsWith("def")) { if(result.equals("false")) checkBox[h].setSelected(false); else checkBox[h].setSelected(true); } } //n.b. no default labels on bools if(type.startsWith("def") && (!att.startsWith("bool"))) { String l = getMinMaxDefault(null,null,result,field); if(lab[field] != null) ((JLabel)lab[field].getComponent(1)).setText(" " + l); } else if(type.startsWith("min")) { String l = getMinMaxDefault(result,null,null,field); if(lab[field] != null) ((JLabel)lab[field].getComponent(1)).setText(" " + l); } else if(type.startsWith("max")) { String l = getMinMaxDefault(null,result,null,field); if(lab[field] != null) ((JLabel)lab[field].getComponent(1)).setText(" " + l); } }// use to resize sections// if(!isShadedGUI) { sectionResize(BuildJembossForm.addSection); sectionResize(BuildJembossForm.advSection); sectionResize(BuildJembossForm.reqdSection); sectionResize(BuildJembossForm.outSection); } p3.setVisible(false); //this seems to be necessary to force p3.setVisible(true); //it to re-display sections properly!! } /** * * Set the shading or visibility of a component * @param c component * @param useThis true if enabled/visible * @param field field number in the ACD * */ private void setShadingAndVisibility(Component c, boolean useThis, int field) { if( c != null) { if(isShadedGUI) { c.setEnabled(useThis); } else { c.setVisible(useThis); if(lab[field] != null) lab[field].setVisible(useThis); } } } /** * * Resize the section panel * @param p section panel * */ private void sectionResize(JPanel p) { if(p != null) { Dimension min = p.getMinimumSize(); int w = maxSectionWidth; int h = (int)min.getHeight(); Dimension d = new Dimension (w,h); p.setMaximumSize(d); p.setPreferredSize(d); p.setVisible(false); p.setVisible(true); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -