1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

External code commit from Leo Treggiari from Intel that adds support for adding and removing error psarser on a managed build project

This commit is contained in:
Sean Evoy 2004-04-22 18:10:51 +00:00
parent 4528b2a06c
commit ae1b577d72
11 changed files with 402 additions and 22 deletions

View file

@ -9,6 +9,7 @@ MngCCWizard.description=Create a new C++ project and let Eclipse create and mana
#The property pages
MngBuildProp.name=C/C++ Build
MngOtherProp.name= Error Parsers
# Build Model Names
TargetName.cygw=Cygwin

View file

@ -65,6 +65,20 @@
</filter>
</page>
</extension>
<extension
point="org.eclipse.ui.propertyPages">
<page
objectClass="org.eclipse.core.resources.IProject"
adaptable="true"
name="%MngOtherProp.name"
class="org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderPropertyPage"
id="org.eclipse.cdt.managedbuilder.ui.properties.ManagedBuilderProperties">
<filter
name="nature"
value="org.eclipse.cdt.managedbuilder.core.managedBuildNature">
</filter>
</page>
</extension>
<!-- Managed Make Builder Tool Specifications -->
<extension
id="cdt.managed.build.info"

View file

@ -0,0 +1,86 @@
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* QNX Software Systems - Move to Make plugin
* Intel Corp - Use in Managed Make system
***********************************************************************/
package org.eclipse.cdt.managedbuilder.internal.ui;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.managedbuilder.core.ITarget;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.ui.wizards.NewManagedProjectOptionPage;
import org.eclipse.cdt.managedbuilder.ui.wizards.NewManagedProjectWizard;
import org.eclipse.cdt.ui.dialogs.AbstractErrorParserBlock;
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.core.resources.IProject;
public class ErrorParserBlock extends AbstractErrorParserBlock {
public ErrorParserBlock() {
super(null);
}
protected String[] getErrorParserIDs(ITarget target) {
// Get the list of error parsers specified with this Target
String[] errorParsers = target.getErrorParserList();
if (errorParsers != null) {
return errorParsers;
}
else {
// If no error parsers are specified by the target, the default is
// all error parsers
return CCorePlugin.getDefault().getAllErrorParsersIDs();
}
}
protected String[] getErrorParserIDs(IProject project) {
ITarget target = ManagedBuildManager.getSelectedTarget(project);
if (target == null) {
// This case occurs when modifying the properties of an existing
// managed build project, and the user selects the error parsers
// page before the "C/C++ Build" page.
// Get the build information
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project, true);
target = info.getDefaultTarget();
}
if (target != null) {
return getErrorParserIDs(target);
} else {
return CCorePlugin.getDefault().getAllErrorParsersIDs();
}
}
protected String[] getErrorParserIDs() {
// Get the currently selected target from the page's container
// This is invoked by the managed builder new project wizard before the
// project is created.
ICOptionContainer container = getContainer();
if (container instanceof NewManagedProjectOptionPage) {
NewManagedProjectOptionPage parent = (NewManagedProjectOptionPage)getContainer();
NewManagedProjectWizard wizard = (NewManagedProjectWizard)parent.getWizard();
ITarget target = wizard.getSelectedTarget();
return getErrorParserIDs(target);
}
return CCorePlugin.getDefault().getAllErrorParsersIDs();
}
public void saveErrorParsers(IProject project, String[] parsers) {
ITarget target = ManagedBuildManager.getSelectedTarget(project);
if (target != null) {
StringBuffer buf = new StringBuffer();
for (int i = 0; i < parsers.length; i++) {
if (i > 0) buf.append(';');
buf.append(parsers[i]);
}
target.setErrorParserIds(buf.toString());
}
}
}

View file

@ -12,11 +12,18 @@ package org.eclipse.cdt.managedbuilder.internal.ui;
* **********************************************************************/
import java.text.MessageFormat;
import java.lang.reflect.InvocationTargetException;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.swt.widgets.Shell;
public class ManagedBuilderUIPlugin extends Plugin {
@ -76,4 +83,38 @@ public class ManagedBuilderUIPlugin extends Plugin {
return getDefault().getDescriptor().getUniqueIdentifier();
}
public static void log(IStatus status) {
ResourcesPlugin.getPlugin().getLog().log(status);
}
public static void log(Throwable e) {
if (e instanceof InvocationTargetException)
e = ((InvocationTargetException) e).getTargetException();
IStatus status = null;
if (e instanceof CoreException)
status = ((CoreException) e).getStatus();
else
status = new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.OK, e.getMessage(), e);
log(status);
}
/**
* Utility method with conventions
*/
public static void errorDialog(Shell shell, String title, String message, Throwable t) {
log(t);
IStatus status;
if (t instanceof CoreException) {
status = ((CoreException) t).getStatus();
// if the 'message' resource string and the IStatus' message are the same,
// don't show both in the dialog
if (status != null && message.equals(status.getMessage())) {
message = null;
}
} else {
status = new Status(IStatus.ERROR, ManagedBuilderUIPlugin.getUniqueIdentifier(), -1, "Internal Error: ", t); //$NON-NLS-1$
}
ErrorDialog.openError(shell, title, message, status);
}
}

View file

@ -16,20 +16,25 @@ import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
public class ManagedProjectOptionBlock extends TabFolderOptionBlock {
ErrorParserBlock errParserBlock;
/**
* @param parent
*/
public ManagedProjectOptionBlock(ICOptionContainer parent) {
super(parent);
// TODO Auto-generated constructor stub
}
/* (non-Javadoc)
* @see org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock#addTabs()
*/
protected void addTabs() {
// TODO Auto-generated method stub
errParserBlock = new ErrorParserBlock();
addTab(errParserBlock);
}
public ErrorParserBlock getErrorParserBlock() {
return errParserBlock;
}
}

View file

@ -113,5 +113,6 @@ FileListControl.deletedialog.title=Confirm Delete
FileListControl.editdialog.title=Edit Dialog
FileListControl.newdialog.title=New Dialog
# ----------- Property Page ----------
MngMakeProjectPropertyPage.closedproject=Project Closed
MngMakeProjectPropertyPage.internalError=An Internal error has occur please check error log.

View file

@ -171,6 +171,8 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
protected Control createContents(Composite parent) {
// Initialize the key data
targets = ManagedBuildManager.getTargets(getProject());
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject(), true);
ITarget defaultTarget = info.getDefaultTarget();
// Create the container we return to the property page editor
Composite composite = ControlFactory.createComposite(parent, 1);
@ -188,7 +190,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
configGroup.setLayout(form);
Label platformLabel = ControlFactory.createLabel(configGroup, ManagedBuilderUIPlugin.getResourceString(PLATFORM_LABEL));
targetSelector = ControlFactory.createSelectCombo(configGroup, getPlatformNames(), null);
targetSelector = ControlFactory.createSelectCombo(configGroup, getPlatformNames(), defaultTarget.getName());
targetSelector.addListener(SWT.Selection, new Listener () {
public void handleEvent(Event e) {
handleTargetSelection();
@ -486,6 +488,13 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
return null;
}
/* (non-Javadoc)
* @return
*/
public ITarget getSelectedTarget() {
return selectedTarget;
}
/* (non-Javadoc)
* @return
*/
@ -683,6 +692,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
// Cache the platform at the selection index
selectedTarget = targets[targetSelector.getSelectionIndex()];
ManagedBuildManager.setSelectedTarget(getProject(), selectedTarget);
// Update the contents of the configuration widget
populateConfigurations();

View file

@ -0,0 +1,173 @@
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Intel Corp - use in Managed Make system
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.ui.properties;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedProjectOptionBlock;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
import org.eclipse.cdt.managedbuilder.internal.ui.ErrorParserBlock;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.ITarget;
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferencePageContainer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
import org.eclipse.ui.dialogs.PropertyPage;
public class ManagedBuilderPropertyPage extends PropertyPage implements ICOptionContainer {
protected ManagedProjectOptionBlock fOptionBlock;
protected ITarget displayedTarget;
private static final String MSG_CLOSEDPROJECT = "MngMakeProjectPropertyPage.closedproject"; //$NON-NLS-1$
public ManagedBuilderPropertyPage() {
super();
}
public void setContainer(IPreferencePageContainer preferencePageContainer) {
super.setContainer(preferencePageContainer);
if (fOptionBlock == null) {
fOptionBlock = new ManagedProjectOptionBlock(this);
}
}
protected Control createContents(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new FillLayout());
IProject project = getProject();
if (!project.isOpen()) {
contentForClosedProject(composite);
} else {
contentForCProject(composite);
}
return composite;
}
private void contentForCProject(Composite parent) {
fOptionBlock.createContents(parent);
// WorkbenchHelp.setHelp(parent, ICMakeHelpContextIds.PROJECT_PROPERTY_PAGE);
}
private void contentForClosedProject(Composite parent) {
Label label = new Label(parent, SWT.LEFT);
label.setText(ManagedBuilderUIPlugin.getResourceString(MSG_CLOSEDPROJECT));
label.setFont(parent.getFont());
noDefaultAndApplyButton();
}
/**
* @see PreferencePage#performOk
*/
public boolean performOk() {
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
fOptionBlock.performApply(monitor);
}
};
// If the user did not come to this page when the current selected target
// was the selected target, then there is nothing to do. The page was either
// never visited, or was visited for another target.
ITarget target = getSelectedTarget();
if (target != displayedTarget) return true;
IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
try {
new ProgressMonitorDialog(getShell()).run(false, true, op);
} catch (InvocationTargetException e) {
Throwable e1 = e.getTargetException();
ManagedBuilderUIPlugin.errorDialog(getShell(), ManagedBuilderUIPlugin.getResourceString("ManagedProjectPropertyPage.internalError"),e1.toString(), e1); //$NON-NLS-1$
return false;
} catch (InterruptedException e) {
// cancelled
return false;
}
// Write out the build model info
IProject project = getProject();
ManagedBuildManager.saveBuildInfo(project, false);
return true;
}
public IProject getProject() {
Object element = getElement();
if (element instanceof IProject) {
return (IProject) element;
}
return null;
}
/**
* @see DialogPage#setVisible(boolean)
*/
public void setVisible(boolean visible) {
super.setVisible(visible);
fOptionBlock.setVisible(visible);
if (visible) {
ErrorParserBlock errorParsers = fOptionBlock.getErrorParserBlock();
errorParsers.updateValues();
displayedTarget = getSelectedTarget();
}
}
protected ITarget getSelectedTarget() {
// If the selected target is not yet set, set it to the default target
// The selected target is needed for saving error parser information
IProject project = getProject();
ITarget target = ManagedBuildManager.getSelectedTarget(project);
if (target == null) {
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project, true);
target = info.getDefaultTarget();
ManagedBuildManager.setSelectedTarget(project, target);
}
return target;
}
public void updateContainer() {
fOptionBlock.update();
setValid(fOptionBlock.isValid());
setErrorMessage(fOptionBlock.getErrorMessage());
}
protected void performDefaults() {
fOptionBlock.performDefaults();
super.performDefaults();
}
public boolean isValid() {
updateContainer();
return super.isValid();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getPreferences()
*/
public Preferences getPreferences() {
return null;
}
}

View file

@ -23,6 +23,7 @@ import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.core.boot.BootLoader;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
@ -37,6 +38,7 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.cdt.ui.wizards.NewCProjectWizard;
public class CProjectPlatformPage extends WizardPage {
/*
@ -46,6 +48,7 @@ public class CProjectPlatformPage extends WizardPage {
protected ITarget selectedTarget;
protected String[] targetNames;
protected ArrayList targets;
protected NewManagedProjectWizard parentWizard;
/*
* Dialog variables and string constants
@ -61,15 +64,16 @@ public class CProjectPlatformPage extends WizardPage {
/**
* Constructor.
* @param wizard
* @param pageName
* @param wizard
*/
public CProjectPlatformPage(String pageName) {
public CProjectPlatformPage(String pageName, NewManagedProjectWizard parentWizard) {
super(pageName);
setPageComplete(false);
populateTargets();
selectedTarget = null;
selectedConfigurations = new ArrayList(0);
this.parentWizard = parentWizard;
}
/**
@ -174,7 +178,10 @@ public class CProjectPlatformPage extends WizardPage {
int index;
if (platformSelection != null
&& (index = platformSelection.getSelectionIndex()) != -1) {
selectedTarget = (ITarget) targets.get(index);
if (selectedTarget != (ITarget) targets.get(index)) {
selectedTarget = (ITarget) targets.get(index);
parentWizard.updateTargetProperties();
}
}
populateConfigurations();
setPageComplete(validatePage());
@ -226,4 +233,11 @@ public class CProjectPlatformPage extends WizardPage {
// TODO Auto-generated method stub
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getProject()
*/
public IProject getProject() {
return ((NewCProjectWizard)getWizard()).getNewProject();
}
}

View file

@ -13,7 +13,7 @@ package org.eclipse.cdt.managedbuilder.ui.wizards;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedProjectOptionBlock;
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.cdt.managedbuilder.internal.ui.ErrorParserBlock;
import org.eclipse.cdt.ui.dialogs.ReferenceBlock;
import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
import org.eclipse.cdt.ui.wizards.NewCProjectWizard;
@ -24,28 +24,49 @@ import org.eclipse.core.runtime.Preferences;
public class NewManagedProjectOptionPage extends NewCProjectWizardOptionPage {
public class ManagedWizardOptionBlock extends ManagedProjectOptionBlock {
NewManagedProjectOptionPage parent;
ErrorParserBlock errorParsers;
public ManagedWizardOptionBlock(ICOptionContainer parent) {
super(parent);
public ManagedWizardOptionBlock(NewManagedProjectOptionPage parentPage) {
super(parentPage);
parent = parentPage;
}
public void updateTargetProperties() {
// Update the error parser list
if (errorParsers != null) {
errorParsers.updateValues();
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock#addTabs()
*/
protected void addTabs() {
addTab(new ReferenceBlock());
errorParsers = new ErrorParserBlock();
addTab(errorParsers);
}
}
protected ManagedWizardOptionBlock optionBlock;
protected NewManagedProjectWizard parentWizard;
/**
* @param pageName
*/
public NewManagedProjectOptionPage(String pageName) {
public NewManagedProjectOptionPage(String pageName, NewManagedProjectWizard parentWizard) {
super(pageName);
this.parentWizard = parentWizard;
optionBlock = new ManagedWizardOptionBlock(this);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.ui.wizards.NewCProjectWizardOptionPage#createOptionBlock()
*/
protected TabFolderOptionBlock createOptionBlock() {
return new ManagedWizardOptionBlock(this);
return optionBlock;
}
/* (non-Javadoc)
@ -61,5 +82,9 @@ public class NewManagedProjectOptionPage extends NewCProjectWizardOptionPage {
public Preferences getPreferences() {
return ManagedBuilderUIPlugin.getDefault().getPluginPreferences();
}
public void updateTargetProperties() {
// Update the error parser list
optionBlock.updateTargetProperties();
}
}

View file

@ -64,17 +64,22 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
super.addPages();
// Add the configuration selection page
targetConfigurationPage = new CProjectPlatformPage(PREFIX);
targetConfigurationPage = new CProjectPlatformPage(PREFIX, this);
targetConfigurationPage.setTitle(ManagedBuilderUIPlugin.getResourceString(CONF_TITLE));
targetConfigurationPage.setDescription(ManagedBuilderUIPlugin.getResourceString(CONF_DESC));
addPage(targetConfigurationPage);
// Add the options (tabbed) page
optionPage = new NewManagedProjectOptionPage(PREFIX);
optionPage = new NewManagedProjectOptionPage(PREFIX, this);
optionPage.setTitle(ManagedBuilderUIPlugin.getResourceString(OPTIONS_TITLE));
optionPage.setDescription(ManagedBuilderUIPlugin.getResourceString(OPTIONS_DESC));
addPage(optionPage);
}
public void updateTargetProperties() {
// Update the error parser list
optionPage.updateTargetProperties();
}
protected void doRun(IProgressMonitor monitor) throws CoreException {
if (monitor == null) {
@ -98,11 +103,6 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
} catch (CoreException e) {
// Bail out of the project creation
}
// Modify the project settings
if (newProject != null) {
optionPage.performApply(new SubProgressMonitor(monitor, 2));
}
// Add the target to the project
ITarget newTarget = null;
@ -128,6 +128,7 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
if (newConfigs.length > 0) {
ManagedBuildManager.setDefaultConfiguration(newProject, newConfigs[0]);
}
ManagedBuildManager.setSelectedTarget(newProject, newTarget);
}
} catch (BuildException e) {
// TODO Flag the error to the user
@ -145,6 +146,11 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
} catch (CoreException e) {
// TODO Flag the error to the user
}
// Modify the project settings
if (newProject != null) {
optionPage.performApply(new SubProgressMonitor(monitor, 2));
}
// Save the build options
monitor.subTask(ManagedBuilderUIPlugin.getResourceString(MSG_SAVE));
@ -175,5 +181,9 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
return "org.eclipse.cdt.make.core.make"; //$NON-NLS-1$
// return ManagedBuilderCorePlugin.getUniqueIdentifier() + ".make"; //$NON-NLS-1$
}
public ITarget getSelectedTarget() {
return targetConfigurationPage.getSelectedTarget();
}
}