diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index 9ea9ba56c8f..eb1df2c5889 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -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 * utils.ui/.../controls/ControlFactory.java: removed unsed hyperlink stuff since it was leaking Cursors. diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties index 58df87b4397..74eb069a19e 100644 --- a/core/org.eclipse.cdt.ui/plugin.properties +++ b/core/org.eclipse.cdt.ui/plugin.properties @@ -46,6 +46,7 @@ CEditor.name=C Editor CPluginPreferencePage.name=C/C++ CPluginEditorPreferencePage.name=C/C++ Editor CPluginTemplatePreferencePage.name=Code Templates +CPluginBuildConsolePreferencePage.name=Build Console CProjectPropertyPage.name=C/C++ Project CLaunchingPropertyPage.executionArguments.name=C Execution Arguments CApplicationLauncher.label=Executable diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index da27a6e776f..8c383548e08 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -29,9 +29,9 @@ - - + + @@ -139,8 +139,8 @@ id="org.eclipse.cdt.ui.MakeView"> - + + + diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsoleManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsoleManager.java index 984ce06f60e..6dd48cbbd0f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsoleManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsoleManager.java @@ -5,12 +5,14 @@ package org.eclipse.cdt.internal.ui; import java.io.IOException; +import java.util.Collection; import java.util.HashMap; +import java.util.Iterator; import org.eclipse.cdt.core.ConsoleOutputStream; import org.eclipse.cdt.core.resources.IConsole; -import org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage; -import org.eclipse.cdt.ui.*; +import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage; +import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.IBuildConsoleListener; import org.eclipse.cdt.ui.IBuildConsoleManager; 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.Document; import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.ListenerList; +import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPage; @@ -28,26 +32,67 @@ import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; -public class BuildConsoleManager implements IBuildConsoleManager, IResourceChangeListener { +public class BuildConsoleManager implements IBuildConsoleManager, IResourceChangeListener, IPropertyChangeListener { private HashMap fConsoleDocumentMap; 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 { - protected IDocument fDocument; + private BuildConsoleDocument fDocument; public BuildConsole() { - fDocument = new Document(); + fDocument = new BuildConsoleDocument(BuildConsolePreferencePage.buildConsoleLines()); + } + + public void setConsoleSize(int nLines) { + fDocument.setDocumentSize(nLines); } public void start(IProject project) { - if (CPluginPreferencePage.isClearBuildConsole() ) { + if (BuildConsolePreferencePage.isClearBuildConsole()) { clear(); } - Object[] list = listeners.getListeners(); - if ( list .length > 0 ) { - for ( int i = 0; i < list.length; i++ ) { - IBuildConsoleListener listener = (IBuildConsoleListener)list[i]; - ConsoleEvent event = new ConsoleEvent(project, ConsoleEvent.CONSOLE_START); + Object[] list = listeners.getListeners(); + if (list.length > 0) { + for (int i = 0; i < list.length; i++) { + IBuildConsoleListener listener = (IBuildConsoleListener) list[i]; + ConsoleEvent event = new ConsoleEvent(BuildConsoleManager.this, project, ConsoleEvent.CONSOLE_START); listener.consoleChange(event); } } @@ -73,18 +118,17 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang public void flush() throws IOException { flush(false); } - + public void flush(boolean force) throws IOException { - if ( force || fBuffer.length() > 512) { + if (force || fBuffer.length() > 512) { Display.getDefault().syncExec(new Runnable() { public void run() { - if (CPluginPreferencePage.isConsoleOnTop()) + if (BuildConsolePreferencePage.isConsoleOnTop()) bringConsoleOnTop(); try { int len = fDocument.getLength(); 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 IViewPart cBuild = page.findView(CUIPlugin.CONSOLE_ID); if (cBuild == null) { - if (CPluginPreferencePage.isAutoOpenConsole()) { + if (BuildConsolePreferencePage.isAutoOpenConsole()) { IWorkbenchPart activePart = page.getActivePart(); cBuild = page.showView(CUIPlugin.CONSOLE_ID); //restore focus page.activate(activePart); } - } - else { + } else { page.bringToTop(cBuild); } - } - catch (PartInitException pie) { + } catch (PartInitException pie) { } } } @@ -122,7 +164,7 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang } } - + public BuildConsoleManager() { fConsoleDocumentMap = new HashMap(); } @@ -134,23 +176,33 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent) */ public void resourceChanged(IResourceChangeEvent event) { - if ( fConsoleDocumentMap == null ) { + if (fConsoleDocumentMap == null) { return; } 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); + 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() { CUIPlugin.getWorkspace().removeResourceChangeListener(this); + CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this); } - + public void startup() { CUIPlugin.getWorkspace().addResourceChangeListener(this); + CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); } private BuildConsole getBuildConsole(IProject project) { @@ -178,4 +230,15 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang 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()); + } + } + } + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ConsoleEvent.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ConsoleEvent.java index 5cf322da782..14ab2d7b580 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ConsoleEvent.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ConsoleEvent.java @@ -3,14 +3,17 @@ * All Rights Reserved. */package org.eclipse.cdt.internal.ui; +import java.util.EventObject; + import org.eclipse.cdt.ui.IBuildConsoleEvent; import org.eclipse.core.resources.IProject; -public class ConsoleEvent implements IBuildConsoleEvent { +public class ConsoleEvent extends EventObject implements IBuildConsoleEvent { private IProject fProject; private int fType; - public ConsoleEvent(IProject project, int type) { + public ConsoleEvent(Object source, IProject project, int type) { + super(source); fProject = project; fType = type; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleView.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleView.java index 22a4bd3a473..7ca4f61eefd 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleView.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleView.java @@ -8,7 +8,7 @@ package org.eclipse.cdt.internal.ui.buildconsole; import java.util.ResourceBundle; 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.IBuildConsoleEvent; import org.eclipse.cdt.ui.IBuildConsoleListener; @@ -70,7 +70,7 @@ public class BuildConsoleView extends ViewPart implements ISelectionListener, IB fFont = null; fPropertyChangeListener = new IPropertyChangeListener() { 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()); } } @@ -137,10 +137,10 @@ public class BuildConsoleView extends ViewPart implements ISelectionListener, IB protected IProject getProject() { return selProject; } - + protected IDocument setDocument() { IProject project = getProject(); - if (project != null ) { + if (project != null) { fTextViewer.setDocument(fConsoleManager.getConsoleDocument(project)); } return null; @@ -149,20 +149,19 @@ public class BuildConsoleView extends ViewPart implements ISelectionListener, IB protected void setTitle() { String title = origTitle; IProject project = getProject(); - if (project != null ) { + if (project != null) { title += " [" + project.getName() + "]"; } setTitle(title); } - + protected void initializeWidgetFont(StyledText styledText) { IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore(); - String prefKey = CPluginPreferencePage.PREF_CONSOLE_FONT; + String prefKey = BuildConsolePreferencePage.PREF_CONSOLE_FONT; FontData data = null; if (store.contains(prefKey) && !store.isDefault(prefKey)) { data = PreferenceConverter.getFontData(store, prefKey); - } - else { + } else { data = PreferenceConverter.getDefaultFontData(store, prefKey); } if (data != null) { @@ -173,8 +172,7 @@ public class BuildConsoleView extends ViewPart implements ISelectionListener, IB fFont.dispose(); fFont = font; - } - else { + } else { // if all the preferences failed styledText.setFont(JFaceResources.getTextFont()); } @@ -247,16 +245,15 @@ public class BuildConsoleView extends ViewPart implements ISelectionListener, IB if (fFont != null) { fFont.dispose(); fFont = null; - } + } getSite().getPage().removeSelectionListener(this); fConsoleManager.removeConsoleListener(this); } - + public void selectionChanged(IWorkbenchPart part, ISelection selection) { IProject newProject = convertSelectionToProject(selection); IProject oldProject = getProject(); - if (oldProject == null || - (newProject != null && !newProject.equals(oldProject))) { + if (oldProject == null || (newProject != null && !newProject.equals(oldProject))) { setProject(newProject); setDocument(); setTitle(); @@ -264,9 +261,12 @@ public class BuildConsoleView extends ViewPart implements ISelectionListener, IB } 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(); selProject = event.getProject(); + if (event.getType() == IBuildConsoleEvent.CONSOLE_CLOSE && selProject != event.getProject()) { + return; + } display.asyncExec(new Runnable() { public void run() { setDocument(); @@ -278,7 +278,7 @@ public class BuildConsoleView extends ViewPart implements ISelectionListener, IB IProject convertSelectionToProject(ISelection selection) { IProject project = null; - if ( selection == null ) { + if (selection == null) { return project; } try { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java index 02cb878d5b0..4e519b3f3ec 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java @@ -1012,7 +1012,7 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge boolean refreshViewer= false; - if (event.getProperty() == CPluginPreferencePage.SHOW_CU_CHILDREN) { + if (event.getProperty() == CPluginPreferencePage.PREF_SHOW_CU_CHILDREN) { boolean showCUChildren= CPluginPreferencePage.showCompilationUnitChildren(); ((CContentProvider)viewer.getContentProvider()).setProvideMembers(showCUChildren); refreshViewer= true; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java new file mode 100644 index 00000000000..d3143eff4b3 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java @@ -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]); + } + } + + } + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java index ae05ea09a2a..f92edb71d9c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java @@ -9,12 +9,7 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds; 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.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; @@ -25,25 +20,11 @@ import org.eclipse.ui.help.WorkbenchHelp; */ 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"; - public static final String 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"; + public static final String PREF_SHOW_CU_CHILDREN= "CUChildren"; //$NON-NLS-1$ + 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 EDITOR_FONT_LABEL= "CBasePreferencePage.editorFont.label"; - private static final String CONSOLE_FONT_LABEL= "CBasePreferencePage.consoleFont.label"; public CPluginPreferencePage() { super(GRID); @@ -63,72 +44,24 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements */ protected void createFieldEditors() { 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); 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(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() { return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_LINK_TO_EDITOR); } 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 */ @@ -139,21 +72,8 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements * Initializes the default values of this page in the preference bundle. */ 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(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]); - } - } + prefs.setDefault(PREF_SHOW_CU_CHILDREN, true); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java index 8272bf0a756..338876d30aa 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java @@ -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.editor.CDocumentProvider; 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.CPluginPreferencePage; import org.eclipse.cdt.internal.ui.text.CTextTools; @@ -228,6 +229,7 @@ public class CUIPlugin extends AbstractUIPlugin { CPluginPreferencePage.initDefaults(store); CEditorPreferencePage.initDefaults(store); CView.initDefaults(store); + BuildConsolePreferencePage.initDefaults(store); } }); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleEvent.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleEvent.java index 6e5d9b4b574..b889084fea2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleEvent.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleEvent.java @@ -8,6 +8,7 @@ import org.eclipse.core.resources.IProject; public interface IBuildConsoleEvent { final static int CONSOLE_START = 1; + final static int CONSOLE_CLOSE = 2; IProject getProject(); int getType();