Skip to content

Commit

Permalink
Add depth option to import dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikl committed Nov 10, 2022
1 parent 420cf06 commit fa43992
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*------------------------------------------------------------------------------
* Copyright (C) 2006-2017 University of Dundee. All rights reserved.
* Copyright (C) 2006-2022 University of Dundee. All rights reserved.
*
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -160,18 +160,6 @@ public static ExperimenterData getUserDetails()
LookupNames.CURRENT_USER_DETAILS);
}

/**
* Returns how deep to scan when a folder is selected.
*
* @return See above.
*/
public static int getScanningDepth()
{
Integer value = (Integer) registry.lookup("/options/ScanningDepth");
if (value == null || value.intValue() < 0) return 1;
return value.intValue();
}

/**
* Returns the available user groups.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*------------------------------------------------------------------------------
* Copyright (C) 2006-2021 University of Dundee. All rights reserved.
* Copyright (C) 2006-2022 University of Dundee. All rights reserved.
*
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -214,6 +214,9 @@ public class ImportDialog extends ClosableTabbedPaneComponent
/** Text for metadata pane */
private static final String TEXT_METADATA_DEFAULTS = "Metadata Defaults";

/** Text for metadata pane */
private static final String TEXT_ADVANCED = "Advanced options";

/** Text for naming panel */
private static final String TEXT_DIRECTORIES_BEFORE_FILE =
"Directories before File";
Expand Down Expand Up @@ -328,6 +331,9 @@ public class ImportDialog extends ClosableTabbedPaneComponent
/** Text field indicating how many folders to include. */
private NumericalTextField numberOfFolders;

/** Text field indicating Bioformats search depth */
private NumericalTextField depth;

/** Button to bring up the tags wizard. */
private JButton tagButton;

Expand Down Expand Up @@ -671,6 +677,13 @@ public void actionPerformed(ActionEvent e) {
tagsMap = new LinkedHashMap<JButton, TagAnnotationData>();
mapAnnotation=new LinkedHashMap<String,List<MapAnnotationData>>();

depth = new NumericalTextField();
depth.setMinimum(1);
depth.setText(System.getProperty("omero.import.depth", "50"));
depth.setColumns(4);
depth.setToolTipText("Maximum depth Bioformats uses for looking for importable files");
depth.addPropertyChangeListener(this);

IconManager icons = IconManager.getInstance();

refreshFilesButton = new JButton(TEXT_REFRESH_FILES);
Expand Down Expand Up @@ -970,6 +983,15 @@ private JPanel buildPixelSizeComponent() {
return UIUtilities.buildComponentPanel(p);
}

private JPanel buildAdvancedComponent() {
JPanel p = new JPanel();
JLabel l = new JLabel();
l.setText("Depth: ");
p.add(l);
p.add(depth);
return UIUtilities.buildComponentPanel(p);
}

/**
* Builds and lays out the components displaying the naming options.
*
Expand Down Expand Up @@ -1068,9 +1090,14 @@ private JComponent buildOptionsPane() {
c.gridy = 2;
options.add(buildPane(TEXT_METADATA_DEFAULTS, buildPixelSizeComponent()), c);

// Constraints for meta data component
c.gridx = 0;
c.gridy = 3;
options.add(buildPane(TEXT_ADVANCED, buildAdvancedComponent()), c);

// Fills in bottom space of GridBagLayout
c.gridx = 0;
c.gridy = 3;
c.gridy = 4;
c.weighty = 1;
options.add(new JLabel(" "), c);

Expand Down Expand Up @@ -1219,7 +1246,6 @@ public void importFiles() {
object.setMapAnnotation(mapAnnotation);
}

object.setScanningDepth(ImporterAgent.getScanningDepth());
Boolean loadThumbnails = (Boolean) ImporterAgent.getRegistry()
.lookup(LOAD_THUMBNAIL);
if (loadThumbnails != null)
Expand All @@ -1241,6 +1267,8 @@ public void importFiles() {
object.setTags(l);
}

object.setDepth((Integer) depth.getValueAsNumber());

if (partialName.isSelected()) {
Integer number = (Integer) numberOfFolders.getValueAsNumber();
if (number != null && number >= 0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*------------------------------------------------------------------------------
* Copyright (C) 2006-2021 University of Dundee. All rights reserved.
* Copyright (C) 2006-2022 University of Dundee. All rights reserved.
*
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -5874,6 +5874,7 @@ Object importImageFile(SecurityContext ctx, ImportableObject object,
* @param ctx The security context.
* @param object Host information about the file to import.
* @param file The file to import.
* @param status The status tracking object.
* @return See above.
* @throws ImportException If an error occurred while importing.
*/
Expand All @@ -5895,7 +5896,7 @@ ImportCandidates getImportCandidates(SecurityContext ctx,
reader = new OMEROWrapper(config);
String[] paths = new String[1];
paths[0] = file.getAbsolutePath();
ImportCandidates icans = new ImportCandidates(reader, paths, status);
ImportCandidates icans = new ImportCandidates(object.getDepth(), reader, paths, status);

for(ImportContainer ic : icans.getContainers()) {
if(object.isOverrideName()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*------------------------------------------------------------------------------
* Copyright (C) 2006-2018 University of Dundee. All rights reserved.
* Copyright (C) 2006-2022 University of Dundee. All rights reserved.
*
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -212,14 +212,6 @@ private int getNumberOfRenderingEngines(SecurityContext ctx, long pixelsID)

/**
* Imports the specified candidates.
*
* @param ctx The security context.
* @param status The original status.
* @param object The object hosting information about the import.
* @param list The list of annotations.
* @param userID The identifier of the user.
* @param hcs Value returns by the import containers.
* @param userName The login name of the user to import for.
*/
private Object importCandidates(SecurityContext ctx,
Map<File, Status> files, Status status,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*------------------------------------------------------------------------------
* Copyright (C) 2006-2018 University of Dundee. All rights reserved.
* Copyright (C) 2006-2022 University of Dundee. All rights reserved.
*
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -190,9 +190,6 @@ public static boolean isArbitraryFile(File f)
/** The depth when the name is overridden. */
private int depthForName;

/** The depth used when scanning a folder. */
private int scanningDepth;

/**
* Flag indicating to override the name set by B-F when importing the data.
*/
Expand Down Expand Up @@ -225,6 +222,9 @@ public static boolean isArbitraryFile(File f)
/** Map of skip options mapping to ImportConfig functions */
private Map<String, Object> skipChoices;

/** The depth Bioformats uses to find the importable files */
private int depth = Integer.valueOf(System.getProperty("omero.import.depth", "4"));

/**
* Returns the object corresponding to the passed file.
*
Expand Down Expand Up @@ -355,24 +355,7 @@ public void setMapAnnotation(Map<String,List<MapAnnotationData>> map)
{
this.mapAnnots=getCloneOfMap(map);
}


/**
* Sets the depth used scanning a folder.
*
* @param scanningDepth The value to set.
*/
public void setScanningDepth(int scanningDepth)
{
this.scanningDepth = scanningDepth;
}

/**
* Returns the depth used scanning a folder.
*
* @return See above.
*/
public int getScanningDepth() { return scanningDepth; }

/**
* Sets the depth used when the name is overridden.
Expand Down Expand Up @@ -764,4 +747,19 @@ public boolean skipThumbnails() {
return option != null && !option;
}

/**
* Get the depth Bioformats uses to find the importable files
* @return See above
*/
public int getDepth() {
return depth;
}

/**
* Set the depth Bioformats uses to find the importable files
* @param depth The depth
*/
public void setDepth(int depth) {
this.depth = depth;
}
}

0 comments on commit fa43992

Please sign in to comment.