// }
// }
final ArrayList descriptors=new ArrayList();
Session session=SessionFactory.getInstance().getSession(false);
Job job=(Job)SessionFactory.callNoEx(session,"getLoadProjectDescriptorsJob",new Class[]{boolean.class,java.util.List.class,boolean.class},new Object[]{true,descriptors,true});
job.addSwingRunnable(new JobRunnable("Local: add"){ //$NON-NLS-1$
public Object run() throws Exception{
Closure setter=new Closure(){
public void execute(Object obj){
}
};
Closure getter=new Closure(){
public void execute(Object obj){
final Object[] r=(Object[])obj;
if (r!=null){
final DocumentData data=(DocumentData)r[0];
if (data.isMaster())
return;
insertSubproject(project, data.getUniqueId(), true);
// Project openedAlready = ProjectFactory.getInstance().findFromId(data.getUniqueId());
//
// if (!project.canInsertProject(data.getUniqueId())) {
// Alert.error("The selected project is already a subproject in this consolidated project.");
// return;
// }
// if (openedAlready != null && openedAlready.isOpenedAsSubproject()) {
// Alert.error("The selected project is already opened as a subproject in another consolidated project.");
// return;
// }
// Subproject subprojectTask = new Subproject(project,data.getUniqueId());
// Node subprojectNode = getCurrentFrame().addNodeForImpl(subprojectTask,NodeModel.EVENT);
// ProjectFactory.getInstance().openSubproject(project, subprojectNode, true);
}
}
};
try {
OpenProjectDialog dlg = OpenProjectDialog.getInstance(getFrame(),descriptors,Messages.getString("Text.insertProject"),false, false, project); //$NON-NLS-1$
dlg.execute(setter,getter);
} catch (Exception e) {
Alert.error(Messages.getString("Message.serverUnreachable"),getContainer()); //$NON-NLS-1$
//TODO need more precise exception
e.printStackTrace();
} finally {
doingOpenDialog = false;
}
return null;
}
});
session.schedule(job);
}