问题
i want to open multiple console view with different input text on single swt button click in eclipse rcp application Can anybody tell me about this ? Thank you.
回答1:
Add org.eclipse.ui.console as dependency and after that you can create different extensions.
Some more details about the implementation you can find on this page http://www.eclipsezone.com/eclipse/forums/t66777.html.
Here a simple implementation (source):
plugin.xml
<plugin>
<extension point="org.eclipse.ui.console.consoleFactories">
<consoleFactory label="ConsoleX" class="console.Factory">
</consoleFactory>
</extension>
</plugin>
class Factory
package console;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.IConsoleFactory;
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.MessageConsole;
public class Factory implements IConsoleFactory {
private static MessageConsole _console;
public void openConsole() {
MessageConsole console = getConsole();
if (console != null) {
IConsoleManager manager =
ConsolePlugin.getDefault().getConsoleManager();
IConsole[] existing = manager.getConsoles();
boolean exists = false;
for (int i = 0; i < existing.length; i++) {
if(console == existing[i])
exists = true;
}
if(! exists)
manager.addConsoles(new IConsole[] {console});
manager.showConsoleView(console);
}
}
public static MessageConsole getConsole() {
if (_console == null) {
_console = new MessageConsole("ConsoleX",null);
}
return _console;
}
}
Usage
Factory.getConsole().activate();
Factory.getConsole().newOutputStream().write("Hello world.".getBytes());
来源:https://stackoverflow.com/questions/10580516/how-to-open-multiple-consoleview-with-different-input-text