Skip to content
Snippets Groups Projects
Commit 5351a73d authored by helene ortiz's avatar helene ortiz
Browse files

Class NewFileHelper deleted.

parent f6db8012
No related branches found
No related tags found
No related merge requests found
4.3.4 dd/mm/yyyy
-----
* Class NewFileHelper deleted.
4.3.3 15/02/2024
-----
* Initialise save dialog with scan name while editing an user's script.
......
......@@ -117,20 +117,7 @@ public abstract class CommandWorkspacePeer implements NomadFileNameEntryListener
DialogManager.getInstance().nomadMessageDialog("saveDialogWrongNameMessage", "saveDialogWrongNameTitle");
}
/*
public final String[] getDirectories() {
Set<String> sub = new LinkedHashSet<String>();
Set<String> directories = NewFileHelper.getSubDirectories(CommandWindow.USERS_XBU_DIR + ConfigManager.FILE_SEPARATOR);
for (String directory : directories) {
if (directory.equals(CommandWindow.SHARED_DIR) || directory.equals(ExperimentData.getInstance().getProposalDirectory())) {
sub.add(directory);
}
}
String[] folders = sub.toArray(new String[sub.size()]);
return folders;
}*/
public String[] getDirectories() {
Set<String> sub = new LinkedHashSet<String>();
if (ExperimentData.getInstance().lastUserIsStaff()) {
......
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package fr.ill.ics.tools;
import java.io.File;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.logging.Logger;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import fr.ill.ics.bridge.ResourceManager;
public class NewFileHelper {
private static final Logger LOGGER = Logger.getLogger(NewFileHelper.class.getName());
public static Set<String> getSubDirectories(String directoryName) {
Set<String> directories = new HashSet<String>();
try {
String jsonString = ResourceManager.getInstance().getTree(directoryName, "", true);
JSONParser parser = new JSONParser();
Object obj = parser.parse(jsonString);
JSONObject jsonObject = (JSONObject)obj;
if (!jsonObject.isEmpty()) {
String name = (String)jsonObject.get(ResourceManager.NAME);
name = name.substring(name.lastIndexOf("/")+1);
// children
JSONArray children = (JSONArray)jsonObject.get(ResourceManager.CHILDREN);
Iterator<JSONObject> iterator = children.iterator();
while (iterator.hasNext()) {
JSONObject child = iterator.next();
name = (String)child.get(ResourceManager.NAME);
if (name != null && new File(name).isDirectory()) {
name = name.substring(name.lastIndexOf("/")+1);
directories.add(name);
}
}
}
} catch (ParseException e) {
e.printStackTrace();
}
return directories;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment