rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
System.out.println("Added "+column.getColumnName()+" to playpen (temporary, only for testing)"); | logger.debug("Added "+column.getColumnName()+" to playpen (temporary, only for testing)"); | public void drop(DropTargetDropEvent dtde) { Transferable t = dtde.getTransferable(); JComponent c = (JComponent) dtde.getDropTargetContext().getComponent(); DataFlavor importFlavor = bestImportFlavor(c, t.getTransferDataFlavors()); if (importFlavor == null) { dtde.rejectDrop(); } else { try { Object someData = t.getTransferData(importFlavor); System.out.println("MyJTreeTransferHandler.importData: got object of type "+someData.getClass().getName()); if (someData instanceof SQLTable) { dtde.acceptDrop(DnDConstants.ACTION_COPY); SQLTable table = (SQLTable) someData; TablePane tp = new TablePane(table); c.add(tp, dtde.getLocation()); tp.revalidate(); dtde.dropComplete(true); return; } else if (someData instanceof SQLColumn) { dtde.acceptDrop(DnDConstants.ACTION_COPY); SQLColumn column = (SQLColumn) someData; JLabel colName = new JLabel(column.getColumnName()); colName.setSize(colName.getPreferredSize()); c.add(colName, dtde.getLocation()); System.out.println("Added "+column.getColumnName()+" to playpen (temporary, only for testing)"); colName.revalidate(); dtde.dropComplete(true); return; } else if (someData instanceof SQLObject[]) { dtde.acceptDrop(DnDConstants.ACTION_COPY); SQLObject[] objects = (SQLObject[]) someData; for (int i = 0; i < objects.length; i++) { if (objects[i] instanceof SQLTable) { TablePane tp = new TablePane((SQLTable) objects[i]); c.add(tp, dtde.getLocation()); tp.revalidate(); } } dtde.dropComplete(true); return; } else { dtde.rejectDrop(); } } catch (UnsupportedFlavorException ufe) { ufe.printStackTrace(); dtde.rejectDrop(); } catch (IOException ioe) { ioe.printStackTrace(); dtde.rejectDrop(); } catch (InvalidDnDOperationException ex) { ex.printStackTrace(); dtde.rejectDrop(); } } } |
} catch (ArchitectException ex) { ex.printStackTrace(); dtde.rejectDrop(); | public void drop(DropTargetDropEvent dtde) { Transferable t = dtde.getTransferable(); JComponent c = (JComponent) dtde.getDropTargetContext().getComponent(); DataFlavor importFlavor = bestImportFlavor(c, t.getTransferDataFlavors()); if (importFlavor == null) { dtde.rejectDrop(); } else { try { Object someData = t.getTransferData(importFlavor); System.out.println("MyJTreeTransferHandler.importData: got object of type "+someData.getClass().getName()); if (someData instanceof SQLTable) { dtde.acceptDrop(DnDConstants.ACTION_COPY); SQLTable table = (SQLTable) someData; TablePane tp = new TablePane(table); c.add(tp, dtde.getLocation()); tp.revalidate(); dtde.dropComplete(true); return; } else if (someData instanceof SQLColumn) { dtde.acceptDrop(DnDConstants.ACTION_COPY); SQLColumn column = (SQLColumn) someData; JLabel colName = new JLabel(column.getColumnName()); colName.setSize(colName.getPreferredSize()); c.add(colName, dtde.getLocation()); System.out.println("Added "+column.getColumnName()+" to playpen (temporary, only for testing)"); colName.revalidate(); dtde.dropComplete(true); return; } else if (someData instanceof SQLObject[]) { dtde.acceptDrop(DnDConstants.ACTION_COPY); SQLObject[] objects = (SQLObject[]) someData; for (int i = 0; i < objects.length; i++) { if (objects[i] instanceof SQLTable) { TablePane tp = new TablePane((SQLTable) objects[i]); c.add(tp, dtde.getLocation()); tp.revalidate(); } } dtde.dropComplete(true); return; } else { dtde.rejectDrop(); } } catch (UnsupportedFlavorException ufe) { ufe.printStackTrace(); dtde.rejectDrop(); } catch (IOException ioe) { ioe.printStackTrace(); dtde.rejectDrop(); } catch (InvalidDnDOperationException ex) { ex.printStackTrace(); dtde.rejectDrop(); } } } |
|
System.out.println("blockOut "+block+": before "+blocks); | public void blockOut(int start, int length) { Block block = new Block(start, length); System.out.println("blockOut "+block+": before "+blocks); ListIterator it = blocks.listIterator(); while (it.hasNext()) { Block nextBlock = (Block) it.next(); if (nextBlock.start > start) { it.previous(); it.add(block); break; } } System.out.println("blockOut "+block+": after "+blocks); } |
|
System.out.println("blockOut "+block+": after "+blocks); | public void blockOut(int start, int length) { Block block = new Block(start, length); System.out.println("blockOut "+block+": before "+blocks); ListIterator it = blocks.listIterator(); while (it.hasNext()) { Block nextBlock = (Block) it.next(); if (nextBlock.start > start) { it.previous(); it.add(block); break; } } System.out.println("blockOut "+block+": after "+blocks); } |
|
System.out.println("Updating leftGap = "+closestLeftGap); | public int findGapToLeft(int start, int length) { int closestLeftGap = Integer.MIN_VALUE; int prevBlockEnd = Integer.MIN_VALUE; Iterator it = blocks.iterator(); while (it.hasNext()) { Block block = (Block) it.next(); if ( (prevBlockEnd < block.start - length) && (block.start - length <= start) ) { closestLeftGap = block.start - length; System.out.println("Updating leftGap = "+closestLeftGap); } if ( block.start > start ) { // we have reached a block to the right of start break; } prevBlockEnd = block.start + block.length; } // if we're still at one of the sentinel values, return the mouse location if (//closestLeftGap == Integer.MAX_VALUE-length || closestLeftGap == Integer.MIN_VALUE) { return start; } else { // otherwise, the answer is correct return closestLeftGap; } } |
|
start = block.start + block.length; | start = Math.max(block.start + block.length, start); | public int findGapToRight(int start, int length) { Iterator it = blocks.iterator(); while (it.hasNext()) { Block block = (Block) it.next(); if ( (start + length) < block.start ) { // current gap fits at right-hand side.. done! return start; } else { start = block.start + block.length; } } return start; } |
System.out.println("PlayPenLayout.layoutContainer"); | logger.debug("PlayPenLayout.layoutContainer"); | public void layoutContainer(Container parent) { System.out.println("PlayPenLayout.layoutContainer"); } |
System.out.println("PlayPenLayout.removeLayoutComponent"); | logger.debug("PlayPenLayout.removeLayoutComponent"); | public void removeLayoutComponent(Component comp) { System.out.println("PlayPenLayout.removeLayoutComponent"); } |
Rectangle visibleArea = parent.getVisibleRect(); Point p = new Point(); for (int i = 0, n = parent.getComponentCount(); i < n; i++) { JComponent c = (JComponent) parent.getComponent(i); p = c.getLocation(p); p.x += xdist; p.y += ydist; c.setLocation(p); | synchronized (parent) { Rectangle visibleArea = parent.getVisibleRect(); Point p = new Point(); for (int i = 0, n = parent.getComponentCount(); i < n; i++) { JComponent c = (JComponent) parent.getComponent(i); p = c.getLocation(p); p.x += xdist; p.y += ydist; c.setLocation(p); } visibleArea.x += xdist; visibleArea.y += ydist; parent.scrollRectToVisible(visibleArea); | protected void translateAllComponents(int xdist, int ydist) { Rectangle visibleArea = parent.getVisibleRect(); Point p = new Point(); for (int i = 0, n = parent.getComponentCount(); i < n; i++) { JComponent c = (JComponent) parent.getComponent(i); p = c.getLocation(p); p.x += xdist; p.y += ydist; c.setLocation(p); } visibleArea.x += xdist; visibleArea.y += ydist; parent.scrollRectToVisible(visibleArea); } |
visibleArea.x += xdist; visibleArea.y += ydist; parent.scrollRectToVisible(visibleArea); | protected void translateAllComponents(int xdist, int ydist) { Rectangle visibleArea = parent.getVisibleRect(); Point p = new Point(); for (int i = 0, n = parent.getComponentCount(); i < n; i++) { JComponent c = (JComponent) parent.getComponent(i); p = c.getLocation(p); p.x += xdist; p.y += ydist; c.setLocation(p); } visibleArea.x += xdist; visibleArea.y += ydist; parent.scrollRectToVisible(visibleArea); } |
|
public PlayPen() { | public PlayPen(SQLDatabase db) { | public PlayPen() { super(); setLayout(new PlayPenLayout(this)); setName("Play Pen"); setMinimumSize(new Dimension(200,200)); setOpaque(true); dt = new DropTarget(this, new PlayPenDropListener()); } |
tableNames = new HashMap(); | public PlayPen() { super(); setLayout(new PlayPenLayout(this)); setName("Play Pen"); setMinimumSize(new Dimension(200,200)); setOpaque(true); dt = new DropTarget(this, new PlayPenDropListener()); } |
|
ActionErrors errors = new ActionErrors(); | public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionErrors errors = new ActionErrors(); LoginForm loginForm = (LoginForm) actionForm; AuthService authService = ServiceFactory.getAuthService(); try{ authService.login(Utils.getServiceContext(context), loginForm.getUsername(), loginForm.getPassword()); }catch(ServiceException se){ errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(ErrorCodes.WEB_UI_ERROR_KEY, se.getMessage())); request.setAttribute(Globals.ERROR_KEY, errors); return mapping.getInputForward(); }catch(Exception ex){ //TODO Architcture should handle this (ExceptionHandler) errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(ErrorCodes.UNKNOWN_ERROR)); request.setAttribute(Globals.ERROR_KEY, errors); return mapping.getInputForward(); } return mapping.findForward(Forwards.SUCCESS); } |
|
try{ authService.login(Utils.getServiceContext(context), loginForm.getUsername(), loginForm.getPassword()); }catch(ServiceException se){ errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(ErrorCodes.WEB_UI_ERROR_KEY, se.getMessage())); request.setAttribute(Globals.ERROR_KEY, errors); return mapping.getInputForward(); }catch(Exception ex){ errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(ErrorCodes.UNKNOWN_ERROR)); request.setAttribute(Globals.ERROR_KEY, errors); return mapping.getInputForward(); } | authService.login(Utils.getServiceContext(context), loginForm.getUsername(), loginForm.getPassword()); | public ActionForward execute(WebContext context, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception { ActionErrors errors = new ActionErrors(); LoginForm loginForm = (LoginForm) actionForm; AuthService authService = ServiceFactory.getAuthService(); try{ authService.login(Utils.getServiceContext(context), loginForm.getUsername(), loginForm.getPassword()); }catch(ServiceException se){ errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(ErrorCodes.WEB_UI_ERROR_KEY, se.getMessage())); request.setAttribute(Globals.ERROR_KEY, errors); return mapping.getInputForward(); }catch(Exception ex){ //TODO Architcture should handle this (ExceptionHandler) errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(ErrorCodes.UNKNOWN_ERROR)); request.setAttribute(Globals.ERROR_KEY, errors); return mapping.getInputForward(); } return mapping.findForward(Forwards.SUCCESS); } |
loadInfoMenuItem.setEnabled(false); | public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command == "Open"){ int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { try{ theData = new HaploData(fc.getSelectedFile()); infileName = fc.getSelectedFile().getName(); //compute D primes and monitor progress progressMonitor = new ProgressMonitor(this, "Computing " + theData.getToBeCompleted() + " values of D prime","", 0, theData.getToBeCompleted()); progressMonitor.setProgress(0); progressMonitor.setMillisToDecideToPopup(2000); final SwingWorker worker = new SwingWorker(){ public Object construct(){ theData.doMonitoredComputation(); return ""; } }; timer = new javax.swing.Timer(500, new ActionListener(){ public void actionPerformed(ActionEvent evt){ progressMonitor.setProgress(theData.getComplete()); if (theData.getComplete() == theData.getToBeCompleted()){ timer.stop(); progressMonitor.close(); infoKnown=false; drawPicture(theData); loadInfoMenuItem.setEnabled(true); hapMenuItem.setEnabled(true); customizeHapsMenuItem.setEnabled(true); exportMenuItem.setEnabled(true); saveDprimeMenuItem.setEnabled(true); clearBlocksMenuItem.setEnabled(true); guessBlocksMenuItem.setEnabled(true); } } }); worker.start(); timer.start(); }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } } } else if (command == loadInfoStr){ int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { try{ theData.prepareMarkerInput(fc.getSelectedFile()); infoKnown=true; loadInfoMenuItem.setEnabled(false); drawPicture(theData); }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } } }else if (command == "Clear All Blocks"){ theBlocks.clearBlocks(); }else if (command == "Define Blocks"){ defineBlocks(); }else if (command == "Customize Haplotype Output"){ customizeHaps(); }else if (command == "Tutorial"){ showHelp(); }else if (command == "Export LD Picture to JPG"){ doExportDPrime(); }else if (command == "Dump LD Output to Text"){ saveDprimeToText(); }else if (command == "Save Haplotypes to Text"){ saveHapsToText(); }else if (command == "Save Haplotypes to JPG"){ saveHapsPic(); }else if (command == "Generate Haplotypes"){ try{ drawHaplos(theData.generateHaplotypes(theData.blocks, haploThresh)); saveHapsMenuItem.setEnabled(true); saveHapsPicMenuItem.setEnabled(true); }catch (IOException ioe){} } else if (command == "Exit"){ System.exit(0); } } |
|
dm.dPrimeDraw(theData.dPrimeTable, image.getGraphics()); | dm.dPrimeDraw(theData.dPrimeTable, infoKnown, theData.markerInfo, image.getGraphics()); | void doExportDPrime(){ int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION){ try { int scaleSize = theData.dPrimeTable.length*30; DrawingMethods dm = new DrawingMethods(); BufferedImage image = new BufferedImage(scaleSize, scaleSize, BufferedImage.TYPE_3BYTE_BGR); dm.dPrimeDraw(theData.dPrimeTable, image.getGraphics()); dm.saveImage(image, fc.getSelectedFile().getPath()); } catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } } } |
theDPrime = new DPrimePanel(theData.dPrimeTable); | theDPrime = new DPrimePanel(theData.dPrimeTable, infoKnown, theData.markerInfo); | void drawPicture(HaploData theData){ contents = getContentPane(); contents.removeAll(); //first, draw the D' picture contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); theDPrime = new DPrimePanel(theData.dPrimeTable); JPanel holderPanel = new JPanel(); holderPanel.add(theDPrime); holderPanel.setBackground(new Color(192,192,192)); JScrollPane dPrimeScroller = new JScrollPane(holderPanel); dPrimeScroller.getVerticalScrollBar().setUnitIncrement(60); dPrimeScroller.getHorizontalScrollBar().setUnitIncrement(60); contents.add(dPrimeScroller); //next add a little spacer contents.add(Box.createRigidArea(new Dimension(0,5))); //and then add the block display theBlocks = new BlockDisplay(theData.markerInfo, theData.blocks, theDPrime, infoKnown); contents.setBackground(Color.black); //put the block display in a scroll pane in case the data set is very large. JScrollPane blockScroller = new JScrollPane(theBlocks, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); blockScroller.getHorizontalScrollBar().setUnitIncrement(60); blockScroller.setMinimumSize(new Dimension(800, 100)); contents.add(blockScroller); repaint(); setVisible(true); } |
StringBuffer output = new StringBuffer(component.draw(context)); | StringBuffer output = new StringBuffer(); output.append("<div id=\"" + getId() + "\">"); output.append(component.draw(context)); output.append("</div>"); | public String draw(DashboardContext context) { StringBuffer output = new StringBuffer(component.draw(context)); String appId = context.getWebContext().getApplicationConfig().getApplicationId(); output.append("\n<script>"); output.append("self.setTimeout(\"refreshDBComponent("); output.append("''"); output.append(getId()); output.append("'', "); output.append(refreshInterval + ", " + appId + ")\", " + refreshInterval + ");"); output.append("</script>"); return output.toString(); } |
if ( match ) newRowMap.add(row); | if ( match ) { newRowMap.add(tableTextConverter.modelIndex(row)); } | private void search(String searchText) { rowMapping = null; fireTableDataChanged(); List<Integer> newRowMap = new ArrayList<Integer>(); CharSequence searchSubSequence = searchText == null ? null : searchText.toLowerCase().subSequence(0,searchText.length()); for ( int row = 0; row < tableModel.getRowCount(); row++ ) { boolean match = false; if ( searchSubSequence == null ) { match = true; } else { for ( int column = 0; column < tableModel.getColumnCount(); column++ ) { String value = tableTextConverter.getTextForCell(row, column); if (value.toLowerCase().contains(searchSubSequence)) { if (logger.isDebugEnabled()) { logger.debug("Match: "+value.toLowerCase()+" contains "+searchSubSequence); } match = true; break; } } } if ( match ) newRowMap.add(row); } setSearchText(searchText); rowMapping = newRowMap; if (logger.isDebugEnabled()) { logger.debug("new row mapping after search: "+rowMapping); } fireTableDataChanged(); } |
hash3 = ImageInstance.calcHash( testfile3); PhotoInfo photos3[] = PhotoInfo.retrieveByOrigHash( hash3 ); if ( photos3 != null ) { for ( int n = 0; n < photos3.length; n++ ) { photos3[n].delete(); } } | public void setUp() { File testfile1 = null; File testfile2 = null; try { // Create the directories extVolDir = File.createTempFile( "pv_indexer_test_", "" ); extVolDir.delete(); extVolDir.mkdir(); File extVolSubdir = new File( extVolDir, "test" ); extVolSubdir.mkdir(); testfile1 = new File("testfiles", "test1.jpg"); testfile2 = new File( "testfiles", "test2.jpg" ); photo1 = new File( extVolDir, "test1.jpg"); FileUtils.copyFile( testfile1, photo1 ); photo2inst1 = new File( extVolDir, "test2.jpg"); FileUtils.copyFile( testfile2, photo2inst1 ); photo2inst2 = new File( extVolSubdir, "test2.jpg"); FileUtils.copyFile( testfile2, photo2inst2 ); // Non-image file in volume File txtFile = new File( extVolDir, "test.txt" ); FileWriter writer = new FileWriter( txtFile ); writer.write( "Not an image"); writer.close(); } catch (IOException ex) { ex.printStackTrace(); } // Create top folder for indexed files topFolder = PhotoFolder.create( "ExtVolTest", PhotoFolder.getRoot() ); // Remove the test files from database if they are already there hash1 = ImageInstance.calcHash( testfile1 ); PhotoInfo photos1[] = PhotoInfo.retrieveByOrigHash( hash1 ); if ( photos1 != null ) { for ( int n = 0; n < photos1.length; n++ ) { photos1[n].delete(); } } hash2 = ImageInstance.calcHash( testfile2); PhotoInfo photos2[] = PhotoInfo.retrieveByOrigHash( hash2 ); if ( photos2 != null ) { for ( int n = 0; n < photos2.length; n++ ) { photos2[n].delete(); } } } |
|
PhotoInfo photos1[] = PhotoInfo.retrieveByOrigHash( hash1 ); if ( photos1 != null ) { for ( int n = 0; n < photos1.length; n++ ) { photos1[n].delete(); } } PhotoInfo photos2[] = PhotoInfo.retrieveByOrigHash( hash2 ); if ( photos2 != null ) { for ( int n = 0; n < photos2.length; n++ ) { photos2[n].delete(); } } PhotoInfo photos3[] = PhotoInfo.retrieveByOrigHash( hash3 ); if ( photos3 != null ) { for ( int n = 0; n < photos3.length; n++ ) { photos3[n].delete(); } } | public void tearDown() { FileUtils.deleteTree( extVolDir ); topFolder.delete(); } |
|
ImageInstance i1 = p1.getInstance( 0 ); assertEquals( i1.getImageFile(), photo1 ); | public void testIndexing() { int n; ExternalVolume v = new ExternalVolume( "extVol", extVolDir.getAbsolutePath() ); ExtVolIndexer indexer = new ExtVolIndexer( v ); indexer.setTopFolder( topFolder ); TestListener l = new TestListener(); indexer.addIndexerListener( l ); assertEquals( "Indexing not started -> completeness must be 0", 0, indexer.getPercentComplete() ); assertNull( "StartTime must be null before starting", indexer.getStartTime() ); indexer.run(); // Check that all the files can be found PhotoInfo[] photos1 = PhotoInfo.retrieveByOrigHash( hash1 ); assertEquals( "Only 1 photo per picture should be found", 1, photos1.length ); PhotoInfo p1 = photos1[0]; assertEquals( "2 instances should be found in photo 1", 2, p1.getNumInstances() ); ImageInstance i1 = p1.getInstance( 0 ); assertEquals( i1.getImageFile(), photo1 ); PhotoInfo[] photos2 = PhotoInfo.retrieveByOrigHash( hash2 ); assertEquals( "1 photo per picture should be found", 1, photos2.length ); PhotoInfo p2 = photos2[0]; assertEquals( "3 instances should be found in photo 2", 3, p2.getNumInstances() ); boolean found[] = {false, false}; File files[] = {photo2inst1, photo2inst2}; for ( n = 0; n < p2.getNumInstances(); n++ ) { ImageInstance i = p2.getInstance( n ); for ( int m = 0; m < found.length; m++ ) { if ( files[m].equals( i.getImageFile() ) ) { found[m] = true; } } } for ( n = 0; n < found.length; n++ ) { assertTrue( "Photo " + n + " not found", found[n] ); } // Check that the folders have the correct photos PhotoInfo[] photosInTopFolder = { p1, p2 }; assertFolderHasPhotos( topFolder, photosInTopFolder ); PhotoFolder subFolder = topFolder.getSubfolder( 0 ); assertEquals( "Subfolder name not correct", "test", subFolder.getName() ); PhotoInfo[] photosInSubFolder = { p2 }; assertFolderHasPhotos( subFolder, photosInSubFolder ); // Check that the listener was called correctly assertEquals( "Wrong photo count in listener", 2, l.photoCount ); assertEquals( "Wrong photo count in indexer statistics", 2, indexer.getNewPhotoCount() ); assertEquals( "Wrong instance count in listener", 3, l.instanceCount ); assertEquals( "Wrong instance count in indexer statistics", 3, indexer.getNewInstanceCount() ); assertEquals( "Indexing complete 100%", 100, indexer.getPercentComplete() ); assertNotNull( "StartTime still null", indexer.getStartTime() ); } |
|
try { File testfile3 = new File( "testfiles", "test3.jpg" ); File f3 = new File( extVolDir, "test3.jpg"); FileUtils.copyFile( testfile3, f3 ); File f1 = new File ( extVolDir, "test1.jpg" ); FileUtils.copyFile( testfile3, f1 ); File f2 = new File( extVolDir, "test2.jpg" ); f2.delete(); } catch (IOException ex) { fail( "IOException while altering external volume: " + ex.getMessage() ); } indexer = new ExtVolIndexer( v ); indexer.setTopFolder( topFolder ); l = new TestListener(); indexer.addIndexerListener( l ); assertEquals( "Indexing not started -> completeness must be 0", 0, indexer.getPercentComplete() ); assertNull( "StartTime must be null before starting", indexer.getStartTime() ); indexer.run(); PhotoInfo[] photos3 = PhotoInfo.retrieveByOrigHash( hash3 ); assertEquals( "1 photo per picture should be found", 1, photos3.length ); PhotoInfo p3 = photos3[0]; PhotoInfo photosInTopFolder2[] = { p3 }; assertFolderHasPhotos( topFolder, photosInTopFolder2 ); assertEquals( "More than 1 subfolder in topFolder", 1, topFolder.getSubfolderCount() ); subFolder = topFolder.getSubfolder( 0 ); assertEquals( "Subfolder name not correct", "test", subFolder.getName() ); PhotoInfo[] photosInSubFolder2 = { p2 }; assertFolderHasPhotos( subFolder, photosInSubFolder2 ); Collection p2folders = p2.getFolders(); assertFalse( "p2 must not be in topFolder", p2folders.contains( topFolder ) ); | public void testIndexing() { int n; ExternalVolume v = new ExternalVolume( "extVol", extVolDir.getAbsolutePath() ); ExtVolIndexer indexer = new ExtVolIndexer( v ); indexer.setTopFolder( topFolder ); TestListener l = new TestListener(); indexer.addIndexerListener( l ); assertEquals( "Indexing not started -> completeness must be 0", 0, indexer.getPercentComplete() ); assertNull( "StartTime must be null before starting", indexer.getStartTime() ); indexer.run(); // Check that all the files can be found PhotoInfo[] photos1 = PhotoInfo.retrieveByOrigHash( hash1 ); assertEquals( "Only 1 photo per picture should be found", 1, photos1.length ); PhotoInfo p1 = photos1[0]; assertEquals( "2 instances should be found in photo 1", 2, p1.getNumInstances() ); ImageInstance i1 = p1.getInstance( 0 ); assertEquals( i1.getImageFile(), photo1 ); PhotoInfo[] photos2 = PhotoInfo.retrieveByOrigHash( hash2 ); assertEquals( "1 photo per picture should be found", 1, photos2.length ); PhotoInfo p2 = photos2[0]; assertEquals( "3 instances should be found in photo 2", 3, p2.getNumInstances() ); boolean found[] = {false, false}; File files[] = {photo2inst1, photo2inst2}; for ( n = 0; n < p2.getNumInstances(); n++ ) { ImageInstance i = p2.getInstance( n ); for ( int m = 0; m < found.length; m++ ) { if ( files[m].equals( i.getImageFile() ) ) { found[m] = true; } } } for ( n = 0; n < found.length; n++ ) { assertTrue( "Photo " + n + " not found", found[n] ); } // Check that the folders have the correct photos PhotoInfo[] photosInTopFolder = { p1, p2 }; assertFolderHasPhotos( topFolder, photosInTopFolder ); PhotoFolder subFolder = topFolder.getSubfolder( 0 ); assertEquals( "Subfolder name not correct", "test", subFolder.getName() ); PhotoInfo[] photosInSubFolder = { p2 }; assertFolderHasPhotos( subFolder, photosInSubFolder ); // Check that the listener was called correctly assertEquals( "Wrong photo count in listener", 2, l.photoCount ); assertEquals( "Wrong photo count in indexer statistics", 2, indexer.getNewPhotoCount() ); assertEquals( "Wrong instance count in listener", 3, l.instanceCount ); assertEquals( "Wrong instance count in indexer statistics", 3, indexer.getNewInstanceCount() ); assertEquals( "Indexing complete 100%", 100, indexer.getPercentComplete() ); assertNotNull( "StartTime still null", indexer.getStartTime() ); } |
|
isConsistent = (dbHash.equals( realHash ) ); | isConsistent = Arrays.equals( dbHash, realHash ); | public boolean doConsistencyCheck() { boolean isConsistent = true; boolean needsHashCheck = false; ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); File f = this.getImageFile(); if ( f.exists() ) { long size = f.length(); if ( size != this.fileSize ) { isConsistent = false; if ( this.fileSize == 0 ) { needsHashCheck = true; } } long mtime = f.lastModified(); if ( mtime != this.mtime ) { needsHashCheck = true; } if ( needsHashCheck ) { byte[] dbHash = hash.clone(); calcHash(); byte[] realHash = hash.clone(); isConsistent = (dbHash.equals( realHash ) ); if ( isConsistent ) { txw.lock( this, Transaction.WRITE ); this.mtime = mtime; this.fileSize = size; } } } /* Update the database with check result if it was positive */ if ( isConsistent ) { txw.lock( this, Transaction.WRITE ); this.checkTime = new java.util.Date(); } txw.commit(); return isConsistent; } |
Filter<?> filter = Filter.getOpenFilter((Class<? extends Storable>) property.getType()); | Filter<?> filter = Filter.getOpenFilter(property.getEnclosingType()); | private boolean isProperJoin(StorableProperty<?> property) throws SupportException, RepositoryException { if (!property.isJoin() || property.isQuery()) { return false; } // Make up a filter over the join's internal properties and then search // for an index that filters with no remainder. Filter<?> filter = Filter.getOpenFilter((Class<? extends Storable>) property.getType()); int count = property.getJoinElementCount(); for (int i=0; i<count; i++) { filter = filter.and(property.getExternalJoinElement(i).getName(), RelOp.EQ); } // Java generics are letting me down. I cannot use proper specification // because compiler gets confused with all the wildcards. Collection indexes = indexesFor(filter.getStorableType()); if (indexes != null) { for (Object index : indexes) { FilteringScore score = FilteringScore.evaluate((StorableIndex) index, filter); if (score.getRemainderCount() == 0) { return true; } } } return false; } |
filter = filter.and(property.getExternalJoinElement(i).getName(), RelOp.EQ); | filter = filter.and(property.getInternalJoinElement(i).getName(), RelOp.EQ); | private boolean isProperJoin(StorableProperty<?> property) throws SupportException, RepositoryException { if (!property.isJoin() || property.isQuery()) { return false; } // Make up a filter over the join's internal properties and then search // for an index that filters with no remainder. Filter<?> filter = Filter.getOpenFilter((Class<? extends Storable>) property.getType()); int count = property.getJoinElementCount(); for (int i=0; i<count; i++) { filter = filter.and(property.getExternalJoinElement(i).getName(), RelOp.EQ); } // Java generics are letting me down. I cannot use proper specification // because compiler gets confused with all the wildcards. Collection indexes = indexesFor(filter.getStorableType()); if (indexes != null) { for (Object index : indexes) { FilteringScore score = FilteringScore.evaluate((StorableIndex) index, filter); if (score.getRemainderCount() == 0) { return true; } } } return false; } |
BufferedImage bi = null; | public void testRotationChange() { ThumbnailView view = new ThumbnailView(); view.setPhoto( photo ); pane.add( view ); showFrame(); Iterator writers = ImageIO.getImageWritersByFormatName("png"); ImageWriter writer = (ImageWriter)writers.next(); tester.waitForIdle(); // TODO: FIX for build errors // BufferedImage bi = abbot.tester.Robot.capture( view ); BufferedImage bi = null; File f = new File( testRefImageDir, "thumbnailRotation1.png" ); assertTrue( "thumbnailRotationnnot correct", photovault.test.ImgTestUtils.compareImgToFile( bi, f ) ); photo.setPrefRotation( 107 ); tester.waitForIdle(); // TODO: FIX for build errors // bi = abbot.tester.Robot.capture( view ); f = new File( testRefImageDir, "thumbnailRotation2.png" ); assertTrue( "107 deg rotation not correct", photovault.test.ImgTestUtils.compareImgToFile( bi, f ) ); } |
|
bi = tester.capture( view ); | public void testRotationChange() { ThumbnailView view = new ThumbnailView(); view.setPhoto( photo ); pane.add( view ); showFrame(); Iterator writers = ImageIO.getImageWritersByFormatName("png"); ImageWriter writer = (ImageWriter)writers.next(); tester.waitForIdle(); // TODO: FIX for build errors // BufferedImage bi = abbot.tester.Robot.capture( view ); BufferedImage bi = null; File f = new File( testRefImageDir, "thumbnailRotation1.png" ); assertTrue( "thumbnailRotationnnot correct", photovault.test.ImgTestUtils.compareImgToFile( bi, f ) ); photo.setPrefRotation( 107 ); tester.waitForIdle(); // TODO: FIX for build errors // bi = abbot.tester.Robot.capture( view ); f = new File( testRefImageDir, "thumbnailRotation2.png" ); assertTrue( "107 deg rotation not correct", photovault.test.ImgTestUtils.compareImgToFile( bi, f ) ); } |
|
BufferedImage bi = null; | BufferedImage bi = tester.capture( view ); | public void testThumbnailShow() { ThumbnailView view = new ThumbnailView(); view.setPhoto( photo ); pane.add( view ); showFrame(); view.repaint(); tester.waitForIdle();// Iterator writers = ImageIO.getImageWritersByFormatName("png");// ImageWriter writer = (ImageWriter)writers.next();// BufferedImage bi = abbot.tester.Robot.capture( view ); // TODO: Fix for build problem BufferedImage bi = null; File f = new File( testRefImageDir, "thumbnailShow1.png" ); assertTrue( photovault.test.ImgTestUtils.compareImgToFile( bi, f ) ); view.setShowShootingTime( false ); tester.waitForIdle(); // TODO: Fix for build errors // bi = abbot.tester.Robot.capture( view ); f = new File( testRefImageDir, "thumbnailShow2.png" ); assertTrue( photovault.test.ImgTestUtils.compareImgToFile( bi, f ) ); view.setShowShootingPlace( false ); tester.waitForIdle(); // TODO: FIX for build errors // bi = abbot.tester.Robot.capture( view ); f = new File( testRefImageDir, "thumbnailShow3.png" ); assertTrue( photovault.test.ImgTestUtils.compareImgToFile( bi, f ) ); } |
bi = tester.capture( view ); | public void testThumbnailShow() { ThumbnailView view = new ThumbnailView(); view.setPhoto( photo ); pane.add( view ); showFrame(); view.repaint(); tester.waitForIdle();// Iterator writers = ImageIO.getImageWritersByFormatName("png");// ImageWriter writer = (ImageWriter)writers.next();// BufferedImage bi = abbot.tester.Robot.capture( view ); // TODO: Fix for build problem BufferedImage bi = null; File f = new File( testRefImageDir, "thumbnailShow1.png" ); assertTrue( photovault.test.ImgTestUtils.compareImgToFile( bi, f ) ); view.setShowShootingTime( false ); tester.waitForIdle(); // TODO: Fix for build errors // bi = abbot.tester.Robot.capture( view ); f = new File( testRefImageDir, "thumbnailShow2.png" ); assertTrue( photovault.test.ImgTestUtils.compareImgToFile( bi, f ) ); view.setShowShootingPlace( false ); tester.waitForIdle(); // TODO: FIX for build errors // bi = abbot.tester.Robot.capture( view ); f = new File( testRefImageDir, "thumbnailShow3.png" ); assertTrue( photovault.test.ImgTestUtils.compareImgToFile( bi, f ) ); } |
|
permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); | if (tdtPanel != null){ permSet.cat(tdtPanel.getTestSet()); } if (hapAssocPanel != null){ permSet.cat(hapAssocPanel.getTestSet()); } | public void stateChanged(ChangeEvent e) { if (tabs.getSelectedIndex() != -1){ window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); String title = tabs.getTitleAt(tabs.getSelectedIndex()); if (title.equals(VIEW_DPRIME) || title.equals(VIEW_HAPLOTYPES)){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(true); exportMenuItems[2].setEnabled(true); }else if (title.equals(VIEW_ASSOC) || title.equals(VIEW_CHECK_PANEL) || title.equals(VIEW_TAGGER)){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(false); exportMenuItems[2].setEnabled(true); }else if (title.equals(VIEW_PLINK)){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(false); exportMenuItems[2].setEnabled(false); }else{ exportMenuItems[0].setEnabled(false); exportMenuItems[1].setEnabled(false); } //if we've adjusted the haps display thresh we need to change the haps ass panel if (title.equals(VIEW_ASSOC)){ JTabbedPane metaAssoc = ((JTabbedPane)((HaploviewTab)tabs.getSelectedComponent()).getComponent(0)); //this is the haps ass tab inside the assoc super-tab HaploAssocPanel htp = (HaploAssocPanel) metaAssoc.getComponent(1); if (htp.initialHaplotypeDisplayThreshold != Options.getHaplotypeDisplayThreshold() && !Chromosome.getDataChrom().equalsIgnoreCase("chrx")){ htp.makeTable(new AssociationTestSet(theData.getHaplotypes(), null)); permutationPanel.setBlocksChanged(); AssociationTestSet custSet = null; if (custAssocPanel != null){ custSet = custAssocPanel.getTestSet(); } AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet( new PermutationTestSet(0,theData.getPedFile(),custSet,permSet)); } } if (title.equals(VIEW_DPRIME)){ keyMenu.setEnabled(true); }else{ keyMenu.setEnabled(false); } viewMenuItems[tabs.getSelectedIndex()].setSelected(true); if (checkPanel != null && checkPanel.changed){ //first store up the current blocks Vector currentBlocks = new Vector(); for (int blocks = 0; blocks < theData.blocks.size(); blocks++){ int thisBlock[] = (int[]) theData.blocks.elementAt(blocks); int thisBlockReal[] = new int[thisBlock.length]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlockReal[marker] = Chromosome.realIndex[thisBlock[marker]]; } currentBlocks.add(thisBlockReal); } Chromosome.doFilter(checkPanel.getMarkerResults()); //after editing the filtered marker list, needs to be prodded into //resizing correctly dPrimeDisplay.computePreferredSize(); dPrimeDisplay.colorDPrime(); dPrimeDisplay.revalidate(); hapDisplay.theData = theData; if (currentBlockDef != BLOX_CUSTOM){ changeBlocks(currentBlockDef); }else{ //adjust the blocks Vector theBlocks = new Vector(); for (int x = 0; x < currentBlocks.size(); x++){ Vector goodies = new Vector(); int currentBlock[] = (int[])currentBlocks.elementAt(x); for (int marker = 0; marker < currentBlock.length; marker++){ for (int y = 0; y < Chromosome.realIndex.length; y++){ //we only keep markers from the input that are "good" from checkdata //we also realign the input file to the current "good" subset since input is //indexed of all possible markers in the dataset if (Chromosome.realIndex[y] == currentBlock[marker]){ goodies.add(new Integer(y)); } } } int thisBlock[] = new int[goodies.size()]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlock[marker] = ((Integer)goodies.elementAt(marker)).intValue(); } if (thisBlock.length > 1){ theBlocks.add(thisBlock); } } theData.guessBlocks(BLOX_CUSTOM, theBlocks); } if (tdtPanel != null){ tdtPanel.refreshTable(); } if (taggerConfigPanel != null){ taggerConfigPanel.refreshTable(); } if(permutationPanel != null) { permutationPanel.setBlocksChanged(); AssociationTestSet custSet = null; if (custAssocPanel != null){ custSet = custAssocPanel.getTestSet(); } AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet( new PermutationTestSet(0,theData.getPedFile(),custSet,permSet)); } checkPanel.changed=false; } if (hapDisplay != null && theData.blocksChanged){ try{ hapDisplay.getHaps(); if(Options.getAssocTest() != ASSOC_NONE ){ //this is the haps ass tab inside the assoc super-tab hapAssocPanel.makeTable(new AssociationTestSet(theData.getHaplotypes(), null)); permutationPanel.setBlocksChanged(); AssociationTestSet custSet = null; if (custAssocPanel != null){ custSet = custAssocPanel.getTestSet(); } AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet( new PermutationTestSet(0,theData.getPedFile(),custSet,permSet)); } }catch(HaploViewException hv){ JOptionPane.showMessageDialog(window, hv.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); theData.blocksChanged = false; } if (theData.finished){ setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } |
StringTokenizer enum = new StringTokenizer( text, "," ); | StringTokenizer dimensionEnum = new StringTokenizer( text, "," ); | public Object convert(Class type, Object value) { if ( value != null ) { String text = value.toString(); StringTokenizer enum = new StringTokenizer( text, "," ); int width = 0; int height = 0; if ( enum.hasMoreTokens() ) { width = parseNumber( enum.nextToken() ); } if ( enum.hasMoreTokens() ) { height = parseNumber( enum.nextToken() ); } |
if ( enum.hasMoreTokens() ) { width = parseNumber( enum.nextToken() ); | if ( dimensionEnum.hasMoreTokens() ) { width = parseNumber( dimensionEnum.nextToken() ); | public Object convert(Class type, Object value) { if ( value != null ) { String text = value.toString(); StringTokenizer enum = new StringTokenizer( text, "," ); int width = 0; int height = 0; if ( enum.hasMoreTokens() ) { width = parseNumber( enum.nextToken() ); } if ( enum.hasMoreTokens() ) { height = parseNumber( enum.nextToken() ); } |
if ( enum.hasMoreTokens() ) { height = parseNumber( enum.nextToken() ); | if ( dimensionEnum.hasMoreTokens() ) { height = parseNumber( dimensionEnum.nextToken() ); | public Object convert(Class type, Object value) { if ( value != null ) { String text = value.toString(); StringTokenizer enum = new StringTokenizer( text, "," ); int width = 0; int height = 0; if ( enum.hasMoreTokens() ) { width = parseNumber( enum.nextToken() ); } if ( enum.hasMoreTokens() ) { height = parseNumber( enum.nextToken() ); } |
return new Dimension( width, height ); } return null; } | public Object convert(Class type, Object value) { if ( value != null ) { String text = value.toString(); StringTokenizer enum = new StringTokenizer( text, "," ); int width = 0; int height = 0; if ( enum.hasMoreTokens() ) { width = parseNumber( enum.nextToken() ); } if ( enum.hasMoreTokens() ) { height = parseNumber( enum.nextToken() ); } |
|
if (freqs[i] > fourGameteCutoff) numGam++; | if (freqs[i] > fourGameteCutoff + 1E-8) numGam++; | static Vector do4Gamete(PairwiseLinkage[][] dPrime){ Vector blocks = new Vector(); Vector strongPairs = new Vector(); //first make a list of marker pairs with < 4 gametes, sorted by distance apart for (int x = 0; x < dPrime.length-1; x++){ for (int y = x+1; y < dPrime.length; y++){ PairwiseLinkage thisPair = dPrime[x][y]; if (thisPair == null) { continue; } double[] freqs = thisPair.getFreqs(); int numGam = 0; for (int i = 0; i < freqs.length; i++){ if (freqs[i] > fourGameteCutoff) numGam++; } if (numGam > 3){ continue; } Vector addMe = new Vector(); //a vector of x, y, separation int sep = y - x - 1; //compute separation of two markers addMe.add(String.valueOf(x)); addMe.add(String.valueOf(y)); addMe.add(String.valueOf(sep)); if (strongPairs.size() == 0){ //put first pair first strongPairs.add(addMe); }else{ //sort by descending separation of markers in each pair boolean unplaced = true; for (int v = 0; v < strongPairs.size(); v ++){ if (sep >= Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(2))){ strongPairs.insertElementAt(addMe, v); unplaced = false; break; } } if (unplaced) {strongPairs.add(addMe);} } } } //now take this list of pairs with 3 gametes and construct blocks boolean[] usedInBlock = new boolean[dPrime.length + 1]; for (int v = 0; v < strongPairs.size(); v++){ boolean isABlock = true; int first = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(0)); int last = Integer.parseInt((String)((Vector)strongPairs.elementAt(v)).elementAt(1)); //first see if this block overlaps with another: if (usedInBlock[first] || usedInBlock[last]) continue; //test this block. for (int y = first+1; y <= last; y++){ //loop over columns in row y for (int x = first; x < y; x++){ PairwiseLinkage thisPair = dPrime[x][y]; if(thisPair == null){ continue; } double[] freqs = thisPair.getFreqs(); int numGam = 0; for (int i = 0; i < freqs.length; i++){ if (freqs[i] > fourGameteCutoff) numGam++; } if (numGam > 3){ isABlock = false; } } } if (isABlock){ //add to the block list, but in order by first marker number: if (blocks.size() == 0){ //put first block first blocks.add(first + " " + last); }else{ //sort by ascending separation of markers in each pair boolean placed = false; for (int b = 0; b < blocks.size(); b ++){ StringTokenizer st = new StringTokenizer((String)blocks.elementAt(b)); if (first < Integer.parseInt(st.nextToken())){ blocks.insertElementAt(first + " " + last, b); placed = true; break; } } //make sure to put in blocks which fall on the tail end if (!placed) blocks.add(first + " " + last); } for (int used = first; used <= last; used++){ usedInBlock[used] = true; } } } return stringVec2intVec(blocks); } |
else { | else if(var == null) { | protected void processBean(String var, Object bean) throws Exception { if (var != null) { context.setVariable(var, bean); } // now lets try set the parent property via calling the adder or the setter method if (bean != null) { Object parentObject = getParentObject(); if (parentObject != null) { if (parentObject instanceof Collection) { Collection collection = (Collection) parentObject; collection.add(bean); } else { // lets see if there's a setter method... Method method = findAddMethod(parentObject.getClass(), bean.getClass()); if (method != null) { Object[] args = { bean }; try { method.invoke(parentObject, args); } catch (Exception e) { throw new JellyException( "failed to invoke method: " + method + " on bean: " + parentObject + " reason: " + e, e ); } } else { BeanUtils.setProperty(parentObject, tagName, bean); } } } else { // lets try find a parent List to add this bean to CollectionTag tag = (CollectionTag) findAncestorWithClass(CollectionTag.class); if (tag != null) { tag.addItem(bean); } else { log.warn( "Could not add bean to parent for bean: " + bean ); } } } } |
"If you are reporting a problem please include the contents of this log.\[email protected]\n"+ | "If you are reporting a problem please include the contents of this log.\n"+ Constants.EMAIL_STRING+"\n"+ | private static void createAndShowGUI() { contentFrame = new JFrame("Haploview Error Log"); contentFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); JComponent newContentPane = new JPanel(); newContentPane.setOpaque(true); //content panes must be opaque errorTextArea = new JTextArea(15,50); errorTextArea.setEditable(false); errorTextArea.setLineWrap(true); JScrollPane scrollPane = new JScrollPane(errorTextArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); errorTextArea.append("*************************\n"+ "If you are reporting a problem please include the contents of this log.\[email protected]\n"+ "*************************\n"); newContentPane.add(scrollPane); contentFrame.setContentPane(newContentPane); contentFrame.pack(); contentFrame.setVisible(true); } |
public String getURL(String action) { return doc.getURL(action, context); | public String getURL() { return doc.getURL("view", context); | public String getURL(String action) { return doc.getURL(action, context); } |
SQLObject so = (SQLObject) p.getLastPathComponent(); if (so instanceof SQLDatabase) { DBConnectionSpec dbcs = ((SQLDatabase) so).getConnectionSpec(); | Object [] pathArray = p.getPath(); int ii = 0; SQLDatabase sd = null; while (ii < pathArray.length && sd == null) { if (pathArray[ii] instanceof SQLDatabase) { sd = (SQLDatabase) pathArray[ii]; } ii++; } if (sd != null) { DBConnectionSpec dbcs = sd.getConnectionSpec(); | public void actionPerformed(ActionEvent e) { TreePath p = getSelectionPath(); if (p == null) { return; } SQLObject so = (SQLObject) p.getLastPathComponent(); if (so instanceof SQLDatabase) { DBConnectionSpec dbcs = ((SQLDatabase) so).getConnectionSpec(); logger.debug("Setting existing DBCS on panel: "+dbcs); edittingDB = (SQLDatabase) so; dbcsPanel.setDbcs(dbcs); propDialog.setVisible(true); propDialog.requestFocus(); } else if (so instanceof SQLCatalog) { // XXX: no action yet } else if (so instanceof SQLSchema) { // XXX: no action yet } else if (so instanceof SQLTable) { // XXX: no action yet } else if (so instanceof SQLColumn) { // XXX: no action yet } } |
edittingDB = (SQLDatabase) so; | edittingDB = sd; | public void actionPerformed(ActionEvent e) { TreePath p = getSelectionPath(); if (p == null) { return; } SQLObject so = (SQLObject) p.getLastPathComponent(); if (so instanceof SQLDatabase) { DBConnectionSpec dbcs = ((SQLDatabase) so).getConnectionSpec(); logger.debug("Setting existing DBCS on panel: "+dbcs); edittingDB = (SQLDatabase) so; dbcsPanel.setDbcs(dbcs); propDialog.setVisible(true); propDialog.requestFocus(); } else if (so instanceof SQLCatalog) { // XXX: no action yet } else if (so instanceof SQLSchema) { // XXX: no action yet } else if (so instanceof SQLTable) { // XXX: no action yet } else if (so instanceof SQLColumn) { // XXX: no action yet } } |
} else if (so instanceof SQLCatalog) { } else if (so instanceof SQLSchema) { } else if (so instanceof SQLTable) { } else if (so instanceof SQLColumn) { | public void actionPerformed(ActionEvent e) { TreePath p = getSelectionPath(); if (p == null) { return; } SQLObject so = (SQLObject) p.getLastPathComponent(); if (so instanceof SQLDatabase) { DBConnectionSpec dbcs = ((SQLDatabase) so).getConnectionSpec(); logger.debug("Setting existing DBCS on panel: "+dbcs); edittingDB = (SQLDatabase) so; dbcsPanel.setDbcs(dbcs); propDialog.setVisible(true); propDialog.requestFocus(); } else if (so instanceof SQLCatalog) { // XXX: no action yet } else if (so instanceof SQLSchema) { // XXX: no action yet } else if (so instanceof SQLTable) { // XXX: no action yet } else if (so instanceof SQLColumn) { // XXX: no action yet } } |
|
System.out.println ("Schema enabled"); | logger.info("Schema enabled"); | public void cleanup() throws ArchitectException { setCleanupExceptionMessage("Could not populate catalog dropdown!"); catalogComboBox.removeAllItems(); catalogComboBox.setEnabled(false); schemaComboBox.removeAllItems(); schemaComboBox.setEnabled(false); try { if (database.isCatalogContainer()) { for (SQLObject o : (List<SQLObject>) database.getChildren()) { catalogComboBox.addItem(o); } catalogComboBox.setEnabled(true); } if (database.isSchemaContainer()) { for (SQLObject o : (List<SQLObject>) database.getChildren()) { schemaComboBox.addItem(o); } schemaComboBox.setEnabled(true); System.out.println ("Schema enabled"); } } catch (ArchitectException ex) { JOptionPane.showMessageDialog(panel, "Database Connection Erorr", "Error", JOptionPane.ERROR_MESSAGE); database = null; } finally { } } |
String testImgDir = "c:\\java\\photovault\\testfiles"; | public void testPhotoAddition() { String testImgDir = "c:\\java\\photovault\\testfiles"; String fname = "test1.jpg"; File f = new File( testImgDir, fname ); PhotoInfo photo = null; try { photo = PhotoInfo.addToDB( f ); } catch ( PhotoNotFoundException e ) { fail( "Could not find photo: " + e.getMessage() ); } PhotoFolder folder = null; // Create a folder for the photo try { folder = PhotoFolder.create( "PhotoAdditionTest", PhotoFolder.getRoot() ); folder.addPhoto( photo ); assertEquals( "Photo not visible in folders' photo count", folder.getPhotoCount(), 1 ); } finally { // Clean up the test folder PhotoFolder parent = folder.getParentFolder(); parent.removeSubfolder( folder ); } } |
|
try { | logger.debug("all done, terminating timer thread..."); try { logger.debug("monitorable.isFinished():" + monitorable.isFinished()); | public void actionPerformed(ActionEvent evt) { // update the progress bar try { Integer jobSize = monitorable.getJobSize(); if (jobSize == null) { bar.setIndeterminate(true); } else { bar.setIndeterminate(false); bar.setMaximum(jobSize.intValue()); } if (label != null) { label.setVisible(true); } bar.setVisible(true); bar.setValue(monitorable.getProgress()); bar.setIndeterminate(false); } catch (ArchitectException e) { logger.error("Couldn't update progress bar (Monitorable threw an exception)", e); } finally { try { if (monitorable.isFinished()) { if (label != null) { label.setVisible(false); } bar.setVisible(false); timer.stop(); } } catch (ArchitectException e1) { logger.error("Couldn't tell if Monitorable was finished (it threw an exception)", e1); } } } |
logger.debug("did the timer thread stop???"); | public void actionPerformed(ActionEvent evt) { // update the progress bar try { Integer jobSize = monitorable.getJobSize(); if (jobSize == null) { bar.setIndeterminate(true); } else { bar.setIndeterminate(false); bar.setMaximum(jobSize.intValue()); } if (label != null) { label.setVisible(true); } bar.setVisible(true); bar.setValue(monitorable.getProgress()); bar.setIndeterminate(false); } catch (ArchitectException e) { logger.error("Couldn't update progress bar (Monitorable threw an exception)", e); } finally { try { if (monitorable.isFinished()) { if (label != null) { label.setVisible(false); } bar.setVisible(false); timer.stop(); } } catch (ArchitectException e1) { logger.error("Couldn't tell if Monitorable was finished (it threw an exception)", e1); } } } |
|
logger.debug("in constructor, setting finished to false..."); | public LoadJDBCDrivers (List driverJarList) throws ArchitectException { this.driverJarList = driverJarList; finished = false; } |
|
logger.debug("done loading (error condition), setting finished to true."); | public void execute() { try { Iterator it = driverJarList.iterator(); while (it.hasNext()) { // initialize counters jarCount++; logger.debug("**************** processin file #" + jarCount + " of " + driverJarList.size()); String path = (String) it.next(); addJarFile(new File(path)); } finished = true; } catch ( Exception exp ) { logger.error("something went wrong in LoadJDBCDrivers worker thread!",exp); } finally { finished = true; } } |
|
new javax.swing.Timer(50, watcher).start(); | protected void revertToUserSettings() throws ArchitectException { dtm.setRoot(new DefaultMutableTreeNode()); LoadJDBCDrivers ljd = new LoadJDBCDrivers(session.getDriverJarList()); LoadJDBCDriversWorker worker = new LoadJDBCDriversWorker(ljd); ProgressWatcher watcher = new ProgressWatcher(progressBar,ljd,progressLabel); new javax.swing.Timer(50, watcher).start(); new Thread(worker).start(); } |
|
logWriter = new LogWriter(ArchitectSession.getInstance().getUserSettings().getDDLUserSettings().getString(DDLUserSettings.PROP_DDL_LOG_PATH,"")); | logWriter = new LogWriter(ArchitectSessionImpl.getInstance().getUserSettings().getDDLUserSettings().getString(DDLUserSettings.PROP_DDL_LOG_PATH,"")); | public void doStuff() { finished = false; hasStarted = true; if (isCanceled() || finished) return; SQLDatabase target = new SQLDatabase(targetDataSource); statusLabel.setText("Creating objects in target database " + target.getDataSource() ); // XXX This is not being used but possibly should be?? //ProgressWatcher pw = new ProgressWatcher(progressBar, this, statusLabel); stmtsTried = 0; stmtsCompleted = 0; logger.debug("the Target Database is: " + target.getDataSource()); Connection con; Statement stmt; try { con = target.getConnection(); } catch (ArchitectException ex) { finished = true; throw new RuntimeException( "Couldn't connect to target database: "+ex.getMessage() +"\nPlease check the connection settings and try again.", ex); } catch (Exception ex) { finished = true; logger.error("Unexpected exception in DDL generation", ex); throw new RuntimeException("You have to specify a target database connection" +"\nbefore executing this script."); } try { logger.debug("the connection thinks it is: " + con.getMetaData().getURL()); stmt = con.createStatement(); } catch (SQLException ex) { finished = true; throw new RuntimeException("Couldn't generate DDL statements: " +ex.getMessage()+"\nThe problem was reported by " + "the target database."); } LogWriter logWriter = null; try { logWriter = new LogWriter(ArchitectSession.getInstance().getUserSettings().getDDLUserSettings().getString(DDLUserSettings.PROP_DDL_LOG_PATH,"")); } catch (ArchitectException ex) { finished = true; final Exception fex = ex; throw new RuntimeException("A problem with the DDL log file " + "prevented\n DDL generation from running:\n\n"+fex.getMessage()); } try { logWriter.info("Starting DDL Generation at " + new java.util.Date(System.currentTimeMillis())); logWriter.info("Database Target: " + target.getDataSource()); logWriter.info("Playpen Dump: " + target.getDataSource()); statementResultList.add(new LabelValueBean("Target Table Creation Log" ,"\n")); Iterator it = statements.iterator(); while (it.hasNext() && !finished && !isCanceled()) { DDLStatement ddlStmt = (DDLStatement) it.next(); String status = "Unknown"; try { stmtsTried++; logWriter.info("executing: " + ddlStmt.getSQLText()); stmt.executeUpdate(ddlStmt.getSQLText()); stmtsCompleted++; status = "OK"; } catch (SQLException ex) { final Exception fex = ex; final String fsql = ddlStmt.getSQLText(); final LogWriter fLogWriter = logWriter; logWriter.info("sql statement failed: " + ex.getMessage()); status = "SQL statement failed: " + ex.getMessage(); try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { JTextArea jta = new JTextArea(fsql,25,40); jta.setEditable(false); JScrollPane jsp = new JScrollPane(jta); JLabel errorLabel = new JLabel("<html>This SQL statement failed: "+fex.getMessage() +"<p>Do you want to continue?</html>"); JPanel jp = new JPanel(new BorderLayout()); jp.add(jsp,BorderLayout.CENTER); jp.add(errorLabel,BorderLayout.SOUTH); int decision = JOptionPane.showConfirmDialog (SQLScriptDialog.this, jp, "SQL Failure", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.NO_OPTION) { fLogWriter.info("Export cancelled by user."); statementResultList.add( new LabelValueBean("Wizard cancelled by user", "")); cancelJob(); } } }); } catch (InterruptedException ex2) { logger.warn("DDL Worker was interrupted during InvokeAndWait", ex2); status = "DDL Worker was interrupted during InvokeAndWait"; } catch (InvocationTargetException ex2) { final Exception fex2 = ex2; status = "Worker thread died: " +fex2.getMessage(); throw new RuntimeException("Worker thread died: " +fex2.getMessage()); } if (isCanceled()) { finished = true; // don't return, we might as well display how many statements ended up being processed... } } finally { statementResultList.add(new LabelValueBean( ddlStmt.toString(),status)); } } } catch (Exception exc){ logWriter.info("Caught Unexpected Exception " + exc); ASUtils.showExceptionDialog( SQLScriptDialog.this, "Couldn't finish running this SQL Script due to the following unexpected exception:", exc); } finally { final String resultsMessage = (stmtsCompleted == 0 ? "Did not execute any out of " : "Successfully executed " + stmtsCompleted + " out of ") + stmtsTried + " statements."; logWriter.info(resultsMessage); JOptionPane.showMessageDialog(SQLScriptDialog.this, resultsMessage); // flush and close the LogWriter logWriter.flush(); logWriter.close(); try { if (stmt != null) stmt.close(); } catch (SQLException ex) { logger.error("SQLException while closing statement", ex); } try { if (con != null) con.close(); } catch (SQLException ex) { logger.error("Couldn't close connection", ex); } } finished = true; } |
int i; for (i = 0; i <= 99; i++) { String jarName = prefs.get(jarFilePrefName(i), null); logger.debug("read Jar File entry: " + jarName); if (jarName == null) { break; } | Preferences jarNode = prefs.node(JAR_FILE_NODE_NAME); logger.debug("PreferencesManager.load(): jarNode " + jarNode); session.removeAllDriverJars(); for (int i = 0; i <= MAX_DRIVER_JAR_FILE_NAMES; i++) { String jarName = jarNode.get(jarFilePrefName(i), null); logger.debug("read Jar File entry: " + jarName); if (jarName == null) { break; } | public CoreUserSettings read(ArchitectSession session) throws IOException { logger.debug("loading UserSettings from java.util.prefs."); if ( prefs == null ) { prefs = ArchitectFrame.getMainInstance().getPrefs(); } logger.debug("Preferences class = " + prefs.getClass()); CoreUserSettings userSettings = new CoreUserSettings(); int i; for (i = 0; i <= 99; i++) { String jarName = prefs.get(jarFilePrefName(i), null); logger.debug("read Jar File entry: " + jarName); if (jarName == null) { break; } logger.debug("Adding JarName: " + jarName); session.addDriverJar(jarName); } // XXX Put prefs in sub-node, just delete it before you start. for (; i <= 99; i++) { if (prefs.get(jarFilePrefName(i), null) != null) { prefs.remove(jarFilePrefName(i)); } } userSettings.setPlDotIniPath(prefs.get("PL.INI.PATH", null)); UserSettings swingUserSettings = userSettings.getSwingSettings(); swingUserSettings.setBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, prefs.getBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, false)); ETLUserSettings etlUserSettings = userSettings.getETLUserSettings(); etlUserSettings.setString(ETLUserSettings.PROP_PL_ENGINE_PATH, prefs.get(ETLUserSettings.PROP_PL_ENGINE_PATH, "")); etlUserSettings.setString(ETLUserSettings.PROP_ETL_LOG_PATH, prefs.get(ETLUserSettings.PROP_ETL_LOG_PATH, defaultHomeFile("etl.log"))); DDLUserSettings ddlUserSettings = userSettings.getDDLUserSettings(); ddlUserSettings.setString(DDLUserSettings.PROP_DDL_LOG_PATH,prefs.get(DDLUserSettings.PROP_DDL_LOG_PATH, defaultHomeFile("ddl.log"))); QFAUserSettings qfaUserSettings = userSettings.getQfaUserSettings(); qfaUserSettings.setBoolean(QFAUserSettings.EXCEPTION_REPORTING,prefs.getBoolean(QFAUserSettings.EXCEPTION_REPORTING,true)); PrintUserSettings printUserSettings = userSettings.getPrintUserSettings(); printUserSettings.setDefaultPrinterName( prefs.get(PrintUserSettings.DEFAULT_PRINTER_NAME, "")); return userSettings; } |
logger.debug("Adding JarName: " + jarName); session.addDriverJar(jarName); } for (; i <= 99; i++) { if (prefs.get(jarFilePrefName(i), null) != null) { prefs.remove(jarFilePrefName(i)); } } | logger.debug("Adding JarName: " + jarName); session.addDriverJar(jarName); } | public CoreUserSettings read(ArchitectSession session) throws IOException { logger.debug("loading UserSettings from java.util.prefs."); if ( prefs == null ) { prefs = ArchitectFrame.getMainInstance().getPrefs(); } logger.debug("Preferences class = " + prefs.getClass()); CoreUserSettings userSettings = new CoreUserSettings(); int i; for (i = 0; i <= 99; i++) { String jarName = prefs.get(jarFilePrefName(i), null); logger.debug("read Jar File entry: " + jarName); if (jarName == null) { break; } logger.debug("Adding JarName: " + jarName); session.addDriverJar(jarName); } // XXX Put prefs in sub-node, just delete it before you start. for (; i <= 99; i++) { if (prefs.get(jarFilePrefName(i), null) != null) { prefs.remove(jarFilePrefName(i)); } } userSettings.setPlDotIniPath(prefs.get("PL.INI.PATH", null)); UserSettings swingUserSettings = userSettings.getSwingSettings(); swingUserSettings.setBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, prefs.getBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, false)); ETLUserSettings etlUserSettings = userSettings.getETLUserSettings(); etlUserSettings.setString(ETLUserSettings.PROP_PL_ENGINE_PATH, prefs.get(ETLUserSettings.PROP_PL_ENGINE_PATH, "")); etlUserSettings.setString(ETLUserSettings.PROP_ETL_LOG_PATH, prefs.get(ETLUserSettings.PROP_ETL_LOG_PATH, defaultHomeFile("etl.log"))); DDLUserSettings ddlUserSettings = userSettings.getDDLUserSettings(); ddlUserSettings.setString(DDLUserSettings.PROP_DDL_LOG_PATH,prefs.get(DDLUserSettings.PROP_DDL_LOG_PATH, defaultHomeFile("ddl.log"))); QFAUserSettings qfaUserSettings = userSettings.getQfaUserSettings(); qfaUserSettings.setBoolean(QFAUserSettings.EXCEPTION_REPORTING,prefs.getBoolean(QFAUserSettings.EXCEPTION_REPORTING,true)); PrintUserSettings printUserSettings = userSettings.getPrintUserSettings(); printUserSettings.setDefaultPrinterName( prefs.get(PrintUserSettings.DEFAULT_PRINTER_NAME, "")); return userSettings; } |
if ( prefs == null ) { prefs = ArchitectFrame.getMainInstance().getPrefs(); } | public void write(ArchitectSession session) throws ArchitectException { logger.debug("Saving prefs to java.util.prefs"); if ( prefs == null ) { prefs = ArchitectFrame.getMainInstance().getPrefs(); } CoreUserSettings userSettings = session.getUserSettings(); List<String> driverJarList = session.getDriverJarList(); Iterator<String> it = driverJarList.iterator(); for (int i = 0 ; i <= 99; i++) { if (it.hasNext()) { String name = it.next(); logger.debug("Putting JAR " + i + " " + name); prefs.put(jarFilePrefName(i), name); } else { // XXX optimize this - make jar file be its own node, just delete the node before starting. prefs.remove(jarFilePrefName(i)); } } prefs.put("PL.INI.PATH", userSettings.getPlDotIniPath()); UserSettings swingUserSettings = userSettings.getSwingSettings(); prefs.putBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, swingUserSettings.getBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, false)); ETLUserSettings etlUserSettings = userSettings.getETLUserSettings(); prefs.put(ETLUserSettings.PROP_PL_ENGINE_PATH, etlUserSettings.getString(ETLUserSettings.PROP_PL_ENGINE_PATH,"")); prefs.put(ETLUserSettings.PROP_ETL_LOG_PATH, etlUserSettings.getString(ETLUserSettings.PROP_ETL_LOG_PATH,"")); DDLUserSettings ddlUserSettings = userSettings.getDDLUserSettings(); prefs.put(DDLUserSettings.PROP_DDL_LOG_PATH, ddlUserSettings.getString(DDLUserSettings.PROP_DDL_LOG_PATH,"")); QFAUserSettings qfaUserSettings = userSettings.getQfaUserSettings(); prefs.putBoolean(QFAUserSettings.EXCEPTION_REPORTING,qfaUserSettings.getBoolean(QFAUserSettings.EXCEPTION_REPORTING,true)); PrintUserSettings printUserSettings = userSettings.getPrintUserSettings(); prefs.put(PrintUserSettings.DEFAULT_PRINTER_NAME, printUserSettings.getDefaultPrinterName()); try { prefs.flush(); } catch (BackingStoreException e) { throw new ArchitectException("Unable to flush Java preferences", e); } } |
|
List<String> driverJarList = session.getDriverJarList(); Iterator<String> it = driverJarList.iterator(); for (int i = 0 ; i <= 99; i++) { if (it.hasNext()) { String name = it.next(); logger.debug("Putting JAR " + i + " " + name); prefs.put(jarFilePrefName(i), name); } else { prefs.remove(jarFilePrefName(i)); } } | try { prefs.node(JAR_FILE_NODE_NAME).removeNode(); prefs.flush(); if (prefs.nodeExists(JAR_FILE_NODE_NAME)) { System.err.println("Warning: Jar Node Still Exists!!"); } } catch (BackingStoreException e) { logger.warn("Error: BackingStoreException while removing or testing previous Jar Node!!"); } | public void write(ArchitectSession session) throws ArchitectException { logger.debug("Saving prefs to java.util.prefs"); if ( prefs == null ) { prefs = ArchitectFrame.getMainInstance().getPrefs(); } CoreUserSettings userSettings = session.getUserSettings(); List<String> driverJarList = session.getDriverJarList(); Iterator<String> it = driverJarList.iterator(); for (int i = 0 ; i <= 99; i++) { if (it.hasNext()) { String name = it.next(); logger.debug("Putting JAR " + i + " " + name); prefs.put(jarFilePrefName(i), name); } else { // XXX optimize this - make jar file be its own node, just delete the node before starting. prefs.remove(jarFilePrefName(i)); } } prefs.put("PL.INI.PATH", userSettings.getPlDotIniPath()); UserSettings swingUserSettings = userSettings.getSwingSettings(); prefs.putBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, swingUserSettings.getBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, false)); ETLUserSettings etlUserSettings = userSettings.getETLUserSettings(); prefs.put(ETLUserSettings.PROP_PL_ENGINE_PATH, etlUserSettings.getString(ETLUserSettings.PROP_PL_ENGINE_PATH,"")); prefs.put(ETLUserSettings.PROP_ETL_LOG_PATH, etlUserSettings.getString(ETLUserSettings.PROP_ETL_LOG_PATH,"")); DDLUserSettings ddlUserSettings = userSettings.getDDLUserSettings(); prefs.put(DDLUserSettings.PROP_DDL_LOG_PATH, ddlUserSettings.getString(DDLUserSettings.PROP_DDL_LOG_PATH,"")); QFAUserSettings qfaUserSettings = userSettings.getQfaUserSettings(); prefs.putBoolean(QFAUserSettings.EXCEPTION_REPORTING,qfaUserSettings.getBoolean(QFAUserSettings.EXCEPTION_REPORTING,true)); PrintUserSettings printUserSettings = userSettings.getPrintUserSettings(); prefs.put(PrintUserSettings.DEFAULT_PRINTER_NAME, printUserSettings.getDefaultPrinterName()); try { prefs.flush(); } catch (BackingStoreException e) { throw new ArchitectException("Unable to flush Java preferences", e); } } |
Preferences jarNode = prefs.node(JAR_FILE_NODE_NAME); List<String> driverJarList = session.getDriverJarList(); Iterator<String> it = driverJarList.iterator(); for (int i = 0 ; i <= MAX_DRIVER_JAR_FILE_NAMES; i++) { if (it.hasNext()) { String name = it.next(); logger.debug("Putting JAR " + i + " " + name); jarNode.put(jarFilePrefName(i), name); } } try { prefs.flush(); } catch (BackingStoreException e) { throw new RuntimeException("Unable to flush Java preferences", e); } | public void write(ArchitectSession session) throws ArchitectException { logger.debug("Saving prefs to java.util.prefs"); if ( prefs == null ) { prefs = ArchitectFrame.getMainInstance().getPrefs(); } CoreUserSettings userSettings = session.getUserSettings(); List<String> driverJarList = session.getDriverJarList(); Iterator<String> it = driverJarList.iterator(); for (int i = 0 ; i <= 99; i++) { if (it.hasNext()) { String name = it.next(); logger.debug("Putting JAR " + i + " " + name); prefs.put(jarFilePrefName(i), name); } else { // XXX optimize this - make jar file be its own node, just delete the node before starting. prefs.remove(jarFilePrefName(i)); } } prefs.put("PL.INI.PATH", userSettings.getPlDotIniPath()); UserSettings swingUserSettings = userSettings.getSwingSettings(); prefs.putBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, swingUserSettings.getBoolean(SwingUserSettings.PLAYPEN_RENDER_ANTIALIASED, false)); ETLUserSettings etlUserSettings = userSettings.getETLUserSettings(); prefs.put(ETLUserSettings.PROP_PL_ENGINE_PATH, etlUserSettings.getString(ETLUserSettings.PROP_PL_ENGINE_PATH,"")); prefs.put(ETLUserSettings.PROP_ETL_LOG_PATH, etlUserSettings.getString(ETLUserSettings.PROP_ETL_LOG_PATH,"")); DDLUserSettings ddlUserSettings = userSettings.getDDLUserSettings(); prefs.put(DDLUserSettings.PROP_DDL_LOG_PATH, ddlUserSettings.getString(DDLUserSettings.PROP_DDL_LOG_PATH,"")); QFAUserSettings qfaUserSettings = userSettings.getQfaUserSettings(); prefs.putBoolean(QFAUserSettings.EXCEPTION_REPORTING,qfaUserSettings.getBoolean(QFAUserSettings.EXCEPTION_REPORTING,true)); PrintUserSettings printUserSettings = userSettings.getPrintUserSettings(); prefs.put(PrintUserSettings.DEFAULT_PRINTER_NAME, printUserSettings.getDefaultPrinterName()); try { prefs.flush(); } catch (BackingStoreException e) { throw new ArchitectException("Unable to flush Java preferences", e); } } |
|
public void removeAllDriverJars() { driverJarList.clear(); } | public void removeAllDriverJars(); | public void removeAllDriverJars() { driverJarList.clear(); } |
dPrimeDisplay.dPrimeTable = theData.dPrimeTable; | void readMarkers(File inputFile){ try { theData.prepareMarkerInput(inputFile,maxCompDist); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }/*catch (RuntimeException rtexec){ JOptionPane.showMessageDialog(this, "An error has occured. It is probably related to file format:\n"+rtexec.toString(), "Error", JOptionPane.ERROR_MESSAGE); } */ infoKnown=true; if (dPrimeDisplay != null){ dPrimeDisplay.loadMarkers(); } } |
|
List connections = new ArrayList(); | List<ArchitectDataSource> connections = new ArrayList<ArchitectDataSource>(); | public List getConnections() { List connections = new ArrayList(); Iterator it = fileSections.iterator(); while (it.hasNext()) { Object next = it.next(); if (next instanceof ArchitectDataSource) { connections.add(next); } } Collections.sort(connections); return connections; } |
connections.add(next); | connections.add((ArchitectDataSource) next); | public List getConnections() { List connections = new ArrayList(); Iterator it = fileSections.iterator(); while (it.hasNext()) { Object next = it.next(); if (next instanceof ArchitectDataSource) { connections.add(next); } } Collections.sort(connections); return connections; } |
} Collections.sort(connections); | } Collections.sort(connections, new ArchitectDataSource.DefaultComparator()); | public List getConnections() { List connections = new ArrayList(); Iterator it = fileSections.iterator(); while (it.hasNext()) { Object next = it.next(); if (next instanceof ArchitectDataSource) { connections.add(next); } } Collections.sort(connections); return connections; } |
File volumeDir = new File( volumeRoot ); if ( !volumeDir.exists() ) { volumeDir.mkdirs(); } | public void setUp() { try { photo = PhotoInfo.retrievePhotoInfo( 1 ); } catch ( Exception e ) { fail( "Unable to retrieve PhotoInfo object" ); } volume = new Volume( "imageInstanceTest", volumeRoot ); } |
|
SQLTable t = new SQLTable(); | SQLTable t = null; | public void actionPerformed(ActionEvent evt) { pp.fireCancel(); SQLTable t = new SQLTable(); try { t.initFolders(true); } catch (ArchitectException e) { logger.error("Couldn't add folder to table \""+t.getName()+"\"", e); JOptionPane.showMessageDialog(null, "Failed to add folder to table:\n"+e.getMessage()); } t.setName("New_Table"); TablePane tp = new TablePane(t, pp); pp.addFloating(tp); PlayPen.setMouseMode(PlayPen.MouseModeType.CREATING_TABLE); } |
t = new SQLTable(); | public void actionPerformed(ActionEvent evt) { pp.fireCancel(); SQLTable t = new SQLTable(); try { t.initFolders(true); } catch (ArchitectException e) { logger.error("Couldn't add folder to table \""+t.getName()+"\"", e); JOptionPane.showMessageDialog(null, "Failed to add folder to table:\n"+e.getMessage()); } t.setName("New_Table"); TablePane tp = new TablePane(t, pp); pp.addFloating(tp); PlayPen.setMouseMode(PlayPen.MouseModeType.CREATING_TABLE); } |
|
AntTagSupport parent = (AntTagSupport) getParent(); | AntTagSupport parent = (AntTagSupport) findAncestorWithClass(AntTagSupport.class); | public void doTag(XMLOutput output) throws Exception { Object obj = getObject(); if ( this.task != null ) { Method method = MethodUtils.getAccessibleMethod( this.task.getClass(), "addText", addTaskParamTypes ); if (method != null) { String text = getBodyText(); Object[] args = { text }; method.invoke(this.task, args); } else { getBody().run(context, output); } this.task.perform(); } else { getBody().run( context, output ); AntTagSupport parent = (AntTagSupport) getParent(); Object parentObj = parent.getObject(); IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObj.getClass() ); try { ih.storeElement( getAntProject(), parentObj, getObject(), getTagName() ); } catch (Exception e) { } } } |
ArchitectSession session = ArchitectSession.getInstance(); | ArchitectSession session = ArchitectSessionImpl.getInstance(); | public Connection createConnection() throws SQLException { try { if (dataSource.getDriverClass() == null || dataSource.getDriverClass().trim().length() == 0) { throw new SQLException("Connection \""+dataSource.getName()+"\" has no JDBC Driver class specified."); } if (dataSource.getUrl() == null || dataSource.getUrl().trim().length() == 0) { throw new SQLException("Connection \""+dataSource.getName()+"\" has no JDBC URL."); } if (dataSource.getUser() == null || dataSource.getUser().trim().length() == 0) { throw new SQLException("Connection \""+dataSource.getName()+"\" has no JDBC username."); } ArchitectSession session = ArchitectSession.getInstance(); if (session == null) { throw new SQLException ("Can't connect to database \""+dataSource.getName()+ "\" because ArchitectSession.getInstance() returned null"); } if (logger.isDebugEnabled()) { ClassLoader cl = this.getClass().getClassLoader(); StringBuffer loaders = new StringBuffer(); loaders.append("Local Classloader chain: "); while (cl != null) { loaders.append(cl).append(", "); cl = cl.getParent(); } logger.debug(loaders); } Driver driver = (Driver) Class.forName(dataSource.getDriverClass(), true, session.getJDBCClassLoader()).newInstance(); logger.info("Driver Class "+dataSource.getDriverClass()+" loaded without exception"); if (!driver.acceptsURL(dataSource.getUrl())) { throw new SQLException("Couldn't connect to database:\n" +"JDBC Driver "+dataSource.getDriverClass()+"\n" +"does not accept the URL "+dataSource.getUrl()); } Properties connectionProps = new Properties(); connectionProps.setProperty("user", dataSource.getUser()); connectionProps.setProperty("password", dataSource.getPass()); Connection realConnection = driver.connect(dataSource.getUrl(), connectionProps); if (realConnection == null) { throw new SQLException("JDBC Driver returned a null connection!"); } Connection connection = ConnectionDecorator.createFacade(realConnection); logger.debug("Connection class is: " + connection.getClass().getName()); return connection; } catch (ClassNotFoundException e) { logger.warn("Driver Class not found", e); throw new SQLException("JDBC Driver \""+dataSource.getDriverClass() +"\" not found."); } catch (InstantiationException e) { logger.error("Creating SQL Exception to conform to interface. Real exception is: ", e); throw new SQLException("Couldn't create an instance of the " + "JDBC driver '"+dataSource.getDriverClass()+"'. "+e.getMessage()); } catch (IllegalAccessException e) { logger.error("Creating SQL Exception to conform to interface. Real exception is: ", e); throw new SQLException("Couldn't connect to database because the " + "JDBC driver has no public constructor (this is bad). "+e.getMessage()); } } |
String jarfile = System.getProperty("java.class.path"); | String jarfile; if (System.getProperty("java.class.path").indexOf(" ") > 0 ){ jarfile = ("\""); jarfile += System.getProperty("java.class.path"); jarfile += "\""; }else{ jarfile = System.getProperty("java.class.path"); } | public static void main(String[] args) { int exitValue = 0; String dir = System.getProperty("user.dir"); String sep = System.getProperty("file.separator"); String ver = System.getProperty("java.version"); //TODO:do some version checking and bitch at people with old JVMs /*StringTokenizer st = new StringTokenizer(ver, "."); while (st.hasMoreTokens()){ System.out.println(st.nextToken()); } */ String jarfile = System.getProperty("java.class.path"); String argsToBePassed = new String(); boolean headless = false; for (int a = 0; a < args.length; a++){ argsToBePassed = argsToBePassed.concat(" " + args[a]); if (args[a].equals("-n") || args[a].equalsIgnoreCase("-nogui")){ headless=true; } } try { //if the nogui flag is present we force it into headless mode String runString = "java -Xmx1024m -classpath \"" + jarfile + "\""; if (headless){ runString += " -Djava.awt.headless=true"; } runString += " edu.mit.wi.haploview.HaploView"+argsToBePassed; Process child = Runtime.getRuntime().exec(runString); //start up a thread to simply pump out all messages to stdout StreamGobbler isg = new StreamGobbler(child.getInputStream()); isg.start(); //while the child is alive we wait for error messages boolean dead = false; StringBuffer errorMsg = new StringBuffer("Fatal Error:\n"); BufferedReader besr = new BufferedReader(new InputStreamReader(child.getErrorStream())); String line = null; while ( !dead && (line = besr.readLine()) != null) { if(line.lastIndexOf("Memory") != -1) { errorMsg.append(line); //if the child generated an "Out of Memory" error message, kill it child.destroy(); dead = true; }else { //for any other errors we show them to the user if(headless) { //if were in headless (command line) mode, then print the error text to command line System.err.println(line); } else { //otherwise print it to the error textarea if(errorTextArea == null) { //if this is the first error line then we need to create the JFrame with the //text area javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { createAndShowGUI(); } }); } //if the user closed the contentFrame, then we want to reopen it when theres error text if(!contentFrame.isVisible()) { contentFrame.setVisible(true); } errorTextArea.append(line + "\n"); errorTextArea.setCaretPosition(errorTextArea.getDocument().getLength()); } } } final String realErrorMsg = errorMsg.toString(); //if the child died painfully throw up R.I.P. dialog if (dead){ if (headless){ System.err.println(errorMsg); }else{ Runnable showRip = new Runnable() { public void run() { JFrame jf = new JFrame(); JOptionPane.showMessageDialog(jf, realErrorMsg, null, JOptionPane.ERROR_MESSAGE);} }; SwingUtilities.invokeAndWait(showRip); } exitValue = -1; } } catch (Exception e) { if (headless){ System.err.println("Error:\nUnable to launch Haploview.\n"+e.getMessage()); }else{ JFrame jf = new JFrame(); JOptionPane.showMessageDialog(jf, "Error:\nUnable to launch Haploview.\n"+e.getMessage(), null, JOptionPane.ERROR_MESSAGE); } } System.exit(exitValue); } |
String runString = "java -Xmx1024m -classpath \"" + jarfile + "\""; | String runString = "java -Xmx1024m -classpath " + jarfile; | public static void main(String[] args) { int exitValue = 0; String dir = System.getProperty("user.dir"); String sep = System.getProperty("file.separator"); String ver = System.getProperty("java.version"); //TODO:do some version checking and bitch at people with old JVMs /*StringTokenizer st = new StringTokenizer(ver, "."); while (st.hasMoreTokens()){ System.out.println(st.nextToken()); } */ String jarfile = System.getProperty("java.class.path"); String argsToBePassed = new String(); boolean headless = false; for (int a = 0; a < args.length; a++){ argsToBePassed = argsToBePassed.concat(" " + args[a]); if (args[a].equals("-n") || args[a].equalsIgnoreCase("-nogui")){ headless=true; } } try { //if the nogui flag is present we force it into headless mode String runString = "java -Xmx1024m -classpath \"" + jarfile + "\""; if (headless){ runString += " -Djava.awt.headless=true"; } runString += " edu.mit.wi.haploview.HaploView"+argsToBePassed; Process child = Runtime.getRuntime().exec(runString); //start up a thread to simply pump out all messages to stdout StreamGobbler isg = new StreamGobbler(child.getInputStream()); isg.start(); //while the child is alive we wait for error messages boolean dead = false; StringBuffer errorMsg = new StringBuffer("Fatal Error:\n"); BufferedReader besr = new BufferedReader(new InputStreamReader(child.getErrorStream())); String line = null; while ( !dead && (line = besr.readLine()) != null) { if(line.lastIndexOf("Memory") != -1) { errorMsg.append(line); //if the child generated an "Out of Memory" error message, kill it child.destroy(); dead = true; }else { //for any other errors we show them to the user if(headless) { //if were in headless (command line) mode, then print the error text to command line System.err.println(line); } else { //otherwise print it to the error textarea if(errorTextArea == null) { //if this is the first error line then we need to create the JFrame with the //text area javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { createAndShowGUI(); } }); } //if the user closed the contentFrame, then we want to reopen it when theres error text if(!contentFrame.isVisible()) { contentFrame.setVisible(true); } errorTextArea.append(line + "\n"); errorTextArea.setCaretPosition(errorTextArea.getDocument().getLength()); } } } final String realErrorMsg = errorMsg.toString(); //if the child died painfully throw up R.I.P. dialog if (dead){ if (headless){ System.err.println(errorMsg); }else{ Runnable showRip = new Runnable() { public void run() { JFrame jf = new JFrame(); JOptionPane.showMessageDialog(jf, realErrorMsg, null, JOptionPane.ERROR_MESSAGE);} }; SwingUtilities.invokeAndWait(showRip); } exitValue = -1; } } catch (Exception e) { if (headless){ System.err.println("Error:\nUnable to launch Haploview.\n"+e.getMessage()); }else{ JFrame jf = new JFrame(); JOptionPane.showMessageDialog(jf, "Error:\nUnable to launch Haploview.\n"+e.getMessage(), null, JOptionPane.ERROR_MESSAGE); } } System.exit(exitValue); } |
String fname = "test1.jpg"; File f = new File( testImgDir, fname ); PhotoInfo photo = null; try { photo = PhotoInfo.addToDB( f ); } catch ( PhotoNotFoundException e ) { fail( "Could not find photo: " + e.getMessage() ); } l1.modified = false; folder.addPhoto( photo ); assertTrue( "l1 not called when adding photo", l1.modified ); l1.modified = false; folder.removePhoto( photo ); assertTrue( "l1 not called when removing photo", l1.modified ); photo.delete(); | public void testListener() { PhotoFolder folder = PhotoFolder.create( "testListener", null ); TestListener l1 = new TestListener(); TestListener l2 = new TestListener(); TestCollectionListener l3 = new TestCollectionListener(); folder.addPhotoCollectionChangeListener( l1 ); folder.addPhotoCollectionChangeListener( l2 ); folder.addPhotoCollectionChangeListener( l3 ); folder.setName( "testLiistener" ); assertTrue( "l1 not called", l1.modified ); assertTrue( "l2 not called", l2.modified ); assertTrue( "l3 not called", l3.modified ); folder.setName( "testListener" ); l1.modified = false; l2.modified = false; folder.removePhotoCollectionChangeListener( l2 ); folder.setDescription( "Folder usded to test listener support" ); assertTrue( "l1 not called", l1.modified ); assertFalse( "l2 should not have been called", l2.modified ); // Test creation of a new subfolder PhotoFolder subfolder = PhotoFolder.create( "New subfolder", folder ); assertTrue( "Not notified of subfolder structure change", l1.structureModified ); assertEquals( "subfolder info not correct", folder, l1.structChangeFolder ); l1.structureModified = false; l1.changedFolder = null; subfolder.setDescription( "Changed subfolder" ); assertTrue( "l1 not called for subfolder modification", l1.subfolderModified ); assertEquals( "subfolder info not correct", subfolder, l1.changedFolder ); l1.subfolderModified = false; l1.changedFolder = null; subfolder.delete(); assertTrue( "Not notified of subfolder structure change", l1.structureModified ); assertEquals( "subfolder info not correct", folder, l1.structChangeFolder ); // TODO: test other fields } |
|
photo.delete(); | public void testPhotoAddition() { String fname = "test1.jpg"; File f = new File( testImgDir, fname ); PhotoInfo photo = null; try { photo = PhotoInfo.addToDB( f ); } catch ( PhotoNotFoundException e ) { fail( "Could not find photo: " + e.getMessage() ); } PhotoFolder folder = null; // Create a folder for the photo try { folder = PhotoFolder.create( "PhotoAdditionTest", PhotoFolder.getRoot() ); folder.addPhoto( photo ); assertEquals( "Photo not visible in folders' photo count", folder.getPhotoCount(), 1 ); } finally { // Clean up the test folder PhotoFolder parent = folder.getParentFolder(); parent.removeSubfolder( folder ); } } |
|
saveHapsWriter.write("Multiallelic Dprime: " + multidprime[i] + "\n"); }else{ saveHapsWriter.write("\n"); | saveHapsWriter.write("Multiallelic Dprime: " + nf.format(multidprime[i]) + "\n"); | public void saveHapsToText(Haplotype[][] finishedHaplos, double[] multidprime, File saveHapsFile) throws IOException{ if (finishedHaplos == null) return; NumberFormat nf = NumberFormat.getInstance(Locale.US); nf.setMinimumFractionDigits(3); nf.setMaximumFractionDigits(3); //open file for saving haps text FileWriter saveHapsWriter = new FileWriter(saveHapsFile); //go through each block and print haplos for (int i = 0; i < finishedHaplos.length; i++){ //write block header int[] markerNums = finishedHaplos[i][0].getMarkers(); saveHapsWriter.write("BLOCK " + (i+1) + ". MARKERS:"); boolean[] tags = finishedHaplos[i][0].getTags(); for (int j = 0; j < markerNums.length; j++){ saveHapsWriter.write(" " + (Chromosome.realIndex[markerNums[j]]+1)); if (tags[j]) saveHapsWriter.write("!"); } saveHapsWriter.write("\n"); //write haps and crossover percentages for (int j = 0; j < finishedHaplos[i].length; j++){ int[] theGeno = finishedHaplos[i][j].getGeno(); StringBuffer theHap = new StringBuffer(theGeno.length); for (int k = 0; k < theGeno.length; k++){ theHap.append(theGeno[k]); } saveHapsWriter.write(theHap.toString() + " (" + nf.format(finishedHaplos[i][j].getPercentage()) + ")"); if (i < finishedHaplos.length-1){ saveHapsWriter.write("\t|"); for (int crossCount = 0; crossCount < finishedHaplos[i+1].length; crossCount++){ if (crossCount != 0) saveHapsWriter.write("\t"); saveHapsWriter.write(nf.format(finishedHaplos[i][j].getCrossover(crossCount))); } saveHapsWriter.write("|"); } saveHapsWriter.write("\n"); } if (i < finishedHaplos.length - 1){ saveHapsWriter.write("Multiallelic Dprime: " + multidprime[i] + "\n"); }else{ saveHapsWriter.write("\n"); } } saveHapsWriter.close(); } |
return new ScriptTag( expressionFactory.getBSFEngine() ); | return new ScriptTag( expressionFactory.getBSFEngine(), expressionFactory.getBSFManager()); | protected Tag createScriptTag(String name, Attributes attributes) throws JellyException { try { return new ScriptTag( expressionFactory.getBSFEngine() ); } catch (BSFException e) { throw new JellyException("Failed to create BSFEngine: " + e, e); } } |
hasIDAttribute = false; | public void doTag(XMLOutput output) throws Exception { hasIDAttribute = false; Project project = getAntProject(); String tagName = getTagName(); Object parentObject = findBeanAncestor(); // lets assume that Task instances are not nested inside other Task instances // for example <manifest> inside a <jar> should be a nested object, where as // if the parent is not a Task the <manifest> should create a ManifestTask // // also its possible to have a root Ant tag which isn't a task, such as when // defining <fileset id="...">...</fileset> if (findParentTaskSource() == null && project.getTaskDefinitions().containsKey( tagName )) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { hasIDAttribute = true; project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { Object[] args = { body }; method.invoke(this.task, args); } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? task.perform(); } else { if ( log.isDebugEnabled() ) { log.debug( "Creating a nested object name: " + tagName ); } Object nested = createNestedObject( parentObject, tagName ); if ( nested == null ) { nested = createDataType( tagName ); } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { hasIDAttribute = true; project.addReference( (String) id, nested ); } try{ PropertyUtils.setProperty( nested, "name", tagName ); } catch (Exception e) { } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { if (log.isDebugEnabled()) { log.debug("About to set the: " + tagName + " property on: " + parentObject + " to value: " + nested + " with type: " + nested.getClass() ); } ih.storeElement( project, parentObject, nested, tagName ); } catch (Exception e) { log.warn( "Caught exception setting nested: " + tagName, e ); } // now try to set the property for good measure // as the storeElement() method does not // seem to call any setter methods of non-String types try { BeanUtils.setProperty( parentObject, tagName, nested ); } catch (Exception e) { log.debug("Caught exception trying to set property: " + tagName + " on: " + parentObject); } } } else { // lets treat this tag as static XML... StaticTag tag = new StaticTag("", tagName, tagName); tag.setParent( getParent() ); tag.setBody( getBody() ); tag.setContext(context); for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); tag.setAttribute(name, value); } tag.doTag(output); } } } |
|
Object parentTask = findParentTaskObject(); | public void doTag(XMLOutput output) throws Exception { hasIDAttribute = false; Project project = getAntProject(); String tagName = getTagName(); Object parentObject = findBeanAncestor(); // lets assume that Task instances are not nested inside other Task instances // for example <manifest> inside a <jar> should be a nested object, where as // if the parent is not a Task the <manifest> should create a ManifestTask // // also its possible to have a root Ant tag which isn't a task, such as when // defining <fileset id="...">...</fileset> if (findParentTaskSource() == null && project.getTaskDefinitions().containsKey( tagName )) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { hasIDAttribute = true; project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { Object[] args = { body }; method.invoke(this.task, args); } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? task.perform(); } else { if ( log.isDebugEnabled() ) { log.debug( "Creating a nested object name: " + tagName ); } Object nested = createNestedObject( parentObject, tagName ); if ( nested == null ) { nested = createDataType( tagName ); } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { hasIDAttribute = true; project.addReference( (String) id, nested ); } try{ PropertyUtils.setProperty( nested, "name", tagName ); } catch (Exception e) { } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { if (log.isDebugEnabled()) { log.debug("About to set the: " + tagName + " property on: " + parentObject + " to value: " + nested + " with type: " + nested.getClass() ); } ih.storeElement( project, parentObject, nested, tagName ); } catch (Exception e) { log.warn( "Caught exception setting nested: " + tagName, e ); } // now try to set the property for good measure // as the storeElement() method does not // seem to call any setter methods of non-String types try { BeanUtils.setProperty( parentObject, tagName, nested ); } catch (Exception e) { log.debug("Caught exception trying to set property: " + tagName + " on: " + parentObject); } } } else { // lets treat this tag as static XML... StaticTag tag = new StaticTag("", tagName, tagName); tag.setParent( getParent() ); tag.setBody( getBody() ); tag.setContext(context); for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); tag.setAttribute(name, value); } tag.doTag(output); } } } |
|
if (findParentTaskSource() == null && | if ( (parentTask == null || parentTask instanceof TaskContainer) && | public void doTag(XMLOutput output) throws Exception { hasIDAttribute = false; Project project = getAntProject(); String tagName = getTagName(); Object parentObject = findBeanAncestor(); // lets assume that Task instances are not nested inside other Task instances // for example <manifest> inside a <jar> should be a nested object, where as // if the parent is not a Task the <manifest> should create a ManifestTask // // also its possible to have a root Ant tag which isn't a task, such as when // defining <fileset id="...">...</fileset> if (findParentTaskSource() == null && project.getTaskDefinitions().containsKey( tagName )) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { hasIDAttribute = true; project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { Object[] args = { body }; method.invoke(this.task, args); } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? task.perform(); } else { if ( log.isDebugEnabled() ) { log.debug( "Creating a nested object name: " + tagName ); } Object nested = createNestedObject( parentObject, tagName ); if ( nested == null ) { nested = createDataType( tagName ); } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { hasIDAttribute = true; project.addReference( (String) id, nested ); } try{ PropertyUtils.setProperty( nested, "name", tagName ); } catch (Exception e) { } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { if (log.isDebugEnabled()) { log.debug("About to set the: " + tagName + " property on: " + parentObject + " to value: " + nested + " with type: " + nested.getClass() ); } ih.storeElement( project, parentObject, nested, tagName ); } catch (Exception e) { log.warn( "Caught exception setting nested: " + tagName, e ); } // now try to set the property for good measure // as the storeElement() method does not // seem to call any setter methods of non-String types try { BeanUtils.setProperty( parentObject, tagName, nested ); } catch (Exception e) { log.debug("Caught exception trying to set property: " + tagName + " on: " + parentObject); } } } else { // lets treat this tag as static XML... StaticTag tag = new StaticTag("", tagName, tagName); tag.setParent( getParent() ); tag.setBody( getBody() ); tag.setContext(context); for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); tag.setAttribute(name, value); } tag.doTag(output); } } } |
hasIDAttribute = true; | public void doTag(XMLOutput output) throws Exception { hasIDAttribute = false; Project project = getAntProject(); String tagName = getTagName(); Object parentObject = findBeanAncestor(); // lets assume that Task instances are not nested inside other Task instances // for example <manifest> inside a <jar> should be a nested object, where as // if the parent is not a Task the <manifest> should create a ManifestTask // // also its possible to have a root Ant tag which isn't a task, such as when // defining <fileset id="...">...</fileset> if (findParentTaskSource() == null && project.getTaskDefinitions().containsKey( tagName )) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference task = createTask( tagName ); if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { hasIDAttribute = true; project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { Object[] args = { body }; method.invoke(this.task, args); } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? task.perform(); } else { if ( log.isDebugEnabled() ) { log.debug( "Creating a nested object name: " + tagName ); } Object nested = createNestedObject( parentObject, tagName ); if ( nested == null ) { nested = createDataType( tagName ); } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { hasIDAttribute = true; project.addReference( (String) id, nested ); } try{ PropertyUtils.setProperty( nested, "name", tagName ); } catch (Exception e) { } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { if (log.isDebugEnabled()) { log.debug("About to set the: " + tagName + " property on: " + parentObject + " to value: " + nested + " with type: " + nested.getClass() ); } ih.storeElement( project, parentObject, nested, tagName ); } catch (Exception e) { log.warn( "Caught exception setting nested: " + tagName, e ); } // now try to set the property for good measure // as the storeElement() method does not // seem to call any setter methods of non-String types try { BeanUtils.setProperty( parentObject, tagName, nested ); } catch (Exception e) { log.debug("Caught exception trying to set property: " + tagName + " on: " + parentObject); } } } else { // lets treat this tag as static XML... StaticTag tag = new StaticTag("", tagName, tagName); tag.setParent( getParent() ); tag.setBody( getBody() ); tag.setContext(context); for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); tag.setAttribute(name, value); } tag.doTag(output); } } } |
|
col.setNullable(DatabaseMetaData.columnNoNulls); | public void changeColumnIndex(int oldIdx, int newIdx, boolean putInPK) throws ArchitectException { // remove and add the column directly, then manually fire the event. // This is necessary because the relationships prevent deletion of locked keys. try { startCompoundEdit("Changing column index"); SQLColumn col = (SQLColumn) columnsFolder.children.get(oldIdx); Integer oldPkSeq = col.primaryKeySeq; Integer interimPkSeq; if (putInPK) { interimPkSeq = new Integer(1); // will get sane value when normalized } else { interimPkSeq = null; } col.primaryKeySeq = interimPkSeq; col.fireDbObjectChanged("primaryKeySeq", oldPkSeq, interimPkSeq); columnsFolder.children.remove(oldIdx); columnsFolder.fireDbChildRemoved(oldIdx, col); columnsFolder.children.add(newIdx, col); columnsFolder.fireDbChildInserted(newIdx, col); normalizePrimaryKey(); } finally { endCompoundEdit("Changing column index"); } } |
|
assertEquals(makeIndex(Shipment.class, "shipmentID"), res_0.getLocalIndex()); | assertEquals(makeIndex(Shipment.class, "orderID"), res_0.getLocalIndex()); | public void testFullScanExempt() throws Exception { // Although not all sub-results use an index, one that does has a join // so it is exempt from folding into the full scan. UnionQueryAnalyzer uqa = new UnionQueryAnalyzer(Shipment.class, TestIndexedQueryAnalyzer.RepoAccess.INSTANCE); Filter<Shipment> filter = Filter.filterFor (Shipment.class, "shipmentNotes = ? | orderID = ? & order.orderTotal > ?"); filter = filter.bind(); UnionQueryAnalyzer.Result result = uqa.analyze(filter, null); List<IndexedQueryAnalyzer<Shipment>.Result> subResults = result.getSubResults(); assertEquals(2, subResults.size()); IndexedQueryAnalyzer<Shipment>.Result res_0 = subResults.get(0); IndexedQueryAnalyzer<Shipment>.Result res_1 = subResults.get(1); assertTrue(res_0.handlesAnything()); assertEquals(makeIndex(Shipment.class, "shipmentID"), res_0.getLocalIndex()); assertEquals(null, res_0.getForeignIndex()); assertEquals(null, res_0.getForeignProperty()); assertEquals(0, res_0.getRemainderOrdering().size()); assertEquals(Filter.filterFor(Shipment.class, "shipmentNotes = ?").bind(), res_0.getRemainderFilter()); assertTrue(res_1.handlesAnything()); assertEquals(makeIndex(Shipment.class, "orderID"), res_1.getLocalIndex()); assertEquals(null, res_1.getForeignIndex()); assertEquals(null, res_1.getForeignProperty()); assertEquals(1, res_1.getRemainderOrdering().size()); assertEquals("+shipmentID", res_1.getRemainderOrdering().get(0).toString()); assertEquals(Filter.filterFor(Shipment.class, "order.orderTotal > ?").bind(), res_1.getRemainderFilter()); } |
assertEquals(0, res_0.getRemainderOrdering().size()); assertEquals(Filter.filterFor(Shipment.class, "shipmentNotes = ?").bind(), | assertEquals(1, res_0.getRemainderOrdering().size()); assertEquals("+shipmentID", res_0.getRemainderOrdering().get(0).toString()); assertEquals(Filter.filterFor(Shipment.class, "order.orderTotal > ?").bind(), | public void testFullScanExempt() throws Exception { // Although not all sub-results use an index, one that does has a join // so it is exempt from folding into the full scan. UnionQueryAnalyzer uqa = new UnionQueryAnalyzer(Shipment.class, TestIndexedQueryAnalyzer.RepoAccess.INSTANCE); Filter<Shipment> filter = Filter.filterFor (Shipment.class, "shipmentNotes = ? | orderID = ? & order.orderTotal > ?"); filter = filter.bind(); UnionQueryAnalyzer.Result result = uqa.analyze(filter, null); List<IndexedQueryAnalyzer<Shipment>.Result> subResults = result.getSubResults(); assertEquals(2, subResults.size()); IndexedQueryAnalyzer<Shipment>.Result res_0 = subResults.get(0); IndexedQueryAnalyzer<Shipment>.Result res_1 = subResults.get(1); assertTrue(res_0.handlesAnything()); assertEquals(makeIndex(Shipment.class, "shipmentID"), res_0.getLocalIndex()); assertEquals(null, res_0.getForeignIndex()); assertEquals(null, res_0.getForeignProperty()); assertEquals(0, res_0.getRemainderOrdering().size()); assertEquals(Filter.filterFor(Shipment.class, "shipmentNotes = ?").bind(), res_0.getRemainderFilter()); assertTrue(res_1.handlesAnything()); assertEquals(makeIndex(Shipment.class, "orderID"), res_1.getLocalIndex()); assertEquals(null, res_1.getForeignIndex()); assertEquals(null, res_1.getForeignProperty()); assertEquals(1, res_1.getRemainderOrdering().size()); assertEquals("+shipmentID", res_1.getRemainderOrdering().get(0).toString()); assertEquals(Filter.filterFor(Shipment.class, "order.orderTotal > ?").bind(), res_1.getRemainderFilter()); } |
assertEquals(makeIndex(Shipment.class, "orderID"), res_1.getLocalIndex()); | assertEquals(makeIndex(Shipment.class, "shipmentID"), res_1.getLocalIndex()); | public void testFullScanExempt() throws Exception { // Although not all sub-results use an index, one that does has a join // so it is exempt from folding into the full scan. UnionQueryAnalyzer uqa = new UnionQueryAnalyzer(Shipment.class, TestIndexedQueryAnalyzer.RepoAccess.INSTANCE); Filter<Shipment> filter = Filter.filterFor (Shipment.class, "shipmentNotes = ? | orderID = ? & order.orderTotal > ?"); filter = filter.bind(); UnionQueryAnalyzer.Result result = uqa.analyze(filter, null); List<IndexedQueryAnalyzer<Shipment>.Result> subResults = result.getSubResults(); assertEquals(2, subResults.size()); IndexedQueryAnalyzer<Shipment>.Result res_0 = subResults.get(0); IndexedQueryAnalyzer<Shipment>.Result res_1 = subResults.get(1); assertTrue(res_0.handlesAnything()); assertEquals(makeIndex(Shipment.class, "shipmentID"), res_0.getLocalIndex()); assertEquals(null, res_0.getForeignIndex()); assertEquals(null, res_0.getForeignProperty()); assertEquals(0, res_0.getRemainderOrdering().size()); assertEquals(Filter.filterFor(Shipment.class, "shipmentNotes = ?").bind(), res_0.getRemainderFilter()); assertTrue(res_1.handlesAnything()); assertEquals(makeIndex(Shipment.class, "orderID"), res_1.getLocalIndex()); assertEquals(null, res_1.getForeignIndex()); assertEquals(null, res_1.getForeignProperty()); assertEquals(1, res_1.getRemainderOrdering().size()); assertEquals("+shipmentID", res_1.getRemainderOrdering().get(0).toString()); assertEquals(Filter.filterFor(Shipment.class, "order.orderTotal > ?").bind(), res_1.getRemainderFilter()); } |
assertEquals(1, res_1.getRemainderOrdering().size()); assertEquals("+shipmentID", res_1.getRemainderOrdering().get(0).toString()); assertEquals(Filter.filterFor(Shipment.class, "order.orderTotal > ?").bind(), | assertEquals(0, res_1.getRemainderOrdering().size()); assertEquals(Filter.filterFor(Shipment.class, "shipmentNotes = ?").bind(), | public void testFullScanExempt() throws Exception { // Although not all sub-results use an index, one that does has a join // so it is exempt from folding into the full scan. UnionQueryAnalyzer uqa = new UnionQueryAnalyzer(Shipment.class, TestIndexedQueryAnalyzer.RepoAccess.INSTANCE); Filter<Shipment> filter = Filter.filterFor (Shipment.class, "shipmentNotes = ? | orderID = ? & order.orderTotal > ?"); filter = filter.bind(); UnionQueryAnalyzer.Result result = uqa.analyze(filter, null); List<IndexedQueryAnalyzer<Shipment>.Result> subResults = result.getSubResults(); assertEquals(2, subResults.size()); IndexedQueryAnalyzer<Shipment>.Result res_0 = subResults.get(0); IndexedQueryAnalyzer<Shipment>.Result res_1 = subResults.get(1); assertTrue(res_0.handlesAnything()); assertEquals(makeIndex(Shipment.class, "shipmentID"), res_0.getLocalIndex()); assertEquals(null, res_0.getForeignIndex()); assertEquals(null, res_0.getForeignProperty()); assertEquals(0, res_0.getRemainderOrdering().size()); assertEquals(Filter.filterFor(Shipment.class, "shipmentNotes = ?").bind(), res_0.getRemainderFilter()); assertTrue(res_1.handlesAnything()); assertEquals(makeIndex(Shipment.class, "orderID"), res_1.getLocalIndex()); assertEquals(null, res_1.getForeignIndex()); assertEquals(null, res_1.getForeignProperty()); assertEquals(1, res_1.getRemainderOrdering().size()); assertEquals("+shipmentID", res_1.getRemainderOrdering().get(0).toString()); assertEquals(Filter.filterFor(Shipment.class, "order.orderTotal > ?").bind(), res_1.getRemainderFilter()); } |
assertEquals(OrderingList.get(Shipment.class, "+shipmentID"), result.getTotalOrdering()); | public void testSimpleUnion() throws Exception { UnionQueryAnalyzer uqa = new UnionQueryAnalyzer(Shipment.class, TestIndexedQueryAnalyzer.RepoAccess.INSTANCE); Filter<Shipment> filter = Filter.filterFor(Shipment.class, "shipmentID = ? | orderID = ?"); filter = filter.bind(); UnionQueryAnalyzer.Result result = uqa.analyze(filter, null); List<IndexedQueryAnalyzer<Shipment>.Result> subResults = result.getSubResults(); assertEquals(2, subResults.size()); IndexedQueryAnalyzer<Shipment>.Result res_0 = subResults.get(0); IndexedQueryAnalyzer<Shipment>.Result res_1 = subResults.get(1); assertTrue(res_0.handlesAnything()); assertEquals(Filter.filterFor(Shipment.class, "shipmentID = ?").bind(), res_0.getCompositeScore().getFilteringScore().getIdentityFilter()); assertEquals(makeIndex(Shipment.class, "shipmentID"), res_0.getLocalIndex()); assertEquals(null, res_0.getForeignIndex()); assertEquals(null, res_0.getForeignProperty()); assertEquals(0, res_0.getRemainderOrdering().size()); assertTrue(res_1.handlesAnything()); assertEquals(Filter.filterFor(Shipment.class, "orderID = ?").bind(), res_1.getCompositeScore().getFilteringScore().getIdentityFilter()); assertEquals(makeIndex(Shipment.class, "orderID"), res_1.getLocalIndex()); assertEquals(null, res_1.getForeignIndex()); assertEquals(null, res_1.getForeignProperty()); assertEquals(1, res_1.getRemainderOrdering().size()); assertEquals("+shipmentID", res_1.getRemainderOrdering().get(0).toString()); } |
|
assertFalse(res_1.getCompositeScore().getFilteringScore().hasRangeStart()); | assertTrue(res_1.getCompositeScore().getFilteringScore().hasRangeStart()); | public void testSimpleUnion2() throws Exception { UnionQueryAnalyzer uqa = new UnionQueryAnalyzer(Shipment.class, TestIndexedQueryAnalyzer.RepoAccess.INSTANCE); Filter<Shipment> filter = Filter.filterFor(Shipment.class, "shipmentID = ? | orderID > ?"); filter = filter.bind(); UnionQueryAnalyzer.Result result = uqa.analyze(filter, null); List<IndexedQueryAnalyzer<Shipment>.Result> subResults = result.getSubResults(); assertEquals(2, subResults.size()); IndexedQueryAnalyzer<Shipment>.Result res_0 = subResults.get(0); IndexedQueryAnalyzer<Shipment>.Result res_1 = subResults.get(1); assertTrue(res_0.handlesAnything()); assertEquals(Filter.filterFor(Shipment.class, "shipmentID = ?").bind(), res_0.getCompositeScore().getFilteringScore().getIdentityFilter()); assertEquals(makeIndex(Shipment.class, "shipmentID"), res_0.getLocalIndex()); assertEquals(null, res_0.getForeignIndex()); assertEquals(null, res_0.getForeignProperty()); assertEquals(0, res_0.getRemainderOrdering().size()); // Note: index that has proper ordering is preferred because "orderId > ?" // filter does not specify a complete range. It is not expected to actually // filter much, so we choose to avoid a large sort instead. assertTrue(res_1.handlesAnything()); assertFalse(res_1.getCompositeScore().getFilteringScore().hasRangeStart()); assertFalse(res_1.getCompositeScore().getFilteringScore().hasRangeEnd()); assertEquals(makeIndex(Shipment.class, "shipmentID"), res_1.getLocalIndex()); assertEquals(null, res_1.getForeignIndex()); assertEquals(null, res_1.getForeignProperty()); assertEquals(0, res_0.getRemainderOrdering().size()); // Remainder filter exists because the "orderID" index was not chosen. assertEquals(Filter.filterFor(Shipment.class, "orderID > ?").bind(), res_1.getRemainderFilter()); } |
assertEquals(makeIndex(Shipment.class, "shipmentID"), res_1.getLocalIndex()); | assertEquals(makeIndex(Shipment.class, "orderID"), res_1.getLocalIndex()); | public void testSimpleUnion2() throws Exception { UnionQueryAnalyzer uqa = new UnionQueryAnalyzer(Shipment.class, TestIndexedQueryAnalyzer.RepoAccess.INSTANCE); Filter<Shipment> filter = Filter.filterFor(Shipment.class, "shipmentID = ? | orderID > ?"); filter = filter.bind(); UnionQueryAnalyzer.Result result = uqa.analyze(filter, null); List<IndexedQueryAnalyzer<Shipment>.Result> subResults = result.getSubResults(); assertEquals(2, subResults.size()); IndexedQueryAnalyzer<Shipment>.Result res_0 = subResults.get(0); IndexedQueryAnalyzer<Shipment>.Result res_1 = subResults.get(1); assertTrue(res_0.handlesAnything()); assertEquals(Filter.filterFor(Shipment.class, "shipmentID = ?").bind(), res_0.getCompositeScore().getFilteringScore().getIdentityFilter()); assertEquals(makeIndex(Shipment.class, "shipmentID"), res_0.getLocalIndex()); assertEquals(null, res_0.getForeignIndex()); assertEquals(null, res_0.getForeignProperty()); assertEquals(0, res_0.getRemainderOrdering().size()); // Note: index that has proper ordering is preferred because "orderId > ?" // filter does not specify a complete range. It is not expected to actually // filter much, so we choose to avoid a large sort instead. assertTrue(res_1.handlesAnything()); assertFalse(res_1.getCompositeScore().getFilteringScore().hasRangeStart()); assertFalse(res_1.getCompositeScore().getFilteringScore().hasRangeEnd()); assertEquals(makeIndex(Shipment.class, "shipmentID"), res_1.getLocalIndex()); assertEquals(null, res_1.getForeignIndex()); assertEquals(null, res_1.getForeignProperty()); assertEquals(0, res_0.getRemainderOrdering().size()); // Remainder filter exists because the "orderID" index was not chosen. assertEquals(Filter.filterFor(Shipment.class, "orderID > ?").bind(), res_1.getRemainderFilter()); } |
assertEquals(0, res_0.getRemainderOrdering().size()); assertEquals(Filter.filterFor(Shipment.class, "orderID > ?").bind(), res_1.getRemainderFilter()); | assertEquals(1, res_1.getRemainderOrdering().size()); assertEquals("+shipmentID", res_1.getRemainderOrdering().get(0).toString()); | public void testSimpleUnion2() throws Exception { UnionQueryAnalyzer uqa = new UnionQueryAnalyzer(Shipment.class, TestIndexedQueryAnalyzer.RepoAccess.INSTANCE); Filter<Shipment> filter = Filter.filterFor(Shipment.class, "shipmentID = ? | orderID > ?"); filter = filter.bind(); UnionQueryAnalyzer.Result result = uqa.analyze(filter, null); List<IndexedQueryAnalyzer<Shipment>.Result> subResults = result.getSubResults(); assertEquals(2, subResults.size()); IndexedQueryAnalyzer<Shipment>.Result res_0 = subResults.get(0); IndexedQueryAnalyzer<Shipment>.Result res_1 = subResults.get(1); assertTrue(res_0.handlesAnything()); assertEquals(Filter.filterFor(Shipment.class, "shipmentID = ?").bind(), res_0.getCompositeScore().getFilteringScore().getIdentityFilter()); assertEquals(makeIndex(Shipment.class, "shipmentID"), res_0.getLocalIndex()); assertEquals(null, res_0.getForeignIndex()); assertEquals(null, res_0.getForeignProperty()); assertEquals(0, res_0.getRemainderOrdering().size()); // Note: index that has proper ordering is preferred because "orderId > ?" // filter does not specify a complete range. It is not expected to actually // filter much, so we choose to avoid a large sort instead. assertTrue(res_1.handlesAnything()); assertFalse(res_1.getCompositeScore().getFilteringScore().hasRangeStart()); assertFalse(res_1.getCompositeScore().getFilteringScore().hasRangeEnd()); assertEquals(makeIndex(Shipment.class, "shipmentID"), res_1.getLocalIndex()); assertEquals(null, res_1.getForeignIndex()); assertEquals(null, res_1.getForeignProperty()); assertEquals(0, res_0.getRemainderOrdering().size()); // Remainder filter exists because the "orderID" index was not chosen. assertEquals(Filter.filterFor(Shipment.class, "orderID > ?").bind(), res_1.getRemainderFilter()); } |
assertEquals(OrderingList.get(Shipment.class, "+shipmentID"), result.getTotalOrdering()); | public void testSimpleUnion3() throws Exception { UnionQueryAnalyzer uqa = new UnionQueryAnalyzer(Shipment.class, TestIndexedQueryAnalyzer.RepoAccess.INSTANCE); Filter<Shipment> filter = Filter.filterFor(Shipment.class, "shipmentID = ? | orderID > ? & orderID <= ?"); filter = filter.bind(); UnionQueryAnalyzer.Result result = uqa.analyze(filter, null); List<IndexedQueryAnalyzer<Shipment>.Result> subResults = result.getSubResults(); assertEquals(2, subResults.size()); IndexedQueryAnalyzer<Shipment>.Result res_0 = subResults.get(0); IndexedQueryAnalyzer<Shipment>.Result res_1 = subResults.get(1); assertTrue(res_0.handlesAnything()); assertEquals(Filter.filterFor(Shipment.class, "shipmentID = ?").bind(), res_0.getCompositeScore().getFilteringScore().getIdentityFilter()); assertEquals(makeIndex(Shipment.class, "shipmentID"), res_0.getLocalIndex()); assertEquals(null, res_0.getForeignIndex()); assertEquals(null, res_0.getForeignProperty()); assertEquals(0, res_0.getRemainderOrdering().size()); // Note: index that has proper filtering is preferred because // "orderId > ? & orderID <= ?" filter specifies a complete range. // We'll have to do a sort, but it isn't expected to be over that many records. assertTrue(res_1.handlesAnything()); assertTrue(res_1.getCompositeScore().getFilteringScore().hasRangeStart()); assertTrue(res_1.getCompositeScore().getFilteringScore().hasRangeEnd()); List<PropertyFilter<Shipment>> rangeFilters = res_1.getCompositeScore().getFilteringScore().getRangeStartFilters(); assertEquals(1, rangeFilters.size()); assertEquals(Filter.filterFor(Shipment.class, "orderID > ?").bind(), rangeFilters.get(0)); rangeFilters = res_1.getCompositeScore().getFilteringScore().getRangeEndFilters(); assertEquals(1, rangeFilters.size()); assertEquals(Filter.filterFor(Shipment.class, "orderID <= ?").bind(), rangeFilters.get(0)); assertEquals(makeIndex(Shipment.class, "orderID"), res_1.getLocalIndex()); assertEquals(null, res_1.getForeignIndex()); assertEquals(null, res_1.getForeignProperty()); // Sort operation required because the "shipmentID" index was not chosen. assertEquals("+shipmentID", res_1.getRemainderOrdering().get(0).toString()); } |
|
assertEquals(OrderingList.get(Shipment.class, "+shipmentID", "+orderID"), result.getTotalOrdering()); | public void testSimpleUnionUnspecifiedDirection() throws Exception { UnionQueryAnalyzer uqa = new UnionQueryAnalyzer(Shipment.class, TestIndexedQueryAnalyzer.RepoAccess.INSTANCE); Filter<Shipment> filter = Filter.filterFor(Shipment.class, "shipmentID > ? | orderID = ?"); filter = filter.bind(); OrderingList<Shipment> orderings = makeOrdering(Shipment.class, "~shipmentID", "~orderID"); UnionQueryAnalyzer.Result result = uqa.analyze(filter, orderings); List<IndexedQueryAnalyzer<Shipment>.Result> subResults = result.getSubResults(); assertEquals(2, subResults.size()); IndexedQueryAnalyzer<Shipment>.Result res_0 = subResults.get(0); IndexedQueryAnalyzer<Shipment>.Result res_1 = subResults.get(1); List<OrderedProperty<Shipment>> handled = res_0.getCompositeScore().getOrderingScore().getHandledOrdering(); assertEquals(1, handled.size()); assertEquals("+shipmentID", handled.get(0).toString()); handled = res_1.getCompositeScore().getOrderingScore().getHandledOrdering(); assertEquals(0, handled.size()); assertTrue(res_0.handlesAnything()); assertTrue(res_0.getCompositeScore().getFilteringScore().hasRangeStart()); assertFalse(res_0.getCompositeScore().getFilteringScore().hasRangeEnd()); assertEquals(makeIndex(Shipment.class, "shipmentID"), res_0.getLocalIndex()); assertEquals(null, res_0.getForeignIndex()); assertEquals(null, res_0.getForeignProperty()); assertEquals(1, res_0.getRemainderOrdering().size()); assertEquals("+orderID", res_0.getRemainderOrdering().get(0).toString()); assertTrue(res_1.handlesAnything()); assertEquals(Filter.filterFor(Shipment.class, "orderID = ?").bind(), res_1.getCompositeScore().getFilteringScore().getIdentityFilter()); assertEquals(makeIndex(Shipment.class, "orderID"), res_1.getLocalIndex()); assertEquals(null, res_1.getForeignIndex()); assertEquals(null, res_1.getForeignProperty()); assertEquals(1, res_1.getRemainderOrdering().size()); assertEquals("+shipmentID", res_1.getRemainderOrdering().get(0).toString()); } |
|
getBody().run(context, output); | invokeBody(output); | public void doTag(XMLOutput output) throws Exception { // force project to be lazily constructed getProject().setDefaultGoalName( this.defaultGoalName ); org.apache.tools.ant.Project antProject = AntTagLibrary.getProject( context ); // allow access to Ant methods via the project class context.setVariable( "project", antProject ); getBody().run(context, output); } |
gbrowseItem = new JMenuItem(DOWNLOAD_GBROWSE); gbrowseItem.addActionListener(this); gbrowseItem.setEnabled(false); fileMenu.add(gbrowseItem); | 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 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]); } colorMenuItems[Options.getLDColorScheme()].setSelected(true); displayMenu.add(colorMenu); JMenuItem spacingItem = new JMenuItem("LD Display Spacing"); spacingItem.setMnemonic(KeyEvent.VK_S); spacingItem.addActionListener(this); displayMenu.add(spacingItem); displayMenu.setEnabled(false); //analysis menu 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); analysisMenu.setEnabled(false); //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); **/ /* Configuration.readConfigFile(); if(Configuration.isCheckForUpdate()) { Object[] options = {"Yes", "Not now", "Never ask again"}; int n = JOptionPane.showOptionDialog(this, "Would you like to check if a new version " + "of haploview is available?", "Check for update", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); if(n == JOptionPane.YES_OPTION) { UpdateChecker uc = new UpdateChecker(); if(uc.checkForUpdate()) { JOptionPane.showMessageDialog(this, "A new version of Haploview is available!\n Visit http://www.broad.mit.edu/mpg/haploview/ to download the new version\n (current version: " + Constants.VERSION + " newest version: " + uc.getNewVersion() + ")" , "Update Available", JOptionPane.INFORMATION_MESSAGE); } } else if(n == JOptionPane.CANCEL_OPTION) { Configuration.setCheckForUpdate(false); Configuration.writeConfigFile(); } } */ addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e){ quit(); } }); } |
|
}else if (command.equals(DOWNLOAD_GBROWSE)){ GBrowseDialog gbd = new GBrowseDialog(this, "Connect to HapMap Info Server"); gbd.pack(); gbd.setVisible(true); | public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals(READ_GENOTYPES)){ ReadDataDialog readDialog = new ReadDataDialog("Open new data", this); readDialog.pack(); readDialog.setVisible(true); } else if (command.equals(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.equals(READ_ANALYSIS_TRACK)){ fc.setSelectedFile(new File("")); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION){ readAnalysisFile(fc.getSelectedFile()); } }else if (command.equals(READ_BLOCKS_FILE)){ fc.setSelectedFile(new File("")); if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION){ readBlocksFile(fc.getSelectedFile()); } }else if (command.equals(CUST_BLOCKS)){ TweakBlockDefsDialog tweakDialog = new TweakBlockDefsDialog("Customize Blocks", this); tweakDialog.pack(); tweakDialog.setVisible(true); }else if (command.equals(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")){ Options.setLDColorScheme(Integer.valueOf(command.substring(5)).intValue()); dPrimeDisplay.colorDPrime(); changeKey(); //exporting clauses }else if (command.equals(EXPORT_PNG)){ export(tabs.getSelectedIndex(), PNG_MODE, 0, Chromosome.getSize()); }else if (command.equals(EXPORT_TEXT)){ export(tabs.getSelectedIndex(), TXT_MODE, 0, Chromosome.getSize()); }else if (command.equals(EXPORT_OPTIONS)){ ExportDialog exDialog = new ExportDialog(this); exDialog.pack(); exDialog.setVisible(true); }else if (command.equals("Select All")){ checkPanel.selectAll(); }else if (command.equals("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(); JTable jt = checkPanel.getTable(); jt.repaint(); }else if (command.equals("LD Display Spacing")){ ProportionalSpacingDialog spaceDialog = new ProportionalSpacingDialog(this, "Adjust LD Spacing"); spaceDialog.pack(); spaceDialog.setVisible(true); }else if (command.equals("Tutorial")){ showHelp(); } else if (command.equals("Quit")){ quit(); } else { for (int i = 0; i < viewItems.length; i++) { if (command.equals(viewItems[i])) tabs.setSelectedIndex(i); } } } |
|
gbrowseItem.setEnabled(false); | void readMarkers(File inputFile, String[][] hminfo){ try { theData.prepareMarkerInput(inputFile, hminfo); if (theData.infoKnown){ analysisItem.setEnabled(true); }else{ analysisItem.setEnabled(false); } if (checkPanel != null){ //this is triggered when loading markers after already loading genotypes //it is dumb and sucks, but at least it works. bah. checkPanel = new CheckDataPanel(theData, true); Container checkTab = (Container)tabs.getComponentAt(VIEW_CHECK_NUM); checkTab.removeAll(); JPanel metaCheckPanel = new JPanel(); metaCheckPanel.setLayout(new BoxLayout(metaCheckPanel, BoxLayout.Y_AXIS)); JLabel countsLabel = new JLabel("Using " + theData.numSingletons + " singletons and " + theData.numTrios + " trios from " + theData.numPeds + " families."); if (theData.numTrios + theData.numSingletons == 0){ countsLabel.setForeground(Color.red); } countsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); metaCheckPanel.add(countsLabel); metaCheckPanel.add(checkPanel); cdc = new CheckDataController(window); metaCheckPanel.add(cdc); checkTab.add(metaCheckPanel); repaint(); } if (tdtPanel != null){ tdtPanel.refreshNames(); } if (dPrimeDisplay != null){ dPrimeDisplay.computePreferredSize(); } }catch (HaploViewException e){ JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); }catch (PedFileException pfe){ } } |
|
JFileChooser chooser = new JFileChooser(); chooser.addChoosableFileFilter(ASUtils.architectFileFilter); int returnVal = chooser.showSaveDialog(ArchitectFrame.this); if (returnVal == JFileChooser.APPROVE_OPTION) { project.setFile(chooser.getSelectedFile()); project.setName(project.getFile().getName()); final ProgressMonitor pm = new ProgressMonitor (ArchitectFrame.this, "Saving Project", "", 0, 100); try { project.save(pm); } catch (Exception ex) { JOptionPane.showMessageDialog (ArchitectFrame.this, "Can't save project: "+ex.getMessage()); logger.error("Got exception while saving project", ex); } } | saveOrSaveAs(false); | public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.addChoosableFileFilter(ASUtils.architectFileFilter); int returnVal = chooser.showSaveDialog(ArchitectFrame.this); if (returnVal == JFileChooser.APPROVE_OPTION) { project.setFile(chooser.getSelectedFile()); project.setName(project.getFile().getName()); final ProgressMonitor pm = new ProgressMonitor (ArchitectFrame.this, "Saving Project", "", 0, 100);// new Thread() {// public void run() { try { project.save(pm); } catch (Exception ex) { JOptionPane.showMessageDialog (ArchitectFrame.this, "Can't save project: "+ex.getMessage()); logger.error("Got exception while saving project", ex); }// }// }.start(); } } |
System.exit(0); | saveOrSaveAs(true); | public void actionPerformed(ActionEvent e) { System.exit(0); } |
if (configFile == null) configFile = ConfigFile.getDefaultInstance(); try { sprefs.setInt(SwingUserSettings.DIVIDER_LOCATION, splitPane.getDividerLocation()); sprefs.setInt(SwingUserSettings.MAIN_FRAME_X, getLocation().x); sprefs.setInt(SwingUserSettings.MAIN_FRAME_Y, getLocation().y); sprefs.setInt(SwingUserSettings.MAIN_FRAME_WIDTH, getWidth()); sprefs.setInt(SwingUserSettings.MAIN_FRAME_HEIGHT, getHeight()); configFile.write(prefs); } catch (ArchitectException ex) { logger.error("Couldn't save settings", ex); } | System.exit(0); | public void actionPerformed(ActionEvent e) { if (configFile == null) configFile = ConfigFile.getDefaultInstance(); try { sprefs.setInt(SwingUserSettings.DIVIDER_LOCATION, splitPane.getDividerLocation()); sprefs.setInt(SwingUserSettings.MAIN_FRAME_X, getLocation().x); sprefs.setInt(SwingUserSettings.MAIN_FRAME_Y, getLocation().y); sprefs.setInt(SwingUserSettings.MAIN_FRAME_WIDTH, getWidth()); sprefs.setInt(SwingUserSettings.MAIN_FRAME_HEIGHT, getHeight()); configFile.write(prefs); } catch (ArchitectException ex) { logger.error("Couldn't save settings", ex); } } |
fileMenu.add(new JMenuItem(saveProjectAsAction)); | public ArchitectFrame() throws ArchitectException { mainInstance = this; try { ConfigFile cf = ConfigFile.getDefaultInstance(); prefs = cf.read(); sprefs = prefs.getSwingSettings(); } catch (IOException e) { throw new ArchitectException("prefs.read", e); } Container cp = getContentPane(); cp.setLayout(new BorderLayout()); // Create actions exportDDLAction = new ExportDDLAction(); createRelationshipAction = new CreateRelationshipAction(); createTableAction = new CreateTableAction(); editColumnAction = new EditColumnAction(); insertColumnAction = new InsertColumnAction(); deleteColumnAction = new DeleteColumnAction(); editTableAction = new EditTableAction(); deleteTableAction = new DeleteTableAction(); menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); fileMenu.add(new JMenuItem(newProjectAction)); fileMenu.add(new JMenuItem(openProjectAction)); fileMenu.add(new JMenuItem(saveProjectAction)); fileMenu.add(new JMenuItem(exportDDLAction)); fileMenu.add(new JMenuItem(saveSettingsAction)); fileMenu.add(new JMenuItem(exitAction)); menuBar.add(fileMenu); setJMenuBar(menuBar); toolBar = new JToolBar(); toolBar.add(new JButton(newProjectAction)); toolBar.add(new JButton(openProjectAction)); toolBar.add(new JButton(saveProjectAction)); toolBar.add(new JButton(createTableAction)); toolBar.add(new JButton(deleteTableAction)); toolBar.add(new JButton(editColumnAction)); toolBar.add(new JButton(insertColumnAction)); toolBar.add(new JButton(deleteColumnAction)); toolBar.add(new JButton(createRelationshipAction)); cp.add(toolBar, BorderLayout.NORTH); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); getContentPane().add(splitPane, BorderLayout.CENTER); logger.debug("Added splitpane to content pane"); splitPane.setDividerLocation (sprefs.getInt(SwingUserSettings.DIVIDER_LOCATION, 150)); //dbTree.getPreferredSize().width)); Rectangle bounds = new Rectangle(); bounds.x = sprefs.getInt(SwingUserSettings.MAIN_FRAME_X, 40); bounds.y = sprefs.getInt(SwingUserSettings.MAIN_FRAME_Y, 40); bounds.width = sprefs.getInt(SwingUserSettings.MAIN_FRAME_WIDTH, 600); bounds.height = sprefs.getInt(SwingUserSettings.MAIN_FRAME_HEIGHT, 440); setBounds(bounds); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setProject(new SwingUIProject("New Project")); } |
|
l = new java.util.ArrayList(0) | l = new ArrayList(0); | public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if (var == null) { throw new MissingAttributeException( "var" ); } if (select == null) { throw new MissingAttributeException( "select" ); } Object xpathContext = getXPathContext(); Object value = null; try { if(single!=null && single.booleanValue()==true) { value = select.selectSingleNode(xpathContext); } else { value = select.evaluate(xpathContext); } } catch (JaxenException e) { throw new JellyTagException(e); } if (value instanceof List) { // sort the list if xpCmp is set. if (xpCmp != null && (xpCmp.getXpath() != null)) { Collections.sort((List)value, xpCmp); } } if (single!=null) { if (single.booleanValue()==true) { if(value instanceof List) { List l = (List) value; if (l.size()==0) value=null; else value=l.get(0); } } else { // single == false if(! (value instanceof List) ) { if (value==null) { l = new java.util.ArrayList(0) } else { List l = new java.util.ArrayList(1); l.add(value); } value = l; } } } //log.info( "Evaluated xpath: " + select + " as: " + value + " of type: " + value.getClass().getName() ); context.setVariable(var, value); } |
List l = new java.util.ArrayList(1); | List l = new ArrayList(1); | public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if (var == null) { throw new MissingAttributeException( "var" ); } if (select == null) { throw new MissingAttributeException( "select" ); } Object xpathContext = getXPathContext(); Object value = null; try { if(single!=null && single.booleanValue()==true) { value = select.selectSingleNode(xpathContext); } else { value = select.evaluate(xpathContext); } } catch (JaxenException e) { throw new JellyTagException(e); } if (value instanceof List) { // sort the list if xpCmp is set. if (xpCmp != null && (xpCmp.getXpath() != null)) { Collections.sort((List)value, xpCmp); } } if (single!=null) { if (single.booleanValue()==true) { if(value instanceof List) { List l = (List) value; if (l.size()==0) value=null; else value=l.get(0); } } else { // single == false if(! (value instanceof List) ) { if (value==null) { l = new java.util.ArrayList(0) } else { List l = new java.util.ArrayList(1); l.add(value); } value = l; } } } //log.info( "Evaluated xpath: " + select + " as: " + value + " of type: " + value.getClass().getName() ); context.setVariable(var, value); } |
compressCheckBox = new JCheckBox("Compress image (smaller file)"); formatPanel.add(compressCheckBox); compressCheckBox.setEnabled(false); | public ExportDialog(HaploView h){ super(h, "Export Data"); hv = h; JPanel contents = new JPanel(); contents.setLayout(new BoxLayout(contents, BoxLayout.Y_AXIS)); JPanel tabPanel = new JPanel(); int currTab = hv.tabs.getSelectedIndex(); tabPanel.setBorder(new TitledBorder("Tab to Export")); tabPanel.setLayout(new BoxLayout(tabPanel,BoxLayout.Y_AXIS)); tabPanel.setAlignmentX(CENTER_ALIGNMENT); ButtonGroup g1 = new ButtonGroup(); dpButton = new JRadioButton("LD"); dpButton.setActionCommand("ldtab"); dpButton.addActionListener(this); g1.add(dpButton); tabPanel.add(dpButton); if (currTab == VIEW_D_NUM){ dpButton.setSelected(true); } hapButton = new JRadioButton("Haplotypes"); hapButton.setActionCommand("haptab"); hapButton.addActionListener(this); g1.add(hapButton); tabPanel.add(hapButton); if (currTab == VIEW_HAP_NUM){ hapButton.setSelected(true); } if (hv.checkPanel != null){ checkButton = new JRadioButton("Data Checks"); checkButton.setActionCommand("checktab"); checkButton.addActionListener(this); g1.add(checkButton); tabPanel.add(checkButton); if (currTab == VIEW_CHECK_NUM){ checkButton.setSelected(true); } } if (hv.assocTest != 0){ assocButton = new JRadioButton("Association Tests"); assocButton.setActionCommand("assoctab"); assocButton.addActionListener(this); g1.add(assocButton); tabPanel.add(assocButton); if (currTab == VIEW_TDT_NUM){ assocButton.setSelected(true); } } contents.add(tabPanel); JPanel formatPanel = new JPanel(); formatPanel.setBorder(new TitledBorder("Output Format")); ButtonGroup g2 = new ButtonGroup(); txtButton = new JRadioButton("Text"); txtButton.addActionListener(this); formatPanel.add(txtButton); g2.add(txtButton); txtButton.setSelected(true); pngButton = new JRadioButton("PNG Image"); pngButton.addActionListener(this); formatPanel.add(pngButton); g2.add(pngButton); if (currTab == VIEW_CHECK_NUM || currTab == VIEW_TDT_NUM){ pngButton.setEnabled(false); } contents.add(formatPanel); JPanel rangePanel = new JPanel(); rangePanel.setBorder(new TitledBorder("Range")); ButtonGroup g3 = new ButtonGroup(); allButton = new JRadioButton("All"); allButton.addActionListener(this); rangePanel.add(allButton); g3.add(allButton); allButton.setSelected(true); someButton = new JRadioButton("Marker "); someButton.addActionListener(this); rangePanel.add(someButton); g3.add(someButton); lowRange = new NumberTextField("",5,false); rangePanel.add(lowRange); rangePanel.add(new JLabel(" to ")); upperRange = new NumberTextField("",5,false); rangePanel.add(upperRange); upperRange.setEnabled(false); lowRange.setEnabled(false); adjButton = new JRadioButton("Adjacent markers only"); adjButton.addActionListener(this); rangePanel.add(adjButton); g3.add(adjButton); if (currTab != VIEW_D_NUM){ someButton.setEnabled(false); adjButton.setEnabled(false); } contents.add(rangePanel); JPanel choicePanel = new JPanel(); JButton okButton = new JButton("OK"); okButton.addActionListener(this); choicePanel.add(okButton); JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); choicePanel.add(cancelButton); contents.add(choicePanel); this.setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); } |
|
format = PNG_MODE; | if (compressCheckBox.isSelected()){ format = COMPRESSED_PNG_MODE; }else{ format = PNG_MODE; } | public void actionPerformed (ActionEvent e){ String command = e.getActionCommand(); if (dpButton.isSelected()){ if(txtButton.isSelected()){ adjButton.setEnabled(true); }else{ adjButton.setEnabled(false); if (adjButton.isSelected()){ allButton.setSelected(true); } } someButton.setEnabled(true); }else{ someButton.setEnabled(false); adjButton.setEnabled(false); if (adjButton.isSelected() || someButton.isSelected()){ allButton.setSelected(true); } } if (someButton.isSelected()){ upperRange.setEnabled(true); lowRange.setEnabled(true); }else{ upperRange.setEnabled(false); lowRange.setEnabled(false); } if (command.equals("ldtab") || command.equals("haptab")){ pngButton.setEnabled(true); }else if (command.equals("checktab") || command.equals("assoctab")){ pngButton.setEnabled(false); txtButton.setSelected(true); }else if (command.equals("OK")){ int format, tab; if (pngButton.isSelected()){ format = PNG_MODE; }else{ format = TXT_MODE; } if (dpButton.isSelected()){ tab = VIEW_D_NUM; } else if (hapButton.isSelected()){ tab = VIEW_HAP_NUM; } else if (checkButton.isSelected()){ tab = VIEW_CHECK_NUM; } else { tab = VIEW_TDT_NUM; } this.dispose(); if (allButton.isSelected()){ hv.export(tab,format,0,Chromosome.getSize()); }else if (someButton.isSelected()){ hv.export(tab,format,Integer.parseInt(lowRange.getText())-1, Integer.parseInt(upperRange.getText())); }else{ hv.export(tab,format,-1,-1); } }else if (command.equals("Cancel")){ this.dispose(); } } |
hv.export(tab,format,Integer.parseInt(lowRange.getText())-1, Integer.parseInt(upperRange.getText())); | try{ hv.export(tab,format,Integer.parseInt(lowRange.getText())-1, Integer.parseInt(upperRange.getText())); }catch (NumberFormatException nfe){ JOptionPane.showMessageDialog(hv, "Invalid marker range: " + lowRange.getText() + " - " + upperRange.getText(), "Export Error", JOptionPane.ERROR_MESSAGE); } | public void actionPerformed (ActionEvent e){ String command = e.getActionCommand(); if (dpButton.isSelected()){ if(txtButton.isSelected()){ adjButton.setEnabled(true); }else{ adjButton.setEnabled(false); if (adjButton.isSelected()){ allButton.setSelected(true); } } someButton.setEnabled(true); }else{ someButton.setEnabled(false); adjButton.setEnabled(false); if (adjButton.isSelected() || someButton.isSelected()){ allButton.setSelected(true); } } if (someButton.isSelected()){ upperRange.setEnabled(true); lowRange.setEnabled(true); }else{ upperRange.setEnabled(false); lowRange.setEnabled(false); } if (command.equals("ldtab") || command.equals("haptab")){ pngButton.setEnabled(true); }else if (command.equals("checktab") || command.equals("assoctab")){ pngButton.setEnabled(false); txtButton.setSelected(true); }else if (command.equals("OK")){ int format, tab; if (pngButton.isSelected()){ format = PNG_MODE; }else{ format = TXT_MODE; } if (dpButton.isSelected()){ tab = VIEW_D_NUM; } else if (hapButton.isSelected()){ tab = VIEW_HAP_NUM; } else if (checkButton.isSelected()){ tab = VIEW_CHECK_NUM; } else { tab = VIEW_TDT_NUM; } this.dispose(); if (allButton.isSelected()){ hv.export(tab,format,0,Chromosome.getSize()); }else if (someButton.isSelected()){ hv.export(tab,format,Integer.parseInt(lowRange.getText())-1, Integer.parseInt(upperRange.getText())); }else{ hv.export(tab,format,-1,-1); } }else if (command.equals("Cancel")){ this.dispose(); } } |
this.pp = pp; | this.pp = new PlayPen(pp); | public PrintPanel(PlayPen pp) { super(); setOpaque(true); setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); this.pp = pp; add(new PrintPreviewPanel()); job = PrinterJob.getPrinterJob(); jobAttributes = new HashPrintRequestAttributeSet(); pageFormat = job.defaultPage(); JPanel formPanel = new JPanel(new FormLayout()); formPanel.add(new JLabel("Printer")); formPanel.add(printerBox = new JComboBox(PrinterJob.lookupPrintServices())); printerBox.setSelectedItem(getPreferredPrinter()); formPanel.add(new JLabel("Page Format")); String pf = paperToPrintable(pageFormat); formPanel.add(pageFormatLabel = new JLabel(pf.toString())); formPanel.add(new JLabel("Change Page Format")); formPanel.add(pageFormatButton = new JButton("Change Page Format")); pageFormatButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setPageFormat(job.pageDialog(jobAttributes)); } }); formPanel.add(zoomLabel = new JLabel("Scaling = 100%")); formPanel.add(zoomSlider = new JSlider(JSlider.HORIZONTAL, 1, 300, 100)); setZoom(1.0); zoomSlider.addChangeListener(this); add(formPanel); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.