org.eclipse.ui.console.TextConsole Java Examples

The following examples show how to use org.eclipse.ui.console.TextConsole. 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: XdsConsolePreferencePage.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
private void doApply() {
	// TODO : these settings should be stored under com.excelsior.xds.ui preference store.
	
    XdsConsoleSettings.setShowOnBuild(cbShowWhenBuild.getSelection());
    XdsConsoleSettings.setClearBeforeBuild(cbClearBeforeBuild.getSelection());
    ColorStreamType.NORMAL.setRgb(csText.getColorValue());
    ColorStreamType.SYSTEM.setRgb(csInfo.getColorValue());
    ColorStreamType.ERROR.setRgb(csError.getColorValue());
    ColorStreamType.XDS_LOG_ERROR.setRgb(csCompError.getColorValue());
    ColorStreamType.XDS_LOG_WARNING.setRgb(csCompWarning.getColorValue());
    ColorStreamType.USER_INPUT.setRgb(csUserInput.getColorValue());
    ColorStreamType.BACKGROUND.setRgb(csBackground.getColorValue());
    // Force background change:
    for (IConsole con : ConsolePlugin.getDefault().getConsoleManager().getConsoles()) {
        if (con instanceof TextConsole) {
            ((TextConsole) con).setBackground(new Color(Display.getDefault(), csBackground.getColorValue()));
        }
    }
    
    WorkspacePreferencesManager.getInstance().flush();
}
 
Example #2
Source File: LogContent.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private void openJavaSource(String url) {
  TextConsole console = getLaunchConsole();
  if (console != null) {
    new DevModeStackTraceHyperlink(url, console).linkActivated();
  } else {
    MessageDialog.openInformation(getShell(), "GWT Eclipse Plugin",
        "Could not find Java source context.");
  }
}
 
Example #3
Source File: LogContent.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Find the TextConsole associated with the launch. This is required by the
 * {@link JavaStackTraceHyperlink} class (which we subclass).
 */
private TextConsole getLaunchConsole() {
  LaunchConfiguration launchConfiguration = null;
  T entity = log.getEntity();

  if (entity instanceof BrowserTab) {
    BrowserTab browserTab = (BrowserTab) entity;
    launchConfiguration = browserTab.getLaunchConfiguration();
  } else if (entity instanceof LaunchConfiguration) {
    launchConfiguration = (LaunchConfiguration) entity;
  }

  if (launchConfiguration != null) {
    IProcess[] processes = launchConfiguration.getLaunch().getProcesses();
    if (processes.length > 0) {
      /*
       * Just get the console for the first process. If there are multiple
       * processes, they will all link back to the same ILaunch (which is what
       * JavaStackTraceHyperlink uses the console for anyway).
       */
      IConsole console = DebugUITools.getConsole(processes[0]);
      if (console instanceof TextConsole) {
        return (TextConsole) console;
      }
    }
  }

  return null;
}
 
Example #4
Source File: LogContent.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public DevModeStackTraceHyperlink(String url, TextConsole console) {
  super(console);
  assert (url.startsWith(JAVA_SOURCE_URL_PREFIX));
  url = url.substring(JAVA_SOURCE_URL_PREFIX.length());

  try {
    url = URLDecoder.decode(url, "UTF-8");
  } catch (UnsupportedEncodingException e) {
    // Should never happen, but if it did, then presumably encoding failed
    // as well, so ignore
  }
  this.url = url;
}
 
Example #5
Source File: LogViewer.java    From LogViewer with Eclipse Public License 2.0 5 votes vote down vote up
public void clearCurrentLogFile() {
	try {
		LogFileType type = getSelectedTab().getDocument().getFile().getType();
		if (type == LogFileType.LOGFILE_ECLIPSE_CONSOLE) {

			final IConsole con = getSelectedTab().getDocument().getReader().getConsoleTail().getConsole();
			if (con instanceof TextConsole) {
				Display.getDefault().syncExec(new Runnable() {
					public void run() {
						((TextConsole) con).clearConsole();
					}
				});
			} else {
				logger.logWarning("Console" + "[ " + con.getName() + " ]" + " clear not supported");//$NON-NLS-1$
			}
		} else {
			FileTail file = getSelectedTab().getDocument().getReader().getFileTail();
			Buffer buffer = file.getBuffer();
			if (buffer != null) {
				file.stopFileMapping(buffer);
			}
			PrintWriter pw = new PrintWriter(getCurrentLogFilePath());
			pw.write(" ");
			pw.close();
		}
	} catch (Exception e) {
		logger.logError("unable to clear selected file: " + getCurrentLogFilePath()); //$NON-NLS-1$
	}
	refreshCurrentLogFile();
}
 
Example #6
Source File: ConsoleThemePageParticipant.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
public void init(IPageBookViewPage page, IConsole console)
{
	if (console instanceof TextConsole)
	{
		TextConsole textConsole = (TextConsole) console;
		Object themeConsoleStreamToColor = textConsole.getAttribute(THEME_CONSOLE_STREAM_TO_COLOR_ATTRIBUTE);
		if (themeConsoleStreamToColor instanceof Map<?, ?>)
		{
			Map m = (Map) themeConsoleStreamToColor;
			Set<Map.Entry> entrySet = m.entrySet();
			for (Map.Entry entry : entrySet)
			{
				if (!(entry.getKey() instanceof IOConsoleOutputStream) || !(entry.getValue() instanceof String))
				{
					return; // Cannot handle it.
				}
			}
			this.extension = new ConsoleThemer(textConsole, (Map) themeConsoleStreamToColor);
		}
		if (page instanceof TextConsolePage)
		{
			TextConsolePage tcp = (TextConsolePage) page;
			TextViewerThemer themer = new TextViewerThemer(tcp.getViewer());
			themer.apply();
		}
	}
	this.page = page;
}
 
Example #7
Source File: PatternToHyperlinkConverter.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Override
public void matchFound(PatternMatchEvent event) {
  if (event.getSource() instanceof TextConsole) {
    try {
      final TextConsole console = (TextConsole) event.getSource();
      final int start = event.getOffset();
      final int length = event.getLength();
      IHyperlink link = new BrowserSupportBasedHyperlink(console.getDocument().get(start, length));
      console.addHyperlink(link, start, length);
    } catch (BadLocationException e) {
      logger.log(Level.SEVERE, "Cannot create hyperlink", e);
    }
  }
}
 
Example #8
Source File: XdsConsolePage.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
public XdsConsolePage(TextConsole console, IConsoleView view) {
    super(console, view);

    fPropertyChangeListener = new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            String property = event.getProperty();
            if (property.equals(IConsoleConstants.P_CONSOLE_OUTPUT_COMPLETE)) {
                setReadOnly();
            }
        }
    };
    console.addPropertyChangeListener(fPropertyChangeListener);
}
 
Example #9
Source File: XtendFileHyperlink.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
public XtendFileHyperlink(final String fileName, final IWorkbench workbench, final TextConsole console) {
  final int indexOfColon = fileName.indexOf(":");
  if ((indexOfColon != (-1))) {
    this.fileName = fileName.substring(0, indexOfColon);
    this.lineNumber = (Integer.valueOf(fileName.substring((indexOfColon + 1)))).intValue();
  } else {
    this.fileName = fileName;
  }
  this.workbench = workbench;
  this.console = console;
}
 
Example #10
Source File: ConsoleThemer.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Should be called in the UI thread. Usually, there's no way to create this extension from any console, as the
 * ConsoleThemePageParticipant takes care of that for all consoles (provided they are properly configured).
 * 
 * @see com.aptana.theme.extensions.ConsoleThemePageParticipant
 * @param textConsole
 *            console with the streams.
 * @param themeConsoleStreamToColor
 *            a map with the stream to the related color name (one of the CONSOLE_XXX constants in this class).
 */
public ConsoleThemer(TextConsole textConsole, Map themeConsoleStreamToColor)
{
	this.fConsole = textConsole;
	this.fThemeConsoleStreamToColor = themeConsoleStreamToColor;

	this.listenForThemeChanges();

	// apply theme
	this.applyTheme();
}
 
Example #11
Source File: PathMatcher.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public void connect(TextConsole console) {
 fConsole = console;
}
 
Example #12
Source File: IOConsoleViewer.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
public IOConsoleViewer(Composite parent, TextConsole console) {
	super(parent, console);
}
 
Example #13
Source File: CppStyleConsolePatternMatchListener.java    From CppStyle with MIT License 4 votes vote down vote up
@Override
public void connect(TextConsole console) {
	pattern = Pattern.compile(patternMsg);
}
 
Example #14
Source File: PydevConsole.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Overridden to get the line trackers that'll add hyperlinks to the console.
 */
@Override
public List<IConsoleLineTracker> createLineTrackers(final TextConsole console) {
    return staticCreateLineTrackers(console);
}
 
Example #15
Source File: ToolsConsolePage.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
public ToolsConsolePage(TextConsole console, IConsoleView view) {
	super(console, view);
	
	setReadOnly();
}
 
Example #16
Source File: ToolsConsolePage.java    From goclipse with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected TextConsoleViewer createViewer(Composite parent) {
	return new IOConsoleViewer(parent, (TextConsole)getConsole());
}
 
Example #17
Source File: N4JSExceptionConsoleTracker.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void connect(TextConsole textConsole) {
	this.console = textConsole;
}
 
Example #18
Source File: ConsoleHyperlinking.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void connect(final TextConsole console) {
  this.console = console;
}
 
Example #19
Source File: XdsConsoleViewer.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
public XdsConsoleViewer(Composite parent, TextConsole console) {
    super(parent, console);
    StyledText styledText = getTextWidget();
    styledText.setDoubleClickEnabled(false);
    styledText.addListener(SWT.MouseDoubleClick, mouseDoubleClickListener);
}
 
Example #20
Source File: XdsConsolePage.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
protected TextConsoleViewer createViewer(Composite parent) {
    return new XdsConsoleViewer(parent, (TextConsole)getConsole());
}
 
Example #21
Source File: PatternToHyperlinkConverter.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
@Override
public void connect(TextConsole console) {
}
 
Example #22
Source File: ErrorLineMatcher.java    From corrosion with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void connect(TextConsole console) {
	this.console = console;
}
 
Example #23
Source File: N4JSStackTraceHyperlink.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Needs to be called directly after construction.
 */
public void setTextConsole(TextConsole console) {
	this.console = console;
}
 
Example #24
Source File: N4JSExceptionConsoleTracker.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Returns the console, only available after connecting a console via {@link #connect(TextConsole)}.
 */
protected TextConsole getConsole() {
	return console;
}
 
Example #25
Source File: ScriptConsole.java    From Pydev with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * @return a list of trackers that'll identify links in the console passed.
 */
public abstract List<IConsoleLineTracker> createLineTrackers(final TextConsole console);
 
Example #26
Source File: N4JSStackTraceHyperlink.java    From n4js with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Returns the console this link is contained in.
 *
 * @return console
 */
protected TextConsole getConsole() {
	return console;
}