From e7c1bd5900472c3dbb18fbe883ce1a7b09815939 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Fri, 21 May 2010 16:01:26 +0000 Subject: [PATCH] bug 306222: Further enhancement of Save Build Console feature Discontinue logging per configuration added in bug 294106 --- .../eclipse/cdt/make/core/MakeBuilder.java | 7 +- .../managedbuilder/core/IConfiguration.java | 32 +-- .../internal/core/CommonBuilder.java | 50 ++-- .../internal/core/Configuration.java | 34 +-- .../internal/core/MultiConfiguration.java | 38 +-- .../ui/tests/util/TestConfiguration.java | 18 -- .../ui/properties/BuilderSettingsTab.java | 155 +----------- .../ui/properties/messages.properties | 4 - .../cdt/internal/core/BuildOutputLogger.java | 224 ------------------ 9 files changed, 41 insertions(+), 521 deletions(-) delete mode 100644 core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/BuildOutputLogger.java diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java index 26da850209c..4479b7cea5f 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java @@ -9,7 +9,8 @@ * QNX Software Systems - Initial API and implementation * Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136) * Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation - * Save build output + * Save build output (bug 294106) + * Andrew Gvozdev (Quoin Inc) - Saving build output implemented in different way (bug 306222) *******************************************************************************/ package org.eclipse.cdt.make.core; @@ -30,7 +31,6 @@ import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.cdt.core.resources.ACBuilder; import org.eclipse.cdt.core.resources.IConsole; -import org.eclipse.cdt.internal.core.BuildOutputLogger; import org.eclipse.cdt.internal.core.ConsoleOutputSniffer; import org.eclipse.cdt.make.internal.core.MakeMessages; import org.eclipse.cdt.make.internal.core.StreamMonitor; @@ -218,8 +218,7 @@ public class MakeBuilder extends ACBuilder { } ErrorParserManager epm = new ErrorParserManager(getProject(), workingDirectoryURI, this, info.getErrorParsers()); epm.setOutputStream(cos); - BuildOutputLogger bol = new BuildOutputLogger(getProject(), epm.getOutputStream()); - StreamMonitor streamMon = new StreamMonitor(new SubProgressMonitor(monitor, 100), bol, last.intValue()); + StreamMonitor streamMon = new StreamMonitor(new SubProgressMonitor(monitor, 100), epm, last.intValue()); OutputStream stdout = streamMon; OutputStream stderr = streamMon; // Sniff console output for scanner info diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java index 598e19f6a81..383f791e652 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java @@ -7,7 +7,8 @@ * * Contributors: * IBM - Initial API and implementation - * Dmitry Kozlov (CodeSourcery) - Save build output preferences + * Dmitry Kozlov (CodeSourcery) - Save build output preferences (bug 294106) + * Andrew Gvozdev (Quoin Inc) - Saving build output implemented in different way (bug 306222) *******************************************************************************/ package org.eclipse.cdt.managedbuilder.core; @@ -631,33 +632,4 @@ public interface IConfiguration extends IBuildObject, IBuildObjectPropertiesCont IBuildPropertyValue getBuildArtefactType(); void setBuildArtefactType(String id) throws BuildException; - - /** - * Set name of file to save build log - * @param fileName full file name where to build log file - * @since 7.0 - */ - public void setBuildLogFilename(String fileName); - - /** - * Get name of file to which build log is saved - * @return full filename where to save build log file - * @since 7.0 - */ - public String getBuildLogFilename(); - - /** - * Set whether to save build log - * @param saveBuildLog whether to save build log - * @since 7.0 - */ - public void setSavingBuildLog(boolean saveBuildLog); - - /** - * Test if build log saving is turned on - * @return true if saving build log is enabled - * @since 7.0 - */ - public boolean isSavingBuildLog(); - } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java index 6dbc329d55b..860ffcd4c42 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java @@ -9,7 +9,8 @@ * Intel Corporation - Initial API and implementation * IBM Corporation * Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation - * Save build output + * Save build output (bug 294106) + * Andrew Gvozdev (Quoin Inc) - Saving build output implemented in different way (bug 306222) *******************************************************************************/ package org.eclipse.cdt.managedbuilder.internal.core; @@ -43,7 +44,6 @@ import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.util.ListComparator; -import org.eclipse.cdt.internal.core.BuildOutputLogger; import org.eclipse.cdt.internal.core.ConsoleOutputSniffer; import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector; @@ -908,7 +908,6 @@ public class CommonBuilder extends ACBuilder { ConsoleOutputStream consoleOutStream = null; IConsole console = null; OutputStream epmOutputStream = null; - BuildOutputLogger bol = null; try { int flags = 0; IResourceDelta delta = getDelta(currentProject); @@ -950,19 +949,10 @@ public class CommonBuilder extends ACBuilder { buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$ } + consoleOutStream.write(buf.toString().getBytes()); + consoleOutStream.flush(); IBuildDescription des = BuildDescriptionManager.createBuildDescription(cfg, cBS, delta, flags); - // Hook up an error parser manager - String[] errorParsers = builder.getErrorParsers(); - ErrorParserManager epm = new ErrorParserManager(currentProject, des.getDefaultBuildDirLocationURI(), this, errorParsers); - epm.setOutputStream(consoleOutStream); - // This variable is necessary to ensure that the EPM stream stay open - // until we explicitly close it. See bug#123302. - epmOutputStream = epm.getOutputStream(); - bol = new BuildOutputLogger(getProject(), epmOutputStream); - - bol.write(buf.toString().getBytes()); - bol.flush(); DescriptionBuilder dBuilder = null; if (!isParallel) @@ -972,13 +962,21 @@ public class CommonBuilder extends ACBuilder { // Remove all markers for this project removeAllMarkers(currentProject); + // Hook up an error parser manager + String[] errorParsers = builder.getErrorParsers(); + ErrorParserManager epm = new ErrorParserManager(currentProject, des.getDefaultBuildDirLocationURI(), this, errorParsers); + epm.setOutputStream(consoleOutStream); + // This variable is necessary to ensure that the EPM stream stay open + // until we explicitly close it. See bug#123302. + epmOutputStream = epm.getOutputStream(); + int status = 0; long t1 = System.currentTimeMillis(); if (isParallel) - status = ParallelBuilder.build(des, null, null, bol, bol, monitor, resumeOnErr, buildIncrementaly); + status = ParallelBuilder.build(des, null, null, epmOutputStream, epmOutputStream, monitor, resumeOnErr, buildIncrementaly); else - status = dBuilder.build(bol, bol, monitor); + status = dBuilder.build(epmOutputStream, epmOutputStream, monitor); long t2 = System.currentTimeMillis(); // Report either the success or failure of our mission @@ -1018,9 +1016,10 @@ public class CommonBuilder extends ACBuilder { } buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$ // Write message on the console - bol.write(buf.toString().getBytes()); - bol.flush(); - + consoleOutStream.write(buf.toString().getBytes()); + consoleOutStream.flush(); + epmOutputStream.close(); + epmOutputStream = null; // Generate any error markers that the build has discovered monitor.subTask(ManagedMakeMessages .getResourceString(MARKERS)); @@ -1030,8 +1029,8 @@ public class CommonBuilder extends ACBuilder { buf = new StringBuffer(); buf.append(ManagedMakeMessages.getFormattedString(NOTHING_BUILT, currentProject.getName())); buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$ - bol.write(buf.toString().getBytes()); - bol.flush(); + consoleOutStream.write(buf.toString().getBytes()); + consoleOutStream.flush(); } } catch (Exception e) { @@ -1052,12 +1051,6 @@ public class CommonBuilder extends ACBuilder { } forgetLastBuiltState(); } finally { - if ( bol != null ) { - try { - bol.close(); - } catch (IOException e) { - } - } if(epmOutputStream != null){ try { epmOutputStream.close(); @@ -1910,8 +1903,7 @@ public class CommonBuilder extends ACBuilder { } ErrorParserManager epm = new ErrorParserManager(currProject, workingDirectoryURI, this, builder.getErrorParsers()); epm.setOutputStream(cos); - BuildOutputLogger bol = new BuildOutputLogger(getProject(), epm.getOutputStream()); - StreamMonitor streamMon = new StreamMonitor(new SubProgressMonitor(monitor, 100), bol, last.intValue()); + StreamMonitor streamMon = new StreamMonitor(new SubProgressMonitor(monitor, 100), epm, last.intValue()); OutputStream stdout = streamMon; OutputStream stderr = streamMon; // Sniff console output for scanner info diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java index ab33b0bd53b..789446b3617 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java @@ -8,7 +8,8 @@ * Contributors: * IBM - Initial API and implementation * James Blackburn (Broadcom Corp.) - * Dmitry Kozlov (CodeSourcery) - Save build output preferences + * Dmitry Kozlov (CodeSourcery) - Save build output preferences (bug 294106) + * Andrew Gvozdev (Quoin Inc) - Saving build output implemented in different way (bug 306222) *******************************************************************************/ package org.eclipse.cdt.managedbuilder.internal.core; @@ -158,8 +159,6 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild private static final String RC_CHANGE_STATE = "rcState"; //$NON-NLS-1$ //resource change state private int resourceChangeState = -1; - private String buildLogFilename = null; - private boolean savingBuildLog = false; //Internal Builder state //NOTE: these are temporary properties @@ -3058,33 +3057,4 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild public boolean isExtensionBuildObject() { return isExtensionElement(); } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IConfiguration#setBuildLogFilename() - */ - public void setBuildLogFilename(String fileName) { - buildLogFilename = fileName; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IConfiguration#getBuildLogFilename() - */ - public String getBuildLogFilename() { - return buildLogFilename; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IConfiguration#setSavingBuildLog() - */ - public void setSavingBuildLog(boolean save) { - savingBuildLog = save; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IConfiguration#isSavingBuildLog() - */ - public boolean isSavingBuildLog() { - return savingBuildLog; - } - } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MultiConfiguration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MultiConfiguration.java index 1632ae16203..b7f697a63b0 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MultiConfiguration.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/MultiConfiguration.java @@ -7,7 +7,8 @@ * * Contributors: * Intel Corporation - Initial API and implementation - * Dmitry Kozlov (CodeSourcery) - Save build output preferences + * Dmitry Kozlov (CodeSourcery) - Save build output preferences (bug 294106) + * Andrew Gvozdev (Quoin Inc) - Saving build output implemented in different way (bug 306222) *******************************************************************************/ package org.eclipse.cdt.managedbuilder.internal.core; @@ -1254,39 +1255,4 @@ public class MultiConfiguration extends MultiItemsHolder implements } return res; } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IConfiguration#setBuildLogFilename() - * Multiconfiguration implementation is not provided - * since the control is disabled in properties in this mode. - */ - public String getBuildLogFilename() { - return ""; //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IConfiguration#isSavingBuildLog() - * Multiconfiguration implementation is not provided - * since the control is disabled in properties in this mode. - */ - public boolean isSavingBuildLog() { - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IConfiguration#setBuildLogFilename() - * Multiconfiguration implementation is not provided - * since the control is disabled in properties in this mode. - */ - public void setBuildLogFilename(String fileName) { - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.build.managed.IConfiguration#setSavingBuildLog() - * Multiconfiguration implementation is not provided - * since the control is disabled in properties in this mode. - */ - public void setSavingBuildLog(boolean saveBuildLog) { - } - } diff --git a/build/org.eclipse.cdt.managedbuilder.ui.tests/src/org/eclipse/cdt/managedbuilder/ui/tests/util/TestConfiguration.java b/build/org.eclipse.cdt.managedbuilder.ui.tests/src/org/eclipse/cdt/managedbuilder/ui/tests/util/TestConfiguration.java index d35334cb7a6..2fe85b99d18 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui.tests/src/org/eclipse/cdt/managedbuilder/ui/tests/util/TestConfiguration.java +++ b/build/org.eclipse.cdt.managedbuilder.ui.tests/src/org/eclipse/cdt/managedbuilder/ui/tests/util/TestConfiguration.java @@ -559,22 +559,4 @@ public class TestConfiguration implements IConfiguration { } - public String getBuildLogFilename() { - // TODO Auto-generated method stub - return null; - } - - public boolean isSavingBuildLog() { - // TODO Auto-generated method stub - return false; - } - - public void setBuildLogFilename(String fileName) { - // TODO Auto-generated method stub - } - - public void setSavingBuildLog(boolean saveBuildLog) { - // TODO Auto-generated method stub - } - } diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuilderSettingsTab.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuilderSettingsTab.java index 9f6a1e1ebff..3aa51032ae4 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuilderSettingsTab.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuilderSettingsTab.java @@ -8,23 +8,18 @@ * Contributors: * Intel Corporation - Initial API and implementation * IBM Corporation - * Dmitry Kozlov (CodeSourcery) - save build output preferences + * Dmitry Kozlov (CodeSourcery) - save build output preferences (bug 294106) + * Andrew Gvozdev (Quoin Inc) - Saving build output implemented in different way (bug 306222) *******************************************************************************/ package org.eclipse.cdt.managedbuilder.ui.properties; -import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; -import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICResourceDescription; -import org.eclipse.cdt.internal.core.BuildOutputLogger; import org.eclipse.cdt.managedbuilder.core.IBuilder; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IMultiConfiguration; -import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.internal.core.Configuration; import org.eclipse.cdt.managedbuilder.internal.core.MultiConfiguration; import org.eclipse.cdt.ui.newui.AbstractCPropertyTab; -import org.eclipse.cdt.ui.newui.CDTPropertyManager; -import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; @@ -37,7 +32,6 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; @@ -63,11 +57,7 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab { private Button b_dirFile; private Button b_dirVars; private Group group_dir; - private Text saveBuildFilename; - private Button saveBuildFileButton; - private Button saveBuildCheckbox; - private Group buildOutputGroup; - + private IBuilder bldr; private IConfiguration icfg; private boolean canModify = true; @@ -89,7 +79,7 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab { public void widgetSelected(SelectionEvent event) { enableInternalBuilder(c_builderType.getSelectionIndex() == 1); updateButtons(); - }}); + }}); b_useDefault = setupCheck(g1, Messages.getString("BuilderSettingsTab.4"), 3, GridData.BEGINNING); //$NON-NLS-1$ @@ -133,46 +123,6 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab { b_dirWsp = setupBottomButton(c, WORKSPACEBUTTON_NAME); b_dirFile = setupBottomButton(c, FILESYSTEMBUTTON_NAME); b_dirVars = setupBottomButton(c, VARIABLESBUTTON_NAME); - - // Save build output group - if ( page.isForProject() ) { - buildOutputGroup = setupGroup(usercomp, - Messages.getString("BuilderSettingsTab.23"), //$NON-NLS-1$ - 3, GridData.FILL_HORIZONTAL); - @SuppressWarnings("unused") - Label l = setupLabel(buildOutputGroup, Messages.getString("BuilderSettingsTab.24"), 1, GridData.BEGINNING); //$NON-NLS-1$ - saveBuildFilename = setupText(buildOutputGroup, 1, GridData.FILL_HORIZONTAL); - saveBuildFilename.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - if ( BuildOutputLogger.canWriteToFile(saveBuildFilename.getText())) { - saveBuildCheckbox.setEnabled(true); - //saveBuildCheckbox.setSelection(true); - } else { - saveBuildCheckbox.setEnabled(false); - saveBuildCheckbox.setSelection(false); - } - icfg.setBuildLogFilename(saveBuildFilename.getText()); - icfg.setSavingBuildLog(saveBuildCheckbox.getSelection()); - }} ); - saveBuildFileButton = new Button(buildOutputGroup, SWT.PUSH); - saveBuildFileButton.setText(Messages.getString("BuilderSettingsTab.25")); //$NON-NLS-1$ - saveBuildFileButton.setData(saveBuildFilename); - saveBuildFileButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - buttonVarPressed(event); - }}); - saveBuildCheckbox = new Button(buildOutputGroup, SWT.CHECK); - saveBuildCheckbox.setText(Messages.getString("BuilderSettingsTab.26")); //$NON-NLS-1$ - saveBuildCheckbox.setEnabled(false); - saveBuildCheckbox.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - if ( ((Control)event.widget) == saveBuildCheckbox ) { - icfg.setSavingBuildLog(!icfg.isSavingBuildLog()); - } - }}); - } } private void setManagedBuild(boolean enable) { @@ -246,30 +196,6 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab { if (external) { // just set relatet text widget state, checkPressed(b_useDefault, false); // do not update } - - if ( page.isForProject() ) { - if ( page.isMultiCfg() ) { - buildOutputGroup.setVisible(false); - } else { - boolean b = icfg.isSavingBuildLog(); - buildOutputGroup.setVisible(true); - String s = icfg.getBuildLogFilename(); - if ( s != null ) { - saveBuildFilename.setText(s); - } else { - saveBuildFilename.setText(""); //$NON-NLS-1$ - } - - if ( s != null && BuildOutputLogger.canWriteToFile(s) ) { - saveBuildCheckbox.setSelection(b); - icfg.setSavingBuildLog(b); - } else { - saveBuildCheckbox.setEnabled(false); - saveBuildCheckbox.setSelection(false); - icfg.setSavingBuildLog(false); - } - } - } canModify = true; } @@ -298,10 +224,10 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab { b.setData(t); // to get know which text is affected t.setData(b); // to get know which button to enable/disable b.addSelectionListener(new SelectionAdapter() { - @Override + @Override public void widgetSelected(SelectionEvent event) { - buttonVarPressed(event); - }}); + buttonVarPressed(event); + }}); if (check != null) check.setData(t); return t; } @@ -320,11 +246,6 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab { } else if (b.equals(b_dirFile)) { x = getFileSystemDirDialog(usercomp.getShell(), EMPTY_STR); if (x != null) ((Text)b.getData()).setText(x); - } else if (b.equals(saveBuildFileButton)) { - FileDialog dialog = new FileDialog(usercomp.getShell(), SWT.SAVE); - dialog.setText(FILESYSTEM_FILE_DIALOG_TITLE); - x = dialog.open(); - if (x != null) ((Text)b.getData()).setText(x); } else { x = AbstractCPropertyTab.getVariableDialog(usercomp.getShell(), getResDesc().getConfiguration()); if (x != null) ((Text)b.getData()).insert(x); @@ -369,8 +290,7 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab { } /** - * get make command - * @return + * @return make command */ private String getMC() { String makeCommand = bldr.getCommand(); @@ -381,67 +301,17 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab { /** * Performs common settings for all controls * (Copy from config to widgets) - * @param cfgd - */ - @Override + @Override public void updateData(ICResourceDescription cfgd) { if (cfgd == null) return; icfg = getCfg(cfgd.getConfiguration()); - if (icfg.getBuildLogFilename() == null) { - // In this case this tab is loaded for the first time, - // and we need to populate configuration with values stored - // in Preferences. This is horrible workaround because we need - // to use this settings in build console which is in cdt ui, - // hence IConfiguration is not accessible there and this values - // have be stored separately. - // That is why we have convention that IConfiguration have - // buildLogFilename set to null this means that it is not loaded. - // Otherwise it is loaded and doesn't require reloading. - // performOk, performApply and performDefaults shouldn't never write - // null values to Preferences to distinct this case from overs. - // - // To properly fix this problem without this workaround we need - // to make IConfiguration accessible for buildconsole package - loadBuildLogSettings(page.getProject(), icfg); - } updateButtons(); } - private static void loadBuildLogSettings(IProject project, IConfiguration icfg) { - BuildOutputLogger.SaveBuildOutputPreferences bp = BuildOutputLogger.readSaveBuildOutputPreferences(project, icfg.getName()); - icfg.setBuildLogFilename(bp.fileName); - icfg.setSavingBuildLog(bp.isSaving); - } - - @Override + @Override public void performApply(ICResourceDescription src, ICResourceDescription dst) { BuildBehaviourTab.apply(src, dst, page.isMultiCfg()); - BuildOutputLogger.SaveBuildOutputPreferences bp = new BuildOutputLogger.SaveBuildOutputPreferences(); - bp.fileName = icfg.getBuildLogFilename(); - bp.isSaving = icfg.isSavingBuildLog(); - BuildOutputLogger.writeSaveBuildOutputPreferences(page.getProject(), icfg.getName(), bp); - } - - @Override - public void performOK() { - if ( page.isForProject() ) { - // Saving for all configurations - ICProjectDescription pd = CDTPropertyManager.getProjectDescription(page.getProject()); - if ( pd != null ) { - ICConfigurationDescription cfgs[] = pd.getConfigurations(); - if ( cfgs != null ) { - for (ICConfigurationDescription cd : cfgs) { - IConfiguration c = ManagedBuildManager.getConfigurationForDescription(cd); - BuildOutputLogger.SaveBuildOutputPreferences bp = new BuildOutputLogger.SaveBuildOutputPreferences(); - bp.fileName = c.getBuildLogFilename(); - bp.isSaving = c.isSavingBuildLog(); - BuildOutputLogger.writeSaveBuildOutputPreferences(page.getProject(), c.getName(), bp); - c.setBuildLogFilename(null); - c.setSavingBuildLog(false); - } - } - } - } } /* (non-Javadoc) @@ -470,17 +340,14 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab { @Override protected void performDefaults() { - icfg.setBuildLogFilename(""); //$NON-NLS-1$ - icfg.setSavingBuildLog(false); if (icfg instanceof IMultiConfiguration) { IConfiguration[] cfs = (IConfiguration[])((IMultiConfiguration)icfg).getItems(); for (int i=0; i 0 ) { - // Check path exists in filesystem - File f = new File(fileName); - if ( f.getParentFile() != null && - f.getParentFile().exists() && - f.getParentFile().isDirectory() && - ( !f.exists() || (f.exists() && f.canWrite()) ) ) { - // File can be written - return true; - } - } - return false; - } - - public static String getFileNameKey(IProject project, String cfgName) { - // Make this preference key to be per project - return SAVE_CONSOLE_FILE_ID + "." + project.getName() + "." + cfgName; //$NON-NLS-1$ //$NON-NLS-2$ - } - - public static String getIsSavingKey(IProject project, String cfgName) { - // Make this preference key to be per project - return SAVE_CONSOLE_STATE_ID + "." + project.getName() + "." + cfgName; //$NON-NLS-1$ //$NON-NLS-2$ - } - -}