Skip to content

Commit

Permalink
Add an option to immediately open the spreadsheet.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender committed Sep 4, 2023
1 parent c5e36c2 commit 9cf0926
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import org.eclipse.chemclipse.pcr.report.supplier.tabular.excel.preferences.PreferenceSupplier;
import org.eclipse.chemclipse.pcr.report.supplier.tabular.excel.ui.Activator;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.ui.IWorkbench;
Expand All @@ -36,6 +37,7 @@ public PreferencePage() {
public void createFieldEditors() {

addField(new StringFieldEditor(PreferenceSupplier.P_ANALYSIS_SEPARATOR, "Sample Analysis Separator:", getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceSupplier.P_OPEN_REPORT, "Open report after generation.", getFieldEditorParent()));
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.eclipse.chemclipse.pcr.report.supplier.tabular.model.WellComparator;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.chemclipse.processing.core.ProcessingInfo;
import org.eclipse.chemclipse.support.editor.SystemEditor;
import org.eclipse.core.runtime.IProgressMonitor;

public class PCRExportConverter extends AbstractPlateExportConverter implements IPlateExportConverter {
Expand Down Expand Up @@ -98,17 +99,17 @@ public IProcessingInfo<File> convert(File file, IPlate plate, IProgressMonitor m
} catch(FileNotFoundException e) {
logger.warn(e);
processingInfo.addErrorMessage(DESCRIPTION, "File not found.");
} catch(IOException e) {
processingInfo.addErrorMessage(DESCRIPTION, "Input/Output problem.");
logger.warn(e);
}
} else {
processingInfo.addErrorMessage(DESCRIPTION, "The PCR plate is not available.");
}
} catch(IOException e1) {
logger.warn(e1);
} catch(IOException e) {
processingInfo.addErrorMessage(DESCRIPTION, "Input/Output problem.");
logger.warn(e);
}
if(PreferenceSupplier.isOpenReport()) {
SystemEditor.open(file);
}
//
return processingInfo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class PreferenceSupplier implements IPreferenceSupplier {
public static final String DEF_LIST_PATH_EXPORT = "";
public static final String P_ANALYSIS_SEPARATOR = "xlsx-pcr-analysis-separator";
public static final String DEF_ANALYSIS_SEPARATOR = "_";
public static final String P_OPEN_REPORT = "xlsx-pcr-open-report";
public static final String DEF_OPEN_REPORT = Boolean.toString(true);
//
private static IPreferenceSupplier preferenceSupplier;

Expand Down Expand Up @@ -70,6 +72,7 @@ public Map<String, String> getDefaultValues() {
defaultValues.put(P_CHANNEL_MAPPING, DEF_CHANNEL_MAPPING);
defaultValues.put(P_IGNORE_SUBSETS, DEF_IGNORE_SUBSETS);
defaultValues.put(P_ANALYSIS_SEPARATOR, DEF_ANALYSIS_SEPARATOR);
defaultValues.put(P_OPEN_REPORT, DEF_OPEN_REPORT);
return defaultValues;
}

Expand Down Expand Up @@ -129,6 +132,16 @@ public static void setListPathExport(String filterPath) {
setFilterPath(P_LIST_PATH_EXPORT, filterPath);
}

public static Boolean isOpenReport() {

return Boolean.valueOf(getFilterPath(P_OPEN_REPORT, DEF_OPEN_REPORT));
}

public static void setOpenReport(boolean open) {

setFilterPath(P_OPEN_REPORT, String.valueOf(open));
}

private static String getFilterPath(String key, String def) {

IEclipsePreferences preferences = INSTANCE().getPreferences();
Expand Down

0 comments on commit 9cf0926

Please sign in to comment.