Skip to content

Commit

Permalink
Mass changes to Spreadsheet class. Pulled out a lot of function code …
Browse files Browse the repository at this point in the history
…(copy/paste etc) into a separate class. Tested and all seems good.
  • Loading branch information
eamonnmag committed Feb 11, 2011
1 parent 3ed0379 commit 292a107
Show file tree
Hide file tree
Showing 10 changed files with 2,036 additions and 1,985 deletions.
Expand Up @@ -164,7 +164,7 @@ public void run() {
for (Assay a : s.getAssays().values()) {
localFiles.put(a.getAssayReference(), new ArrayList<String>());
// getFilesDefinedInTable will get all files and directory paths listed in each file column in the table!
for (String file : a.getSpreadsheetUI().getTable().getFilesDefinedInTable()) {
for (String file : a.getSpreadsheetUI().getTable().getSpreadsheetFunctions().getFilesDefinedInTable()) {
if (!file.startsWith("ftp") && !file.startsWith("http")) {

localFiles.get(a.getAssayReference()).add(file);
Expand Down Expand Up @@ -272,8 +272,7 @@ public void zipDir(String sourceDir, File dirToZip, ZipOutputStream zos, byte[]
fis.close();
}
}
}
catch (Exception e) {
} catch (Exception e) {
//handle exception
log.error(e.getMessage());
}
Expand Down
Expand Up @@ -104,7 +104,7 @@ public void saveISAFiles(boolean removeEmptyColumns, Investigation inv) {
File.separator + s.getStudySampleFileIdentifier());

Spreadsheet tmpSheet = s.getStudySample().getSpreadsheetUI().getTable();
if (!tmpSheet.exportTable(fileToSave, "\t", removeEmptyColumns)) {
if (!tmpSheet.getSpreadsheetFunctions().exportTable(fileToSave, "\t", removeEmptyColumns)) {
errorSheets.add(tmpSheet);
shouldShowIncorrectOrderGUI = true;
}
Expand All @@ -118,7 +118,7 @@ public void saveISAFiles(boolean removeEmptyColumns, Investigation inv) {
File.separator + a.getAssayReference());

tmpSheet = a.getSpreadsheetUI().getTable();
if (!tmpSheet.exportTable(fileToSave, "\t", removeEmptyColumns)) {
if (!tmpSheet.getSpreadsheetFunctions().exportTable(fileToSave, "\t", removeEmptyColumns)) {
errorSheets.add(tmpSheet);
shouldShowIncorrectOrderGUI = true;
}
Expand Down
18 changes: 9 additions & 9 deletions trunk/src/main/java/org/isatools/isacreator/model/Study.java
Expand Up @@ -361,12 +361,12 @@ public void removeAssay(String assayRef) {
*/
public void removeFactor(String factorName) {
for (String key : assays.keySet()) {
assays.get(key).getSpreadsheetUI().getTable()
assays.get(key).getSpreadsheetUI().getTable().getSpreadsheetFunctions()
.removeColumnByName("Factor Value[" + factorName + "]");
}

studySampleRecord.getSpreadsheetUI().getTable()
.removeColumnByName("Factor Value[" + factorName + "]");
.getSpreadsheetFunctions().removeColumnByName("Factor Value[" + factorName + "]");

Factor toRemove = null;

Expand Down Expand Up @@ -439,13 +439,13 @@ public void replaceFactors(String previousFactorName, String newFactorName) {

for (String key : assays.keySet()) {
assays.get(key).getSpreadsheetUI().getTable()
.substituteHeaderNames(previousFactorName, newFactorName);
.getSpreadsheetFunctions().substituteHeaderNames(previousFactorName, newFactorName);
System.out.print(".");
}

studySampleRecord.getSpreadsheetUI().getTable()
.substituteHeaderNames(previousFactorName,
newFactorName);
.getSpreadsheetFunctions().substituteHeaderNames(previousFactorName,
newFactorName);
}

/**
Expand All @@ -458,13 +458,13 @@ public void replaceProtocols(String previousProtocolName,
String newProtocolName) {
for (String key : assays.keySet()) {
assays.get(key).getSpreadsheetUI().getTable()
.susbstituteTermsInColumn("Protocol REF",
previousProtocolName, newProtocolName);
.getSpreadsheetFunctions().susbstituteTermsInColumn("Protocol REF",
previousProtocolName, newProtocolName);
}

studySampleRecord.getSpreadsheetUI().getTable()
.susbstituteTermsInColumn("Protocol REF",
previousProtocolName, newProtocolName);
.getSpreadsheetFunctions().susbstituteTermsInColumn("Protocol REF",
previousProtocolName, newProtocolName);

if (newProtocolName.equals("")) {
// we are removing the protocol
Expand Down
Expand Up @@ -420,9 +420,9 @@ public void mousePressed(MouseEvent event) {
colName, typeAsText + " value", DataTypes.STRING,
"", false, false, false);

st.addFieldToReferenceObject(charFo);
st.getSpreadsheetFunctions().addFieldToReferenceObject(charFo);

st.addColumnAfterPosition(colName, null, -1);
st.getSpreadsheetFunctions().addColumnAfterPosition(colName, null, -1);

SwingUtilities.invokeLater(new Runnable() {
public void run() {
Expand Down Expand Up @@ -473,17 +473,17 @@ public void run() {

String colName = typeAsText + "[" + toAdd + "]";

if (!st.checkColumnExists(colName)) {
if (!st.getSpreadsheetFunctions().checkColumnExists(colName)) {
boolean useOntology = qualitativeOp.isSelected();
DataTypes type = useOntology ? DataTypes.ONTOLOGY_TERM
: DataTypes.STRING;
TableFieldObject charFo = new TableFieldObject(st.getColumnCount(),
colName, typeAsText + " value", type,
"", false, false, false);
st.addFieldToReferenceObject(charFo);
st.getSpreadsheetFunctions().addFieldToReferenceObject(charFo);

if (!toAdd.equals("")) {
st.addColumnAfterPosition(colName, null, -1);
st.getSpreadsheetFunctions().addColumnAfterPosition(colName, null, -1);
}

if (quantativeOp.isSelected()) {
Expand All @@ -492,8 +492,8 @@ public void run() {
"Unit for definition of value",
DataTypes.ONTOLOGY_TERM, "", false, false,
false);
st.addFieldToReferenceObject(unitFo);
st.addColumnAfterPosition("Unit",
st.getSpreadsheetFunctions().addFieldToReferenceObject(unitFo);
st.getSpreadsheetFunctions().addColumnAfterPosition("Unit",
unitField.getText(), -1);
}

Expand Down
Expand Up @@ -71,7 +71,7 @@ private void addRows() {
int i = Integer.parseInt(numRowsTxt.getText());

if ((i < Spreadsheet.MAX_ROWS) && ((i + st.getTable().getRowCount()) <= Spreadsheet.MAX_ROWS)) {
st.addRows(i, false);
st.getSpreadsheetFunctions().addRows(i, false);
st.getParentFrame().hideSheet();
} else {
numRowsTxt.setText("Max rows = " + Spreadsheet.MAX_ROWS);
Expand Down
Expand Up @@ -162,7 +162,7 @@ public void mousePressed(MouseEvent event) {
secondaryAscending = false;
}

st.performMultipleSort(primaryCol, secondaryCol, primaryAscending, secondaryAscending);
st.getSpreadsheetFunctions().performMultipleSort(primaryCol, secondaryCol, primaryAscending, secondaryAscending);
st.getParentFrame().hideSheet();
} catch (Exception e) {
JOptionPane.showMessageDialog(null,
Expand Down

0 comments on commit 292a107

Please sign in to comment.