Skip to content

Commit

Permalink
Merge pull request #2 from jburel/fs-lite-merge
Browse files Browse the repository at this point in the history
Fs lite merge
  • Loading branch information
Colin Blackburn committed Sep 27, 2012
2 parents 3968f37 + 7af4aff commit e06cdf3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
Expand All @@ -51,14 +48,12 @@
import info.clearthought.layout.TableLayout;

//Application-internal dependencies
import org.openmicroscopy.shoola.agents.fsimporter.ImporterAgent;
import org.openmicroscopy.shoola.agents.fsimporter.view.Importer;
import org.openmicroscopy.shoola.agents.util.browser.DataNode;
import org.openmicroscopy.shoola.env.data.model.ImportableFile;
import org.openmicroscopy.shoola.util.ui.IconManager;
import org.openmicroscopy.shoola.util.ui.MultilineHeaderSelectionRenderer;
import org.openmicroscopy.shoola.util.ui.TooltipTableHeader;
import org.openmicroscopy.shoola.util.ui.UIUtilities;
import pojos.DatasetData;
import pojos.GroupData;

Expand Down Expand Up @@ -117,10 +112,7 @@ class FileSelectionTable
* as a dataset.
*/
static final int FOLDER_AS_CONTAINER_INDEX = 4;

/** The index of the column indicating to archive the file. */
private static final int ARCHIVED_INDEX = 5;


/** The columns of the table. */
private static final Vector<String> COLUMNS;

Expand All @@ -133,18 +125,9 @@ class FileSelectionTable
/** The tool-tip of the columns. */
private static final String[] COLUMNS_NO_GROUP_TOOLTIP;

/** String used to retrieve if the value of the archived flag. */
private static final String ARCHIVED = "/options/Archived";

/** String used to retrieve if the archived option is displayed. */
private static final String ARCHIVED_AVAILABLE = "/options/ArchivedTunable";

/** The text displayed to use the folder as container. */
private static final String FAD_TEXT = "Folder as\nDataset";

/** Indicate to archive or not the files. */
private static final String ARCHIVED_TEXT = "Archive";

/** Indicate to select the files. */
private static final String FILE_TEXT = "File or\nFolder";

Expand All @@ -162,14 +145,13 @@ class FileSelectionTable
private static final String GROUP_TEXT = "Group";

static {
int n = 6;
int n = 5;
COLUMNS = new Vector<String>(n);
COLUMNS.add(FILE_TEXT);
COLUMNS.add(SIZE_TEXT);
COLUMNS.add(CONTAINER_PROJECT_TEXT);
COLUMNS.add(GROUP_TEXT);
COLUMNS.add(FAD_TEXT);
COLUMNS.add(ARCHIVED_TEXT);
COLUMNS_TOOLTIP = new String[n];
COLUMNS_TOOLTIP[FILE_INDEX] = "File or Folder to import.";
COLUMNS_TOOLTIP[SIZE_INDEX] = "Size of File or Folder.";
Expand All @@ -178,23 +160,19 @@ class FileSelectionTable
COLUMNS_TOOLTIP[GROUP_INDEX] = "The group where to import data.";
COLUMNS_TOOLTIP[FOLDER_AS_CONTAINER_INDEX] =
"Convert the folder as dataset.";
COLUMNS_TOOLTIP[ARCHIVED_INDEX] = "Archive the data.";

COLUMNS_NO_GROUP = new Vector<String>(n-1);
COLUMNS_NO_GROUP.add(FILE_TEXT);
COLUMNS_NO_GROUP.add(SIZE_TEXT);
COLUMNS_NO_GROUP.add(CONTAINER_PROJECT_TEXT);
COLUMNS_NO_GROUP.add(FAD_TEXT);
COLUMNS_NO_GROUP.add(ARCHIVED_TEXT);
COLUMNS_NO_GROUP_TOOLTIP = new String[n-1];
COLUMNS_NO_GROUP_TOOLTIP[FILE_INDEX] = COLUMNS_TOOLTIP[FILE_INDEX];
COLUMNS_NO_GROUP_TOOLTIP[SIZE_INDEX] = COLUMNS_TOOLTIP[SIZE_INDEX];
COLUMNS_NO_GROUP_TOOLTIP[CONTAINER_INDEX] =
COLUMNS_TOOLTIP[CONTAINER_INDEX];
COLUMNS_NO_GROUP_TOOLTIP[FOLDER_AS_CONTAINER_INDEX-1] =
COLUMNS_TOOLTIP[FOLDER_AS_CONTAINER_INDEX];
COLUMNS_NO_GROUP_TOOLTIP[ARCHIVED_INDEX-1] =
COLUMNS_TOOLTIP[ARCHIVED_INDEX];
}

/** The button to move an item from the remaining items to current items. */
Expand All @@ -212,15 +190,6 @@ class FileSelectionTable
/** Reference to the model. */
private ImportDialog model;

/** The default value of the archived file. */
private boolean archived;

/** The default value of the archived file. */
private boolean archivedTunable;

/** Indicates to archive the files. */
private JCheckBox archivedBox;

/** The key listener added to the queue. */
private KeyAdapter keyListener;

Expand All @@ -246,20 +215,12 @@ private void formatTableModel()
tc.setCellEditor(table.getDefaultEditor(Boolean.class));
tc.setCellRenderer(table.getDefaultRenderer(Boolean.class));
tc.setResizable(false);
tc = tcm.getColumn(ARCHIVED_INDEX);
tc.setCellEditor(table.getDefaultEditor(Boolean.class));
tc.setCellRenderer(table.getDefaultRenderer(Boolean.class));
tc.setResizable(false);
tips = COLUMNS_TOOLTIP;
} else {
tc = tcm.getColumn(FOLDER_AS_CONTAINER_INDEX-1);
tc.setCellEditor(table.getDefaultEditor(Boolean.class));
tc.setCellRenderer(table.getDefaultRenderer(Boolean.class));
tc.setResizable(false);
tc = tcm.getColumn(ARCHIVED_INDEX-1);
tc.setCellEditor(table.getDefaultEditor(Boolean.class));
tc.setCellRenderer(table.getDefaultRenderer(Boolean.class));
tc.setResizable(false);
tips = COLUMNS_NO_GROUP_TOOLTIP;
}

Expand All @@ -278,11 +239,7 @@ private void formatTableModel()
tc.setHeaderRenderer(new MultilineHeaderSelectionRenderer());
tc = tcm.getColumn(FOLDER_AS_CONTAINER_INDEX);
tc.setHeaderRenderer(new MultilineHeaderSelectionRenderer());
tcm.getColumn(ARCHIVED_INDEX).setHeaderRenderer(
new MultilineHeaderSelectionRenderer(table, archivedBox));
} else {
tcm.getColumn(ARCHIVED_INDEX-1).setHeaderRenderer(
new MultilineHeaderSelectionRenderer(table, archivedBox));
tc = tcm.getColumn(FOLDER_AS_CONTAINER_INDEX-1);
tc.setHeaderRenderer(new MultilineHeaderSelectionRenderer());
}
Expand Down Expand Up @@ -311,10 +268,6 @@ private void initComponents()
removeButton.addActionListener(this);
removeAllButton.setActionCommand(""+REMOVE_ALL);
removeAllButton.addActionListener(this);
Boolean b = (Boolean) ImporterAgent.getRegistry().lookup(ARCHIVED);
if (b != null) archived = b.booleanValue();
b = (Boolean) ImporterAgent.getRegistry().lookup(ARCHIVED_AVAILABLE);
if (b != null) archivedTunable = b.booleanValue();
if (model.isSingleGroup()) selectedColumns = COLUMNS_NO_GROUP;
else selectedColumns = COLUMNS;

Expand All @@ -335,20 +288,6 @@ public void keyPressed(KeyEvent e)
}
};
table.addKeyListener(keyListener);

archivedBox = new JCheckBox();
archivedBox.setBackground(UIUtilities.BACKGROUND);
archivedBox.setSelected(archived);
archivedBox.setEnabled(archivedTunable);
if (archivedTunable) {
archivedBox.addChangeListener(new ChangeListener() {

public void stateChanged(ChangeEvent e) {
markFileToArchive(archivedBox.isSelected());
}
});
}

formatTableModel();
}

Expand Down Expand Up @@ -495,17 +434,13 @@ List<ImportableFile> getFilesToImport()
file = element.getFile();
dataset = dne.getLocation();
if (single) {
b = Boolean.valueOf((Boolean) dtm.getValueAt(i,
b = Boolean.valueOf((Boolean) dtm.getValueAt(i,
FOLDER_AS_CONTAINER_INDEX-1));
importable = new ImportableFile(file,
Boolean.valueOf((Boolean) dtm.getValueAt(i,
ARCHIVED_INDEX-1)), b);
importable = new ImportableFile(file, b);
} else {
b = Boolean.valueOf((Boolean) dtm.getValueAt(i,
b = Boolean.valueOf((Boolean) dtm.getValueAt(i,
FOLDER_AS_CONTAINER_INDEX));
importable = new ImportableFile(file,
Boolean.valueOf((Boolean) dtm.getValueAt(i,
ARCHIVED_INDEX)), b);
importable = new ImportableFile(file, b);
}

if (b) dataset = null;
Expand Down Expand Up @@ -584,7 +519,6 @@ void addFiles(List<File> files, boolean fad, GroupData group)
node.setParent(model.getParentImportLocation());
String value = null;
boolean v = false;
boolean a = archivedBox.isSelected();
long gID = group.getId();
while (i.hasNext()) {
f = i.next();
Expand All @@ -597,7 +531,6 @@ void addFiles(List<File> files, boolean fad, GroupData group)
value = f.getName();
v = fad;
if (model.getType() == Importer.SCREEN_TYPE) {
a = false;
value = null;
}
} else {
Expand All @@ -606,19 +539,17 @@ void addFiles(List<File> files, boolean fad, GroupData group)
v = true;
element.setToggleContainer(v);
}
if (model.getType() == Importer.SCREEN_TYPE)
a = false;
}
if (multi) {
dtm.addRow(new Object[] {element,
element.getFileLengthAsString(),
new DataNodeElement(node, value), group.getName(),
Boolean.valueOf(v), Boolean.valueOf(a)});
Boolean.valueOf(v)});
} else {
dtm.addRow(new Object[] {element,
element.getFileLengthAsString(),
new DataNodeElement(node, value),
Boolean.valueOf(v), Boolean.valueOf(a)});
Boolean.valueOf(v)});
}
}
}
Expand Down Expand Up @@ -663,25 +594,6 @@ void markFolderAsDataset(boolean fad)
}
}

/**
* Marks to archive the images.
*
* @param archive Pass <code>true</code> to archive the images,
* <code>false</code> otherwise.
*/
void markFileToArchive(boolean archive)
{
int n = table.getRowCount();
if (n == 0) return;
DefaultTableModel dtm = (DefaultTableModel) table.getModel();
int index = ARCHIVED_INDEX;
if (model.isSingleGroup())
index = index-1;
for (int i = 0; i < n; i++) {
dtm.setValueAt(archive, i, index);
}
}

/** Resets the names of all selected files. */
void resetFilesName()
{
Expand Down Expand Up @@ -760,17 +672,7 @@ public boolean isCellEditable(int row, int column)
case SIZE_INDEX:
return false;
case FOLDER_AS_CONTAINER_INDEX:
if (getColumnCount() ==
COLUMNS_NO_GROUP.size())
return archivedTunable;
if (f.getType() == Importer.SCREEN_TYPE)
return false;
return false;
case ARCHIVED_INDEX: {
if (f.getType() == Importer.SCREEN_TYPE)
return false;
return archivedTunable;
}
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6379,16 +6379,15 @@ ScriptCallback createFigure(SecurityContext ctx, List<Long> objectIDs,
* @param object Information about the file to import.
* @param container The folder to import the image.
* @param name The name to give to the imported image.
* @param archived Pass <code>true</code> if the image has to be archived,
* <code>false</code> otherwise.
* @param Pass <code>true</code> to close the import,
* @param usedFiles The files returned composing the import.
* @param close Pass <code>true</code> to close the import,
* <code>false</code> otherwise.
* @return See above.
* @throws ImportException If an error occurred while importing.
*/
Object importImage(SecurityContext ctx, ImportableObject object,
IObject container, File file, StatusLabel status, boolean archived,
boolean close)
IObject container, File file, StatusLabel status,
String[] usedFiles, boolean close)
throws ImportException
{

Expand All @@ -6399,14 +6398,14 @@ Object importImage(SecurityContext ctx, ImportableObject object,
new OMEROWrapper(new ImportConfig()));
library.addObserver(status);
ImportContainer ic = new ImportContainer(file, -1L, container,
archived, object.getPixelsSize(), null, null, null);
false, object.getPixelsSize(), null, usedFiles, null);
ic.setUseMetadataFile(true);
if (object.isOverrideName()) {
int depth = object.getDepthForName();
ic.setCustomImageName(UIUtilities.getDisplayedFileName(
file.getAbsolutePath(), depth));
}

library.uploadFilesToRepository(ic);
List<Pixels> pixels = library.importImage(ic, 0, 0, 1);
Iterator<Pixels> j;
Pixels p;
Expand Down

0 comments on commit e06cdf3

Please sign in to comment.