private TableReferenceObject getTableReferenceObject(String technology, String endpoint) { if (endpoint.equalsIgnoreCase("[sample]")) { return ConfigurationManager.selectTROForUserSelection(MappingObject.STUDY_SAMPLE); } else { technology = technology.equalsIgnoreCase(AssaySelectionUI.NO_TECHNOLOGY_TEXT) ? "" : technology; return ConfigurationManager.selectTROForUserSelection(endpoint, technology); } }
/** * Create JPanel asking users to select the assay used in each file (iteratively) * * @param fileToMap - file to be mapped. * @return JPanel containing elements allowing confirmation of assay type */ private JLayeredPane createAssayUsedPanel(final String fileToMap) { Map<String, List<String>> measToAllowedTechnologies = ConfigurationManager.getAllowedTechnologiesPerEndpoint(); final AssaySelectionUI assaySelection = new AssaySelectionUI(measToAllowedTechnologies); assaySelection.createGUI(); if (preExistingMapping != null) { assaySelection.addAssaysToDefine(preExistingMapping.getPreviousAssaySelections()); } final JLayeredPane finalPanel = getGeneralLayout( selectAssaysUsedHeader, breadcrumb2, fileBeingMapped, assaySelection, getHeight()); // by having an array of MouseListeners, we can pass this to a History object which allows the // functionality specific // to buttons on certain pages to be transported. final MouseListener[] listeners = new MouseListener[2]; listeners[0] = new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { backButton.setIcon(backOver); } public void mouseExited(MouseEvent mouseEvent) { backButton.setIcon(back); } public void mousePressed(MouseEvent mouseEvent) { backButton.setIcon(back); SwingUtilities.invokeLater( new Runnable() { public void run() { HistoryComponent hc = previousPage.pop(); assignListenerToLabel(backButton, hc.getListeners()[0]); assignListenerToLabel(nextButton, hc.getListeners()[1]); setCurrentPage(hc.getDisplayComponent()); } }); } }; assignListenerToLabel(backButton, listeners[0]); listeners[1] = new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { nextButton.setIcon(nextOver); } public void mouseExited(MouseEvent mouseEvent) { nextButton.setIcon(next); } public void mousePressed(MouseEvent mouseEvent) { nextButton.setIcon(next); previousPage.push(new HistoryComponent(finalPanel, listeners)); assaysToBeDefined = assaySelection.getAssaysToDefine(); assaySelections = new HashMap<String, AssaySelection>(); Thread loadFileProcess = new Thread( new Runnable() { public void run() { // attempt to load the supplied fileToMap/directory... Loader l = new Loader(); String fileName = null; try { Map<String, String[]> fileColumnMap = l.loadFile(new File(fileToMap)); fileColumns = null; for (String file : fileColumnMap.keySet()) { fileColumns = fileColumnMap.get(file); fileBeingMapped = file.substring(file.lastIndexOf(File.separator) + 1); fileName = file; break; } status.setText(""); reader = l.getReaderToUse(); if (reader == FileLoader.SHEET_READER) { fileName = fileToMap; } // we will always start off with defining the study sample file! // it will be in the create mappings listeners where we // will iterate around the assays to be defined. setCurrentPage( createMappings( -1, getTableReferenceObject("", "[Sample]"), fileColumns, fileName, reader)); } catch (NoAvailableLoaderException e) { setCurrentPage(lastPage); showErrorPanel(); log.error("No loader available for file format!"); } catch (MultipleExtensionsException e) { setCurrentPage(lastPage); showErrorPanel(); log.error( "There are files with different extensions in the selected folder! This is not allowed."); } catch (BiffException e) { setCurrentPage(lastPage); showErrorPanel(); log.error(e.getMessage()); } catch (IOException e) { setCurrentPage(lastPage); showErrorPanel(); log.error(e.getMessage()); } } }); lastPage = currentPage; setCurrentPage(workingProgressScreen); loadFileProcess.start(); } }; assignListenerToLabel(nextButton, listeners[1]); return finalPanel; }