org.eclipse.ui.console.IOConsole Java Examples

The following examples show how to use org.eclipse.ui.console.IOConsole. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CodewindConsoleFactory.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private static void onNewConsole(IOConsole console) {
	IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();

	// See if a console exists matching this one and remove it if it does,
	// so that we don't have multiple of the same console (they would be identical anyway)
	IConsole[] existingMCConsoles = consoleManager.getConsoles();
	for (IConsole existingConsole : existingMCConsoles) {
		if (existingConsole.getName().equals(console.getName())) {
			consoleManager.removeConsoles(new IConsole[] { existingConsole } );
			break;
		}
	}
		
	Logger.log(String.format("Creating new application console: %s of type %s", 				//$NON-NLS-1$
			console.getName(), console.getClass().getSimpleName()));

	consoleManager.addConsoles(new IConsole[] { console });
}
 
Example #2
Source File: ConsoleFactory.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * Fins the console with a given name
 * @param name, name of the console
 * @return
 */
private static IOConsole findConsole(String name)
{
    if (name == null)
    {
        throw new IllegalArgumentException("Console name must be not null");
    }
    IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();

    IConsole[] existing = consoleManager.getConsoles();
    // try to find existing
    for (int i = 0; i < existing.length; i++)
    {
        if (name.equals(existing[i].getName()))
        {
            return (IOConsole) existing[i];
        }
    }

    // no console found, create a new one
    IOConsole myConsole = new IOConsole(name, null);
    consoleManager.addConsoles(new IConsole[] { myConsole });
    return myConsole;
}
 
Example #3
Source File: PyOpenLastConsoleHyperlink.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@SuppressWarnings("restriction")
private void processIOConsole(IOConsole ioConsole) {
    IDocument document = ioConsole.getDocument();
    try {
        Position[] positions = document.getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY);
        Arrays.sort(positions, new Comparator<Position>() {

            @Override
            public int compare(Position o1, Position o2) {
                return Integer.compare(o1.getOffset(), o2.getOffset());
            }
        });
        if (positions.length > 0) {
            Position p = positions[positions.length - 1];
            if (p instanceof ConsoleHyperlinkPosition) {
                ConsoleHyperlinkPosition consoleHyperlinkPosition = (ConsoleHyperlinkPosition) p;
                IHyperlink hyperLink = consoleHyperlinkPosition.getHyperLink();
                hyperLink.linkActivated();
            }
        }
    } catch (BadPositionCategoryException e) {
        Log.log(e);
    }
}
 
Example #4
Source File: ConsoleColorCache.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
private ArrayList<IOConsole> getCurrentRefs() {
    int size = weakrefs.size();
    ArrayList<IOConsole> currentRefs = new ArrayList<IOConsole>(size);
    for (int i = 0; i < size; i++) {
        WeakReference<IOConsole> ref = weakrefs.get(i);
        IOConsole object = ref.get();
        if (object == null) {
            weakrefs.remove(i);
            i--;
            size--;
        } else {
            currentRefs.add(object);
        }
    }
    return currentRefs;
}
 
Example #5
Source File: ConsoleColorCache.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
private void addRef(IOConsole console) {
    synchronized (referencesLock) {
        //We'll clear the current references and add the new one if it's not there already.
        int size = weakrefs.size();
        for (int i = 0; i < size; i++) {
            WeakReference<IOConsole> ref = weakrefs.get(i);
            Object object = ref.get();
            if (object == console) {
                return; //already there (nothing to add).
            }
            if (object == null) {
                weakrefs.remove(i);
                i--;
                size--;
            }
        }
        //Add the new reference.
        weakrefs.add(new WeakReference<IOConsole>(console));
    }
}
 
Example #6
Source File: LocalAppEngineServerLaunchConfigurationDelegate.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
private CloudSdkDebugTarget(ILaunch launch, LocalAppEngineServerBehaviour serverBehaviour,
    IOConsole console) {
  super(null);
  this.launch = launch;
  this.serverBehaviour = serverBehaviour;
  server = serverBehaviour.getServer();
  this.console = console;
}
 
Example #7
Source File: FormulaConsoleAction.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private IOConsole findOrCreateConsole(String name) {
	ConsolePlugin plugin = ConsolePlugin.getDefault();
	IConsoleManager conMan = plugin.getConsoleManager();
	IConsole[] existing = conMan.getConsoles();
	for (int i = 0; i < existing.length; i++)
		if (name.equals(existing[i].getName()))
			return (IOConsole) existing[i];
	IOConsole console = new IOConsole(name, null);
	conMan.addConsoles(new IConsole[] { console });
	return console;
}
 
Example #8
Source File: AbstractDebugTargetWithTransmission.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
protected void addProcessConsole(IOConsole c) {
    // What we'd like to do is not put in the input stream the contents we received
    // in the console UNLESS we're waiting for input (but unfortunately, it seems there's
    // no API for that).
    //
    // This means that if the user writes something (to do an evaluation) and later
    // does a raw_input('say something:\n'), the raw_input will get the contents that
    // the user wrote for the evaluation and not the contents it'd write now.
    // As we now have a separate input console, this shouldn't be so troublesome, as
    // we control things better when the user writes to the PromptOverlay console, but
    // if he writes to the other console, things may misbehave.
}
 
Example #9
Source File: PyOpenLastConsoleHyperlink.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void run(IAction action) {
    for (IConsoleView c : ScriptConsole.iterConsoles()) {
        IConsole console = c.getConsole();
        if (console instanceof IOConsole) {
            IOConsole ioConsole = (IOConsole) console;
            processIOConsole(ioConsole);
            break;
        }
    }
}
 
Example #10
Source File: ConsoleColorCache.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void preferenceChange(PreferenceChangeEvent event) {
    String key = event.getKey();
    if ("org.eclipse.debug.ui.consoleBackground".equals(key) || "org.eclipse.debug.ui.outColor".equals(key)
            || "org.eclipse.debug.ui.errorColor".equals(key)) {
        synchronized (referencesLock) {
            ArrayList<IOConsole> currentRefs = getCurrentRefs();
            for (IOConsole console : currentRefs) {
                updateConsole(console);
            }
        }
    }
}
 
Example #11
Source File: RuntimeConsoleUtil.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
public static void clearConsole() {
    ConsolePlugin plugin = ConsolePlugin.getDefault();
    IConsoleManager conMan = plugin.getConsoleManager();
    IConsole[] existing = conMan.getConsoles();
    for (int i = 0; i < existing.length; i++) {
        if (KARAF_CONSOLE.equals(existing[i].getName())) {
            ((IOConsole) existing[i]).destroy();
            conMan.removeConsoles(new IConsole[] { existing[i] });
        }
    }
}
 
Example #12
Source File: RuntimeConsoleUtil.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
public static IOConsole findConsole() {
    ConsolePlugin plugin = ConsolePlugin.getDefault();
    IConsoleManager conMan = plugin.getConsoleManager();
    IConsole[] existing = conMan.getConsoles();
    for (int i = 0; i < existing.length; i++) {
        if (KARAF_CONSOLE.equals(existing[i].getName()))
            return (IOConsole) existing[i];
    }
    // no console found, so create a new one
    IOConsole myConsole = new IOConsole(KARAF_CONSOLE, null);
    conMan.addConsoles(new IConsole[] { myConsole });
    return myConsole;
}
 
Example #13
Source File: CommandExecutionUtils.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void consume(InputStream outputStream)
{
	IOConsole messageConsole = getMessageConsole(consoleName);
	messageConsole.activate();
	MessageConsoleWriter messageConsoleWriter = new MessageConsoleWriter(messageConsole, outputStream, isStdErr);
	new Thread(messageConsoleWriter).start();
}
 
Example #14
Source File: ConsoleView.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void ownCreatePartControl(final Composite parent) {
	msgConsole = new IOConsole("GAMA Console", null);
	setCharacterLimit(GamaPreferences.Interface.CORE_CONSOLE_SIZE.getValue());
	GamaPreferences.Interface.CORE_CONSOLE_SIZE.onChange(newValue -> setCharacterLimit(newValue));
	viewer = new IOConsoleViewer(parent, msgConsole);
	viewer.setWordWrap(GamaPreferences.Interface.CORE_CONSOLE_WRAP.getValue());
}
 
Example #15
Source File: StatechartLaunchShortcut.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected void showConsole() {
	IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
	IConsole[] consoles = consoleManager.getConsoles();
	for (IConsole iConsole : consoles) {
		if (TYPE.equals(iConsole.getType())) {
			if (iConsole instanceof IOConsole) {
				((IOConsole) iConsole).activate();
				consoleManager.showConsoleView(iConsole);
			}
		}
	}
}
 
Example #16
Source File: TLCProcessJob.java    From tlaplus with MIT License 5 votes vote down vote up
private static BufferedReader getConsoleReader() {
	final IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
	final List<IConsole> tlcConsole = Arrays.asList(consoleManager.getConsoles()).stream()
			.filter(c -> "TLC-Console".equals(c.getName())).collect(Collectors.toList());
	if (!tlcConsole.isEmpty()) {
		final IConsole iConsole = tlcConsole.get(0);
		if (iConsole instanceof IOConsole) {
			IOConsoleInputStream inputStream = ((IOConsole) iConsole).getInputStream();
			return new BufferedReader(new InputStreamReader(inputStream));
		}
	}
	return null;
}
 
Example #17
Source File: CommandExecutionUtils.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
private MessageConsoleWriter(IOConsole messageConsole, InputStream from, boolean isStdErr)
{
	this.messageConsole = messageConsole;
	this.from = from;
	this.isStdErr = isStdErr;
}
 
Example #18
Source File: CommandExecutionUtils.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public InputStream getInputStream()
{
	IOConsole messageConsole = getMessageConsole(consoleName);
	messageConsole.activate();
	return messageConsole.getInputStream();
}
 
Example #19
Source File: LogViewer.java    From LogViewer with Eclipse Public License 2.0 4 votes vote down vote up
public IOConsole getConsole() {
    if (console == null)
        createConsole();
    return console;
}
 
Example #20
Source File: FormulaConsoleAction.java    From olca-app with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void run() {
	IOConsole console = findOrCreateConsole(M.FormulaInterpreter);
	ConsoleJob job = new ConsoleJob(console);
	job.schedule();
}
 
Example #21
Source File: ConsoleFactory.java    From tlaplus with MIT License 4 votes vote down vote up
public static IOConsole getTLCConsole()
{
	IOConsole console = findConsole(TLC_ID);

    return console;
}
 
Example #22
Source File: FormulaConsoleAction.java    From olca-app with Mozilla Public License 2.0 4 votes vote down vote up
public ConsoleJob(IOConsole console) {
	super(M.FormulaInterpreter);
	this.console = console;
}
 
Example #23
Source File: ConsoleColorCache.java    From Pydev with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * In this method we'll make sure a console will have its colors properly updated.
 * 
 * @param console This is the console to keep updated. 
 * 
 * The console should have a getAttribute("themeConsoleStreamToColor") which returns a Map<IOConsoleOutputStream, String>
 * where the values may be: 
 * 
 * "console.output" or "console.error"
 */
public void keepConsoleColorsSynched(IOConsole console) {
    updateConsole(console);
    addRef(console);
}