package org.simantics.modeling.ui.actions; import org.simantics.Simantics; import org.simantics.db.Resource; import org.simantics.db.common.request.PossibleIndexRoot; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.adapter.ActionFactory; import org.simantics.modeling.ui.ModelingUIUtils; import org.simantics.utils.ui.ErrorLogger; /** * @author Antti Villberg */ public class NewSCLQuery implements ActionFactory { @Override public Runnable create(Object target) { if(!(target instanceof Resource)) return null; final Resource parent = (Resource)target; return new Runnable() { @Override public void run() { try { Resource indexRoot = Simantics.getSession().syncRequest(new PossibleIndexRoot(parent)); if(indexRoot == null) return; Simantics.getSession().markUndoPoint(); ModelingUIUtils.newSCLQuery(parent, indexRoot); } catch (DatabaseException e) { ErrorLogger.defaultLogError(e); } } }; } }