public AddAssociationDialog( Component parentComponent, boolean modal, AlgorithmView view, boolean createSelected, String project, String traits, String markers) { super(); parentComponentReference = parentComponent; currentComponentReference = this; this.view = view; labelFactory(); textFieldFactory(); comboBoxFactory(); radioButtonFactory(); buttonFactory(); panelFactory(); dialogSettings(); componentSettings(); for (int i = 0; i < Algorithms.AssociationAlgorithms.algonames().size(); i++) { this.algorithmComboBox.addItem(Algorithms.AssociationAlgorithms.getalgorithms().get(i)); } ArrayList<Project> temp = Model.getInstance().getProjects(); for (int i = 0; i < temp.size(); i++) { this.projectComboBox.addItem(temp.get(i).getName()); } if (project != null) { this.projectComboBox.setSelectedItem(project); } if (traits != null) { this.traitSetComboBox.setSelectedItem(traits); } if (markers != null) { this.markerSetComboBox.setSelectedItem(markers); } if (project != null && traits == null) { if (this.traitSetComboBox.getItemCount() > 1) { this.traitSetComboBox.setSelectedIndex(1); if (this.markerSetComboBox.getItemCount() > 1) { this.markerSetComboBox.setSelectedIndex(1); } } } }
/** * Checks conditions and starts the algorithm. * * @param evt */ private void runButtonActionPerformed(java.awt.event.ActionEvent evt) { if (this.projectComboBox.getSelectedItem().equals("")) { UIMessages.showErrorMessage("Please select a project", "Error"); return; } if (this.traitSetComboBox.getSelectedIndex() < 0) { UIMessages.showErrorMessage("Please select a trait option", "Error"); return; } String projectName = projectComboBox.getSelectedItem().toString(); String traitName = traitSetComboBox.getSelectedItem().toString(); String markerName = markerSetComboBox.getSelectedItem().toString(); Project ap = Model.getInstance().getProject(projectName); TraitSet ts = ap.getTrait(traitName); MarkerSet ms = ap.getMarker(markerName); if (this.algorithmComboBox.getSelectedIndex() < 0 && !this.loadAssociationRadioButton.isSelected()) { UIMessages.showErrorMessage("Please select an algorithm", "Error"); return; } if (this.algorithmComboBox.getSelectedItem().equals("Adaptive Multi-Task Lasso")) { ArrayList<String> where = new ArrayList<String>(); where.add("markersetid = " + ms.getId()); if (Integer.parseInt( DataManager.runSelectQuery("count(*)", "feature", true, where, null).get(0)) < 1) { UIMessages.showErrorMessage("Selected marker set does not have features", "Error"); return; } } if (this.markerSetComboBox.getSelectedIndex() < 0) { UIMessages.showErrorMessage("Please select a marker", "Error"); return; } if (this.networkComboBox.getSelectedIndex() < 0 && this.networkComboBox.isEnabled()) { UIMessages.showErrorMessage( "Please select a valid network option for selected algorithm", "Error"); return; } if (this.networkComboBox.getSelectedIndex() < 0 && this.networkComboBox.isEnabled()) { UIMessages.showErrorMessage( "Please select a valid Population option for selected algorithm", "Error"); return; } if (this.numberComboBox.isEnabled() && this.numberComboBox.getSelectedIndex() < 0) { UIMessages.showErrorMessage( "Please select a valid Population option for this algorithm", "Error"); return; } if (this.nameTextField.getText().equals("")) { UIMessages.showErrorMessage("Please specify a valid name", "Error"); return; } if (Model.getInstance() .getProject(projectComboBox.getSelectedItem().toString()) .isAssocNamePresentInProject(this.nameTextField.getText())) { UIMessages.showErrorMessage("Specified name already exists for this project", "Error"); return; } String networkName = this.networkComboBox.getSelectedItem().toString(); String algoName = this.algorithmComboBox.getSelectedItem().toString(); String popno = this.numberComboBox.getSelectedItem().toString(); if (!this.numberComboBox.isEnabled()) { popno = "1"; } algoName = (algoName.equals("")) ? null : algoName; Network net = (Network) ts.getTraitStructure(networkName); if (ts.getNetworks().size() == 0) // without a network, we will be unable // to view this visualization, so we add it here. { try { view.addAlgorithm( Algorithms.NetworkAlgorithms.algonames().get(0), Algorithms.NetworkAlgorithms.jobTypeID().get(0), ap.getId(), ts.getId(), ms.getId()); } catch (Exception e) { } } if (this.createAssociationRadioButton.isSelected()) { int structtype = algorithmComboBox.getSelectedIndex() < 0 ? -1 : Algorithms.AssociationAlgorithms.inputStructure() .get(algorithmComboBox.getSelectedIndex()); IOFilesForIOLasso ioffio = null; if (structtype == 3) { ioffio = new IOFilesForIOLasso(currentComponentReference); ioffio.setVisible(true); if (ioffio.getInputFilePath() == null || ioffio.getInputFilePath().length() < 5 || ioffio.getOutputFilePath() == null || ioffio.getOutputFilePath().length() < 5) { UIMessages.showErrorMessage("I/O Lasso needs valid group files", "Error"); return; } } AssociationParameterObject apo = new AssociationParameterObject( (Network) ts.getTraitStructure(networkName), this.nameTextField.getText(), ms.getPopulation(networkName), popno, ioffio); int idx = this.algorithmComboBox.getSelectedIndex() - 1; view.addAlgorithm( Algorithms.AssociationAlgorithms.algonames().get(idx), Algorithms.AssociationAlgorithms.jobTypeID().get(idx), ap.getId(), ts.getId(), ms.getId(), apo); } else { DataAddRemoveHandler.getInstance() .addAssociation( ap.getId(), ts, ms, this.nameTextField.getText(), this.associationFilePathTextField.getText(), null); } this.dispose(); }