1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-05 07:15:39 +02:00

new build console line cap

This commit is contained in:
David Inglis 2002-11-27 19:54:40 +00:00
parent 339d480d39
commit f28b06a289
11 changed files with 242 additions and 135 deletions

View file

@ -1,3 +1,18 @@
2002-11-27 David Inglis
* plugin.properties:
* plugin.xml:
* src/.../internal/ui/BuildConsoleManager.java:
* src/.../internal/ui/ConsoleEvent.java:
* src/.../internal/ui/buildconsole/BuildConsoleView.java:
* src/.../internal/ui/cview/CView.java:
* src/.../ui/preferences/BuildConsolePreferencePage.java:
* src/.../internal/ui/preferences/CPluginPreferencePage.java:
* src/.../ui/CUIPlugin.java:
* src/.../ui/IBuildConsoleEvent.java:
refactored CPluginPreferencePage into a BuildConsolePreferencePage.
added a configurable cap on the number of lines to keep in the build console.
2002-11-27 David Inglis 2002-11-27 David Inglis
* utils.ui/.../controls/ControlFactory.java: * utils.ui/.../controls/ControlFactory.java:
removed unsed hyperlink stuff since it was leaking Cursors. removed unsed hyperlink stuff since it was leaking Cursors.

View file

@ -46,6 +46,7 @@ CEditor.name=C Editor
CPluginPreferencePage.name=C/C++ CPluginPreferencePage.name=C/C++
CPluginEditorPreferencePage.name=C/C++ Editor CPluginEditorPreferencePage.name=C/C++ Editor
CPluginTemplatePreferencePage.name=Code Templates CPluginTemplatePreferencePage.name=Code Templates
CPluginBuildConsolePreferencePage.name=Build Console
CProjectPropertyPage.name=C/C++ Project CProjectPropertyPage.name=C/C++ Project
CLaunchingPropertyPage.executionArguments.name=C Execution Arguments CLaunchingPropertyPage.executionArguments.name=C Execution Arguments
CApplicationLauncher.label=Executable CApplicationLauncher.label=Executable

View file

@ -29,9 +29,9 @@
<extension-point id="CCompletionContributor" name="%completionContributorName"/> <extension-point id="CCompletionContributor" name="%completionContributorName"/>
<extension-point id="CElementFilters" name="%elementFiltersName"/> <extension-point id="CElementFilters" name="%elementFiltersName"/>
<!-- =========================================================================== --> <!-- =========================================================================== -->
<!-- Extension Implementation: must implement org.eclipse.jface.text.ITextHover -->
<!-- Purpose: Provide a perspective specific text hovering for CEditor files -->
<!-- Extension point: org.eclipse.cdt.ui.textHovers --> <!-- Extension point: org.eclipse.cdt.ui.textHovers -->
<!-- Purpose: Provide a perspective specific text hovering for CEditor files -->
<!-- Extension Implementation: must implement org.eclipse.jface.text.ITextHover -->
<!-- =========================================================================== --> <!-- =========================================================================== -->
<extension-point id="textHovers" name="%textHoversName"/> <extension-point id="textHovers" name="%textHoversName"/>
@ -139,8 +139,8 @@
id="org.eclipse.cdt.ui.MakeView"> id="org.eclipse.cdt.ui.MakeView">
</view> </view>
</extension> </extension>
<!-- The wizards -->
<!-- For C Wizards --> <!-- For C Wizards -->
<!-- The wizards -->
<extension <extension
point="org.eclipse.ui.newWizards"> point="org.eclipse.ui.newWizards">
<category <category
@ -249,6 +249,12 @@
class="org.eclipse.cdt.internal.ui.preferences.TemplatePreferencePage" class="org.eclipse.cdt.internal.ui.preferences.TemplatePreferencePage"
id="org.eclipse.cdt.ui.preferences.TemplatePreferencePage"> id="org.eclipse.cdt.ui.preferences.TemplatePreferencePage">
</page> </page>
<page
name="%CPluginBuildConsolePreferencePage.name"
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
class="org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage"
id="org.eclipse.cdt.ui.preferneces.CBuildConsolePreferernces">
</page>
</extension> </extension>
<extension <extension
point="org.eclipse.ui.propertyPages"> point="org.eclipse.ui.propertyPages">

View file

@ -5,12 +5,14 @@
package org.eclipse.cdt.internal.ui; package org.eclipse.cdt.internal.ui;
import java.io.IOException; import java.io.IOException;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import org.eclipse.cdt.core.ConsoleOutputStream; import org.eclipse.cdt.core.ConsoleOutputStream;
import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage; import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage;
import org.eclipse.cdt.ui.*; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.IBuildConsoleListener; import org.eclipse.cdt.ui.IBuildConsoleListener;
import org.eclipse.cdt.ui.IBuildConsoleManager; import org.eclipse.cdt.ui.IBuildConsoleManager;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -20,7 +22,9 @@ import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document; import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.ListenerList; import org.eclipse.jface.util.ListenerList;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IViewPart; import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPage;
@ -28,26 +32,67 @@ import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException; import org.eclipse.ui.PartInitException;
public class BuildConsoleManager implements IBuildConsoleManager, IResourceChangeListener { public class BuildConsoleManager implements IBuildConsoleManager, IResourceChangeListener, IPropertyChangeListener {
private HashMap fConsoleDocumentMap; private HashMap fConsoleDocumentMap;
ListenerList listeners = new ListenerList(1); ListenerList listeners = new ListenerList(1);
private class BuildConsoleDocument extends Document {
private int fMaxLines;
public BuildConsoleDocument(int nLines) {
super();
fMaxLines = nLines;
}
public void setDocumentSize(int nLines) {
fMaxLines = nLines;
nLines = getNumberOfLines();
if (nLines > fMaxLines) {
try {
int start = getLineOffset(nLines - fMaxLines);
String part = get(start, getLength() - start);
set(part);
} catch (BadLocationException e) {
}
}
}
public BuildConsoleDocument(String initialContent) {
super(initialContent);
}
public void replace(int offset, int length, String text) throws BadLocationException {
super.replace(offset, length, text);
int nLines = getNumberOfLines();
if (nLines > fMaxLines) {
int start = getLineOffset(nLines - fMaxLines);
String part = get(start, getLength() - start);
set(part);
}
}
}
private class BuildConsole extends ConsoleOutputStream implements IConsole { private class BuildConsole extends ConsoleOutputStream implements IConsole {
protected IDocument fDocument; private BuildConsoleDocument fDocument;
public BuildConsole() { public BuildConsole() {
fDocument = new Document(); fDocument = new BuildConsoleDocument(BuildConsolePreferencePage.buildConsoleLines());
}
public void setConsoleSize(int nLines) {
fDocument.setDocumentSize(nLines);
} }
public void start(IProject project) { public void start(IProject project) {
if (CPluginPreferencePage.isClearBuildConsole() ) { if (BuildConsolePreferencePage.isClearBuildConsole()) {
clear(); clear();
} }
Object[] list = listeners.getListeners(); Object[] list = listeners.getListeners();
if (list.length > 0) { if (list.length > 0) {
for (int i = 0; i < list.length; i++) { for (int i = 0; i < list.length; i++) {
IBuildConsoleListener listener = (IBuildConsoleListener) list[i]; IBuildConsoleListener listener = (IBuildConsoleListener) list[i];
ConsoleEvent event = new ConsoleEvent(project, ConsoleEvent.CONSOLE_START); ConsoleEvent event = new ConsoleEvent(BuildConsoleManager.this, project, ConsoleEvent.CONSOLE_START);
listener.consoleChange(event); listener.consoleChange(event);
} }
} }
@ -78,13 +123,12 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
if (force || fBuffer.length() > 512) { if (force || fBuffer.length() > 512) {
Display.getDefault().syncExec(new Runnable() { Display.getDefault().syncExec(new Runnable() {
public void run() { public void run() {
if (CPluginPreferencePage.isConsoleOnTop()) if (BuildConsolePreferencePage.isConsoleOnTop())
bringConsoleOnTop(); bringConsoleOnTop();
try { try {
int len = fDocument.getLength(); int len = fDocument.getLength();
fDocument.replace(len, 0, readBuffer()); fDocument.replace(len, 0, readBuffer());
} } catch (BadLocationException x) {
catch (BadLocationException x) {
} }
} }
}); });
@ -101,18 +145,16 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
// show the build console // show the build console
IViewPart cBuild = page.findView(CUIPlugin.CONSOLE_ID); IViewPart cBuild = page.findView(CUIPlugin.CONSOLE_ID);
if (cBuild == null) { if (cBuild == null) {
if (CPluginPreferencePage.isAutoOpenConsole()) { if (BuildConsolePreferencePage.isAutoOpenConsole()) {
IWorkbenchPart activePart = page.getActivePart(); IWorkbenchPart activePart = page.getActivePart();
cBuild = page.showView(CUIPlugin.CONSOLE_ID); cBuild = page.showView(CUIPlugin.CONSOLE_ID);
//restore focus //restore focus
page.activate(activePart); page.activate(activePart);
} }
} } else {
else {
page.bringToTop(cBuild); page.bringToTop(cBuild);
} }
} } catch (PartInitException pie) {
catch (PartInitException pie) {
} }
} }
} }
@ -138,19 +180,29 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
return; return;
} }
IResource resource = event.getResource(); IResource resource = event.getResource();
if ( event.getType() == IResourceChangeEvent.PRE_DELETE ) {
if (resource.getType() == IResource.PROJECT) { if (resource.getType() == IResource.PROJECT) {
if (event.getType() == IResourceChangeEvent.PRE_DELETE || event.getType() == IResourceChangeEvent.PRE_CLOSE) {
fConsoleDocumentMap.remove(resource); fConsoleDocumentMap.remove(resource);
Object[] list = listeners.getListeners();
if (list.length > 0) {
for (int i = 0; i < list.length; i++) {
IBuildConsoleListener listener = (IBuildConsoleListener) list[i];
ConsoleEvent consoleEvent = new ConsoleEvent(this, (IProject) resource, ConsoleEvent.CONSOLE_CLOSE);
listener.consoleChange(consoleEvent);
}
}
} }
} }
} }
public void shutdown() { public void shutdown() {
CUIPlugin.getWorkspace().removeResourceChangeListener(this); CUIPlugin.getWorkspace().removeResourceChangeListener(this);
CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
} }
public void startup() { public void startup() {
CUIPlugin.getWorkspace().addResourceChangeListener(this); CUIPlugin.getWorkspace().addResourceChangeListener(this);
CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
} }
private BuildConsole getBuildConsole(IProject project) { private BuildConsole getBuildConsole(IProject project) {
@ -178,4 +230,15 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang
listeners.remove(listener); listeners.remove(listener);
} }
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty() == BuildConsolePreferencePage.PREF_BUILDCONSOLE_LINES) {
Collection consoles = fConsoleDocumentMap.values();
Iterator iter = consoles.iterator();
while (iter.hasNext()) {
BuildConsole console = (BuildConsole) iter.next();
console.setConsoleSize(BuildConsolePreferencePage.buildConsoleLines());
}
}
}
} }

View file

@ -3,14 +3,17 @@
* All Rights Reserved. * All Rights Reserved.
*/package org.eclipse.cdt.internal.ui; */package org.eclipse.cdt.internal.ui;
import java.util.EventObject;
import org.eclipse.cdt.ui.IBuildConsoleEvent; import org.eclipse.cdt.ui.IBuildConsoleEvent;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
public class ConsoleEvent implements IBuildConsoleEvent { public class ConsoleEvent extends EventObject implements IBuildConsoleEvent {
private IProject fProject; private IProject fProject;
private int fType; private int fType;
public ConsoleEvent(IProject project, int type) { public ConsoleEvent(Object source, IProject project, int type) {
super(source);
fProject = project; fProject = project;
fType = type; fType = type;
} }

View file

@ -8,7 +8,7 @@ package org.eclipse.cdt.internal.ui.buildconsole;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage; import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.IBuildConsoleEvent; import org.eclipse.cdt.ui.IBuildConsoleEvent;
import org.eclipse.cdt.ui.IBuildConsoleListener; import org.eclipse.cdt.ui.IBuildConsoleListener;
@ -70,7 +70,7 @@ public class BuildConsoleView extends ViewPart implements ISelectionListener, IB
fFont = null; fFont = null;
fPropertyChangeListener = new IPropertyChangeListener() { fPropertyChangeListener = new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) { public void propertyChange(PropertyChangeEvent event) {
if (fTextViewer != null && event.getProperty().equals(CPluginPreferencePage.PREF_CONSOLE_FONT)) { if (fTextViewer != null && event.getProperty().equals(BuildConsolePreferencePage.PREF_CONSOLE_FONT)) {
initializeWidgetFont(fTextViewer.getTextWidget()); initializeWidgetFont(fTextViewer.getTextWidget());
} }
} }
@ -157,12 +157,11 @@ public class BuildConsoleView extends ViewPart implements ISelectionListener, IB
protected void initializeWidgetFont(StyledText styledText) { protected void initializeWidgetFont(StyledText styledText) {
IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore(); IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
String prefKey = CPluginPreferencePage.PREF_CONSOLE_FONT; String prefKey = BuildConsolePreferencePage.PREF_CONSOLE_FONT;
FontData data = null; FontData data = null;
if (store.contains(prefKey) && !store.isDefault(prefKey)) { if (store.contains(prefKey) && !store.isDefault(prefKey)) {
data = PreferenceConverter.getFontData(store, prefKey); data = PreferenceConverter.getFontData(store, prefKey);
} } else {
else {
data = PreferenceConverter.getDefaultFontData(store, prefKey); data = PreferenceConverter.getDefaultFontData(store, prefKey);
} }
if (data != null) { if (data != null) {
@ -173,8 +172,7 @@ public class BuildConsoleView extends ViewPart implements ISelectionListener, IB
fFont.dispose(); fFont.dispose();
fFont = font; fFont = font;
} } else {
else {
// if all the preferences failed // if all the preferences failed
styledText.setFont(JFaceResources.getTextFont()); styledText.setFont(JFaceResources.getTextFont());
} }
@ -255,8 +253,7 @@ public class BuildConsoleView extends ViewPart implements ISelectionListener, IB
public void selectionChanged(IWorkbenchPart part, ISelection selection) { public void selectionChanged(IWorkbenchPart part, ISelection selection) {
IProject newProject = convertSelectionToProject(selection); IProject newProject = convertSelectionToProject(selection);
IProject oldProject = getProject(); IProject oldProject = getProject();
if (oldProject == null || if (oldProject == null || (newProject != null && !newProject.equals(oldProject))) {
(newProject != null && !newProject.equals(oldProject))) {
setProject(newProject); setProject(newProject);
setDocument(); setDocument();
setTitle(); setTitle();
@ -264,9 +261,12 @@ public class BuildConsoleView extends ViewPart implements ISelectionListener, IB
} }
public void consoleChange(IBuildConsoleEvent event) { public void consoleChange(IBuildConsoleEvent event) {
if ( event.getType() == IBuildConsoleEvent.CONSOLE_START ) { if (event.getType() == IBuildConsoleEvent.CONSOLE_START || event.getType() == IBuildConsoleEvent.CONSOLE_CLOSE) {
Display display = fTextViewer.getControl().getDisplay(); Display display = fTextViewer.getControl().getDisplay();
selProject = event.getProject(); selProject = event.getProject();
if (event.getType() == IBuildConsoleEvent.CONSOLE_CLOSE && selProject != event.getProject()) {
return;
}
display.asyncExec(new Runnable() { display.asyncExec(new Runnable() {
public void run() { public void run() {
setDocument(); setDocument();

View file

@ -1012,7 +1012,7 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
boolean refreshViewer= false; boolean refreshViewer= false;
if (event.getProperty() == CPluginPreferencePage.SHOW_CU_CHILDREN) { if (event.getProperty() == CPluginPreferencePage.PREF_SHOW_CU_CHILDREN) {
boolean showCUChildren= CPluginPreferencePage.showCompilationUnitChildren(); boolean showCUChildren= CPluginPreferencePage.showCompilationUnitChildren();
((CContentProvider)viewer.getContentProvider()).setProvideMembers(showCUChildren); ((CContentProvider)viewer.getContentProvider()).setProvideMembers(showCUChildren);
refreshViewer= true; refreshViewer= true;

View file

@ -0,0 +1,96 @@
/*
* (c) Copyright QNX Software System Ltd. 2002.
* All Rights Reserved.
*/
package org.eclipse.cdt.internal.ui.preferences;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.FontFieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
public class BuildConsolePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
public static final String PREF_CONSOLE_FONT = "consoleFont";
private static final String PREF_CLEAR_CONSOLE = "clearConsole";
private static final String PREF_CONSOLE_ON_TOP = "consoleOnTop";
private static final String PREF_AUTO_OPEN_CONSOLE = "autoOpenConsole";
public static final String PREF_BUILDCONSOLE_LINES = "buildConsoleLines";
private static final String CLEAR_CONSOLE_LABEL= "CBasePreferencePage.clearConsole.label";
private static final String CONSOLE_ON_TOP_LABEL= "CBasePreferencePage.consoleOnTop.label";
private static final String AUTO_OPEN_CONSOLE_LABEL= "CBasePreferencePage.autoOpenConsole.label";
private static final String CONSOLE_FONT_LABEL= "CBasePreferencePage.consoleFont.label";
public BuildConsolePreferencePage() {
super(GRID);
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
}
protected void createFieldEditors() {
Composite parent = getFieldEditorParent();
BooleanFieldEditor clearConsole =
new BooleanFieldEditor(PREF_CLEAR_CONSOLE, CUIPlugin.getResourceString(CLEAR_CONSOLE_LABEL), parent);
addField(clearConsole);
BooleanFieldEditor autoOpenConsole =
new BooleanFieldEditor(PREF_AUTO_OPEN_CONSOLE, CUIPlugin.getResourceString(AUTO_OPEN_CONSOLE_LABEL), parent);
addField(autoOpenConsole);
BooleanFieldEditor consoleOnTop =
new BooleanFieldEditor(PREF_CONSOLE_ON_TOP, CUIPlugin.getResourceString(CONSOLE_ON_TOP_LABEL), parent);
addField(consoleOnTop);
IntegerFieldEditor buildCount = new IntegerFieldEditor( PREF_BUILDCONSOLE_LINES, "&Build console lines: ", parent );
buildCount.setValidRange( 10, Integer.MAX_VALUE );
addField( buildCount );
addField(new FontFieldEditor(PREF_CONSOLE_FONT, CUIPlugin.getResourceString(CONSOLE_FONT_LABEL), parent));
}
/**
* Returns the current preference setting if the build console should
* be cleared before each build.
*/
public static boolean isClearBuildConsole() {
return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_CLEAR_CONSOLE);
}
public static boolean isAutoOpenConsole() {
return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_AUTO_OPEN_CONSOLE);
}
public static boolean isConsoleOnTop() {
return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_CONSOLE_ON_TOP);
}
public static int buildConsoleLines() {
return CUIPlugin.getDefault().getPreferenceStore().getInt(PREF_BUILDCONSOLE_LINES);
}
public void init(IWorkbench workbench) {
}
public static void initDefaults(IPreferenceStore prefs) {
prefs.setDefault(PREF_CLEAR_CONSOLE, true);
prefs.setDefault(PREF_AUTO_OPEN_CONSOLE, false);
prefs.setDefault(PREF_CONSOLE_ON_TOP, true);
prefs.setDefault(PREF_BUILDCONSOLE_LINES, 100);
Font font = JFaceResources.getTextFont();
if (font != null) {
FontData[] data = font.getFontData();
if (data != null && data.length > 0) {
PreferenceConverter.setDefault(prefs, PREF_CONSOLE_FONT, data[0]);
}
}
}
}

View file

@ -9,12 +9,7 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.FontFieldEditor;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.IWorkbenchPreferencePage;
@ -25,25 +20,11 @@ import org.eclipse.ui.help.WorkbenchHelp;
*/ */
public class CPluginPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { public class CPluginPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
public static final String PREF_CONSOLE_FONT= "consoleFont";
// private static final String PREF_BUILD_LOCATION= "buildLocation";
// private static final String PREF_STOP_ON_ERROR= "stopOnError";
private static final String PREF_CLEAR_CONSOLE= "clearConsole";
private static final String PREF_CONSOLE_ON_TOP= "consoleOnTop";
private static final String PREF_AUTO_OPEN_CONSOLE = "autoOpenConsole";
private static final String PREF_LINK_TO_EDITOR= "linkToEditor"; private static final String PREF_LINK_TO_EDITOR= "linkToEditor";
public static final String SHOW_CU_CHILDREN="CUChildren"; //$NON-NLS-1$ public static final String PREF_SHOW_CU_CHILDREN= "CUChildren"; //$NON-NLS-1$
private static final String PAGE_DESC= "CBasePreferencePage.description";
// private static final String BUILD_LOC_LABEL= "CBasePreferencePage.buildLocation.label";
private static final String CLEAR_CONSOLE_LABEL= "CBasePreferencePage.clearConsole.label";
private static final String CONSOLE_ON_TOP_LABEL= "CBasePreferencePage.consoleOnTop.label";
private static final String AUTO_OPEN_CONSOLE_LABEL= "CBasePreferencePage.autoOpenConsole.label";
private static final String LINK_TO_EDITOR_LABEL= "CBasePreferencePage.linkToEditor.label"; private static final String LINK_TO_EDITOR_LABEL= "CBasePreferencePage.linkToEditor.label";
private static final String SHOW_CU_CHILDREN_LABEL= "CBasePreferencePage.CUChildren.label"; private static final String SHOW_CU_CHILDREN_LABEL= "CBasePreferencePage.CUChildren.label";
//private static final String EDITOR_FONT_LABEL= "CBasePreferencePage.editorFont.label";
private static final String CONSOLE_FONT_LABEL= "CBasePreferencePage.consoleFont.label";
public CPluginPreferencePage() { public CPluginPreferencePage() {
super(GRID); super(GRID);
@ -63,72 +44,24 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
*/ */
protected void createFieldEditors() { protected void createFieldEditors() {
Composite parent= getFieldEditorParent(); Composite parent= getFieldEditorParent();
/*
Label buildText= new Label(parent, SWT.NONE);
GridData gd= new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan= 3;
buildText.setLayoutData(gd);
buildText.setText(CUIPlugin.getResourceString(PAGE_DESC));
FileFieldEditor editor= new FileFieldEditor(PREF_BUILD_LOCATION, CUIPlugin.getResourceString(BUILD_LOC_LABEL), true, parent) {
protected boolean checkState() {
return true;
}
};
addField(editor);
*/
BooleanFieldEditor clearConsole= new BooleanFieldEditor(PREF_CLEAR_CONSOLE, CUIPlugin.getResourceString(CLEAR_CONSOLE_LABEL), parent);
addField(clearConsole);
BooleanFieldEditor autoOpenConsole = new BooleanFieldEditor(PREF_AUTO_OPEN_CONSOLE, CUIPlugin.getResourceString(AUTO_OPEN_CONSOLE_LABEL), parent);
addField(autoOpenConsole);
BooleanFieldEditor consoleOnTop= new BooleanFieldEditor(PREF_CONSOLE_ON_TOP, CUIPlugin.getResourceString(CONSOLE_ON_TOP_LABEL), parent);
addField(consoleOnTop);
BooleanFieldEditor linkEditor= new BooleanFieldEditor(PREF_LINK_TO_EDITOR, CUIPlugin.getResourceString(LINK_TO_EDITOR_LABEL), parent); BooleanFieldEditor linkEditor= new BooleanFieldEditor(PREF_LINK_TO_EDITOR, CUIPlugin.getResourceString(LINK_TO_EDITOR_LABEL), parent);
addField(linkEditor); addField(linkEditor);
BooleanFieldEditor showCUChildrenEditor= new BooleanFieldEditor(SHOW_CU_CHILDREN, CUIPlugin.getResourceString(SHOW_CU_CHILDREN_LABEL), parent); BooleanFieldEditor showCUChildrenEditor= new BooleanFieldEditor(PREF_SHOW_CU_CHILDREN, CUIPlugin.getResourceString(SHOW_CU_CHILDREN_LABEL), parent);
addField(showCUChildrenEditor); addField(showCUChildrenEditor);
addField(new FontFieldEditor(PREF_CONSOLE_FONT, CUIPlugin.getResourceString(CONSOLE_FONT_LABEL), parent));
//addField(new FontFieldEditor(AbstractTextEditor.PREFERENCE_FONT, CUIPlugin.getResourceString(EDITOR_FONT_LABEL), parent));
} }
/**
* Returns the current preference setting if the build console should
* be cleared before each build.
*/
public static boolean isClearBuildConsole() {
return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_CLEAR_CONSOLE);
}
public static boolean isAutoOpenConsole() {
return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_AUTO_OPEN_CONSOLE);
}
public static boolean isConsoleOnTop() {
return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_CONSOLE_ON_TOP);
}
public static boolean isLinkToEditor() { public static boolean isLinkToEditor() {
return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_LINK_TO_EDITOR); return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_LINK_TO_EDITOR);
} }
public static boolean showCompilationUnitChildren() { public static boolean showCompilationUnitChildren() {
return CUIPlugin.getDefault().getPreferenceStore().getBoolean(SHOW_CU_CHILDREN); return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_SHOW_CU_CHILDREN);
} }
/**
* Returns the current preference setting of the build command location.
*/
// public static String getBuildLocation() {
// return CUIPlugin.getDefault().getPreferenceStore().getString(PREF_BUILD_LOCATION);
// }
// public static boolean isStopOnError() {
// return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_STOP_ON_ERROR);
// }
/** /**
* @see IWorkbenchPreferencePage#init * @see IWorkbenchPreferencePage#init
*/ */
@ -139,21 +72,8 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
* Initializes the default values of this page in the preference bundle. * Initializes the default values of this page in the preference bundle.
*/ */
public static void initDefaults(IPreferenceStore prefs) { public static void initDefaults(IPreferenceStore prefs) {
// prefs.setDefault(PREF_BUILD_LOCATION, "make");
// prefs.setDefault(PREF_STOP_ON_ERROR, false);
prefs.setDefault(PREF_CLEAR_CONSOLE, true);
prefs.setDefault(PREF_AUTO_OPEN_CONSOLE, false);
prefs.setDefault(PREF_CONSOLE_ON_TOP, true);
prefs.setDefault(PREF_LINK_TO_EDITOR, true); prefs.setDefault(PREF_LINK_TO_EDITOR, true);
prefs.setDefault(SHOW_CU_CHILDREN, true); prefs.setDefault(PREF_SHOW_CU_CHILDREN, true);
Font font= JFaceResources.getTextFont();
if (font != null) {
FontData[] data= font.getFontData();
if (data != null && data.length > 0) {
//PreferenceConverter.setDefault(prefs, AbstractTextEditor.PREFERENCE_FONT, data[0]);
PreferenceConverter.setDefault(prefs, PREF_CONSOLE_FONT, data[0]);
}
}
} }
} }

View file

@ -18,6 +18,7 @@ import org.eclipse.cdt.internal.ui.ResourceAdapterFactory;
import org.eclipse.cdt.internal.ui.cview.CView; import org.eclipse.cdt.internal.ui.cview.CView;
import org.eclipse.cdt.internal.ui.editor.CDocumentProvider; import org.eclipse.cdt.internal.ui.editor.CDocumentProvider;
import org.eclipse.cdt.internal.ui.editor.asm.AsmTextTools; import org.eclipse.cdt.internal.ui.editor.asm.AsmTextTools;
import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage;
import org.eclipse.cdt.internal.ui.preferences.CEditorPreferencePage; import org.eclipse.cdt.internal.ui.preferences.CEditorPreferencePage;
import org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage; import org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage;
import org.eclipse.cdt.internal.ui.text.CTextTools; import org.eclipse.cdt.internal.ui.text.CTextTools;
@ -228,6 +229,7 @@ public class CUIPlugin extends AbstractUIPlugin {
CPluginPreferencePage.initDefaults(store); CPluginPreferencePage.initDefaults(store);
CEditorPreferencePage.initDefaults(store); CEditorPreferencePage.initDefaults(store);
CView.initDefaults(store); CView.initDefaults(store);
BuildConsolePreferencePage.initDefaults(store);
} }
}); });
} }

View file

@ -8,6 +8,7 @@ import org.eclipse.core.resources.IProject;
public interface IBuildConsoleEvent { public interface IBuildConsoleEvent {
final static int CONSOLE_START = 1; final static int CONSOLE_START = 1;
final static int CONSOLE_CLOSE = 2;
IProject getProject(); IProject getProject();
int getType(); int getType();