import org.simantics.scl.ui.Activator;
import org.simantics.scl.ui.assist.SCLContentProposalProvider;
import org.simantics.scl.ui.assist.StyledTextContentAdapter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import gnu.trove.set.hash.THashSet;
* @author Hannu Niemistö
*/
public class SCLConsole extends AbstractCommandConsole {
+
+ /**
+ * Use this option mask to exclude {@link SCLConsoleListener}s contributed as
+ * OSGi services from listening to this console.
+ */
+ public static final int EXCLUDE_CONTRIBUTED_LISTENERS = 1 << 10;
+
public static final String JOB_NAME = "org.simantics.scl.console.job";
public static final long TERMINATE_GRACE_PERIOD = 1000L;
CommandSession session = new CommandSession(SCLOsgi.MODULE_REPOSITORY, handler);
ContentProposalAdapter contentProposalAdapter;
-
+
public SCLConsole(Composite parent, int style) {
- super(parent, style);
-
+ this(parent, style, 0);
+ }
+
+ public SCLConsole(Composite parent, int style, int options) {
+ super(parent, style, options);
+ createContentProposalAdapter();
+ if (!hasOption(EXCLUDE_CONTRIBUTED_LISTENERS))
+ addContributedListeners();
+ }
+
+ protected void createContentProposalAdapter() {
+ if (input == null)
+ return;
+
StyledTextContentAdapter styledTextContentAdapter = new StyledTextContentAdapter();
SCLContentProposalProvider contentProvider = new SCLContentProposalProvider(session);
-
try {
contentProposalAdapter = new ContentProposalAdapter(
input,
} catch (ParseException e) {
// No content assist then.
}
-
- addContributedListeners();
}
@Override
protected boolean canExecuteCommand() {
- return !contentProposalAdapter.isProposalPopupOpen();
+ return contentProposalAdapter == null || !contentProposalAdapter.isProposalPopupOpen();
}
-
+
@Override
public ErrorAnnotation[] validate(String command) {
if(command.isEmpty())
public CommandSession getSession() {
return session;
}
+
+ public SCLReportingHandler getHandler() {
+ return handler;
+ }
+
public void interruptCurrentCommands() {
synchronized(currentJobs) {
for(Job job : currentJobs)
consoleIsEmpty = true;
}
- private void addContributedListeners() {
+ protected void addContributedListeners() {
final BundleContext context = Activator.getInstance().getBundle().getBundleContext();
new ServiceTracker<SCLConsoleListener, SCLConsoleListener>(context,
SCLConsoleListener.class, null) {
}
}.open();
}
+
+ @Override
+ public Logger getLogger() {
+ return LoggerFactory.getLogger(getClass());
+ }
+
}