rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
if (connection != null && !connection.isClosed()) return; connection = (Connection) dbConnections.get(connectionSpec); if (connection != null && !connection.isClosed()) return; | public synchronized void connect() throws ArchitectException { if (connection != null) return; connection = (Connection) dbConnections.get(connectionSpec); if (connection != null) return; try { Class.forName(connectionSpec.getDriverClass()); logger.info("Driver Class "+connectionSpec.getDriverClass()+" loaded without exception"); connection = DriverManager.getConnection(connectionSpec.getUrl(), connectionSpec.getUser(), connectionSpec.getPass()); dbConnections.put(connectionSpec, connection); } catch (ClassNotFoundException e) { logger.warn("Driver Class not found"); throw new ArchitectException("dbconnect.noDriver", e); } catch (SQLException e) { throw new ArchitectException("dbconnect.connectionFailed", e); } } |
|
if (connection == null && connectionSpec != null) connect(); | if (connectionSpec != null) { connect(); } | public Connection getConnection() throws ArchitectException { if (connection == null && connectionSpec != null) connect(); return this.connection; } |
col1 = new SQLColumn(table,"Column 1",1,2,3); col2 = new SQLColumn(table,"Column 2",2,3,4); col3 = new SQLColumn(table,"Column 3",1,2,3); col4 = new SQLColumn(table,"Column 4",1,2,3); | col1 = new SQLColumn(null,"Column 1",1,2,3); col2 = new SQLColumn(null,"Column 2",2,3,4); col3 = new SQLColumn(null,"Column 3",1,2,3); col4 = new SQLColumn(null,"Column 4",1,2,3); | protected void setUp() throws Exception { db = new SQLDatabase(); table = new SQLTable(db,"Table1","remark1","Table",true); table2 = new SQLTable(db,"Table2","remark2","Table",true); db.addChild(0,table); col1 = new SQLColumn(table,"Column 1",1,2,3); col2 = new SQLColumn(table,"Column 2",2,3,4); col3 = new SQLColumn(table,"Column 3",1,2,3); col4 = new SQLColumn(table,"Column 4",1,2,3); col2.setAutoIncrement(false); col2.setNullable(0); col2.setPrimaryKeySeq(0); table.addColumn(col1); table.addColumn(col2); table.addColumn(col3); table2.addColumn(col4); panel = new ColumnEditPanel(table,1); super.setUp(); } |
col2.setNullable(0); | col2.setNullable(DatabaseMetaData.columnNoNulls); | protected void setUp() throws Exception { db = new SQLDatabase(); table = new SQLTable(db,"Table1","remark1","Table",true); table2 = new SQLTable(db,"Table2","remark2","Table",true); db.addChild(0,table); col1 = new SQLColumn(table,"Column 1",1,2,3); col2 = new SQLColumn(table,"Column 2",2,3,4); col3 = new SQLColumn(table,"Column 3",1,2,3); col4 = new SQLColumn(table,"Column 4",1,2,3); col2.setAutoIncrement(false); col2.setNullable(0); col2.setPrimaryKeySeq(0); table.addColumn(col1); table.addColumn(col2); table.addColumn(col3); table2.addColumn(col4); panel = new ColumnEditPanel(table,1); super.setUp(); } |
panel = new ColumnEditPanel(table,1); | panel = new ColumnEditPanel(table,table.getColumnIndex(col2)); | protected void setUp() throws Exception { db = new SQLDatabase(); table = new SQLTable(db,"Table1","remark1","Table",true); table2 = new SQLTable(db,"Table2","remark2","Table",true); db.addChild(0,table); col1 = new SQLColumn(table,"Column 1",1,2,3); col2 = new SQLColumn(table,"Column 2",2,3,4); col3 = new SQLColumn(table,"Column 3",1,2,3); col4 = new SQLColumn(table,"Column 4",1,2,3); col2.setAutoIncrement(false); col2.setNullable(0); col2.setPrimaryKeySeq(0); table.addColumn(col1); table.addColumn(col2); table.addColumn(col3); table2.addColumn(col4); panel = new ColumnEditPanel(table,1); super.setUp(); } |
public void testEditColumn() { | public void testEditColumn() throws ArchitectException { assertEquals(null, col1.getPrimaryKeySeq()); assertEquals(1, table.getColumnIndex(col2)); assertEquals("The column we're editing is not in PK", null, col2.getPrimaryKeySeq()); | public void testEditColumn() { assertEquals("Wrong column name",col2.getName(),panel.getColName().getText()); assertEquals("Wrong Precision",col2.getPrecision(),((Integer) (panel.getColPrec().getValue())).intValue()); assertEquals("Wrong type",2,((SQLType)(panel.getColType().getSelectedItem())).getType()); assertEquals("Wrong Scale",col2.getScale(),((Integer) (panel.getColScale().getValue())).intValue()); assertFalse(panel.getColAutoInc().getModel().isSelected()); assertFalse(panel.getColAutoInc().getModel().isEnabled()); assertFalse(panel.getColInPK().getModel().isSelected()); assertTrue(panel.getColInPK().getModel().isEnabled()); assertFalse(panel.getColNullable().getModel().isSelected()); assertTrue(panel.getColNullable().getModel().isEnabled()); assertEquals("None Specified",panel.getSourceDB().getText()); assertEquals("None Specified",panel.getSourceTableCol().getText()); } |
ColumnEditPanel editPanel = new ColumnEditPanel(table,0); | int previousIdx = table.getColumnIndex(table.getColumnByName("PKColumn 1")); ColumnEditPanel editPanel = new ColumnEditPanel(table, previousIdx); | public void testPKColumnMoveRegression() throws ArchitectException{ SQLColumn c1 = new SQLColumn(table,"PKColumn 1",1,2,3); SQLColumn c2 = new SQLColumn(table,"PKColumn 2",1,2,3); table.addColumn(c1); table.addColumn(c2); c1.setPrimaryKeySeq(0); c2.setPrimaryKeySeq(1); assertEquals (5, table.getColumns().size()); ColumnEditPanel editPanel = new ColumnEditPanel(table,0); editPanel.applyChanges(); assertEquals (0, table.getColumnIndex(table.getColumnByName("PKColumn 1"))); } |
assertEquals (0, table.getColumnIndex(table.getColumnByName("PKColumn 1"))); | assertEquals (previousIdx, table.getColumnIndex(table.getColumnByName("PKColumn 1"))); | public void testPKColumnMoveRegression() throws ArchitectException{ SQLColumn c1 = new SQLColumn(table,"PKColumn 1",1,2,3); SQLColumn c2 = new SQLColumn(table,"PKColumn 2",1,2,3); table.addColumn(c1); table.addColumn(c2); c1.setPrimaryKeySeq(0); c2.setPrimaryKeySeq(1); assertEquals (5, table.getColumns().size()); ColumnEditPanel editPanel = new ColumnEditPanel(table,0); editPanel.applyChanges(); assertEquals (0, table.getColumnIndex(table.getColumnByName("PKColumn 1"))); } |
ComponentTag tag = (ComponentTag) findAncestorWithClass( ComponentTag.class ); if ( tag != null ) { tag.setBorder(border); } else { | if (var == null) { | public void doTag(final XMLOutput output) throws Exception { Border border = createBorder(); // allow some nested tags to set properties invokeBody(output); if (var != null) { context.setVariable(var, border); } else { ComponentTag tag = (ComponentTag) findAncestorWithClass( ComponentTag.class ); if ( tag != null ) { tag.setBorder(border); } else { throw new JellyException( "Either the 'var' attribute must be specified to export this Border or this tag must be nested within a JellySwing widget tag" ); } } } |
"Added application with ID "+config.getApplicationId()); | "Added application "+ "\""+config.getName()+"\""); | public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) { ApplicationForm appForm = (ApplicationForm)actionForm; String appId = ApplicationConfig.getNextApplicationId(); Integer port = appForm.getPort() != null && !"".equals(appForm.getPort()) ? new Integer(appForm.getPort()) : null; ApplicationConfig config = ApplicationConfigFactory.create(appId, appForm.getName(), appForm.getType(), appForm.getHost(), port, null, appForm.getUsername(), appForm.getPassword(), null); ApplicationConfigManager.addApplication(config); UserActivityLogger.getInstance().logActivity( context.getUser().getUsername(), "Added application with ID "+config.getApplicationId()); return mapping.findForward(Forwards.SUCCESS); } |
public void doAssociationTests(Vector affStatus, boolean[] permuteInd) { | public void doAssociationTests(Vector affStatus, Vector permuteInd) { | public void doAssociationTests(Vector affStatus, boolean[] permuteInd) { if(superprob == null || superdata == null || realAffectedStatus == null) { return; } if(affStatus == null){ affStatus = realAffectedStatus; } if(permuteInd == null) { permuteInd = new boolean[superdata.length]; Arrays.fill(permuteInd, false); } Vector caseCounts = new Vector(); Vector controlCounts = new Vector(); double[] tempCase, tempControl, totalCase, totalControl; if (Options.getAssocTest() == ASSOC_CC){ tempCase = new double[superprob.length]; tempControl = new double[superprob.length]; totalCase = new double[superprob.length]; totalControl = new double[superprob.length]; double tempnorm=0; for (int i = numFileteredTrios*2; i < superdata.length; i++){ for (int n=0; n<superdata[i].nsuper; n++) { if (((Integer)affStatus.elementAt(i)).intValue() == 1){ tempControl[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempControl[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; }else if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempCase[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempCase[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; } tempnorm += superdata[i].superposs[n].p; } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempCase[j] > 0.0000 || tempControl[j] > 0.0000) { totalCase[j] += (tempCase[j]/tempnorm); totalControl[j] += (tempControl[j]/tempnorm); tempCase[j]=tempControl[j]=0.0000; } } tempnorm=0.00; } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { caseCounts.add(new Double(totalCase[j])); controlCounts.add(new Double(totalControl[j])); } } } double[] tempT,totalT,tempU,totalU; Vector obsT = new Vector(); Vector obsU = new Vector(); if(Options.getAssocTest() == ASSOC_TRIO) { double tempnorm=0,product; tempT = new double[superprob.length]; totalT = new double[superprob.length]; tempU = new double[superprob.length]; totalU = new double[superprob.length]; for (int i=0; i<numFileteredTrios*2; i+=2) { if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempnorm=0.00; for (int n=0; n<superdata[i].nsuper; n++) { for (int m=0; m<superdata[i+1].nsuper; m++) { if(kidConsistentCache[i/2][n][m]) { product=superdata[i].superposs[n].p*superdata[i+1].superposs[m].p; /*if(i<5) { System.out.println(superdata[i+1].superposs[m].h1 + "\t" + product); } */ if(permuteInd[i]) { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempU[superdata[i].superposs[n].h1]+=product; tempT[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempU[superdata[i+1].superposs[m].h1]+=product; tempT[superdata[i+1].superposs[m].h2]+=product; } } else { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempT[superdata[i].superposs[n].h1]+=product; tempU[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempT[superdata[i+1].superposs[m].h1]+=product; tempU[superdata[i+1].superposs[m].h2]+=product; } } /* normalize by all possibilities, even double hom */ tempnorm+=product; } } } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempT[j] > 0.0000 || tempU[j] > 0.0000) { totalT[j] += (tempT[j]/tempnorm); totalU[j] += (tempU[j]/tempnorm); tempT[j]=tempU[j]=0.0000; } } tempnorm=0.00; } } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { obsT.add(new Double(totalT[j])); obsU.add(new Double(totalU[j])); } } } if (Options.getAssocTest() == ASSOC_TRIO){ this.obsT = obsT; this.obsU = obsU; } else if (Options.getAssocTest() == ASSOC_CC){ this.caseCounts = caseCounts; this.controlCounts = controlCounts; } } |
permuteInd = new boolean[superdata.length]; Arrays.fill(permuteInd, false); | permuteInd = new Vector(); for (int i = 0; i < superdata.length; i++){ permuteInd.add(new Boolean(false)); } | public void doAssociationTests(Vector affStatus, boolean[] permuteInd) { if(superprob == null || superdata == null || realAffectedStatus == null) { return; } if(affStatus == null){ affStatus = realAffectedStatus; } if(permuteInd == null) { permuteInd = new boolean[superdata.length]; Arrays.fill(permuteInd, false); } Vector caseCounts = new Vector(); Vector controlCounts = new Vector(); double[] tempCase, tempControl, totalCase, totalControl; if (Options.getAssocTest() == ASSOC_CC){ tempCase = new double[superprob.length]; tempControl = new double[superprob.length]; totalCase = new double[superprob.length]; totalControl = new double[superprob.length]; double tempnorm=0; for (int i = numFileteredTrios*2; i < superdata.length; i++){ for (int n=0; n<superdata[i].nsuper; n++) { if (((Integer)affStatus.elementAt(i)).intValue() == 1){ tempControl[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempControl[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; }else if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempCase[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempCase[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; } tempnorm += superdata[i].superposs[n].p; } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempCase[j] > 0.0000 || tempControl[j] > 0.0000) { totalCase[j] += (tempCase[j]/tempnorm); totalControl[j] += (tempControl[j]/tempnorm); tempCase[j]=tempControl[j]=0.0000; } } tempnorm=0.00; } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { caseCounts.add(new Double(totalCase[j])); controlCounts.add(new Double(totalControl[j])); } } } double[] tempT,totalT,tempU,totalU; Vector obsT = new Vector(); Vector obsU = new Vector(); if(Options.getAssocTest() == ASSOC_TRIO) { double tempnorm=0,product; tempT = new double[superprob.length]; totalT = new double[superprob.length]; tempU = new double[superprob.length]; totalU = new double[superprob.length]; for (int i=0; i<numFileteredTrios*2; i+=2) { if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempnorm=0.00; for (int n=0; n<superdata[i].nsuper; n++) { for (int m=0; m<superdata[i+1].nsuper; m++) { if(kidConsistentCache[i/2][n][m]) { product=superdata[i].superposs[n].p*superdata[i+1].superposs[m].p; /*if(i<5) { System.out.println(superdata[i+1].superposs[m].h1 + "\t" + product); } */ if(permuteInd[i]) { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempU[superdata[i].superposs[n].h1]+=product; tempT[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempU[superdata[i+1].superposs[m].h1]+=product; tempT[superdata[i+1].superposs[m].h2]+=product; } } else { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempT[superdata[i].superposs[n].h1]+=product; tempU[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempT[superdata[i+1].superposs[m].h1]+=product; tempU[superdata[i+1].superposs[m].h2]+=product; } } /* normalize by all possibilities, even double hom */ tempnorm+=product; } } } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempT[j] > 0.0000 || tempU[j] > 0.0000) { totalT[j] += (tempT[j]/tempnorm); totalU[j] += (tempU[j]/tempnorm); tempT[j]=tempU[j]=0.0000; } } tempnorm=0.00; } } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { obsT.add(new Double(totalT[j])); obsU.add(new Double(totalU[j])); } } } if (Options.getAssocTest() == ASSOC_TRIO){ this.obsT = obsT; this.obsU = obsU; } else if (Options.getAssocTest() == ASSOC_CC){ this.caseCounts = caseCounts; this.controlCounts = controlCounts; } } |
for (int i = numFileteredTrios*2; i < superdata.length; i++){ | for (int i = numFilteredTrios*2; i < superdata.length; i++){ | public void doAssociationTests(Vector affStatus, boolean[] permuteInd) { if(superprob == null || superdata == null || realAffectedStatus == null) { return; } if(affStatus == null){ affStatus = realAffectedStatus; } if(permuteInd == null) { permuteInd = new boolean[superdata.length]; Arrays.fill(permuteInd, false); } Vector caseCounts = new Vector(); Vector controlCounts = new Vector(); double[] tempCase, tempControl, totalCase, totalControl; if (Options.getAssocTest() == ASSOC_CC){ tempCase = new double[superprob.length]; tempControl = new double[superprob.length]; totalCase = new double[superprob.length]; totalControl = new double[superprob.length]; double tempnorm=0; for (int i = numFileteredTrios*2; i < superdata.length; i++){ for (int n=0; n<superdata[i].nsuper; n++) { if (((Integer)affStatus.elementAt(i)).intValue() == 1){ tempControl[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempControl[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; }else if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempCase[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempCase[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; } tempnorm += superdata[i].superposs[n].p; } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempCase[j] > 0.0000 || tempControl[j] > 0.0000) { totalCase[j] += (tempCase[j]/tempnorm); totalControl[j] += (tempControl[j]/tempnorm); tempCase[j]=tempControl[j]=0.0000; } } tempnorm=0.00; } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { caseCounts.add(new Double(totalCase[j])); controlCounts.add(new Double(totalControl[j])); } } } double[] tempT,totalT,tempU,totalU; Vector obsT = new Vector(); Vector obsU = new Vector(); if(Options.getAssocTest() == ASSOC_TRIO) { double tempnorm=0,product; tempT = new double[superprob.length]; totalT = new double[superprob.length]; tempU = new double[superprob.length]; totalU = new double[superprob.length]; for (int i=0; i<numFileteredTrios*2; i+=2) { if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempnorm=0.00; for (int n=0; n<superdata[i].nsuper; n++) { for (int m=0; m<superdata[i+1].nsuper; m++) { if(kidConsistentCache[i/2][n][m]) { product=superdata[i].superposs[n].p*superdata[i+1].superposs[m].p; /*if(i<5) { System.out.println(superdata[i+1].superposs[m].h1 + "\t" + product); } */ if(permuteInd[i]) { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempU[superdata[i].superposs[n].h1]+=product; tempT[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempU[superdata[i+1].superposs[m].h1]+=product; tempT[superdata[i+1].superposs[m].h2]+=product; } } else { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempT[superdata[i].superposs[n].h1]+=product; tempU[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempT[superdata[i+1].superposs[m].h1]+=product; tempU[superdata[i+1].superposs[m].h2]+=product; } } /* normalize by all possibilities, even double hom */ tempnorm+=product; } } } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempT[j] > 0.0000 || tempU[j] > 0.0000) { totalT[j] += (tempT[j]/tempnorm); totalU[j] += (tempU[j]/tempnorm); tempT[j]=tempU[j]=0.0000; } } tempnorm=0.00; } } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { obsT.add(new Double(totalT[j])); obsU.add(new Double(totalU[j])); } } } if (Options.getAssocTest() == ASSOC_TRIO){ this.obsT = obsT; this.obsU = obsU; } else if (Options.getAssocTest() == ASSOC_CC){ this.caseCounts = caseCounts; this.controlCounts = controlCounts; } } |
for (int i=0; i<numFileteredTrios*2; i+=2) { | for (int i=0; i<numFilteredTrios*2; i+=2) { | public void doAssociationTests(Vector affStatus, boolean[] permuteInd) { if(superprob == null || superdata == null || realAffectedStatus == null) { return; } if(affStatus == null){ affStatus = realAffectedStatus; } if(permuteInd == null) { permuteInd = new boolean[superdata.length]; Arrays.fill(permuteInd, false); } Vector caseCounts = new Vector(); Vector controlCounts = new Vector(); double[] tempCase, tempControl, totalCase, totalControl; if (Options.getAssocTest() == ASSOC_CC){ tempCase = new double[superprob.length]; tempControl = new double[superprob.length]; totalCase = new double[superprob.length]; totalControl = new double[superprob.length]; double tempnorm=0; for (int i = numFileteredTrios*2; i < superdata.length; i++){ for (int n=0; n<superdata[i].nsuper; n++) { if (((Integer)affStatus.elementAt(i)).intValue() == 1){ tempControl[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempControl[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; }else if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempCase[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempCase[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; } tempnorm += superdata[i].superposs[n].p; } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempCase[j] > 0.0000 || tempControl[j] > 0.0000) { totalCase[j] += (tempCase[j]/tempnorm); totalControl[j] += (tempControl[j]/tempnorm); tempCase[j]=tempControl[j]=0.0000; } } tempnorm=0.00; } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { caseCounts.add(new Double(totalCase[j])); controlCounts.add(new Double(totalControl[j])); } } } double[] tempT,totalT,tempU,totalU; Vector obsT = new Vector(); Vector obsU = new Vector(); if(Options.getAssocTest() == ASSOC_TRIO) { double tempnorm=0,product; tempT = new double[superprob.length]; totalT = new double[superprob.length]; tempU = new double[superprob.length]; totalU = new double[superprob.length]; for (int i=0; i<numFileteredTrios*2; i+=2) { if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempnorm=0.00; for (int n=0; n<superdata[i].nsuper; n++) { for (int m=0; m<superdata[i+1].nsuper; m++) { if(kidConsistentCache[i/2][n][m]) { product=superdata[i].superposs[n].p*superdata[i+1].superposs[m].p; /*if(i<5) { System.out.println(superdata[i+1].superposs[m].h1 + "\t" + product); } */ if(permuteInd[i]) { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempU[superdata[i].superposs[n].h1]+=product; tempT[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempU[superdata[i+1].superposs[m].h1]+=product; tempT[superdata[i+1].superposs[m].h2]+=product; } } else { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempT[superdata[i].superposs[n].h1]+=product; tempU[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempT[superdata[i+1].superposs[m].h1]+=product; tempU[superdata[i+1].superposs[m].h2]+=product; } } /* normalize by all possibilities, even double hom */ tempnorm+=product; } } } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempT[j] > 0.0000 || tempU[j] > 0.0000) { totalT[j] += (tempT[j]/tempnorm); totalU[j] += (tempU[j]/tempnorm); tempT[j]=tempU[j]=0.0000; } } tempnorm=0.00; } } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { obsT.add(new Double(totalT[j])); obsU.add(new Double(totalU[j])); } } } if (Options.getAssocTest() == ASSOC_TRIO){ this.obsT = obsT; this.obsU = obsU; } else if (Options.getAssocTest() == ASSOC_CC){ this.caseCounts = caseCounts; this.controlCounts = controlCounts; } } |
if(permuteInd[i]) { | if(((Boolean)permuteInd.get(i)).booleanValue()) { | public void doAssociationTests(Vector affStatus, boolean[] permuteInd) { if(superprob == null || superdata == null || realAffectedStatus == null) { return; } if(affStatus == null){ affStatus = realAffectedStatus; } if(permuteInd == null) { permuteInd = new boolean[superdata.length]; Arrays.fill(permuteInd, false); } Vector caseCounts = new Vector(); Vector controlCounts = new Vector(); double[] tempCase, tempControl, totalCase, totalControl; if (Options.getAssocTest() == ASSOC_CC){ tempCase = new double[superprob.length]; tempControl = new double[superprob.length]; totalCase = new double[superprob.length]; totalControl = new double[superprob.length]; double tempnorm=0; for (int i = numFileteredTrios*2; i < superdata.length; i++){ for (int n=0; n<superdata[i].nsuper; n++) { if (((Integer)affStatus.elementAt(i)).intValue() == 1){ tempControl[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempControl[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; }else if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempCase[superdata[i].superposs[n].h1] += superdata[i].superposs[n].p; tempCase[superdata[i].superposs[n].h2] += superdata[i].superposs[n].p; } tempnorm += superdata[i].superposs[n].p; } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempCase[j] > 0.0000 || tempControl[j] > 0.0000) { totalCase[j] += (tempCase[j]/tempnorm); totalControl[j] += (tempControl[j]/tempnorm); tempCase[j]=tempControl[j]=0.0000; } } tempnorm=0.00; } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { caseCounts.add(new Double(totalCase[j])); controlCounts.add(new Double(totalControl[j])); } } } double[] tempT,totalT,tempU,totalU; Vector obsT = new Vector(); Vector obsU = new Vector(); if(Options.getAssocTest() == ASSOC_TRIO) { double tempnorm=0,product; tempT = new double[superprob.length]; totalT = new double[superprob.length]; tempU = new double[superprob.length]; totalU = new double[superprob.length]; for (int i=0; i<numFileteredTrios*2; i+=2) { if (((Integer)affStatus.elementAt(i)).intValue() == 2){ tempnorm=0.00; for (int n=0; n<superdata[i].nsuper; n++) { for (int m=0; m<superdata[i+1].nsuper; m++) { if(kidConsistentCache[i/2][n][m]) { product=superdata[i].superposs[n].p*superdata[i+1].superposs[m].p; /*if(i<5) { System.out.println(superdata[i+1].superposs[m].h1 + "\t" + product); } */ if(permuteInd[i]) { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempU[superdata[i].superposs[n].h1]+=product; tempT[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempU[superdata[i+1].superposs[m].h1]+=product; tempT[superdata[i+1].superposs[m].h2]+=product; } } else { if (superdata[i].superposs[n].h1 != superdata[i].superposs[n].h2) { tempT[superdata[i].superposs[n].h1]+=product; tempU[superdata[i].superposs[n].h2]+=product; } if (superdata[i+1].superposs[m].h1 != superdata[i+1].superposs[m].h2) { tempT[superdata[i+1].superposs[m].h1]+=product; tempU[superdata[i+1].superposs[m].h2]+=product; } } /* normalize by all possibilities, even double hom */ tempnorm+=product; } } } if (tempnorm > 0.00) { for (int j=0; j<superprob.length; j++) { if (tempT[j] > 0.0000 || tempU[j] > 0.0000) { totalT[j] += (tempT[j]/tempnorm); totalU[j] += (tempU[j]/tempnorm); tempT[j]=tempU[j]=0.0000; } } tempnorm=0.00; } } } for (int j = 0; j <superprob.length; j++){ if (superprob[j] > .001) { obsT.add(new Double(totalT[j])); obsU.add(new Double(totalU[j])); } } } if (Options.getAssocTest() == ASSOC_TRIO){ this.obsT = obsT; this.obsU = obsU; } else if (Options.getAssocTest() == ASSOC_CC){ this.caseCounts = caseCounts; this.controlCounts = controlCounts; } } |
numFileteredTrios = inputHaploTrios.size() / 4; | numFilteredTrios = inputHaploTrios.size() / 4; | public void doEM(int[] theBlock) throws HaploViewException{ //break up large blocks if needed int[] block_size; if (theBlock.length < 9){ block_size = new int[1]; block_size[0] = theBlock.length; } else { //some base-8 arithmetic int ones = theBlock.length%8; int eights = (theBlock.length - ones)/8; if (ones == 0){ block_size = new int[eights]; for (int i = 0; i < eights; i++){ block_size[i]=8; } } else { block_size = new int[eights+1]; for (int i = 0; i < eights-1; i++){ block_size[i]=8; } block_size[eights-1] = (8+ones)/2; block_size[eights] = 8+ones-block_size[eights-1]; } } byte[] thisHap; Vector inputHaploSingletons = new Vector(); Vector inputHaploTrios = new Vector(); Vector affSingletons = new Vector(); Vector affTrios = new Vector(); //whichVector[i] stores a value which indicates which vector chromosome i's genotype should go in //1 indicates inputHaploSingletons (singletons), 2 indicates inputHaploTrios, //3 indicates a person from a broken trio who is treated as a singleton //0 indicates none (too much missing data) int[] whichVector = new int[chromosomes.size()]; for(int i=0;i<numTrios*4; i+=4) { Chromosome parentAFirst = (Chromosome) chromosomes.elementAt(i); Chromosome parentASecond = (Chromosome) chromosomes.elementAt(i+1); Chromosome parentBFirst = (Chromosome) chromosomes.elementAt(i+2); Chromosome parentBSecond = (Chromosome) chromosomes.elementAt(i+3); boolean tooManyMissingInASegmentA = false; boolean tooManyMissingInASegmentB = false; int totalMissingA = 0; int totalMissingB = 0; int segmentShift = 0; for (int n = 0; n < block_size.length; n++){ int missingA = 0; int missingB = 0; for (int j = 0; j < block_size[n]; j++){ byte AFirstGeno = parentAFirst.getGenotype(theBlock[segmentShift+j]); byte ASecondGeno = parentASecond.getGenotype(theBlock[segmentShift+j]); byte BFirstGeno = parentBFirst.getGenotype(theBlock[segmentShift+j]); byte BSecondGeno = parentBSecond.getGenotype(theBlock[segmentShift+j]); if(AFirstGeno == 0 || ASecondGeno == 0) missingA++; if(BFirstGeno == 0 || BSecondGeno == 0) missingB++; } segmentShift += block_size[n]; if (missingA >= MISSINGLIMIT){ tooManyMissingInASegmentA = true; } if (missingB >= MISSINGLIMIT){ tooManyMissingInASegmentB = true; } totalMissingA += missingA; totalMissingB += missingB; } if(!tooManyMissingInASegmentA && totalMissingA <= 1+theBlock.length/3 && !tooManyMissingInASegmentB && totalMissingB <= 1+theBlock.length/3) { //both parents are good so all 4 chroms are added as a trio whichVector[i] = 2; whichVector[i+1] = 2; whichVector[i+2] = 2; whichVector[i+3] = 2; } else if(!tooManyMissingInASegmentA && totalMissingA <= 1+theBlock.length/3) { //first person good, so he's added as a singleton, other parent is dropped whichVector[i] = 3; whichVector[i+1] =3; whichVector[i+2] =0; whichVector[i+3]=0; } else if(!tooManyMissingInASegmentB && totalMissingB <= 1+theBlock.length/3) { //second person good, so he's added as a singleton, other parent is dropped whichVector[i] = 0; whichVector[i+1] =0; whichVector[i+2] =3; whichVector[i+3]=3; } else { //both people have too much missing data so neither is used whichVector[i] = 0; whichVector[i+1] =0; whichVector[i+2] =0; whichVector[i+3]=0; } } for (int i = numTrios*4; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); Chromosome nextChrom = (Chromosome)chromosomes.elementAt(++i); boolean tooManyMissingInASegment = false; int totalMissing = 0; int segmentShift = 0; for (int n = 0; n < block_size.length; n++){ int missing = 0; for (int j = 0; j < block_size[n]; j++){ byte theGeno = thisChrom.getGenotype(theBlock[segmentShift+j]); byte nextGeno = nextChrom.getGenotype(theBlock[segmentShift+j]); if(theGeno == 0 || nextGeno == 0) missing++; } segmentShift += block_size[n]; if (missing >= MISSINGLIMIT){ tooManyMissingInASegment = true; } totalMissing += missing; } //we want to use chromosomes without too many missing genotypes in a given //subsegment (first term) or without too many missing genotypes in the //whole block (second term) if (!tooManyMissingInASegment && totalMissing <= 1+theBlock.length/3){ whichVector[i-1] = 1; whichVector[i] = 1; } } //we only want to add an affected status every other chromosome, so we flip this boolean each time boolean addAff = true; for (int i = 0; i < chromosomes.size(); i++){ Chromosome thisChrom = (Chromosome)chromosomes.elementAt(i); if(whichVector[i] > 0) { thisHap = new byte[theBlock.length]; for (int j = 0; j < theBlock.length; j++){ byte a1 = Chromosome.getMarker(theBlock[j]).getMajor(); byte a2 = Chromosome.getMarker(theBlock[j]).getMinor(); byte theGeno = thisChrom.getGenotype(theBlock[j]); if (theGeno >= 5){ thisHap[j] = 'h'; } else { if (theGeno == 0){ thisHap[j] = '0'; }else if (theGeno == a1){ thisHap[j] = '1'; }else if (theGeno == a2){ thisHap[j] = '2'; }else{ throw new HaploViewException("Marker with > 2 alleles: " + Chromosome.getMarker(theBlock[j]).getName()); } } } if(whichVector[i] == 1) { inputHaploSingletons.add(thisHap); if(addAff) { affSingletons.add(new Integer(thisChrom.getAffected())); } } else if(whichVector[i] ==2) { inputHaploTrios.add(thisHap); if(addAff) { affTrios.add(new Integer(thisChrom.getAffected())); } }else if (whichVector[i] == 3){ inputHaploSingletons.add(thisHap); if(addAff) { affSingletons.add(new Integer(0)); } } if(addAff) { addAff = false; } else { addAff =true; } } } numFileteredTrios = inputHaploTrios.size() / 4; inputHaploTrios.addAll(inputHaploSingletons); affTrios.addAll(affSingletons); byte[][] input_haplos = (byte[][])inputHaploTrios.toArray(new byte[0][0]); full_em_breakup(input_haplos, block_size, affTrios); } |
kidConsistentCache = new boolean[numFileteredTrios][][]; for(int i=0;i<numFileteredTrios*2;i+=2) { | kidConsistentCache = new boolean[numFilteredTrios][][]; for(int i=0;i<numFilteredTrios*2;i+=2) { | private void full_em_breakup( byte[][] input_haplos, int[] block_size, Vector affStatus) throws HaploViewException{ int num_poss, iter;//, maxk, numk; double total;//, maxprob; int block, start_locus, end_locus, biggest_block_size; int poss_full;//, best, h1, h2; int num_indivs=0; int num_blocks = block_size.length; int num_haplos = input_haplos.length; int num_loci = input_haplos[0].length; Recovery tempRec; if (num_loci > MAXLOCI){ throw new HaploViewException("Too many loci in a single block (> 100)"); } //figure out the size of the biggest block biggest_block_size=block_size[0]; for (int i=1; i<num_blocks; i++) { if (block_size[i] > biggest_block_size) biggest_block_size=block_size[i]; } num_poss = two_n[biggest_block_size]; data = new OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) data[i]= new OBS(); superdata = new SUPER_OBS[num_haplos/2]; for (int i=0; i<num_haplos/2; i++) superdata[i]= new SUPER_OBS(num_blocks); double[][] hprob = new double[num_blocks][num_poss]; int[][] hlist = new int[num_blocks][num_poss]; int[] num_hlist = new int[num_blocks]; int[] hint = new int[num_poss]; prob = new double[num_poss]; /* for trio option */ if (Options.getAssocTest() == ASSOC_TRIO) { ambighet = new int[(num_haplos/4)][num_loci]; store_dhet_status(num_haplos,num_loci,input_haplos); } end_locus=-1; //System.out.println("made it to 110"); //now we loop through the blocks for (block=0; block<num_blocks; block++) { start_locus=end_locus+1; end_locus=start_locus+block_size[block]-1; num_poss=two_n[block_size[block]]; //read_observations initializes the values in data[] (array of OBS) num_indivs=read_observations(num_haplos,num_loci,input_haplos,start_locus,end_locus); // start prob array with probabilities from full observations for (int j=0; j<num_poss; j++) { prob[j]=PSEUDOCOUNT; } total=(double)num_poss; total *= PSEUDOCOUNT; /* starting prob is phase known haps + 0.1 (PSEUDOCOUNT) count of every haplotype - i.e., flat when nothing is known, close to phase known if a great deal is known */ for (int i=0; i<num_indivs; i++) { if (data[i].nposs==1) { tempRec = (Recovery)data[i].poss.elementAt(0); prob[tempRec.h1]+=1.0; prob[tempRec.h2]+=1.0; total+=2.0; } } // normalize for (int j=0; j<num_poss; j++) { prob[j] /= total; } // EM LOOP: assign ambiguous data based on p, then re-estimate p iter=0; while (iter<20) { // compute probabilities of each possible observation for (int i=0; i<num_indivs; i++) { total=0.0; for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); tempRec.p = (float)(prob[tempRec.h1]*prob[tempRec.h2]); total+=tempRec.p; } // normalize for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); tempRec.p /= total; } } // re-estimate prob for (int j=0; j<num_poss; j++) { prob[j]=1e-10; } total=num_poss*1e-10; for (int i=0; i<num_indivs; i++) { for (int k=0; k<data[i].nposs; k++) { tempRec = (Recovery) data[i].poss.elementAt(k); prob[tempRec.h1]+=tempRec.p; prob[tempRec.h2]+=tempRec.p; total+=(2.0*(tempRec.p)); } } // normalize for (int j=0; j<num_poss; j++) { prob[j] /= total; } iter++; } // printf("FINAL PROBABILITIES:\n"); int m=0; for (int j=0; j<num_poss; j++) { hint[j]=-1; if (prob[j] > .001) { // printf("haplo %s p = %.4lf\n",haplo_str(j,block_size[block]),prob[j]); hlist[block][m]=j; hprob[block][m]=prob[j]; hint[j]=m; m++; } } num_hlist[block]=m; // store current block results in super obs structure store_block_haplos(hlist, hprob, hint, block, num_indivs); } /* for each block */ poss_full=1; for (block=0; block<num_blocks; block++) { poss_full *= num_hlist[block]; } //TODO:System.out.println(poss_full); /* LIGATE and finish this mess :) *//* if (poss_full > 1000000) {/* what we really need to do is go through and pare backto using a smaller number (e.g., > .002, .005)//printf("too many possibilities: %d\n",poss_full);return(-5);}*/ superprob = new double[poss_full]; create_super_haplos(num_indivs,num_blocks,num_hlist); /* run standard EM on supercombos */ /* start prob array with probabilities from full observations */ for (int j=0; j<poss_full; j++) { superprob[j]=PSEUDOCOUNT; } total=(double)poss_full; total *= PSEUDOCOUNT; /* starting prob is phase known haps + 0.1 (PSEUDOCOUNT) count of every haplotype - i.e., flat when nothing is known, close to phase known if a great deal is known */ for (int i=0; i<num_indivs; i++) { if (superdata[i].nsuper==1) { superprob[superdata[i].superposs[0].h1]+=1.0; superprob[superdata[i].superposs[0].h2]+=1.0; total+=2.0; } } /* normalize */ for (int j=0; j<poss_full; j++) { superprob[j] /= total; } /* EM LOOP: assign ambiguous data based on p, then re-estimate p */ iter=0; while (iter<20) { /* compute probabilities of each possible observation */ for (int i=0; i<num_indivs; i++) { total=0.0; for (int k=0; k<superdata[i].nsuper; k++) { superdata[i].superposs[k].p = (float) (superprob[superdata[i].superposs[k].h1]* superprob[superdata[i].superposs[k].h2]); total+=superdata[i].superposs[k].p; } /* normalize */ for (int k=0; k<superdata[i].nsuper; k++) { superdata[i].superposs[k].p /= total; } } /* re-estimate prob */ for (int j=0; j<poss_full; j++) { superprob[j]=1e-10; } total=poss_full*1e-10; for (int i=0; i<num_indivs; i++) { for (int k=0; k<superdata[i].nsuper; k++) { superprob[superdata[i].superposs[k].h1]+=superdata[i].superposs[k].p; superprob[superdata[i].superposs[k].h2]+=superdata[i].superposs[k].p; total+=(2.0*superdata[i].superposs[k].p); } } /* normalize */ for (int j=0; j<poss_full; j++) { superprob[j] /= total; } iter++; } /* we're done - the indices of superprob now have to be decoded to reveal the actual haplotypes they represent */ if(Options.getAssocTest() == ASSOC_TRIO) { kidConsistentCache = new boolean[numFileteredTrios][][]; for(int i=0;i<numFileteredTrios*2;i+=2) { if (((Integer)affStatus.elementAt(i)).intValue() == 2){ kidConsistentCache[i/2] = new boolean[superdata[i].nsuper][]; for (int n=0; n<superdata[i].nsuper; n++) { kidConsistentCache[i/2][n] = new boolean[superdata[i+1].nsuper]; for (int m=0; m<superdata[i+1].nsuper; m++) { kidConsistentCache[i/2][n][m] = kid_consistent(superdata[i].superposs[n].h1, superdata[i+1].superposs[m].h1,num_blocks, block_size,hlist,num_hlist,i/2,num_loci); } } } } } realAffectedStatus = affStatus; doAssociationTests(affStatus, null); Vector haplos_present = new Vector(); Vector haplo_freq= new Vector(); for (int j=0; j<poss_full; j++) { if (superprob[j] > .001) { haplos_present.addElement(decode_haplo_str(j,num_blocks,block_size,hlist,num_hlist)); //sprintf(haplos_present[k],"%s",decode_haplo_str(j,num_blocks,block_size,hlist,num_hlist)); haplo_freq.addElement(new Double(superprob[j])); } } double[] freqs = new double[haplo_freq.size()]; for(int j=0;j<haplo_freq.size();j++) { freqs[j] = ((Double)haplo_freq.elementAt(j)).doubleValue(); } this.haplotypes = (int[][])haplos_present.toArray(new int[0][0]); this.frequencies = freqs; /* if (dump_phased_haplos) { if ((fpdump=fopen("emphased.haps","w"))!=NULL) { for (i=0; i<num_indivs; i++) { best=0; for (k=0; k<superdata[i].nsuper; k++) { if (superdata[i].superposs[k].p > superdata[i].superposs[best].p) { best=k; } } h1 = superdata[i].superposs[best].h1; h2 = superdata[i].superposs[best].h2; fprintf(fpdump,"%s\n",decode_haplo_str(h1,num_blocks,block_size,hlist,num_hlist)); fprintf(fpdump,"%s\n",decode_haplo_str(h2,num_blocks,block_size,hlist,num_hlist)); } fclose(fpdump); } } */ //return 0; } |
public Object getVariableValue( String namespaceURI, String prefix, String localName ) { return context.getVariable( localName ); | public Object getVariableValue( String namespaceURI, String prefix, String localName) { Object value = context.getVariable(localName); return value; | public Object getVariableValue( String namespaceURI, String prefix, String localName ) { return context.getVariable( localName ); } |
private SQLColumn() { | public SQLColumn() { logger.debug("NEW COLUMN (noargs) @"+hashCode()); | private SQLColumn() { } |
XMLOutput newOutput = XMLOutput.createXMLOutput(new FileOutputStream(name)); | XMLOutput newOutput = createXMLOutput(); | public void doTag(final XMLOutput output) throws Exception { if ( name == null ) { throw new MissingAttributeException( "name" ); } XMLOutput newOutput = XMLOutput.createXMLOutput(new FileOutputStream(name)); try { newOutput.startDocument(); invokeBody(newOutput); newOutput.endDocument(); } finally { newOutput.close(); } } |
float newScale = getScale(); | public void createUI() { setLayout( new BorderLayout() ); imageView = new JAIPhotoView(); scrollPane = new JScrollPane( imageView ); scrollPane.setPreferredSize( new Dimension( 500, 500 ) ); add( scrollPane, BorderLayout.CENTER ); // Listen fot resize events of the scroll area so that fitted image can // be resized as well. addComponentListener( this ); JToolBar toolbar = new JToolBar(); String[] defaultZooms = { "12%", "25%", "50%", "100%", "Fit" }; JLabel zoomLabel = new JLabel( "Zoom" ); JComboBox zoomCombo = new JComboBox( defaultZooms ); zoomCombo.setEditable( true ); zoomCombo.setSelectedItem( "Fit" ); final JAIPhotoViewer viewer = this; zoomCombo.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent ev ) { JComboBox cb = (JComboBox) ev.getSource(); String selected = (String)cb.getSelectedItem(); log.debug( "Selected: " + selected ); isFit = false; // Parse the pattern DecimalFormat percentFormat = new DecimalFormat( "#####.#%" ); if ( selected == "Fit" ) { isFit = true; log.debug( "Fitting to window" ); fit(); float newScale = getScale(); String strNewScale = "Fit"; cb.setSelectedItem( strNewScale ); } else { // Parse the number. First remove all white space to ease the parsing StringBuffer b = new StringBuffer( selected ); int spaceIndex = b.indexOf( " " ); while ( spaceIndex >= 0 ) { b.deleteCharAt( spaceIndex ); spaceIndex = b.indexOf( " " ); } selected = b.toString(); boolean success = false; float newScale = 0; try { newScale = Float.parseFloat( selected ); newScale /= 100.0; success = true; } catch (NumberFormatException e ) { // Not a float } if ( !success ) { try { newScale = percentFormat.parse( selected ).floatValue(); success = true; } catch ( ParseException e ) { } } if ( success ) { log.debug( "New scale: " + newScale ); viewer.setScale( newScale ); String strNewScale = percentFormat.format( newScale ); cb.setSelectedItem( strNewScale ); } } } }); toolbar.add( zoomLabel ); toolbar.add( zoomCombo ); add( toolbar, BorderLayout.NORTH ); } |
|
float newScale = getScale(); | public void actionPerformed( ActionEvent ev ) { JComboBox cb = (JComboBox) ev.getSource(); String selected = (String)cb.getSelectedItem(); log.debug( "Selected: " + selected ); isFit = false; // Parse the pattern DecimalFormat percentFormat = new DecimalFormat( "#####.#%" ); if ( selected == "Fit" ) { isFit = true; log.debug( "Fitting to window" ); fit(); float newScale = getScale(); String strNewScale = "Fit"; cb.setSelectedItem( strNewScale ); } else { // Parse the number. First remove all white space to ease the parsing StringBuffer b = new StringBuffer( selected ); int spaceIndex = b.indexOf( " " ); while ( spaceIndex >= 0 ) { b.deleteCharAt( spaceIndex ); spaceIndex = b.indexOf( " " ); } selected = b.toString(); boolean success = false; float newScale = 0; try { newScale = Float.parseFloat( selected ); newScale /= 100.0; success = true; } catch (NumberFormatException e ) { // Not a float } if ( !success ) { try { newScale = percentFormat.parse( selected ).floatValue(); success = true; } catch ( ParseException e ) { } } if ( success ) { log.debug( "New scale: " + newScale ); viewer.setScale( newScale ); String strNewScale = percentFormat.format( newScale ); cb.setSelectedItem( strNewScale ); } } } |
|
finally { if ( ! context.isCacheTags() ) { clearTag(); } } | public void run(JellyContext context, XMLOutput output) throws Exception { Tag tag = getTag(); if ( tag == null ) { return; } tag.setContext(context); // initialize all the properties of the tag before its used // if there is a problem abort this tag for (int i = 0, size = expressions.length; i < size; i++) { Expression expression = expressions[i]; Method method = methods[i]; Class type = types[i]; // some types are Expression objects so let the tag // evaluate them Object value = null; if (type.isAssignableFrom(Expression.class) && !type.isAssignableFrom(Object.class)) { value = expression; } else { value = expression.evaluate(context); } // convert value to correct type if (value != null) { value = convertType(value, type); } Object[] arguments = { value }; try { method.invoke(tag, arguments); } catch (Exception e) { String valueTypeName = (value != null ) ? value.getClass().getName() : "null"; log.warn( "Cannot call method: " + method.getName() + " as I cannot convert: " + value + " of type: " + valueTypeName + " into type: " + type.getName() ); throw createJellyException( "Cannot call method: " + method.getName() + " on tag of type: " + tag.getClass().getName() + " with value: " + value + " of type: " + valueTypeName + ". Exception: " + e, e ); } } try { tag.doTag(output); } catch (JellyException e) { handleException(e); } catch (Exception e) { handleException(e); } } |
|
logger.debug("SQLDatabase: populate finished"); | public synchronized void populate() throws ArchitectException { if (populated) return; int oldSize = children.size(); Connection con = null; ResultSet rs = null; try { con = getConnection(); DatabaseMetaData dbmd = con.getMetaData(); rs = dbmd.getCatalogs(); while (rs.next()) { String catName = rs.getString(1); SQLCatalog cat = null; if (catName != null) { cat = new SQLCatalog(this, catName); cat.setNativeTerm(dbmd.getCatalogTerm()); logger.debug("Set catalog term to "+cat.getNativeTerm()); children.add(cat); } } rs.close(); rs = null; // if we tried to get Catalogs, and there were none, then I guess // we should look for Schemas instead (i.e. this database has no // catalogs, and schemas attached directly to the database) if ( children.size() == oldSize ) { rs = dbmd.getSchemas(); while (rs.next()) { children.add(new SQLSchema(this, rs.getString(1),false)); } rs.close(); rs = null; } } catch (SQLException e) { throw new ArchitectException("database.populate.fail", e); } finally { populated = true; int newSize = children.size(); if (newSize > oldSize) { int[] changedIndices = new int[newSize - oldSize]; for (int i = 0, n = newSize - oldSize; i < n; i++) { changedIndices[i] = oldSize + i; } fireDbChildrenInserted(changedIndices, children.subList(oldSize, newSize)); } try { if ( rs != null ) rs.close(); } catch (SQLException e2) { throw new ArchitectException("database.rs.close.fail", e2); } } } |
|
select.onChange("handleEvent(''" + getId() + "'', ''onChange'', this.options[this.selectedIndex].value);"); | final String dashboardId = context.getDashboardConfig().getDashboardId(); select.onChange("handleEvent(''" + dashboardId + "'', ''" + getId() + "'', ''onChange'', this.options[this.selectedIndex].value);"); | public void drawInternal(DashboardContext context, StringBuffer output) { Map<String, String> data = getData(context.getWebContext()); Select select = new Select("dummy", size, true); //select.onChange("alert(''test'');"); select.onChange("handleEvent(''" + getId() + "'', ''onChange'', this.options[this.selectedIndex].value);"); for(String id:data.keySet()){ select.addOption(id, data.get(id)); } output.append(select.draw()); } |
getBody().run(context, output); | invokeBody(output); | public void doTag(XMLOutput output) throws Exception { Task task = getTask(); // setDynaBean( new ConvertingWrapDynaBean( task ) ); // if the task has an addText() Method method = MethodUtils.getAccessibleMethod( taskType, "addText", addTaskParamTypes ); if (method != null) { String text = getBodyText(); Object[] args = { text }; method.invoke(task, args); } else { getBody().run(context, output); } task.perform(); } |
return creationDate; | return creationDate != null ? (Date) creationDate.clone() : null; | public Date getCreationDate() { return creationDate; } |
if ( db.getSchemaVersion() < db.CURRENT_SCHEMA_VERSION ) { | int schemaVersion = db.getSchemaVersion(); if ( schemaVersion < db.CURRENT_SCHEMA_VERSION ) { | private boolean login( LoginDlg ld ) { boolean success = false; String user = ld.getUsername(); String passwd = ld.getPassword(); String dbName = ld.getDb(); log.debug( "Using configuration " + dbName ); settings.setConfiguration( dbName ); PVDatabase db = settings.getDatabase( dbName ); String sqldbName = db.getDbName(); log.debug( "Mysql DB name: " + sqldbName ); if ( sqldbName == null ) { JOptionPane.showMessageDialog( ld, "Could not find dbname for configuration " + db, "Configuration error", JOptionPane.ERROR_MESSAGE ); return false; } if ( ODMG.initODMG( user, passwd, db ) ) { log.debug( "Connection succesful!!!" ); // Login is succesfull // ld.setVisible( false ); success = true; } if ( db.getSchemaVersion() < db.CURRENT_SCHEMA_VERSION ) { String options[] = {"Proceed", "Exit Photovault"}; if ( JOptionPane.YES_OPTION == JOptionPane.showOptionDialog( ld, "The database was created with an older version of Photovault\n" + "Photovault will upgrade the database format before starting.", "Upgrade database", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, null ) ) { final SchemaUpdateAction updater = new SchemaUpdateAction( db ); SchemaUpdateStatusDlg statusDlg = new SchemaUpdateStatusDlg( null, true ); updater.addSchemaUpdateListener( statusDlg ); Thread upgradeThread = new Thread() { public void run() { updater.upgradeDatabase(); } }; upgradeThread.start(); statusDlg.setVisible( true ); success = true; } } return success; } |
if (bean instanceof Tag) { Tag tag = (Tag) bean; tag.setBody(getBody()); tag.setContext(getContext()); tag.setParent(getParent()); ((Tag) bean).doTag(output); return; } | public void doTag(XMLOutput output) throws Exception { // lets find any attributes that are not set and for ( Iterator iter = attributes.values().iterator(); iter.hasNext(); ) { Attribute attribute = (Attribute) iter.next(); String name = attribute.getName(); if ( ! setAttributesSet.contains( name ) ) { if ( attribute.isRequired() ) { throw new MissingAttributeException(name); } // lets get the default value Object value = null; Expression expression = attribute.getDefaultValue(); if ( expression != null ) { value = expression.evaluate(context); } // only set non-null values? if ( value != null ) { super.setAttribute(name, value); } } } invokeBody(output); // export the bean if required if ( var != null ) { context.setVariable(var, bean); } // now, I may invoke the 'execute' method if I have one if ( method != null ) { try { method.invoke( bean, emptyArgs ); } catch (IllegalAccessException e) { methodInvocationError(bean, method, e); } catch (IllegalArgumentException e) { methodInvocationError(bean, method, e); } catch (InvocationTargetException e) { // methodInvocationError(bean, method, e); Throwable inner = e.getTargetException(); if ( inner instanceof Exception ) { throw (Exception) inner; } else { throw new JellyException( inner ); } } } } |
|
System.out.println("applied changes:"+columnEditPanel.getColName().getText()); | private void makeDialog(SQLTable st, int colIdx) throws ArchitectException { if (editDialog != null) { columnEditPanel.setModel(st); columnEditPanel.selectColumn(colIdx); editDialog.setTitle("Column Properties of "+st.getName()); editDialog.setVisible(true); //editDialog.requestFocus(); } else { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout(12,12)); panel.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); columnEditPanel = new ColumnEditPanel(st, colIdx); panel.add(columnEditPanel, BorderLayout.CENTER); editDialog = ArchitectPanelBuilder.createArchitectPanelDialog( columnEditPanel, ArchitectFrame.getMainInstance(), "Column Properties of "+st.getName(), "OK", new AbstractAction(){ public void actionPerformed(ActionEvent e) { columnEditPanel.applyChanges();System.out.println("applied changes:"+columnEditPanel.getColName().getText()); EditColumnAction.this.putValue(SHORT_DESCRIPTION, "Editting "+columnEditPanel.getColName().getText() ); } },null); panel.setOpaque(true); editDialog.pack(); editDialog.setLocationRelativeTo(ArchitectFrame.getMainInstance()); editDialog.setVisible(true); } } |
|
System.out.println("applied changes:"+columnEditPanel.getColName().getText()); | public void actionPerformed(ActionEvent e) { columnEditPanel.applyChanges();System.out.println("applied changes:"+columnEditPanel.getColName().getText()); EditColumnAction.this.putValue(SHORT_DESCRIPTION, "Editting "+columnEditPanel.getColName().getText() ); } |
|
List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); int idx = tp.getSelectedColumnIndex(); try { if (idx < 0) idx = tp.getModel().getColumnsFolder().getChildCount(); } catch (ArchitectException e) { idx = 0; | if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN)) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); int idx = tp.getSelectedColumnIndex(); try { if (idx < 0) idx = tp.getModel().getColumnsFolder().getChildCount(); } catch (ArchitectException e) { idx = 0; } tp.getModel().addColumn(idx, new SQLColumn()); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); | public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); int idx = tp.getSelectedColumnIndex(); try { if (idx < 0) idx = tp.getModel().getColumnsFolder().getChildCount(); } catch (ArchitectException e) { idx = 0; } tp.getModel().addColumn(idx, new SQLColumn()); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } } |
tp.getModel().addColumn(idx, new SQLColumn()); | } else if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE)) { TreePath [] selections = dbt.getSelectionPaths(); logger.debug("selections length is: " + selections.length); if (selections.length != 1) { JOptionPane.showMessageDialog(dbt, "To indicate where you would like to insert a column, please select a single item."); } else { TreePath tp = selections[0]; SQLObject so = (SQLObject) tp.getLastPathComponent(); SQLTable st = null; int idx = 0; if (so instanceof SQLTable) { logger.debug("user clicked on table, so we shall try to add a column to the end of the table."); try { st = (SQLTable) so; idx = st.getColumnsFolder().getChildCount(); } catch (ArchitectException ex) { idx = 0; } logger.debug("SQLTable click -- idx set to: " + idx); } else if (so instanceof SQLColumn) { logger.debug("trying to determine insertion index for table."); SQLColumn sc = (SQLColumn) so; st = sc.getParentTable(); idx = st.getColumnIndex(sc); if (idx == -1) { logger.debug("did not find column, inserting at start of table."); idx = 0; } } else { idx = 0; } st.addColumn(idx, new SQLColumn()); } | public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); int idx = tp.getSelectedColumnIndex(); try { if (idx < 0) idx = tp.getModel().getColumnsFolder().getChildCount(); } catch (ArchitectException e) { idx = 0; } tp.getModel().addColumn(idx, new SQLColumn()); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } } |
JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } | } | public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); int idx = tp.getSelectedColumnIndex(); try { if (idx < 0) idx = tp.getModel().getColumnsFolder().getChildCount(); } catch (ArchitectException e) { idx = 0; } tp.getModel().addColumn(idx, new SQLColumn()); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } } |
FolderNode fn = (FolderNode) treeNode.getUserObject(); fn.removeAllPhotos(); | public void removeAllFromFolder( PhotoFolder f ) { addedToFolders.remove( f ); removedFromFolders.add( f ); // Remove the folder from the tree DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) folderNodes.get( f ); DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) treeNode.getParent(); // If this folder has no visible children remove it from the tree /* TODO: * THis is a bugfix to ensure that the folder is not removed from tree if * it has subfolders with photos. Test this before committing changes */ if ( treeNode.getChildCount() == 0 ) { int idx = parentNode.getIndex( treeNode ); parentNode.remove( treeNode ); int[] idxs = new int[1]; idxs[0] = idx; Object[] nodes = new Object[1]; nodes[0] = treeNode; treeModel.nodesWereRemoved( parentNode, idxs, nodes ); } else { // This folder has children that have photos in the model // Don't remove the flder but notify model that representation // should be changed treeModel.nodeChanged(treeNode); } } |
|
JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); | JPanel tt = new JPanel(new BorderLayout(12,12)); tt.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); | public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } } |
cp.add(editPanel, BorderLayout.CENTER); | tt.add(editPanel, BorderLayout.CENTER); tabbedPane.addTab("TableProperties",tt); | public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } } |
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); | JPanel mt = new JPanel(new BorderLayout(12,12)); mt.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); | public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } } |
mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { | mt.add(scrollpMap, BorderLayout.CENTER); tabbedPane.addTab("Column Mappings",mt); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { | public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } } |
editPanel.applyChanges(); d.setVisible(false); | public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } } |
|
buttonMapPanel.add(okMapButton); | buttonPanel.add(okButton); | public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } } |
JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { | JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { | public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } } |
editPanel.discardChanges(); d.setVisible(false); | public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } } |
|
buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); | buttonPanel.add(cancelButton); | public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } } |
d.setContentPane(tabbedPane); | d.getContentPane().add(buttonPanel, BorderLayout.SOUTH); d.getContentPane().add(tabbedPane, BorderLayout.CENTER); | public void actionPerformed(ActionEvent evt) { List selection = pp.getSelectedItems(); if (selection.size() < 1) { JOptionPane.showMessageDialog(pp, "Select a table (by clicking on it) and try again."); } else if (selection.size() > 1) { JOptionPane.showMessageDialog(pp, "You have selected multiple items, but you can only edit one at a time."); } else if (selection.get(0) instanceof TablePane) { TablePane tp = (TablePane) selection.get(0); JTabbedPane tabbedPane = new JTabbedPane(); final JDialog d = new JDialog(ArchitectFrame.getMainInstance(), "Table Properties"); // first tabbed Pane JPanel cp = new JPanel(new BorderLayout(12,12)); cp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final TableEditPanel editPanel = new TableEditPanel(tp.getModel()); cp.add(editPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton("Ok"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.applyChanges(); d.setVisible(false); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { editPanel.discardChanges(); d.setVisible(false); } }); buttonPanel.add(cancelButton); cp.add(buttonPanel, BorderLayout.SOUTH); tabbedPane.addTab("TableProperties",cp); // second tabbed Pane JPanel mcp = new JPanel(new BorderLayout(12,12)); mcp.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); // String[] columnNames = {"SourceDB", "Source Table", "Source Column", "Source Column Type", "Target Column", "Target Column Type"}; SQLTable tTable = (SQLTable)tp.getModel(); try { int colnum = tTable.getColumnsFolder().getChildCount(); for (int i=0;i<=(colnum-1);i++) { SQLColumn tCol = (SQLColumn) tTable.getColumn(i); String tColName = tCol.getName(); SQLColumn sCol= tCol.getSourceColumn(); String sColName = new String(); StringBuffer sTableName = new StringBuffer(); if(sCol != null){ sColName = sCol.getName(); SQLObject sParent = sCol.getParentTable(); while (sParent != null) { sTableName.append(sParent.getName()); } } } } catch (ArchitectException ae){ logger.debug( "Column problems"+ae); } JTable mapTable = new JTable(); JScrollPane scrollpMap = new JScrollPane(mapTable); mcp.add(scrollpMap,BorderLayout.NORTH); JPanel buttonMapPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okMapButton = new JButton("Ok"); okMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.applyChanges(); //d.setVisible(false); } }); buttonMapPanel.add(okMapButton); JButton cancelMapButton = new JButton("Cancel"); cancelMapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //editPanel.discardChanges(); //d.setVisible(false); } }); buttonMapPanel.add(cancelMapButton); mcp.add(buttonMapPanel, BorderLayout.SOUTH); tabbedPane.addTab("Column Mappings",mcp); d.setContentPane(tabbedPane); d.pack(); d.setVisible(true); } else { JOptionPane.showMessageDialog(pp, "The selected item type is not recognised"); } } |
void dropTableNoFail(Connection con, String tableName) throws SQLException { | private static void dropTableNoFail(Connection con, String tableName) throws SQLException { | void dropTableNoFail(Connection con, String tableName) throws SQLException { Statement stmt = null; try { stmt = con.createStatement(); stmt.executeUpdate("DROP TABLE "+tableName); } catch (SQLException e) { System.out.println("Ignoring SQLException. Assuming it means the table we tried to drop didn't exist."); e.printStackTrace(); } finally { if (stmt != null) stmt.close(); } } |
SQLDatabase mydb = new SQLDatabase(db.getDataSource()); Connection con = mydb.getConnection(); Statement stmt = con.createStatement(); dropTableNoFail(con, "SQL_COLUMN_TEST_1PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_3PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_0PK"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_1PK (\n" + " cow numeric(11) CONSTRAINT test1pk PRIMARY KEY,\n" + " moo varchar(10),\n" + " foo char(10))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_3PK (\n" + " cow numeric(11) NOT NULL,\n" + " moo varchar(10) NOT NULL,\n" + " foo char(10) NOT NULL,\n" + " CONSTRAINT test3pk PRIMARY KEY (cow, moo, foo))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_0PK (\n" + " cow numeric(11),\n" + " moo varchar(10),\n" + " foo char(10))"); | protected void setUp() throws Exception { super.setUp(); SQLDatabase mydb = new SQLDatabase(db.getDataSource()); Connection con = mydb.getConnection(); Statement stmt = con.createStatement(); dropTableNoFail(con, "SQL_COLUMN_TEST_1PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_3PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_0PK"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_1PK (\n" + " cow numeric(11) CONSTRAINT test1pk PRIMARY KEY,\n" + " moo varchar(10),\n" + " foo char(10))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_3PK (\n" + " cow numeric(11) NOT NULL,\n" + " moo varchar(10) NOT NULL,\n" + " foo char(10) NOT NULL,\n" + " CONSTRAINT test3pk PRIMARY KEY (cow, moo, foo))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_0PK (\n" + " cow numeric(11),\n" + " moo varchar(10),\n" + " foo char(10))"); table1pk = db.getTableByName("SQL_COLUMN_TEST_1PK"); table0pk = db.getTableByName("SQL_COLUMN_TEST_0PK"); table3pk = db.getTableByName("SQL_COLUMN_TEST_3PK"); stmt.close(); //mydb.disconnect(); FIXME: this should be uncommented when bug 1005 is fixed } |
|
stmt.close(); | protected void setUp() throws Exception { super.setUp(); SQLDatabase mydb = new SQLDatabase(db.getDataSource()); Connection con = mydb.getConnection(); Statement stmt = con.createStatement(); dropTableNoFail(con, "SQL_COLUMN_TEST_1PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_3PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_0PK"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_1PK (\n" + " cow numeric(11) CONSTRAINT test1pk PRIMARY KEY,\n" + " moo varchar(10),\n" + " foo char(10))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_3PK (\n" + " cow numeric(11) NOT NULL,\n" + " moo varchar(10) NOT NULL,\n" + " foo char(10) NOT NULL,\n" + " CONSTRAINT test3pk PRIMARY KEY (cow, moo, foo))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_0PK (\n" + " cow numeric(11),\n" + " moo varchar(10),\n" + " foo char(10))"); table1pk = db.getTableByName("SQL_COLUMN_TEST_1PK"); table0pk = db.getTableByName("SQL_COLUMN_TEST_0PK"); table3pk = db.getTableByName("SQL_COLUMN_TEST_3PK"); stmt.close(); //mydb.disconnect(); FIXME: this should be uncommented when bug 1005 is fixed } |
|
return getNewFname( photo.getShootTime(), strExtension ); | java.util.Date d = photo.getShootTime(); if ( d == null ) { d = new java.util.Date(); } return getNewFname( d, strExtension ); | public File getInstanceName( PhotoInfo photo, String strExtension ) { return getNewFname( photo.getShootTime(), strExtension ); } |
ApplicationConfigManager.checkAppNameAlreadyPresent(appForm.getName()); | public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { AccessController.checkAccess(context.getServiceContext(), ACL_EDIT_APPLICATIONS); ApplicationForm appForm = (ApplicationForm)actionForm; ApplicationConfig config = ApplicationConfigManager.getApplicationConfig( appForm.getApplicationId()); assert config != null; config.setName(appForm.getName()); config.setHost(appForm.getHost()); if(appForm.getPort() != null) config.setPort(new Integer(appForm.getPort())); config.setURL(appForm.getURL()); config.setUsername(appForm.getUsername()); final String password = appForm.getPassword(); if(!password.equals(ApplicationForm.FORM_PASSWORD)){ config.setPassword(password); } ApplicationConfigManager.updateApplication(config); UserActivityLogger.getInstance().logActivity( context.getUser().getUsername(), "Updated application "+"\""+config.getName()+"\""); return mapping.findForward(Forwards.SUCCESS); } |
|
textData.prepareMarkerInput(maybeInfo); | textData.prepareMarkerInput(maybeInfo,arg_distance); | private void processTextOnly(){ try { String fileName; int outputType; long maxDistance; HaploData textData; File OutputFile; File inputFile; //we use this boolean to keep track of the type of file we're processing (haps or ped) //false means haps, true means ped. boolean fileType = false; if(!this.arg_hapsfile.equals("")) { fileName = this.arg_hapsfile; fileType = false; } else { fileName = this.arg_pedfile; fileType = true; } inputFile = new File(fileName); if(!inputFile.exists()){ System.out.println("input file: " + fileName + " does not exist"); System.exit(1); } maxDistance = this.arg_distance * 1000; outputType = this.arg_output; switch(outputType){ case 1: OutputFile = new File(fileName + ".4GAMblocks"); break; case 2: OutputFile = new File(fileName + ".MJDblocks"); break; default: OutputFile = new File(fileName + ".SFSblocks"); break; } textData = new HaploData(); if(!fileType){ //read in haps file textData.prepareHapsInput(inputFile); } else { //read in ped file PedFile ped; Vector pedFileStrings; BufferedReader reader; String line; Vector result; boolean[] markerResultArray; ped = new PedFile(); pedFileStrings = new Vector(); reader = new BufferedReader(new FileReader(inputFile)); while((line = reader.readLine())!=null){ pedFileStrings.add(line); } ped.parse(pedFileStrings); result = ped.check(); if(this.arg_showCheck) { System.out.println("Data check results:\n" + "Name\tObsHET\tPredHET\tHWpval\t%Geno\tFamTrio\tMendErr\tRating"); for(int i=0;i<result.size();i++){ MarkerResult currentResult = (MarkerResult)result.get(i); System.out.println( currentResult.getName() +"\t"+ currentResult.getObsHet() +"\t"+ currentResult.getPredHet() +"\t"+ currentResult.getHWpvalue() +"\t"+ currentResult.getGenoPercent() +"\t"+ currentResult.getFamTrioNum() +"\t"+ currentResult.getMendErrNum()); } } markerResultArray = new boolean[ped.getNumMarkers()]; for (int i = 0; i < markerResultArray.length; i++){ if(((MarkerResult)result.get(i)).getRating() > 0) { markerResultArray[i] = true; } else { markerResultArray[i] = false; } } textData.linkageToChrom(markerResultArray,ped); } String name = fileName; String baseName = fileName.substring(0,name.length()-5); File maybeInfo = new File(baseName + ".info"); if (maybeInfo.exists()){ textData.prepareMarkerInput(maybeInfo); } textData.generateDPrimeTable(maxDistance); Haplotype[][] haplos; textData.guessBlocks(outputType); haplos = textData.generateHaplotypes(textData.blocks, 1); new TextMethods().saveHapsToText(orderHaps(haplos, textData), textData.getMultiDprime(), OutputFile); } catch(IOException e){} } |
final Dimension size = frame.getSize(); final int windowHeight = size.height; | if ( input.getItemCount() <= 0 ) return; final int windowHeight = frame.getSize().height; | public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ } |
final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { | int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if ( rowsPerSubMenu < 3 ) rowsPerSubMenu = 3; if (totalRows <= rowsPerSubMenu) { | public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ } |
JMenu subMenu = new JMenu("More"); | JMenu subMenu = new JMenu("More..."); parentMenu.add(subMenu); | public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ } |
int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { | while (input.getItemCount() > rowsPerSubMenu + 1) { | public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ } |
subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); | subMenu.add(item); if (subMenu.getItemCount() >= rowsPerSubMenu && input.getItemCount() > rowsPerSubMenu + 1 ) { | public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ } |
subMenu = new JMenu("More"); fudge = 1; | subMenu = new JMenu("More..."); parentMenu.add(subMenu); | public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ } |
if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } | public static void breakLongMenu(final Window frame, final JMenu input) { final Dimension size = frame.getSize(); final int windowHeight = size.height; final int totalRows = input.getItemCount(); final int preferredHeight = input.getItem(0).getPreferredSize().height; final int FUDGE = 3; // XXX find a better way to compute this... final int rowsPerSubMenu = (windowHeight/ preferredHeight) - FUDGE; if (totalRows < rowsPerSubMenu) { return; } JMenu parentMenu = input; JMenu subMenu = new JMenu("More"); int fudge = 0; while (input.getItemCount() > rowsPerSubMenu + fudge) { final JMenuItem item = input.getItem(rowsPerSubMenu); subMenu.add(item); int n = subMenu.getItemCount(); if (n >= rowsPerSubMenu) { parentMenu.add(subMenu); // Note that this removes it from the original menu! parentMenu = subMenu; subMenu = new JMenu("More"); fudge = 1; } } if (subMenu.getItemCount() > 0) { parentMenu.add(subMenu); } /** TODO: Resizing the main window does not change the height of the menu. * This is left as an exercise for the reader: * frame.addComponentListener(new ComponentAdapter() { * @Override * public void componentResized(ComponentEvent e) { * JMenu oldMenu = fileMenu; * // Loop over oldMenu, if JMenu, replace with its elements, recursively...! * ASUtils.breakLongMenu(fileMenu); * } * }); */ } |
|
if (BETA_VERSION > 0){ | if (BETA_VERSION > 0 && VERSION == uc.getNewVersion()){ | public UpdateDisplayDialog(HaploView h, String title, UpdateChecker uc) { super(h, title); JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); Font bigguns = new Font("Default", Font.PLAIN, 14); JTextArea announceArea = new JTextArea(); announceArea.setFont(bigguns); if (BETA_VERSION > 0){ announceArea.append("A newer BETA version of Haploview is available: " + uc.getNewVersion() + "beta" + uc.getNewBetaVersion() + "\n"); }else{ announceArea.append("A newer version of Haploview is available: " + uc.getNewVersion() + "\n"); } announceArea.append("\n" + WEBSITE_STRING + "\n"); announceArea.setAlignmentX(Component.CENTER_ALIGNMENT); announceArea.setEditable(false); announceArea.setOpaque(false); JPanel announcePanel = new JPanel(); announcePanel.add(announceArea); JScrollPane changeScroller = null; if (BETA_VERSION == 0){ try { JEditorPane changePane = new JEditorPane(); changePane.setEditable(false); changePane.setPage(new URL("http://www.broad.mit.edu/mpg/haploview/uc/changes.html")); changePane.setOpaque(false); changeScroller = new JScrollPane(changePane); changeScroller.setPreferredSize(new Dimension(250,150)); } catch(IOException ioe) { //if were here then we were able to check for an update, so well just show them a dialog //without listing the changes } } contents.add(announcePanel); if(changeScroller != null) { changeScroller.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel scrollHolder = new JPanel(); scrollHolder.add(changeScroller); contents.add(scrollHolder); } JButton okButton = new JButton("OK"); okButton.addActionListener(this); okButton.setAlignmentX(Component.CENTER_ALIGNMENT); contents.add(okButton); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); } |
logger.debug(e.getStackTrace()); | public final void run() { try { doStuff(); } catch (Exception e) { doStuffException = e; } SwingUtilities.invokeLater(new Runnable() { public void run() { try { cleanup(); if (nextProcess != null) { nextProcess.setCancelled(cancelled); new Thread(nextProcess).start(); } } catch (Exception e) { ASUtils.showExceptionDialog(cleanupExceptionMessage, e); } } }); } |
|
db.setDbName( "pc_testest"); Volume vol = new Volume( "testvolume", dbDir.getAbsolutePath() ); db.addVolume( vol ); | db.setInstanceType( PVDatabase.TYPE_EMBEDDED ); db.setEmbeddedDirectory( dbDir ); | public void testCreateDB() { File confFile = null; File dbDir = null; // Create an empty configuration file & volume directory try { confFile = File.createTempFile( "photovault_settings_", ".xml" ); confFile.delete(); dbDir = File.createTempFile( "photovault_test_volume", "" ); dbDir.delete(); dbDir.mkdir(); } catch (IOException ex) { ex.printStackTrace(); fail( ex.getMessage() ); } System.setProperty( "photovault.configfile", confFile.getAbsolutePath() ); PhotovaultSettings settings = PhotovaultSettings.getSettings(); PVDatabase db = new PVDatabase(); db.setDbName( "pc_testest"); Volume vol = new Volume( "testvolume", dbDir.getAbsolutePath() ); db.addVolume( vol ); settings.addDatabase( db ); settings.saveConfig(); db.createDatabase( "harri", "" ); // Verify that the database can be used by importing a file ODMG.initODMG( "harri", "", db ); File photoFile = new File( "testfiles/test1.jpg" ); PhotoInfo photo = null; try { photo = PhotoInfo.addToDB(photoFile); } catch (PhotoNotFoundException ex) { ex.printStackTrace(); fail( ex.getMessage() ); } photo.setPhotographer( "test" ); try { PhotoInfo photo2 = PhotoInfo.retrievePhotoInfo( photo.getUid() ); Thumbnail thumb = photo2.getThumbnail(); this.assertFalse( "Default thumbnail returned", thumb == Thumbnail.getDefaultThumbnail() ); } catch (PhotoNotFoundException ex) { fail( "Photo not found in database" ); } } |
MockJDBCResultSet rs = new MockJDBCResultSet(null, 2); rs.setColumnName(1, "TABLE_SCHEM"); rs.setColumnName(2, "TABLE_CATALOG"); | Map<String,String> schemas = new TreeMap<String,String>(); | public ResultSet getSchemas() throws SQLException { String catalogList = connection.getProperties().getProperty("catalogs"); MockJDBCResultSet rs = new MockJDBCResultSet(null, 2); rs.setColumnName(1, "TABLE_SCHEM"); rs.setColumnName(2, "TABLE_CATALOG"); if (getSchemaTerm() == null) { logger.debug("getSchemas: schemaTerm==null; returning empty result set"); } else if (getCatalogTerm() == null) { String schemaList = connection.getProperties().getProperty("schemas"); logger.debug("getSchemas: catalogTerm==null; schemaList="+schemaList); if (schemaList == null) throw new SQLException("Missing property: 'schemas'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, null); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+schName+"'"); } } else { logger.debug("getSchemas: database has catalogs and schemas!"); for (String catName : Arrays.asList(catalogList.split(","))) { String schemaList = connection.getProperties().getProperty("schemas."+catName); if (schemaList == null) throw new SQLException("Missing property: 'schemas."+catName+"'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, catName); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+catName+"'.'"+schName+"'"); } } } rs.beforeFirst(); return rs; } |
rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, null); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+schName+"'"); | schemas.put(schName, null); if (logger.isDebugEnabled()) logger.debug("getSchemas: put '"+schName+"'"); | public ResultSet getSchemas() throws SQLException { String catalogList = connection.getProperties().getProperty("catalogs"); MockJDBCResultSet rs = new MockJDBCResultSet(null, 2); rs.setColumnName(1, "TABLE_SCHEM"); rs.setColumnName(2, "TABLE_CATALOG"); if (getSchemaTerm() == null) { logger.debug("getSchemas: schemaTerm==null; returning empty result set"); } else if (getCatalogTerm() == null) { String schemaList = connection.getProperties().getProperty("schemas"); logger.debug("getSchemas: catalogTerm==null; schemaList="+schemaList); if (schemaList == null) throw new SQLException("Missing property: 'schemas'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, null); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+schName+"'"); } } else { logger.debug("getSchemas: database has catalogs and schemas!"); for (String catName : Arrays.asList(catalogList.split(","))) { String schemaList = connection.getProperties().getProperty("schemas."+catName); if (schemaList == null) throw new SQLException("Missing property: 'schemas."+catName+"'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, catName); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+catName+"'.'"+schName+"'"); } } } rs.beforeFirst(); return rs; } |
rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, catName); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+catName+"'.'"+schName+"'"); | schemas.put(schName, catName); if (logger.isDebugEnabled()) logger.debug("getSchemas: put '"+catName+"'.'"+schName+"'"); | public ResultSet getSchemas() throws SQLException { String catalogList = connection.getProperties().getProperty("catalogs"); MockJDBCResultSet rs = new MockJDBCResultSet(null, 2); rs.setColumnName(1, "TABLE_SCHEM"); rs.setColumnName(2, "TABLE_CATALOG"); if (getSchemaTerm() == null) { logger.debug("getSchemas: schemaTerm==null; returning empty result set"); } else if (getCatalogTerm() == null) { String schemaList = connection.getProperties().getProperty("schemas"); logger.debug("getSchemas: catalogTerm==null; schemaList="+schemaList); if (schemaList == null) throw new SQLException("Missing property: 'schemas'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, null); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+schName+"'"); } } else { logger.debug("getSchemas: database has catalogs and schemas!"); for (String catName : Arrays.asList(catalogList.split(","))) { String schemaList = connection.getProperties().getProperty("schemas."+catName); if (schemaList == null) throw new SQLException("Missing property: 'schemas."+catName+"'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, catName); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+catName+"'.'"+schName+"'"); } } } rs.beforeFirst(); return rs; } |
} MockJDBCResultSet rs = new MockJDBCResultSet(null, 2); rs.setColumnName(1, "TABLE_SCHEM"); rs.setColumnName(2, "TABLE_CATALOG"); for (Map.Entry<String,String> e : schemas.entrySet()) { rs.addRow(); rs.updateObject(1, e.getKey()); rs.updateObject(2, e.getValue()); | public ResultSet getSchemas() throws SQLException { String catalogList = connection.getProperties().getProperty("catalogs"); MockJDBCResultSet rs = new MockJDBCResultSet(null, 2); rs.setColumnName(1, "TABLE_SCHEM"); rs.setColumnName(2, "TABLE_CATALOG"); if (getSchemaTerm() == null) { logger.debug("getSchemas: schemaTerm==null; returning empty result set"); } else if (getCatalogTerm() == null) { String schemaList = connection.getProperties().getProperty("schemas"); logger.debug("getSchemas: catalogTerm==null; schemaList="+schemaList); if (schemaList == null) throw new SQLException("Missing property: 'schemas'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, null); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+schName+"'"); } } else { logger.debug("getSchemas: database has catalogs and schemas!"); for (String catName : Arrays.asList(catalogList.split(","))) { String schemaList = connection.getProperties().getProperty("schemas."+catName); if (schemaList == null) throw new SQLException("Missing property: 'schemas."+catName+"'"); for (String schName : Arrays.asList(schemaList.split(","))) { rs.addRow(); rs.updateObject(1, schName); rs.updateObject(2, catName); if (logger.isDebugEnabled()) logger.debug("getSchemas: added '"+catName+"'.'"+schName+"'"); } } } rs.beforeFirst(); return rs; } |
|
T.add(cancel, 2, 1); | T.add(cancel, 3, 1); | private PresentationObject getButtonsBelowTable(IWContext iwc) { Table T = new Table(); T.setCellpadding(0); T.setCellspacing(0); SubmitButton send,cancel; if (submitImage != null) { send = new SubmitButton(submitImage, "nl_send"); } else { send = new SubmitButton(iwrb.getLocalizedImageButton("subscribe", "Subscribe"), "nl_send"); } if (cancelImage != null) { cancel = new SubmitButton(cancelImage, "nl_stop"); } else { cancel = new SubmitButton(iwrb.getLocalizedImageButton("unsubscribe", "Unsubscribe"), "nl_stop"); } T.add(send,1,1); if (_showCancelImage) T.add(cancel, 2, 1); return T; } |
T.add(getButtonsBelowTable(iwc),1,row); | if(_submitBelowTopics) T.add(getButtonsBelowTable(iwc),1,row); | public void main(IWContext iwc) { //debugParameters(iwc); iwb = getBundle(iwc); core = iwc.getIWMainApplication().getCoreBundle(); iwrb = getResourceBundle(iwc); Table T = new Table(); T.setCellpaddingAndCellspacing(0); T.setColor(_bgColor); int row = 1; int categoryID = getCategoryId(); if (categoryID > 0) { processForm(iwc); topics = MailFinder.getInstance().getInstanceTopics(getICObjectInstanceID()); } if(iwc.hasEditPermission(this)){ T.add(getAdminView(iwc), 1, row); T.setAlignment(1, row++, "left"); } if (categoryID > 0 ){ if(topics!=null && !topics.isEmpty()) { T.add(getMailInputTable(iwc),1,row++); PresentationObject obj = null; switch (viewType) { case DROP: obj = getDropdownView(iwc); break; case CHECK: obj = getCheckBoxView(iwc); break; case SINGLE: obj = getCheckBoxView(iwc); break; } if ( obj != null ) T.add(obj,1,row); T.add(getButtonsBelowTable(iwc),1,row); } else{ T.add(iwrb.getLocalizedString("no_topic","Please create a topic"),1,row); } } else{ T.add(iwrb.getLocalizedString("no_category","Please create a category"),1,row); } Form F = new Form(); F.add(T); add(F); } |
if ((evt.getModifiers() & MouseEvent.BUTTON1_MASK) != 0 && evt.getClickCount() == 2) { | if ((evt.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) { | public void mouseClicked(MouseEvent evt) { if ((evt.getModifiers() & MouseEvent.BUTTON1_MASK) != 0 && evt.getClickCount() == 2) { TablePane tp = (TablePane) evt.getSource(); if (tp.isSelected()) { ArchitectFrame af = ArchitectFrame.getMainInstance(); int selectedColIndex = tp.getSelectedColumnIndex(); if (selectedColIndex == COLUMN_INDEX_NONE) { af.editTableAction.actionPerformed (new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "DoubleClick")); } else if (selectedColIndex >= 0) { af.editColumnAction.actionPerformed (new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "DoubleClick")); } } } } |
if (tp.isSelected()) { ArchitectFrame af = ArchitectFrame.getMainInstance(); int selectedColIndex = tp.getSelectedColumnIndex(); if (selectedColIndex == COLUMN_INDEX_NONE) { af.editTableAction.actionPerformed (new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "DoubleClick")); } else if (selectedColIndex >= 0) { af.editColumnAction.actionPerformed (new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "DoubleClick")); | if (evt.getClickCount() == 2) { if (tp.isSelected()) { ArchitectFrame af = ArchitectFrame.getMainInstance(); int selectedColIndex = tp.getSelectedColumnIndex(); if (selectedColIndex == COLUMN_INDEX_NONE) { af.editTableAction.actionPerformed (new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "DoubleClick")); } else if (selectedColIndex >= 0) { af.editColumnAction.actionPerformed (new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "DoubleClick")); } } } else { try { PlayPen pp = (PlayPen) tp.getPlayPen(); int clickCol = tp.pointToColumnIndex(evt.getPoint()); if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { pp.selectNone(); } tp.setSelected(true); tp.selectNone(); if (clickCol < tp.model.getColumns().size()) { tp.selectColumn(clickCol); } } catch (ArchitectException e) { logger.error("Exception converting point to column", e); | public void mouseClicked(MouseEvent evt) { if ((evt.getModifiers() & MouseEvent.BUTTON1_MASK) != 0 && evt.getClickCount() == 2) { TablePane tp = (TablePane) evt.getSource(); if (tp.isSelected()) { ArchitectFrame af = ArchitectFrame.getMainInstance(); int selectedColIndex = tp.getSelectedColumnIndex(); if (selectedColIndex == COLUMN_INDEX_NONE) { af.editTableAction.actionPerformed (new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "DoubleClick")); } else if (selectedColIndex >= 0) { af.editColumnAction.actionPerformed (new ActionEvent(tp, ActionEvent.ACTION_PERFORMED, "DoubleClick")); } } } } |
TablePane tp = (TablePane) evt.getSource(); | public void mousePressed(MouseEvent evt) { evt.getComponent().requestFocus(); if ((evt.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) { try { // table/column selection TablePane tp = (TablePane) evt.getComponent(); PlayPen pp = (PlayPen) tp.getPlayPen(); int clickCol = tp.pointToColumnIndex(evt.getPoint()); if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { pp.selectNone(); } tp.setSelected(true); tp.selectNone(); if (clickCol < tp.model.getColumns().size()) { tp.selectColumn(clickCol); } // dragging if (clickCol == COLUMN_INDEX_TITLE) { Point handle = getPlayPen().zoomPoint(new Point(evt.getPoint())); new PlayPen.FloatingTableListener(getPlayPen(), this, handle); } } catch (ArchitectException e) { logger.error("Exception converting point to column", e); } } maybeShowPopup(evt); } |
|
TablePane tp = (TablePane) evt.getComponent(); | public void mousePressed(MouseEvent evt) { evt.getComponent().requestFocus(); if ((evt.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) { try { // table/column selection TablePane tp = (TablePane) evt.getComponent(); PlayPen pp = (PlayPen) tp.getPlayPen(); int clickCol = tp.pointToColumnIndex(evt.getPoint()); if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { pp.selectNone(); } tp.setSelected(true); tp.selectNone(); if (clickCol < tp.model.getColumns().size()) { tp.selectColumn(clickCol); } // dragging if (clickCol == COLUMN_INDEX_TITLE) { Point handle = getPlayPen().zoomPoint(new Point(evt.getPoint())); new PlayPen.FloatingTableListener(getPlayPen(), this, handle); } } catch (ArchitectException e) { logger.error("Exception converting point to column", e); } } maybeShowPopup(evt); } |
|
int clickCol = tp.pointToColumnIndex(evt.getPoint()); if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { pp.selectNone(); } | int clickCol = tp.pointToColumnIndex(evt.getPoint()); | public void mousePressed(MouseEvent evt) { evt.getComponent().requestFocus(); if ((evt.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) { try { // table/column selection TablePane tp = (TablePane) evt.getComponent(); PlayPen pp = (PlayPen) tp.getPlayPen(); int clickCol = tp.pointToColumnIndex(evt.getPoint()); if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { pp.selectNone(); } tp.setSelected(true); tp.selectNone(); if (clickCol < tp.model.getColumns().size()) { tp.selectColumn(clickCol); } // dragging if (clickCol == COLUMN_INDEX_TITLE) { Point handle = getPlayPen().zoomPoint(new Point(evt.getPoint())); new PlayPen.FloatingTableListener(getPlayPen(), this, handle); } } catch (ArchitectException e) { logger.error("Exception converting point to column", e); } } maybeShowPopup(evt); } |
Point handle = getPlayPen().zoomPoint(new Point(evt.getPoint())); new PlayPen.FloatingTableListener(getPlayPen(), this, handle); } | Iterator it = getPlayPen().getSelectedTables().iterator(); logger.debug("event point: " + evt.getPoint()); logger.debug("zoomed event point: " + getPlayPen().zoomPoint(evt.getPoint())); while (it.hasNext()) { TablePane t3 = (TablePane)it.next(); logger.debug("(" + t3.getModel().getTableName() + ") zoomed selected table point: " + t3.getLocationOnScreen()); logger.debug("(" + t3.getModel().getTableName() + ") unzoomed selected table point: " + getPlayPen().unzoomPoint(t3.getLocationOnScreen())); Point clickedColumn = tp.getLocationOnScreen(); Point otherTable = t3.getLocationOnScreen(); Point handle = getPlayPen().zoomPoint(new Point(evt.getPoint())); logger.debug("(" + t3.getModel().getTableName() + ") translation x=" + (otherTable.getX() - clickedColumn.getX()) + ",y=" + (otherTable.getY() - clickedColumn.getY())); handle.translate((int)(clickedColumn.getX() - otherTable.getX()), (int) (clickedColumn.getY() - otherTable.getY())); new PlayPen.FloatingTableListener(getPlayPen(), t3, handle); } } | public void mousePressed(MouseEvent evt) { evt.getComponent().requestFocus(); if ((evt.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) { try { // table/column selection TablePane tp = (TablePane) evt.getComponent(); PlayPen pp = (PlayPen) tp.getPlayPen(); int clickCol = tp.pointToColumnIndex(evt.getPoint()); if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { pp.selectNone(); } tp.setSelected(true); tp.selectNone(); if (clickCol < tp.model.getColumns().size()) { tp.selectColumn(clickCol); } // dragging if (clickCol == COLUMN_INDEX_TITLE) { Point handle = getPlayPen().zoomPoint(new Point(evt.getPoint())); new PlayPen.FloatingTableListener(getPlayPen(), this, handle); } } catch (ArchitectException e) { logger.error("Exception converting point to column", e); } } maybeShowPopup(evt); } |
} catch ( Exception e ) { | } catch ( Throwable e ) { | public static void initODMG( String user, String passwd, PVDatabase dbDesc ) throws PhotovaultException { getODMGImplementation(); // Find the connection repository info ConnectionRepository cr = MetadataManager.getInstance().connectionRepository(); PBKey connKey = cr.getStandardPBKeyForJcdAlias( "pv" ); JdbcConnectionDescriptor connDesc = cr.getDescriptor( connKey ); // Set up the OJB connection with parameters from photovault.properties if ( dbDesc.getInstanceType() == PVDatabase.TYPE_EMBEDDED ) { connDesc.setDriver( "org.apache.derby.jdbc.EmbeddedDriver" ); connDesc.setDbms( "derby" ); connDesc.setSubProtocol( "derby" ); connDesc.setDbAlias( "photovault" ); File derbyDir = new File( dbDesc.getEmbeddedDirectory(), "derby" ); System.setProperty( "derby.system.home", derbyDir.getAbsolutePath() ); } else { // This is a MySQL database String dbhost = dbDesc.getDbHost(); String dbname = dbDesc.getDbName(); connDesc.setDbAlias( "//" + dbhost + "/" + dbname ); connDesc.setUserName( user ); connDesc.setPassWord( passwd ); connDesc.setDriver( "com.mysql.jdbc.Driver" ); connDesc.setDbms( "MySQL" ); connDesc.setSubProtocol( "mysql" ); } // Open the database connection db = odmg.newDatabase(); boolean success = false; try { log.debug( "Opening database" ); db.open( "pv#" + user + "#" + passwd, Database.OPEN_READ_WRITE ); log.debug( "Success!!!" ); } catch ( Exception e ) { log.error( "Failed to get connection: " + e.getMessage() ); e.printStackTrace(); } // Check whether the database was opened correctly try { PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(connKey); broker.beginTransaction(); Connection con = broker.serviceConnectionManager().getConnection(); broker.commitTransaction(); broker.close(); } catch (Exception ex) { /* Finding the real reason for the error needs a bit of guesswork: first lets find the original exception */ Throwable rootCause = ex; while ( rootCause.getCause() != null ) { rootCause = rootCause.getCause(); } log.error( rootCause.getMessage() ); if ( rootCause instanceof SQLException ) { if ( rootCause instanceof EmbedSQLException ) { /* We are using Derby, the problem is likely that another instance of the database has been started */ throw new PhotovaultException( "Cannot start database.\n" + "Do you have another instance of Photovault running?", rootCause ); } if ( dbDesc.getInstanceType() == PVDatabase.TYPE_SERVER ) { throw new PhotovaultException( "Cannot log in to MySQL database", rootCause ); } } throw new PhotovaultException( "Unknown error while starting database:\n" + rootCause.getMessage(), rootCause ); } // Test the connection by fetching something try { PhotoFolder folder = PhotoFolder.getRoot(); if ( folder != null ) { success = true; } else { log.error( "Could not open database connection" ); try { db.close(); } catch (ODMGException e ) { log.error( "Error closing database" ); } throw new PhotovaultException( "Unknown error while starting database:\n" ); } } catch ( Exception t ) { log.error( "Could not open database connection" ); log.error( t.getMessage() ); t.printStackTrace(); try { db.close(); } catch (ODMGException e ) { log.error( "Error closing database" ); } throw new PhotovaultException( "Unknown error while starting database:\n" + t.getMessage(), t ); } } |
throw new PhotovaultException( "Unknown error while starting database:\n" ); | public static void initODMG( String user, String passwd, PVDatabase dbDesc ) throws PhotovaultException { getODMGImplementation(); // Find the connection repository info ConnectionRepository cr = MetadataManager.getInstance().connectionRepository(); PBKey connKey = cr.getStandardPBKeyForJcdAlias( "pv" ); JdbcConnectionDescriptor connDesc = cr.getDescriptor( connKey ); // Set up the OJB connection with parameters from photovault.properties if ( dbDesc.getInstanceType() == PVDatabase.TYPE_EMBEDDED ) { connDesc.setDriver( "org.apache.derby.jdbc.EmbeddedDriver" ); connDesc.setDbms( "derby" ); connDesc.setSubProtocol( "derby" ); connDesc.setDbAlias( "photovault" ); File derbyDir = new File( dbDesc.getEmbeddedDirectory(), "derby" ); System.setProperty( "derby.system.home", derbyDir.getAbsolutePath() ); } else { // This is a MySQL database String dbhost = dbDesc.getDbHost(); String dbname = dbDesc.getDbName(); connDesc.setDbAlias( "//" + dbhost + "/" + dbname ); connDesc.setUserName( user ); connDesc.setPassWord( passwd ); connDesc.setDriver( "com.mysql.jdbc.Driver" ); connDesc.setDbms( "MySQL" ); connDesc.setSubProtocol( "mysql" ); } // Open the database connection db = odmg.newDatabase(); boolean success = false; try { log.debug( "Opening database" ); db.open( "pv#" + user + "#" + passwd, Database.OPEN_READ_WRITE ); log.debug( "Success!!!" ); } catch ( Exception e ) { log.error( "Failed to get connection: " + e.getMessage() ); e.printStackTrace(); } // Check whether the database was opened correctly try { PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(connKey); broker.beginTransaction(); Connection con = broker.serviceConnectionManager().getConnection(); broker.commitTransaction(); broker.close(); } catch (Exception ex) { /* Finding the real reason for the error needs a bit of guesswork: first lets find the original exception */ Throwable rootCause = ex; while ( rootCause.getCause() != null ) { rootCause = rootCause.getCause(); } log.error( rootCause.getMessage() ); if ( rootCause instanceof SQLException ) { if ( rootCause instanceof EmbedSQLException ) { /* We are using Derby, the problem is likely that another instance of the database has been started */ throw new PhotovaultException( "Cannot start database.\n" + "Do you have another instance of Photovault running?", rootCause ); } if ( dbDesc.getInstanceType() == PVDatabase.TYPE_SERVER ) { throw new PhotovaultException( "Cannot log in to MySQL database", rootCause ); } } throw new PhotovaultException( "Unknown error while starting database:\n" + rootCause.getMessage(), rootCause ); } // Test the connection by fetching something try { PhotoFolder folder = PhotoFolder.getRoot(); if ( folder != null ) { success = true; } else { log.error( "Could not open database connection" ); try { db.close(); } catch (ODMGException e ) { log.error( "Error closing database" ); } throw new PhotovaultException( "Unknown error while starting database:\n" ); } } catch ( Exception t ) { log.error( "Could not open database connection" ); log.error( t.getMessage() ); t.printStackTrace(); try { db.close(); } catch (ODMGException e ) { log.error( "Error closing database" ); } throw new PhotovaultException( "Unknown error while starting database:\n" + t.getMessage(), t ); } } |
|
} catch (ODMGException e ) { | } catch ( Exception e ) { | public static void initODMG( String user, String passwd, PVDatabase dbDesc ) throws PhotovaultException { getODMGImplementation(); // Find the connection repository info ConnectionRepository cr = MetadataManager.getInstance().connectionRepository(); PBKey connKey = cr.getStandardPBKeyForJcdAlias( "pv" ); JdbcConnectionDescriptor connDesc = cr.getDescriptor( connKey ); // Set up the OJB connection with parameters from photovault.properties if ( dbDesc.getInstanceType() == PVDatabase.TYPE_EMBEDDED ) { connDesc.setDriver( "org.apache.derby.jdbc.EmbeddedDriver" ); connDesc.setDbms( "derby" ); connDesc.setSubProtocol( "derby" ); connDesc.setDbAlias( "photovault" ); File derbyDir = new File( dbDesc.getEmbeddedDirectory(), "derby" ); System.setProperty( "derby.system.home", derbyDir.getAbsolutePath() ); } else { // This is a MySQL database String dbhost = dbDesc.getDbHost(); String dbname = dbDesc.getDbName(); connDesc.setDbAlias( "//" + dbhost + "/" + dbname ); connDesc.setUserName( user ); connDesc.setPassWord( passwd ); connDesc.setDriver( "com.mysql.jdbc.Driver" ); connDesc.setDbms( "MySQL" ); connDesc.setSubProtocol( "mysql" ); } // Open the database connection db = odmg.newDatabase(); boolean success = false; try { log.debug( "Opening database" ); db.open( "pv#" + user + "#" + passwd, Database.OPEN_READ_WRITE ); log.debug( "Success!!!" ); } catch ( Exception e ) { log.error( "Failed to get connection: " + e.getMessage() ); e.printStackTrace(); } // Check whether the database was opened correctly try { PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(connKey); broker.beginTransaction(); Connection con = broker.serviceConnectionManager().getConnection(); broker.commitTransaction(); broker.close(); } catch (Exception ex) { /* Finding the real reason for the error needs a bit of guesswork: first lets find the original exception */ Throwable rootCause = ex; while ( rootCause.getCause() != null ) { rootCause = rootCause.getCause(); } log.error( rootCause.getMessage() ); if ( rootCause instanceof SQLException ) { if ( rootCause instanceof EmbedSQLException ) { /* We are using Derby, the problem is likely that another instance of the database has been started */ throw new PhotovaultException( "Cannot start database.\n" + "Do you have another instance of Photovault running?", rootCause ); } if ( dbDesc.getInstanceType() == PVDatabase.TYPE_SERVER ) { throw new PhotovaultException( "Cannot log in to MySQL database", rootCause ); } } throw new PhotovaultException( "Unknown error while starting database:\n" + rootCause.getMessage(), rootCause ); } // Test the connection by fetching something try { PhotoFolder folder = PhotoFolder.getRoot(); if ( folder != null ) { success = true; } else { log.error( "Could not open database connection" ); try { db.close(); } catch (ODMGException e ) { log.error( "Error closing database" ); } throw new PhotovaultException( "Unknown error while starting database:\n" ); } } catch ( Exception t ) { log.error( "Could not open database connection" ); log.error( t.getMessage() ); t.printStackTrace(); try { db.close(); } catch (ODMGException e ) { log.error( "Error closing database" ); } throw new PhotovaultException( "Unknown error while starting database:\n" + t.getMessage(), t ); } } |
if ( !success ) { throw new PhotovaultException( "Unknown exception while starting database" ); } | public static void initODMG( String user, String passwd, PVDatabase dbDesc ) throws PhotovaultException { getODMGImplementation(); // Find the connection repository info ConnectionRepository cr = MetadataManager.getInstance().connectionRepository(); PBKey connKey = cr.getStandardPBKeyForJcdAlias( "pv" ); JdbcConnectionDescriptor connDesc = cr.getDescriptor( connKey ); // Set up the OJB connection with parameters from photovault.properties if ( dbDesc.getInstanceType() == PVDatabase.TYPE_EMBEDDED ) { connDesc.setDriver( "org.apache.derby.jdbc.EmbeddedDriver" ); connDesc.setDbms( "derby" ); connDesc.setSubProtocol( "derby" ); connDesc.setDbAlias( "photovault" ); File derbyDir = new File( dbDesc.getEmbeddedDirectory(), "derby" ); System.setProperty( "derby.system.home", derbyDir.getAbsolutePath() ); } else { // This is a MySQL database String dbhost = dbDesc.getDbHost(); String dbname = dbDesc.getDbName(); connDesc.setDbAlias( "//" + dbhost + "/" + dbname ); connDesc.setUserName( user ); connDesc.setPassWord( passwd ); connDesc.setDriver( "com.mysql.jdbc.Driver" ); connDesc.setDbms( "MySQL" ); connDesc.setSubProtocol( "mysql" ); } // Open the database connection db = odmg.newDatabase(); boolean success = false; try { log.debug( "Opening database" ); db.open( "pv#" + user + "#" + passwd, Database.OPEN_READ_WRITE ); log.debug( "Success!!!" ); } catch ( Exception e ) { log.error( "Failed to get connection: " + e.getMessage() ); e.printStackTrace(); } // Check whether the database was opened correctly try { PersistenceBroker broker = PersistenceBrokerFactory.createPersistenceBroker(connKey); broker.beginTransaction(); Connection con = broker.serviceConnectionManager().getConnection(); broker.commitTransaction(); broker.close(); } catch (Exception ex) { /* Finding the real reason for the error needs a bit of guesswork: first lets find the original exception */ Throwable rootCause = ex; while ( rootCause.getCause() != null ) { rootCause = rootCause.getCause(); } log.error( rootCause.getMessage() ); if ( rootCause instanceof SQLException ) { if ( rootCause instanceof EmbedSQLException ) { /* We are using Derby, the problem is likely that another instance of the database has been started */ throw new PhotovaultException( "Cannot start database.\n" + "Do you have another instance of Photovault running?", rootCause ); } if ( dbDesc.getInstanceType() == PVDatabase.TYPE_SERVER ) { throw new PhotovaultException( "Cannot log in to MySQL database", rootCause ); } } throw new PhotovaultException( "Unknown error while starting database:\n" + rootCause.getMessage(), rootCause ); } // Test the connection by fetching something try { PhotoFolder folder = PhotoFolder.getRoot(); if ( folder != null ) { success = true; } else { log.error( "Could not open database connection" ); try { db.close(); } catch (ODMGException e ) { log.error( "Error closing database" ); } throw new PhotovaultException( "Unknown error while starting database:\n" ); } } catch ( Exception t ) { log.error( "Could not open database connection" ); log.error( t.getMessage() ); t.printStackTrace(); try { db.close(); } catch (ODMGException e ) { log.error( "Error closing database" ); } throw new PhotovaultException( "Unknown error while starting database:\n" + t.getMessage(), t ); } } |
|
public Individual(int numLines) { this.markers = new Vector(numLines); this.zeroed = new boolean[numLines]; | public Individual(int numMarkers) { markersa = new byte[numMarkers]; markersb = new byte[numMarkers]; this.zeroed = new boolean[numMarkers]; | public Individual(int numLines) { this.markers = new Vector(numLines); //this.zeroed = new Vector(numLines); this.zeroed = new boolean[numLines]; this.currMarker = 0; } |
public void addMarker(byte[] marker){ this.markers.add(marker); this.zeroed[currMarker] = false; this.currMarker++; if (!(marker[0] == 0 || marker[1] == 0)){ | public void addMarker(byte markera, byte markerb) { markersa[currMarker] = markera; markersb[currMarker] = markerb; zeroed[currMarker] = false; currMarker++; if (!(markera == 0 || markerb == 0)){ | public void addMarker(byte[] marker){ this.markers.add(marker); //this.zeroed.add(new Boolean(false)); this.zeroed[currMarker] = false; this.currMarker++; if (!(marker[0] == 0 || marker[1] == 0)){ numGoodMarkers++; } } |
return numGoodMarkers/markers.size(); | return numGoodMarkers/markersa.length; | public double getGenoPC(){ return numGoodMarkers/markers.size(); } |
return markers; | return null; | public Vector getMarkers() { return markers; } |
return this.markers.size(); | return this.markersa.length; | public int getNumMarkers(){ return this.markers.size(); } |
public void setMarkers(Vector m){ markers = m; | public void setMarkers(byte[] ma, byte[] mb){ markersa = ma; markersb = mb; | public void setMarkers(Vector m){ markers = m; } |
throw new JellyException(e, columnNumber, lineNumber); | throw new JellyException(e, fileName, elementName, columnNumber, lineNumber); | protected void handleException(Exception e) throws Exception { log.error( "Caught exception: " + e, e ); throw new JellyException(e, columnNumber, lineNumber); } |
configureTagScript(script); | protected TagScript createStaticTag( final String namespaceURI, final String localName, final String qName, Attributes list) throws SAXException { try { StaticTag tag = new StaticTag( namespaceURI, localName, qName ); StaticTagScript script = new StaticTagScript( new TagFactory() { public Tag createTag(String name, Attributes attributes) { return new StaticTag( namespaceURI, localName, qName ); } } ); // now iterate through through the expressions int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeName = list.getLocalName(i); String attributeValue = list.getValue(i); Expression expression = CompositeExpression.parse( attributeValue, getExpressionFactory() ); script.addAttribute(attributeName, expression); } return script; } catch (Exception e) { log.warn( "Could not create static tag for URI: " + namespaceURI + " tag name: " + localName, e); throw createSAXException(e); } } |
|
localName, | script, | protected TagScript createTag( String namespaceURI, String localName, Attributes list) throws SAXException { try { // use the URI to load a taglib TagLibrary taglib = context.getTagLibrary(namespaceURI); if (taglib == null) { if (namespaceURI != null && namespaceURI.startsWith("jelly:")) { String uri = namespaceURI.substring(6); // try to find the class on the claspath try { Class taglibClass = getClassLoader().loadClass(uri); taglib = (TagLibrary) taglibClass.newInstance(); context.registerTagLibrary(namespaceURI, taglib); } catch (ClassNotFoundException e) { log.warn("Could not load class: " + uri + " so disabling the taglib"); } } } if (taglib != null) { TagScript script = taglib.createTagScript(localName, list); if ( script != null ) { // clone the attributes to keep them around after this parse script.setSaxAttributes(new AttributesImpl(list)); // now iterate through through the expressions int size = list.getLength(); for (int i = 0; i < size; i++) { String attributeName = list.getLocalName(i); String attributeValue = list.getValue(i); Expression expression = taglib.createExpression( getExpressionFactory(), localName, attributeName, attributeValue); if (expression == null) { expression = createConstantExpression(localName, attributeName, attributeValue); } script.addAttribute(attributeName, expression); } } return script; } return null; } catch (Exception e) { log.warn( "Could not create taglib or URI: " + namespaceURI + " tag name: " + localName, e); throw createSAXException(e); } } |
TagScript parentTagScript = tagScript; tagScript = createTag(namespaceURI, localName, list); if (tagScript == null) { tagScript = createStaticTag(namespaceURI, localName, qName, list); | TagScript newTagScript = createTag(namespaceURI, localName, list); if (newTagScript == null) { newTagScript = createStaticTag(namespaceURI, localName, qName, list); | public void startElement( String namespaceURI, String localName, String qName, Attributes list) throws SAXException { try { // add check to ensure namespace URI is "" for no namespace if ( namespaceURI == null ) { namespaceURI = ""; } // if this is a tag then create a script to run it // otherwise pass the text to the current body TagScript parentTagScript = tagScript; tagScript = createTag(namespaceURI, localName, list); if (tagScript == null) { tagScript = createStaticTag(namespaceURI, localName, qName, list); } tagScriptStack.add(tagScript); if (tagScript != null) { // set parent relationship... tagScript.setParent(parentTagScript); // set the namespace Map if ( elementNamespaces != null ) { tagScript.setNamespacesMap( elementNamespaces ); elementNamespaces = null; } // set the line number details if ( locator != null ) { tagScript.setLocator(locator); } // sets the file name element names tagScript.setFileName(fileName); tagScript.setElementName(qName); tagScript.setLocalName(localName); if (textBuffer.length() > 0) { addTextScript(textBuffer.toString()); textBuffer.setLength(0); } script.addScript(tagScript); // start a new body scriptStack.push(script); script = new ScriptBlock(); tagScript.setTagBody(script); } else { // XXXX: might wanna handle empty elements later... textBuffer.append("<"); textBuffer.append(qName); int size = list.getLength(); for (int i = 0; i < size; i++) { textBuffer.append(" "); textBuffer.append(list.getQName(i)); textBuffer.append("="); textBuffer.append("\""); textBuffer.append(list.getValue(i)); textBuffer.append("\""); } textBuffer.append(">"); } } catch (SAXException e) { throw e; } catch (Exception e) { log.error( "Caught exception: " + e, e ); throw new SAXException( "Runtime Exception: " + e, e ); } } |
tagScript.setParent(parentTagScript); if ( elementNamespaces != null ) { tagScript.setNamespacesMap( elementNamespaces ); elementNamespaces = null; } | public void startElement( String namespaceURI, String localName, String qName, Attributes list) throws SAXException { try { // add check to ensure namespace URI is "" for no namespace if ( namespaceURI == null ) { namespaceURI = ""; } // if this is a tag then create a script to run it // otherwise pass the text to the current body TagScript parentTagScript = tagScript; tagScript = createTag(namespaceURI, localName, list); if (tagScript == null) { tagScript = createStaticTag(namespaceURI, localName, qName, list); } tagScriptStack.add(tagScript); if (tagScript != null) { // set parent relationship... tagScript.setParent(parentTagScript); // set the namespace Map if ( elementNamespaces != null ) { tagScript.setNamespacesMap( elementNamespaces ); elementNamespaces = null; } // set the line number details if ( locator != null ) { tagScript.setLocator(locator); } // sets the file name element names tagScript.setFileName(fileName); tagScript.setElementName(qName); tagScript.setLocalName(localName); if (textBuffer.length() > 0) { addTextScript(textBuffer.toString()); textBuffer.setLength(0); } script.addScript(tagScript); // start a new body scriptStack.push(script); script = new ScriptBlock(); tagScript.setTagBody(script); } else { // XXXX: might wanna handle empty elements later... textBuffer.append("<"); textBuffer.append(qName); int size = list.getLength(); for (int i = 0; i < size; i++) { textBuffer.append(" "); textBuffer.append(list.getQName(i)); textBuffer.append("="); textBuffer.append("\""); textBuffer.append(list.getValue(i)); textBuffer.append("\""); } textBuffer.append(">"); } } catch (SAXException e) { throw e; } catch (Exception e) { log.error( "Caught exception: " + e, e ); throw new SAXException( "Runtime Exception: " + e, e ); } } |
|
addComponentListener(new ResizeListener()); | public HaploView(){ try{ fc = new JFileChooser(System.getProperty("user.dir")); }catch(NullPointerException n){ try{ UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); fc = new JFileChooser(System.getProperty("user.dir")); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }catch(Exception e){ } } //menu setup JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenuItem menuItem; //file menu JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); menuItem = new JMenuItem(READ_GENOTYPES); setAccelerator(menuItem, 'O', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /* viewGenotypesItem = new JMenuItem(VIEW_GENOTYPES); viewGenotypesItem.addActionListener(this); //viewGenotypesItem.setEnabled(false); fileMenu.add(viewGenotypesItem); */ readMarkerItem = new JMenuItem(READ_MARKERS); setAccelerator(readMarkerItem, 'I', false); readMarkerItem.addActionListener(this); readMarkerItem.setEnabled(false); fileMenu.add(readMarkerItem); analysisItem = new JMenuItem(READ_ANALYSIS_TRACK); setAccelerator(analysisItem, 'A', false); analysisItem.addActionListener(this); analysisItem.setEnabled(false); fileMenu.add(analysisItem); blocksItem = new JMenuItem(READ_BLOCKS_FILE); setAccelerator(blocksItem, 'B', false); blocksItem.addActionListener(this); blocksItem.setEnabled(false); fileMenu.add(blocksItem); /* viewMarkerItem = new JMenuItem(VIEW_MARKERS); viewMarkerItem.addActionListener(this); //viewMarkerItem.setEnabled(false); fileMenu.add(viewMarkerItem); */ fileMenu.addSeparator(); exportMenuItems = new JMenuItem[exportItems.length]; for (int i = 0; i < exportItems.length; i++) { exportMenuItems[i] = new JMenuItem(exportItems[i]); exportMenuItems[i].addActionListener(this); exportMenuItems[i].setEnabled(false); fileMenu.add(exportMenuItems[i]); } fileMenu.addSeparator(); fileMenu.setMnemonic(KeyEvent.VK_F); menuItem = new JMenuItem("Quit"); setAccelerator(menuItem, 'Q', false); menuItem.addActionListener(this); fileMenu.add(menuItem); /// display menu JMenu displayMenu = new JMenu("Display"); displayMenu.setMnemonic(KeyEvent.VK_D); menuBar.add(displayMenu); ButtonGroup group = new ButtonGroup(); viewMenuItems = new JRadioButtonMenuItem[viewItems.length]; for (int i = 0; i < viewItems.length; i++) { viewMenuItems[i] = new JRadioButtonMenuItem(viewItems[i], i == 0); viewMenuItems[i].addActionListener(this); KeyStroke ks = KeyStroke.getKeyStroke('1' + i, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); viewMenuItems[i].setAccelerator(ks); displayMenu.add(viewMenuItems[i]); viewMenuItems[i].setEnabled(false); group.add(viewMenuItems[i]); } displayMenu.addSeparator(); //a submenu ButtonGroup zg = new ButtonGroup(); JMenu zoomMenu = new JMenu("LD zoom"); zoomMenu.setMnemonic(KeyEvent.VK_Z); zoomMenuItems = new JRadioButtonMenuItem[zoomItems.length]; for (int i = 0; i < zoomItems.length; i++){ zoomMenuItems[i] = new JRadioButtonMenuItem(zoomItems[i], i==0); zoomMenuItems[i].addActionListener(this); zoomMenuItems[i].setActionCommand("zoom" + i); zoomMenu.add(zoomMenuItems[i]); zg.add(zoomMenuItems[i]); } displayMenu.add(zoomMenu); //another submenu ButtonGroup cg = new ButtonGroup(); JMenu colorMenu = new JMenu("LD color scheme"); colorMenu.setMnemonic(KeyEvent.VK_C); colorMenuItems = new JRadioButtonMenuItem[colorItems.length]; for (int i = 0; i< colorItems.length; i++){ colorMenuItems[i] = new JRadioButtonMenuItem(colorItems[i],i==0); colorMenuItems[i].addActionListener(this); colorMenuItems[i].setActionCommand("color" + i); colorMenu.add(colorMenuItems[i]); cg.add(colorMenuItems[i]); } displayMenu.add(colorMenu); //analysis menu JMenu analysisMenu = new JMenu("Analysis"); analysisMenu.setMnemonic(KeyEvent.VK_A); menuBar.add(analysisMenu); //a submenu ButtonGroup bg = new ButtonGroup(); JMenu blockMenu = new JMenu("Define Blocks"); blockMenu.setMnemonic(KeyEvent.VK_B); blockMenuItems = new JRadioButtonMenuItem[blockItems.length]; for (int i = 0; i < blockItems.length; i++){ blockMenuItems[i] = new JRadioButtonMenuItem(blockItems[i], i==0); blockMenuItems[i].addActionListener(this); blockMenuItems[i].setActionCommand("block" + i); blockMenuItems[i].setEnabled(false); blockMenu.add(blockMenuItems[i]); bg.add(blockMenuItems[i]); } analysisMenu.add(blockMenu); clearBlocksItem = new JMenuItem(CLEAR_BLOCKS); setAccelerator(clearBlocksItem, 'C', false); clearBlocksItem.addActionListener(this); clearBlocksItem.setEnabled(false); analysisMenu.add(clearBlocksItem); JMenuItem customizeBlocksItem = new JMenuItem(CUST_BLOCKS); customizeBlocksItem.addActionListener(this); analysisMenu.add(customizeBlocksItem); //color key keyMenu = new JMenu("Key"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(keyMenu); /** NEEDS FIXING helpMenu = new JMenu("Help"); menuBar.add(Box.createHorizontalGlue()); menuBar.add(helpMenu); menuItem = new JMenuItem("Tutorial"); menuItem.addActionListener(this); helpMenu.add(menuItem); **/ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); addComponentListener(new ResizeListener()); } |
|
dPrimeDisplay.refresh(); | public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command == READ_GENOTYPES){ ReadDataDialog readDialog = new ReadDataDialog("Open new data", this); readDialog.pack(); readDialog.setVisible(true); } else if (command == READ_MARKERS){ //JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); fc.setSelectedFile(new File("")); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { readMarkers(fc.getSelectedFile(),null); } }else if (command == READ_ANALYSIS_TRACK){ fc.setSelectedFile(new File("")); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION){ readAnalysisFile(fc.getSelectedFile()); } }else if (command == READ_BLOCKS_FILE){ fc.setSelectedFile(new File("")); if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION){ readBlocksFile(fc.getSelectedFile()); } }else if (command == CUST_BLOCKS){ TweakBlockDefsDialog tweakDialog = new TweakBlockDefsDialog("Customize Blocks", this); tweakDialog.pack(); tweakDialog.setVisible(true); }else if (command == CLEAR_BLOCKS){ changeBlocks(BLOX_NONE); //blockdef clauses }else if (command.startsWith("block")){ int method = Integer.valueOf(command.substring(5)).intValue(); changeBlocks(method); /*for (int i = 1; i < colorMenuItems.length; i++){ if (method+1 == i){ colorMenuItems[i].setEnabled(true); }else{ colorMenuItems[i].setEnabled(false); } } colorMenuItems[0].setSelected(true);*/ //zooming clauses }else if (command.startsWith("zoom")){ dPrimeDisplay.zoom(Integer.valueOf(command.substring(4)).intValue()); //coloring clauses }else if (command.startsWith("color")){ currentScheme = Integer.valueOf(command.substring(5)).intValue()+1; dPrimeDisplay.colorDPrime(currentScheme); dPrimeDisplay.refresh(); changeKey(currentScheme); //exporting clauses }else if (command == EXPORT_PNG){ export(tabs.getSelectedIndex(), PNG_MODE, 0, Chromosome.getSize()); }else if (command == EXPORT_TEXT){ export(tabs.getSelectedIndex(), TXT_MODE, 0, Chromosome.getSize()); }else if (command == EXPORT_OPTIONS){ ExportDialog exDialog = new ExportDialog(this); exDialog.pack(); exDialog.setVisible(true); }else if (command == "Select All"){ checkPanel.selectAll(); }else if (command == "Rescore Markers"){ String cut = cdc.hwcut.getText(); if (cut.equals("")){ cut = "0"; } CheckData.hwCut = Double.parseDouble(cut); cut = cdc.genocut.getText(); if (cut.equals("")){ cut="0"; } CheckData.failedGenoCut = Integer.parseInt(cut); cut = cdc.mendcut.getText(); if (cut.equals("")){ cut="0"; } CheckData.numMendErrCut = Integer.parseInt(cut); cut = cdc.mafcut.getText(); if (cut.equals("")){ cut="0"; } CheckData.mafCut = Double.parseDouble(cut); checkPanel.redoRatings(); }else if (command == "Tutorial"){ showHelp(); } else if (command == "Quit"){ quit(); } else { for (int i = 0; i < viewItems.length; i++) { if (command == viewItems[i]) tabs.setSelectedIndex(i); } } } |
|
if(applicationId != null){ request.setAttribute(RequestAttributes.NAV_CURRENT_PAGE, "Edit Cluster"); }else{ request.setAttribute(RequestAttributes.NAV_CURRENT_PAGE, "Add Cluster"); } | public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { AccessController.canAccess(context.getUser(), ACL_ADD_APPLICATIONS); ApplicationClusterForm clusterForm = (ApplicationClusterForm)actionForm; String applicationId = clusterForm.getApplicationId(); List selectedApplications = null; if(applicationId != null){ ApplicationConfig clusterConfig = ApplicationConfigManager.getApplicationConfig(applicationId); assert clusterConfig.isCluster(); clusterForm.setName(clusterConfig.getName()); selectedApplications = clusterConfig.getApplications(); }else{ selectedApplications = new LinkedList(); } List applications = new LinkedList(); for(Iterator it=ApplicationConfigManager.getApplications().iterator(); it.hasNext();){ ApplicationConfig config = (ApplicationConfig)it.next(); if(!config.isCluster() && !selectedApplications.contains(config)){ applications.add(config); } } request.setAttribute("applications", applications); request.setAttribute("selectedApplications", selectedApplications); return mapping.findForward(Forwards.SUCCESS); } |
|
return; | public void drop(DropTargetDropEvent dtde) { TablePane tp = (TablePane) dtde.getDropTargetContext().getComponent(); logger.debug("Drop target drop event on "+tp.getName()+": "+dtde); Transferable t = dtde.getTransferable(); DataFlavor importFlavor = bestImportFlavor(tp, t.getTransferDataFlavors()); if (importFlavor == null) { dtde.rejectDrop(); tp.setInsertionPoint(COLUMN_INDEX_NONE); } else { try { DBTree dbtree = ArchitectFrame.getMainInstance().dbTree; // XXX: bad int insertionPoint = tp.pointToColumnIndex(dtde.getLocation()); if (insertionPoint < 0) insertionPoint = 0; ArrayList paths = (ArrayList) t.getTransferData(importFlavor); Iterator pathIt = paths.iterator(); while (pathIt.hasNext()) { Object someData = dbtree.getNodeForDnDPath((int[]) pathIt.next()); logger.debug("drop: got object of type "+someData.getClass().getName()); if (someData instanceof SQLTable) { SQLTable table = (SQLTable) someData; if (table.getParentDatabase() == tp.getModel().getParentDatabase()) { // can't import table from target into target!! dtde.rejectDrop(); } else { dtde.acceptDrop(DnDConstants.ACTION_COPY); tp.getModel().inherit(insertionPoint, table); dtde.dropComplete(true); } return; } else if (someData instanceof SQLColumn) { SQLColumn col = (SQLColumn) someData; if (col.getParentTable().getParentDatabase() == tp.getModel().getParentDatabase()) { dtde.acceptDrop(DnDConstants.ACTION_MOVE); int removedIndex = col.getParent().getChildren().indexOf(col); if (tp.getModel() == col.getParentTable()) { // moving column inside the same table if (insertionPoint > removedIndex) { insertionPoint--; } } col.getParentTable().removeColumn(col); logger.debug("Adding column '"+col.getName() +"' to table '"+tp.getModel().getName() +"' at position "+insertionPoint); tp.getModel().addColumn(insertionPoint, col); dtde.dropComplete(true); } else { dtde.acceptDrop(DnDConstants.ACTION_COPY); tp.getModel().inherit(insertionPoint, col); logger.debug("Inherited "+col.getColumnName()+" to table"); dtde.dropComplete(true); } return; } else { dtde.rejectDrop(); } } } catch(Exception ex) { JOptionPane.showMessageDialog(tp, "Drop failed: "+ex.getMessage()); logger.error("Error processing drop operation", ex); dtde.rejectDrop(); } finally { tp.setInsertionPoint(COLUMN_INDEX_NONE); } } } |
|
Tag newTag = dynaLib.createTag( tag.getLocalName() ); | Tag newTag = dynaLib.createTag( tag.getLocalName(), getSaxAttributes() ); | protected Tag findDynamicTag(JellyContext context, StaticTag tag) throws Exception { // lets see if there's a tag library for this URI... TagLibrary taglib = context.getTagLibrary( tag.getUri() ); if ( taglib instanceof DynamicTagLibrary ) { DynamicTagLibrary dynaLib = (DynamicTagLibrary) taglib; Tag newTag = dynaLib.createTag( tag.getLocalName() ); if ( newTag != null ) { newTag.setParent( tag.getParent() ); newTag.setBody( tag.getBody() ); return newTag; } } return tag; } |
} | } ASUtils.breakLongMenu(ArchitectFrame.getMainInstance(),connectionsMenu); | protected JPopupMenu refreshMenu(TreePath p) { logger.debug("refreshMenu is being called."); JPopupMenu newMenu = new JPopupMenu(); newMenu.add(connectionsMenu = new JMenu("Add Source Connection")); connectionsMenu.add(new JMenuItem(newDBCSAction)); connectionsMenu.addSeparator(); // populate for (ArchitectDataSource dbcs : ArchitectFrame.getMainInstance().getUserSettings().getConnections()) { connectionsMenu.add(new JMenuItem(new AddDBCSAction(dbcs))); } if (isTargetDatabaseNode(p)) { newMenu.addSeparator(); // two menu items: "Set Target Database" and "Connection Properties newMenu.add(connectionsMenu = new JMenu("Set Target Database")); if (ArchitectFrame.getMainInstance().getUserSettings().getConnections().size() == 0) { // disable if there's no connections in user settings yet (annoying, but less confusing) connectionsMenu.setEnabled(false); } else { SQLDatabase ppdb = ArchitectFrame.getMainInstance().getProject().getPlayPen().getDatabase(); // populate for (ArchitectDataSource dbcs : ArchitectFrame.getMainInstance().getUserSettings().getConnections()) { connectionsMenu.add(new JMenuItem(new SetDataSourceAction(ppdb, dbcs))); } } JMenuItem popupProperties = new JMenuItem(dbcsPropertiesAction); newMenu.add(popupProperties); } else if (isTargetDatabaseChild(p)) { newMenu.addSeparator(); ArchitectFrame af = ArchitectFrame.getMainInstance(); JMenuItem mi; mi = new JMenuItem(); mi.setAction(af.editColumnAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if (p.getLastPathComponent() instanceof SQLColumn) { mi.setEnabled(true); } else { mi.setEnabled(false); } mi = new JMenuItem(); mi.setAction(af.insertColumnAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if (p.getLastPathComponent() instanceof SQLTable || p.getLastPathComponent() instanceof SQLColumn) { mi.setEnabled(true); } else { mi.setEnabled(false); } newMenu.addSeparator(); mi = new JMenuItem(); mi.setAction(showInPlayPenAction); newMenu.add(mi); mi = new JMenuItem(); mi.setAction(af.editTableAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if (p.getLastPathComponent() instanceof SQLTable || p.getLastPathComponent() instanceof SQLColumn) { mi.setEnabled(true); } else { mi.setEnabled(false); } mi = new JMenuItem(); mi.setAction(af.editRelationshipAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if (p.getLastPathComponent() instanceof SQLRelationship) { mi.setEnabled(true); } else { mi.setEnabled(false); } mi = new JMenuItem(); mi.setAction(af.deleteSelectedAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if (p.getLastPathComponent() instanceof SQLTable || p.getLastPathComponent() instanceof SQLColumn || p.getLastPathComponent() instanceof SQLRelationship) { mi.setEnabled(true); } else { mi.setEnabled(false); } } else if (p != null) { // clicked on DBCS item in DBTree newMenu.addSeparator(); if (p.getLastPathComponent() instanceof SQLDatabase) { newMenu.add(new JMenuItem(removeDBCSAction)); } JMenuItem popupProperties = new JMenuItem(dbcsPropertiesAction); newMenu.add(popupProperties); } // Show exception details (SQLException node can appear anywhere in the hierarchy) if (p != null && p.getLastPathComponent() instanceof SQLExceptionNode) { newMenu.addSeparator(); final SQLExceptionNode node = (SQLExceptionNode) p.getLastPathComponent(); newMenu.add(new JMenuItem(new AbstractAction("Show Exception Details") { public void actionPerformed(ActionEvent e) { ASUtils.showExceptionDialog("Exception Node Report", node.getException()); } })); // If the sole child is an exception node, we offer the user a way to re-try the operation try { final SQLObject parent = node.getParent(); if (parent.getChildCount() == 1) { newMenu.add(new JMenuItem(new AbstractAction("Retry") { public void actionPerformed(ActionEvent e) { parent.removeChild(0); parent.setPopulated(false); try { parent.getChildren(); // forces populate } catch (ArchitectException ex) { try { parent.addChild(new SQLExceptionNode(ex, "New exception during retry")); } catch (ArchitectException e1) { logger.error("Couldn't add SQLExceptionNode to menu:", e1); JOptionPane.showMessageDialog(null, "Failed to add SQLExceptionNode:\n"+e1.getMessage()); } ASUtils.showExceptionDialog("Exception occurred during retry", ex); } } })); } } catch (ArchitectException ex) { logger.error("Couldn't count siblings of SQLExceptionNode", ex); } } // add in Show Listeners if debug is enabled if (logger.isDebugEnabled()) { newMenu.addSeparator(); JMenuItem showListeners = new JMenuItem("Show Listeners"); showListeners.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SQLObject so = (SQLObject) getLastSelectedPathComponent(); if (so != null) { JOptionPane.showMessageDialog(DBTree.this, new JScrollPane(new JList(new java.util.Vector(so.getSQLObjectListeners())))); } } }); newMenu.add(showListeners); } return newMenu; } |
log.warn( "getShootingTime" ); | public Date getShootTime( ) { return (Date) shootingDayField.getValue(); } |
|
ctrl.viewChanged( this, (String) field ); | Object value = ((JFormattedTextField) src).getValue(); if ( value != null ) { log.warn( "Property changed: " + (String) field ); System.out.println( "Property changed: " + (String) field ); ctrl.viewChanged( this, (String) field ); } | public void propertyChange( PropertyChangeEvent ev ) { if ( ev.getPropertyName().equals( "value" ) ) { Object src = ev.getSource(); if ( src.getClass() == JFormattedTextField.class ) { Object field = ((JFormattedTextField) src).getClientProperty( FIELD_NAME ); ctrl.viewChanged( this, (String) field ); } } } |
log.warn( "setShootingTime: " + newValue ); | public void setShootTime( Date newValue ) { shootingDayField.setValue( newValue ); } |
|
if (((String)h.getPhasedSelection().get(2)).equals("CEU")){ | if (((String)h.getPhasedSelection().get(2)).equals("YRI")){ | public ReadDataDialog(String title, HaploView h){ super(h, title); //Ped Panel... pedFileField = new JTextField("",20); JButton browsePedFileButton = new JButton("Browse"); browsePedFileButton.setActionCommand(BROWSE_GENO); browsePedFileButton.addActionListener(this); pedInfoField = new JTextField("",20); pedInfoField.getDocument().addDocumentListener(this); JButton browsePedInfoButton = new JButton("Browse"); browsePedInfoButton.setActionCommand(BROWSE_INFO); browsePedInfoButton.addActionListener(this); JPanel assocPanel = new JPanel(); doAssociation = new JCheckBox("Do association test?"); doAssociation.setSelected(false); doAssociation.setEnabled(false); doAssociation.setActionCommand("association"); doAssociation.addActionListener(this); xChrom = new JCheckBox("X Chromosome"); xChrom.setSelected(false); xChrom.setActionCommand("xChrom"); xChrom.addActionListener(this); assocPanel.add(xChrom); assocPanel.add(doAssociation); JPanel tdtOptsPanel = new JPanel(); trioButton = new JRadioButton("Family trio data", true); trioButton.setEnabled(false); trioButton.setActionCommand("tdt"); trioButton.addActionListener(this); ccButton = new JRadioButton("Case/Control data"); ccButton.setEnabled(false); ccButton.setActionCommand("ccButton"); ccButton.addActionListener(this); ButtonGroup group = new ButtonGroup(); group.add(trioButton); group.add(ccButton); tdtOptsPanel.add(trioButton); tdtOptsPanel.add(ccButton); JPanel tdtTypePanel = new JPanel(); standardTDT = new JRadioButton("Standard TDT", true); standardTDT.setEnabled(false); parenTDT = new JRadioButton("ParenTDT", true); parenTDT.setEnabled(false); ButtonGroup tdtGroup = new ButtonGroup(); tdtGroup.add(standardTDT); tdtGroup.add(parenTDT); tdtTypePanel.add(standardTDT); tdtTypePanel.add(parenTDT); testFileField = new JTextField("",20); testFileField.setEnabled(false); testFileField.setBackground(this.getBackground()); browseAssocButton = new JButton("Browse"); browseAssocButton.setActionCommand(BROWSE_ASSOC); browseAssocButton.addActionListener(this); browseAssocButton.setEnabled(false); testFileLabel = new JLabel("Test list file (optional):"); testFileLabel.setEnabled(false); //Haps Panel.. hapsFileField = new JTextField("",20); JButton browseHapsFileButton = new JButton("Browse"); browseHapsFileButton.setActionCommand(BROWSE_HAPS); browseHapsFileButton.addActionListener(this); hapsInfoField = new JTextField("",20); JButton browseHapsInfoButton = new JButton("Browse"); browseHapsInfoButton.setActionCommand(BROWSE_INFO); browseHapsInfoButton.addActionListener(this); hapsXChrom = new JCheckBox("X Chromosome"); hapsXChrom.setSelected(false); hapsXChrom.setActionCommand("xChrom"); hapsXChrom.addActionListener(this); //HMP panel... hmpFileField = new JTextField("",20); JButton browseHmpButton = new JButton("Browse"); browseHmpButton.setActionCommand(BROWSE_HMP); browseHmpButton.addActionListener(this); doGB = new JCheckBox("Download and show HapMap info track? (requires internet connection)"); doGB.setSelected(false); //PHASE panel... phaseFileField = new JTextField("",20); JButton browsePhaseButton = new JButton("Browse"); browsePhaseButton.setActionCommand(BROWSE_PHASE); browsePhaseButton.addActionListener(this); phaseSampleField = new JTextField("",20); JButton browseSampleButton = new JButton("Browse"); browseSampleButton.setActionCommand(BROWSE_SAMPLE); browseSampleButton.addActionListener(this); phaseLegendField = new JTextField("",20); JButton browseLegendButton = new JButton("Browse"); browseLegendButton.setActionCommand(BROWSE_LEGEND); browseLegendButton.addActionListener(this); JPanel phaseGzipPanel = new JPanel(); gZip = new JCheckBox("Files are GZIP compressed", false); gZip.setEnabled(true); phaseGzipPanel.add(gZip); JPanel phaseChromPanel = new JPanel(); phaseChromPanel.add(new JLabel("Chromosome (Required for Info Track):")); loadChromChooser.setSelectedIndex(-1); phaseChromPanel.add(loadChromChooser); JPanel phaseBrowsePanel = new JPanel(); phaseDoGB = new JCheckBox("Download and show HapMap info track? (requires internet connection)"); phaseDoGB.setSelected(false); phaseBrowsePanel.add(phaseDoGB); //Download Panel... JPanel downloadChooserPanel = new JPanel(); downloadChooserPanel.add(new JLabel("Phase")); downloadChooserPanel.add(phaseChooser); phaseChooser.setSelectedIndex(1); downloadChooserPanel.add(new JLabel("Chromosome:")); chromChooser.setSelectedIndex(-1); downloadChooserPanel.add(chromChooser); downloadChooserPanel.add(new JLabel("Population:")); downloadChooserPanel.add(popChooser); JPanel downloadPositionPanel = new JPanel(); chromStartField = new NumberTextField("",6,false); chromStartField.setEnabled(true); chromEndField = new NumberTextField("",6,false); chromEndField.setEnabled(true); downloadPositionPanel.add(new JLabel("Start kb:")); downloadPositionPanel.add(chromStartField); downloadPositionPanel.add(new JLabel("End kb:")); downloadPositionPanel.add(chromEndField); JPanel downloadBrowsePanel = new JPanel(); downloadDoGB = new JCheckBox("Download and show HapMap info track? (requires internet connection)"); downloadDoGB.setSelected(true); downloadBrowsePanel.add(downloadDoGB); //Plink Panel... plinkFileField = new JTextField("",20); JButton browsePlinkFileButton = new JButton("Browse"); browsePlinkFileButton.setActionCommand(BROWSE_WGA); browsePlinkFileButton.addActionListener(this); mapLabel = new JLabel("Map File:"); plinkMapField = new JTextField("",20); browsePlinkMapButton = new JButton("Browse"); browsePlinkMapButton.setActionCommand(BROWSE_MAP); browsePlinkMapButton.addActionListener(this); embeddedMap = new JCheckBox("Integrated Map Info"); embeddedMap.addActionListener(this); embeddedMap.setSelected(false); JPanel pedTab = new JPanel(new GridBagLayout()); pedTab.setPreferredSize(new Dimension(375,200)); JPanel hapsTab = new JPanel(new GridBagLayout()); JPanel hmpTab = new JPanel(new GridBagLayout()); JPanel phaseTab = new JPanel(new GridBagLayout()); JPanel downloadTab = new JPanel(new GridBagLayout()); JPanel plinkTab = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.EAST; c.gridx = 0; c.gridy = 0; c.insets = new Insets(5,5,5,5); pedTab.add(new JLabel("Data File:"),c); hapsTab.add(new JLabel("Data File:"),c); phaseTab.add(new JLabel("Phase File:"),c); plinkTab.add(new JLabel("Results File:"),c); c.weightx = 1; hmpTab.add(new JLabel("Data File:"),c); c.anchor = GridBagConstraints.CENTER; c.weightx = 0; downloadTab.add(downloadChooserPanel,c); c.gridx = 1; pedTab.add(pedFileField,c); hapsTab.add(hapsFileField,c); hmpTab.add(hmpFileField,c); phaseTab.add(phaseFileField,c); plinkTab.add(plinkFileField,c); c.gridx = 2; c.insets = new Insets(0,10,0,0); pedTab.add(browsePedFileButton,c); hapsTab.add(browseHapsFileButton,c); plinkTab.add(browsePlinkFileButton,c); c.anchor = GridBagConstraints.WEST; phaseTab.add(browsePhaseButton,c); c.weightx = 1; hmpTab.add(browseHmpButton,c); c.weightx = 0; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(5,5,5,5); c.gridy = 1; c.gridx = 0; downloadTab.add(downloadPositionPanel,c); c.gridy = 2; downloadTab.add(downloadBrowsePanel,c); c.anchor = GridBagConstraints.EAST; c.gridx = 0; c.gridy = 1; c.insets = new Insets(5,5,5,5); pedTab.add(new JLabel("Locus Information File:"),c); hapsTab.add(new JLabel("Locus Information File:"),c); phaseTab.add(new JLabel("Sample File:"),c); plinkTab.add(mapLabel,c); c.anchor = GridBagConstraints.CENTER; c.gridx = 1; c.insets = new Insets(0,0,0,0); pedTab.add(pedInfoField,c); hapsTab.add(hapsInfoField,c); phaseTab.add(phaseSampleField,c); plinkTab.add(plinkMapField,c); c.gridx = 2; c.insets = new Insets(0,10,0,0); pedTab.add(browsePedInfoButton,c); hapsTab.add(browseHapsInfoButton,c); plinkTab.add(browsePlinkMapButton,c); c.anchor = GridBagConstraints.WEST; phaseTab.add(browseSampleButton,c); c.anchor = GridBagConstraints.CENTER; c.gridx = 0; c.gridy = 2; c.anchor = GridBagConstraints.EAST; c.insets = new Insets(5,5,5,5); phaseTab.add(new JLabel("Legend File:"),c); c.anchor = GridBagConstraints.CENTER; c.gridx = 1; phaseTab.add(phaseLegendField,c); c.gridx = 2; c.insets = new Insets(0,10,0,0); c.anchor = GridBagConstraints.WEST; phaseTab.add(browseLegendButton,c); c.anchor = GridBagConstraints.CENTER; c.gridx = 0; c.gridwidth = 3; c.insets = new Insets(0,0,0,0); pedTab.add(assocPanel,c); hapsTab.add(hapsXChrom, c); hmpTab.add(doGB,c); plinkTab.add(embeddedMap,c); c.gridy = 3; pedTab.add(tdtOptsPanel,c); phaseTab.add(phaseGzipPanel,c); c.gridy = 4; pedTab.add(tdtTypePanel,c); phaseTab.add(phaseChromPanel,c); c.gridy = 5; phaseTab.add(phaseBrowsePanel,c); c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; c.insets = new Insets(0,0,0,5); pedTab.add(testFileLabel,c); c.gridx = 1; c.insets = new Insets(0,0,0,0); pedTab.add(testFileField,c); c.gridx = 2; c.insets = new Insets(0,10,0,0); pedTab.add(browseAssocButton,c); dataFormatPane.setFont(new Font("Default",Font.BOLD,12)); dataFormatPane.addTab("Linkage Format",pedTab); dataFormatPane.addTab("Haps Format",hapsTab); dataFormatPane.addTab("HapMap Format",hmpTab); dataFormatPane.addTab("PHASE Format",phaseTab); dataFormatPane.addTab("<html>Phased HapMap<br>Download",downloadTab); dataFormatPane.addTab("PLINK Format",plinkTab); JButton okButton = new JButton("OK"); okButton.addActionListener(this); this.getRootPane().setDefaultButton(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); JButton proxyButton = new JButton("Proxy Settings"); proxyButton.addActionListener(this); JPanel choicePanel = new JPanel(); choicePanel.add(okButton); choicePanel.add(cancelButton); JPanel proxyPanel = new JPanel(); proxyPanel.add(proxyButton); JPanel contents = new JPanel(); contents.setLayout(new GridBagLayout()); GridBagConstraints a = new GridBagConstraints(); a.gridwidth = 3; a.gridx = 0; a.gridy = 0; contents.add(dataFormatPane, a); JPanel compDistPanel = new JPanel(); compDistPanel.add(new JLabel("Ignore pairwise comparisons of markers >")); maxComparisonDistField = new NumberTextField(String.valueOf(Options.getMaxDistance()/1000),6, false); compDistPanel.add(maxComparisonDistField); compDistPanel.add(new JLabel("kb apart.")); a.gridy = 1; contents.add(compDistPanel,a); JPanel missingCutoffPanel = new JPanel(); missingCutoffField = new NumberTextField(String.valueOf(Options.getMissingThreshold()*100),3, false); missingCutoffPanel.add(new JLabel("Exclude individuals with >")); missingCutoffPanel.add(missingCutoffField); missingCutoffPanel.add(new JLabel("% missing genotypes.")); a.gridy = 2; contents.add(missingCutoffPanel,a); a.gridy = 3; contents.add(choicePanel,a); a.anchor = GridBagConstraints.EAST; a.gridx = 2; contents.add(proxyPanel,a); if (h.getPhasedSelection() != null){ if (((String)h.getPhasedSelection().get(0)).equals("I")){ phaseChooser.setSelectedIndex(0); } if (((String)h.getPhasedSelection().get(1)).equals("X")){ chromChooser.setSelectedIndex(22); }else{ chromChooser.setSelectedIndex(Integer.parseInt((String)h.getPhasedSelection().get(1))-1); } if (((String)h.getPhasedSelection().get(2)).equals("CEU")){ popChooser.setSelectedIndex(1); }else if (((String)h.getPhasedSelection().get(2)).equals("CHB+JPT")){ popChooser.setSelectedIndex(2); } chromStartField.setText((String)h.getPhasedSelection().get(3)); chromEndField.setText((String)h.getPhasedSelection().get(4)); } //contents.setPreferredSize(new Dimension(700,700)); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); this.setResizable(false); } |
if (markerid.equals("marker")){ | if (markerid.equals("rs")){ | public void parsePhasedData(String[] info) throws IOException, PedFileException{ if (info[4].equals("")){ Chromosome.setDataChrom("none"); }else{ Chromosome.setDataChrom("chr" + info[4]); } Chromosome.setDataBuild("ncbi_b35"); Vector sampleData = new Vector(); Vector legendData = new Vector(); Vector legendMarkers = new Vector(); Vector legendPositions = new Vector(); Individual ind = null; byte[] byteDataT = new byte[0]; byte[] byteDataU = new byte[0]; this.allIndividuals = new Vector(); File phasedFile = new File(info[0]); File sampleFile = new File(info[1]); File legendFile = new File(info[2]); if (phasedFile.length() < 1){ throw new PedFileException("Genotypes file is empty or non-existent: " + phasedFile.getName()); }else if (sampleFile.length() < 1){ throw new PedFileException("Sample file is empty or non-existent: " + sampleFile.getName()); }else if (legendFile.length() < 1){ throw new PedFileException("Legend file is empty or non-existent: " + legendFile.getName()); } //read in the individual ids data. try{ BufferedReader sampleBuffReader; if (Options.getGzip()){ FileInputStream sampleFis = new FileInputStream(sampleFile); GZIPInputStream sampleInputStream = new GZIPInputStream(sampleFis); sampleBuffReader = new BufferedReader(new InputStreamReader(sampleInputStream)); }else{ FileReader sampleReader = new FileReader(sampleFile); sampleBuffReader = new BufferedReader(sampleReader); } String sampleLine; while((sampleLine = sampleBuffReader.readLine())!=null){ StringTokenizer sampleTokenizer = new StringTokenizer(sampleLine); sampleData.add(sampleTokenizer.nextToken()); } }catch(NoSuchElementException nse){ throw new PedFileException("File format error: " + sampleFile.getName()); } //read in the legend data try{ BufferedReader legendBuffReader; if (Options.getGzip()){ FileInputStream legendFis = new FileInputStream(legendFile); GZIPInputStream legendInputStream = new GZIPInputStream(legendFis); legendBuffReader = new BufferedReader(new InputStreamReader(legendInputStream)); }else{ FileReader legendReader = new FileReader(legendFile); legendBuffReader = new BufferedReader(legendReader); } String legendLine; String zero, one; while((legendLine = legendBuffReader.readLine())!=null){ StringTokenizer legendSt = new StringTokenizer(legendLine); String markerid = legendSt.nextToken(); if (markerid.equals("marker")){ //skip header continue; } legendMarkers.add(markerid); legendPositions.add(legendSt.nextToken()); byte[] legendBytes = new byte[2]; zero = legendSt.nextToken(); one = legendSt.nextToken(); if (zero.equalsIgnoreCase("A")){ legendBytes[0] = 1; }else if (zero.equalsIgnoreCase("C")){ legendBytes[0] = 2; }else if (zero.equalsIgnoreCase("G")){ legendBytes[0] = 3; }else if (zero.equalsIgnoreCase("T")){ legendBytes[0] = 4; }else{ throw new PedFileException("Invalid allele: " + zero); } if (one.equalsIgnoreCase("A")){ legendBytes[1] = 1; }else if (one.equalsIgnoreCase("C")){ legendBytes[1] = 2; }else if (one.equalsIgnoreCase("G")){ legendBytes[1] = 3; }else if (one.equalsIgnoreCase("T")){ legendBytes[1] = 4; }else{ throw new PedFileException("Invalid allele: " + one); } legendData.add(legendBytes); } hminfo = new String[legendPositions.size()][2]; for (int i = 0; i < legendPositions.size(); i++){ //marker name. hminfo[i][0] = (String)legendMarkers.get(i); //marker position. hminfo[i][1] = (String)legendPositions.get(i); } }catch(NoSuchElementException nse){ throw new PedFileException("File format error: " + legendFile.getName()); } //read in the phased data. try{ BufferedReader phasedBuffReader; if (Options.getGzip()){ FileInputStream phasedFis = new FileInputStream(phasedFile); GZIPInputStream phasedInputStream = new GZIPInputStream(phasedFis); phasedBuffReader = new BufferedReader(new InputStreamReader(phasedInputStream)); }else{ FileReader phasedReader = new FileReader(phasedFile); phasedBuffReader = new BufferedReader(phasedReader); } String phasedLine; int columns = 0; String token; boolean even = false; int iterator = 0; while((phasedLine = phasedBuffReader.readLine()) != null){ StringTokenizer phasedSt = new StringTokenizer(phasedLine); columns = phasedSt.countTokens(); if(even){ iterator++; }else{ //Only set up a new individual every 2 lines. ind = new Individual(columns, true); try{ ind.setIndividualID((String)sampleData.get(iterator)); }catch (ArrayIndexOutOfBoundsException e){ throw new PedFileException("File error: Sample file is missing individual IDs"); } if (columns != legendData.size()){ throw new PedFileException("File error: invalid number of markers on Individual " + ind.getIndividualID()); } String details = (String)hapMapTranslate.get(ind.getIndividualID()); //exception in case of wierd compression combos in input files if (details == null){ throw new PedFileException("File format error: " + sampleFile.getName()); } StringTokenizer dt = new StringTokenizer(details, "\n\t\" \""); ind.setFamilyID(dt.nextToken().trim()); //skip individualID since we already have it. dt.nextToken(); ind.setDadID(dt.nextToken()); ind.setMomID(dt.nextToken()); try { ind.setGender(Integer.parseInt(dt.nextToken().trim())); ind.setAffectedStatus(Integer.parseInt(dt.nextToken().trim())); }catch(NumberFormatException nfe) { throw new PedFileException("File error: invalid gender or affected status for indiv " + ind.getIndividualID()); } //check if the family exists already in the Hashtable Family fam = (Family)this.families.get(ind.getFamilyID()); if(fam == null){ //it doesnt exist, so create a new Family object fam = new Family(ind.getFamilyID()); } fam.addMember(ind); this.families.put(ind.getFamilyID(),fam); this.allIndividuals.add(ind); } int index = 0; if (!even){ byteDataT = new byte[columns]; }else{ byteDataU = new byte[columns]; } while(phasedSt.hasMoreTokens()){ token = phasedSt.nextToken(); if (!even){ if (token.equalsIgnoreCase("0")){ byteDataT[index] = ((byte[])legendData.get(index))[0]; }else if (token.equalsIgnoreCase("1")){ byteDataT[index] = ((byte[])legendData.get(index))[1]; }else { throw new PedFileException("File format error: " + phasedFile.getName()); } }else{ if (token.equalsIgnoreCase("0")){ byteDataU[index] = ((byte[])legendData.get(index))[0]; }else if (token.equalsIgnoreCase("1")){ byteDataU[index] = ((byte[])legendData.get(index))[1]; }else { throw new PedFileException("File format error: " + phasedFile.getName()); } } index++; } if (even){ for(int i=0; i < columns; i++){ ind.addMarker(byteDataT[i], byteDataU[i]); } } even = !even; } }catch(NoSuchElementException nse){ throw new PedFileException("File format error: " + phasedFile.getName()); } } |
for(int i=0; i < columns; i++){ ind.addMarker(byteDataT[i], byteDataU[i]); | if (ind.getGender() == Individual.MALE && Chromosome.getDataChrom().equalsIgnoreCase("chrx")){ for(int i=0; i < columns; i++){ ind.addMarker(byteDataT[i], byteDataT[i]); } }else{ for(int i=0; i < columns; i++){ ind.addMarker(byteDataT[i], byteDataU[i]); } | public void parsePhasedData(String[] info) throws IOException, PedFileException{ if (info[4].equals("")){ Chromosome.setDataChrom("none"); }else{ Chromosome.setDataChrom("chr" + info[4]); } Chromosome.setDataBuild("ncbi_b35"); Vector sampleData = new Vector(); Vector legendData = new Vector(); Vector legendMarkers = new Vector(); Vector legendPositions = new Vector(); Individual ind = null; byte[] byteDataT = new byte[0]; byte[] byteDataU = new byte[0]; this.allIndividuals = new Vector(); File phasedFile = new File(info[0]); File sampleFile = new File(info[1]); File legendFile = new File(info[2]); if (phasedFile.length() < 1){ throw new PedFileException("Genotypes file is empty or non-existent: " + phasedFile.getName()); }else if (sampleFile.length() < 1){ throw new PedFileException("Sample file is empty or non-existent: " + sampleFile.getName()); }else if (legendFile.length() < 1){ throw new PedFileException("Legend file is empty or non-existent: " + legendFile.getName()); } //read in the individual ids data. try{ BufferedReader sampleBuffReader; if (Options.getGzip()){ FileInputStream sampleFis = new FileInputStream(sampleFile); GZIPInputStream sampleInputStream = new GZIPInputStream(sampleFis); sampleBuffReader = new BufferedReader(new InputStreamReader(sampleInputStream)); }else{ FileReader sampleReader = new FileReader(sampleFile); sampleBuffReader = new BufferedReader(sampleReader); } String sampleLine; while((sampleLine = sampleBuffReader.readLine())!=null){ StringTokenizer sampleTokenizer = new StringTokenizer(sampleLine); sampleData.add(sampleTokenizer.nextToken()); } }catch(NoSuchElementException nse){ throw new PedFileException("File format error: " + sampleFile.getName()); } //read in the legend data try{ BufferedReader legendBuffReader; if (Options.getGzip()){ FileInputStream legendFis = new FileInputStream(legendFile); GZIPInputStream legendInputStream = new GZIPInputStream(legendFis); legendBuffReader = new BufferedReader(new InputStreamReader(legendInputStream)); }else{ FileReader legendReader = new FileReader(legendFile); legendBuffReader = new BufferedReader(legendReader); } String legendLine; String zero, one; while((legendLine = legendBuffReader.readLine())!=null){ StringTokenizer legendSt = new StringTokenizer(legendLine); String markerid = legendSt.nextToken(); if (markerid.equals("marker")){ //skip header continue; } legendMarkers.add(markerid); legendPositions.add(legendSt.nextToken()); byte[] legendBytes = new byte[2]; zero = legendSt.nextToken(); one = legendSt.nextToken(); if (zero.equalsIgnoreCase("A")){ legendBytes[0] = 1; }else if (zero.equalsIgnoreCase("C")){ legendBytes[0] = 2; }else if (zero.equalsIgnoreCase("G")){ legendBytes[0] = 3; }else if (zero.equalsIgnoreCase("T")){ legendBytes[0] = 4; }else{ throw new PedFileException("Invalid allele: " + zero); } if (one.equalsIgnoreCase("A")){ legendBytes[1] = 1; }else if (one.equalsIgnoreCase("C")){ legendBytes[1] = 2; }else if (one.equalsIgnoreCase("G")){ legendBytes[1] = 3; }else if (one.equalsIgnoreCase("T")){ legendBytes[1] = 4; }else{ throw new PedFileException("Invalid allele: " + one); } legendData.add(legendBytes); } hminfo = new String[legendPositions.size()][2]; for (int i = 0; i < legendPositions.size(); i++){ //marker name. hminfo[i][0] = (String)legendMarkers.get(i); //marker position. hminfo[i][1] = (String)legendPositions.get(i); } }catch(NoSuchElementException nse){ throw new PedFileException("File format error: " + legendFile.getName()); } //read in the phased data. try{ BufferedReader phasedBuffReader; if (Options.getGzip()){ FileInputStream phasedFis = new FileInputStream(phasedFile); GZIPInputStream phasedInputStream = new GZIPInputStream(phasedFis); phasedBuffReader = new BufferedReader(new InputStreamReader(phasedInputStream)); }else{ FileReader phasedReader = new FileReader(phasedFile); phasedBuffReader = new BufferedReader(phasedReader); } String phasedLine; int columns = 0; String token; boolean even = false; int iterator = 0; while((phasedLine = phasedBuffReader.readLine()) != null){ StringTokenizer phasedSt = new StringTokenizer(phasedLine); columns = phasedSt.countTokens(); if(even){ iterator++; }else{ //Only set up a new individual every 2 lines. ind = new Individual(columns, true); try{ ind.setIndividualID((String)sampleData.get(iterator)); }catch (ArrayIndexOutOfBoundsException e){ throw new PedFileException("File error: Sample file is missing individual IDs"); } if (columns != legendData.size()){ throw new PedFileException("File error: invalid number of markers on Individual " + ind.getIndividualID()); } String details = (String)hapMapTranslate.get(ind.getIndividualID()); //exception in case of wierd compression combos in input files if (details == null){ throw new PedFileException("File format error: " + sampleFile.getName()); } StringTokenizer dt = new StringTokenizer(details, "\n\t\" \""); ind.setFamilyID(dt.nextToken().trim()); //skip individualID since we already have it. dt.nextToken(); ind.setDadID(dt.nextToken()); ind.setMomID(dt.nextToken()); try { ind.setGender(Integer.parseInt(dt.nextToken().trim())); ind.setAffectedStatus(Integer.parseInt(dt.nextToken().trim())); }catch(NumberFormatException nfe) { throw new PedFileException("File error: invalid gender or affected status for indiv " + ind.getIndividualID()); } //check if the family exists already in the Hashtable Family fam = (Family)this.families.get(ind.getFamilyID()); if(fam == null){ //it doesnt exist, so create a new Family object fam = new Family(ind.getFamilyID()); } fam.addMember(ind); this.families.put(ind.getFamilyID(),fam); this.allIndividuals.add(ind); } int index = 0; if (!even){ byteDataT = new byte[columns]; }else{ byteDataU = new byte[columns]; } while(phasedSt.hasMoreTokens()){ token = phasedSt.nextToken(); if (!even){ if (token.equalsIgnoreCase("0")){ byteDataT[index] = ((byte[])legendData.get(index))[0]; }else if (token.equalsIgnoreCase("1")){ byteDataT[index] = ((byte[])legendData.get(index))[1]; }else { throw new PedFileException("File format error: " + phasedFile.getName()); } }else{ if (token.equalsIgnoreCase("0")){ byteDataU[index] = ((byte[])legendData.get(index))[0]; }else if (token.equalsIgnoreCase("1")){ byteDataU[index] = ((byte[])legendData.get(index))[1]; }else { throw new PedFileException("File format error: " + phasedFile.getName()); } } index++; } if (even){ for(int i=0; i < columns; i++){ ind.addMarker(byteDataT[i], byteDataU[i]); } } even = !even; } }catch(NoSuchElementException nse){ throw new PedFileException("File format error: " + phasedFile.getName()); } } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.