import org.simantics.scl.runtime.reporting.SCLReporting;
import org.simantics.scl.runtime.reporting.SCLReportingHandler;
import org.simantics.scl.runtime.tuple.Tuple0;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import gnu.trove.map.hash.THashMap;
import gnu.trove.procedure.TObjectProcedure;
public class CommandSession {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CommandSession.class);
+
ModuleRepository moduleRepository;
SCLReportingHandler defaultHandler;
}
}
} catch(RuntimeException e) {
- e.printStackTrace();
+ LOGGER.error("updateRuntimeEnvironment(clearErrorsFlags={}) failed", clearErrorsFlags, e);
throw e;
}
valueToStringConverter = new ValueToStringConverter(runtimeEnvironment);
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.simantics.scl.compiler.commands.CommandSession;
console.getSession().setImportEntries(entries);
}
+ AtomicReference<ArrayList<CommandSessionImportEntry>> assignedImports = new AtomicReference<>();
+
+ private class SetImportsJob extends Job {
+
+ public SetImportsJob() {
+ super(Messages.SCLConsoleView_SetImports);
+ setUser(true);
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ ArrayList<CommandSessionImportEntry> entries = assignedImports.getAndSet(null);
+ if (entries != null)
+ setCurrentImports(entries);
+ return Status.OK_STATUS;
+ } finally {
+ monitor.done();
+ }
+ }
+
+ @Override
+ public boolean shouldSchedule() {
+ return PlatformUI.isWorkbenchRunning();
+ }
+
+ @Override
+ public boolean shouldRun() {
+ return PlatformUI.isWorkbenchRunning();
+ }
+
+ }
+
+ SetImportsJob setImportsJob = new SetImportsJob();
+
+ private void scheduleSetCurrentImports(ArrayList<CommandSessionImportEntry> entries) {
+ boolean scheduled = assignedImports.getAndSet(entries) != null;
+ if (!scheduled)
+ setImportsJob.schedule();
+ }
+
private void manageImports() {
ManageImportsDialog dialog = new ManageImportsDialog(
getSite().getShell(),
getCurrentImports());
if(dialog.open() == Dialog.OK) {
writeImportPreferences(dialog.getImports());
- setCurrentImports(dialog.getImports());
+ scheduleSetCurrentImports(dialog.getImports());
}
}
toolBarManager.update(true);
setRefreshAutomatically(store.getBoolean(REFRESH_AUTOMATICALLY), false);
+ addScriptDropSupport(console);
+
// Do this after the actions and SCLConsoleListener are
// registered because it can cause output to the console.
- setCurrentImports(readImportPreferences());
- addScriptDropSupport(console);
+ scheduleSetCurrentImports(readImportPreferences());
}
private class ScriptRunningDropTarget extends DropTargetAdapter {