Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Enable binary parser (Elf/PECoff) in wizards and properties

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.34
diff -u -r1.34 ChangeLog
--- ChangeLog	25 Nov 2002 14:22:42 -0000	1.34
+++ ChangeLog	27 Nov 2002 04:40:59 -0000
@@ -1,3 +1,13 @@
+2002-11-27 Alain Magloire
+
+	* src/.../internal/ui/preferences/CProjectPropertyPage.java:
+	Added BinaryParserBlock part of the tab items.
+	(performOK): run this method in a runnable to allow cancellation.
+	* src/.../internal/ui/CContentProvider.java (processDelta):
+	Catch binary parser changes.
+	* src/.../ui/wizards/BinaryParserBlock.java: TabItem to change binary parser.
+	* src/.../ui/wizards/StdMakeProjectWizard.java: TabItem to change binary parser.
+
 2002-11-25 David Inglis
 	* src/.../internal/ui/editor/CEditor.java:(extends TextEditor)
 	* src/.../internal/ui/editor/CEditorActionContributor.java:(extends TextEditorActionContributor)
Index: src/org/eclipse/cdt/internal/ui/CContentProvider.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CContentProvider.java,v
retrieving revision 1.4
diff -u -r1.4 CContentProvider.java
--- src/org/eclipse/cdt/internal/ui/CContentProvider.java	18 Nov 2002 15:51:32 -0000	1.4
+++ src/org/eclipse/cdt/internal/ui/CContentProvider.java	27 Nov 2002 04:41:01 -0000
@@ -123,18 +123,18 @@
 			}
 		}
 
-		if (element instanceof ITranslationUnit ||
-		    element instanceof IBinary || element instanceof IArchive) {
-			if (kind == ICElementDelta.CHANGED) {
+		if (kind == ICElementDelta.CHANGED) {
+			if ((flags & ICElementDelta.F_BINARY_PARSER_CHANGED) != 0) {
+				// throw the towel and do a full refresh of the affected C project. 
+				postRefresh(element.getCProject());
+				return;
+			} else if (element instanceof ITranslationUnit ||
+					element instanceof IBinary || element instanceof IArchive) {
 				postRefresh(element);
 				return;
 			}
-		}
 
-		//if (isBuildPathChange(delta)) {
-			// throw the towel and do a full refresh of the affected C project. 
-			//postRefresh(element.getCProject());
-		//}
+		}
 
 		ICElementDelta[] affectedChildren= delta.getAffectedChildren();
 		for (int i= 0; i < affectedChildren.length; i++) {
@@ -142,9 +142,9 @@
 		}
 
 		// Make sure that containers are updated.
-		if (element instanceof ICRoot) {
-			updateContainer((ICRoot)element);
-		}
+		//if (element instanceof ICRoot) {
+		//	updateContainer((ICRoot)element);
+		//}
 	}
 
 	private void updateContainer(ICRoot root) {
Index: src/org/eclipse/cdt/internal/ui/preferences/CProjectPropertyPage.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CProjectPropertyPage.java,v
retrieving revision 1.7
diff -u -r1.7 CProjectPropertyPage.java
--- src/org/eclipse/cdt/internal/ui/preferences/CProjectPropertyPage.java	20 Nov 2002 22:09:31 -0000	1.7
+++ src/org/eclipse/cdt/internal/ui/preferences/CProjectPropertyPage.java	27 Nov 2002 04:41:03 -0000
@@ -5,24 +5,32 @@
  * All Rights Reserved.
  */
 
+import java.lang.reflect.InvocationTargetException;
+
 import org.eclipse.cdt.internal.ui.ICHelpContextIds;
 import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
 import org.eclipse.cdt.internal.ui.dialogs.StatusTool;
 import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.wizards.BinaryParserBlock;
 import org.eclipse.cdt.ui.wizards.IndexerBlock;
 import org.eclipse.cdt.ui.wizards.SettingsBlock;
 import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
 import org.eclipse.cdt.utils.ui.swt.IValidation;
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Image;
 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.swt.widgets.Shell;
 import org.eclipse.swt.widgets.TabFolder;
 import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
 import org.eclipse.ui.dialogs.PropertyPage;
 import org.eclipse.ui.help.WorkbenchHelp;
 
@@ -34,6 +42,7 @@
 	private TabFolder folder;
 	SettingsBlock settingsBlock;
 	IndexerBlock indexerBlock;
+	BinaryParserBlock binaryParserBlock;
 
 	protected Control createContents(Composite parent) {
 		Composite composite= new Composite(parent, SWT.NONE);
@@ -70,6 +79,15 @@
 			item3.setImage(img3);
 		item3.setData(indexerBlock);
 		item3.setControl(indexerBlock.getControl(folder));
+		
+		binaryParserBlock = new BinaryParserBlock(this, getProject());
+		TabItem item4 = new TabItem(folder, SWT.NONE);
+		item4.setText(binaryParserBlock.getLabel());
+		Image img4 = binaryParserBlock.getImage();
+		if (img4 != null)
+			item4.setImage(img4);
+		item4.setData(binaryParserBlock);
+		item4.setControl(binaryParserBlock.getControl(folder));
 
 		WorkbenchHelp.setHelp(parent, ICHelpContextIds.PROJECT_PROPERTY_PAGE);	
 	}
@@ -91,6 +109,9 @@
 		if (ok && indexerBlock != null) {
 			ok = indexerBlock.isValid();
 		}
+		if (ok && binaryParserBlock != null) {
+			ok = binaryParserBlock.isValid();
+		}
 		setValid(ok);
 	}
 
@@ -98,15 +119,38 @@
 	 * @see PreferencePage#performOk
 	 */	
 	public boolean performOk() {
-		if (settingsBlock != null)
-			settingsBlock.doRun(getProject(), null);
-		if (indexerBlock != null) {
-			indexerBlock.doRun(getProject(), null);
+		Shell shell= getControl().getShell();
+		IRunnableWithProgress runnable= new IRunnableWithProgress() {
+			public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+				monitor.beginTask("Property changes", 20);
+				if (settingsBlock != null) {
+					settingsBlock.doRun(getProject(), monitor);
+				}
+				monitor.worked(2);
+				if (indexerBlock != null) {
+					indexerBlock.doRun(getProject(), monitor);
+				}
+				monitor.worked(10);
+				if (binaryParserBlock != null) {
+					binaryParserBlock.doRun(getProject(), monitor);
+				}
+				monitor.worked(19);
+				monitor.done();
+			}
+		};
+		IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(runnable);
+		try {
+			new ProgressMonitorDialog(shell).run(false, true, op);
+		} catch (InvocationTargetException e) {
+			return false;
+		} catch (InterruptedException e) {
+			// cancelled
+			return false;
 		}
 		return true;
 	}
 		
-	private IProject getProject() {
+	IProject getProject() {
 		Object element= getElement();
 		if (element instanceof IProject) {
 			return (IProject)element;
@@ -122,6 +166,7 @@
 		if (visible && folder != null) {
 			settingsBlock.setVisible(visible);
 			indexerBlock.setVisible(visible);
+			binaryParserBlock.setVisible(visible);
 			folder.setFocus();
 		}
 	}	
Index: src/org/eclipse/cdt/ui/wizards/BinaryParserBlock.java
===================================================================
RCS file: src/org/eclipse/cdt/ui/wizards/BinaryParserBlock.java
diff -N src/org/eclipse/cdt/ui/wizards/BinaryParserBlock.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/ui/wizards/BinaryParserBlock.java	27 Nov 2002 04:41:04 -0000
@@ -0,0 +1,97 @@
+package org.eclipse.cdt.ui.wizards;
+
+/*
+ * (c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.IBinaryParserConfiguration;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.cdt.utils.ui.controls.RadioButtonsArea;
+import org.eclipse.cdt.utils.ui.swt.IValidation;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+
+
+public class BinaryParserBlock implements IWizardTab {
+
+	private static final String PREFIX = "BinaryParserBlock"; //$NON-NLS-1$
+	private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+	
+	private static String[][] radios;
+	private IProject project;
+
+	protected RadioButtonsArea radioButtons;
+	private String defaultFormat;
+//	protected Button defButton;
+
+	IValidation page;
+
+	public BinaryParserBlock(IValidation valid) {
+		this(valid, null);
+	}
+
+	public BinaryParserBlock(IValidation valid, IProject p) {
+		page = valid;
+		project = p;
+		IBinaryParserConfiguration[] configs = CCorePlugin.getDefault().getBinaryParserConfigurations();
+		radios = new String[configs.length][2];
+		for (int i = 0; i < configs.length; i++) {
+			radios[i] = new String[] {configs[i].getName(), configs[i].getFormat()};
+		}
+		CoreModel model = CCorePlugin.getDefault().getCoreModel();
+		if (project == null) {
+			defaultFormat = model.getDefaultBinaryParserFormat();
+		} else {
+			defaultFormat = model.getBinaryParserFormat(project);
+		}
+	}
+
+	public String getLabel() {
+		//return CUIPlugin.getResourceString(LABEL);
+		return "Binary Parser";
+	}
+
+	public Image getImage() {
+		return null;
+	}
+
+	public Composite getControl(Composite parent) {
+		Composite composite = ControlFactory.createComposite(parent, 1);
+
+		radioButtons = new RadioButtonsArea(composite, "Parsers", 1, radios);
+		radioButtons.setEnabled(true);
+		if (defaultFormat != null) {
+			radioButtons.setSelectValue(defaultFormat);
+		}
+		return composite;
+	}
+
+	public boolean isValid() {
+		return true;
+	}
+	
+	public void setVisible(boolean visible) {
+	}
+
+	public void doRun(IProject project, IProgressMonitor monitor) {
+		if (monitor == null) {
+			monitor = new NullProgressMonitor();
+		}
+		monitor.beginTask("Parsers", 1);
+		CoreModel model = CCorePlugin.getDefault().getCoreModel();
+		String format = radioButtons.getSelectedValue();
+		if (format != null) {
+			if (defaultFormat == null || !format.equals(defaultFormat)) {
+				model.setBinaryParserFormat(project, format, monitor);
+				defaultFormat = format;
+			}
+		}
+	}
+
+}
Index: src/org/eclipse/cdt/ui/wizards/ReferenceBlock.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/ReferenceBlock.java,v
retrieving revision 1.3
diff -u -r1.3 ReferenceBlock.java
--- src/org/eclipse/cdt/ui/wizards/ReferenceBlock.java	29 Oct 2002 21:40:58 -0000	1.3
+++ src/org/eclipse/cdt/ui/wizards/ReferenceBlock.java	27 Nov 2002 04:41:04 -0000
@@ -94,7 +94,7 @@
 				ArrayList aList = new ArrayList(15);
 				final IProject[] projects = ((IWorkspace)element).getRoot().getProjects();
 				for (int i = 0; i < projects.length; i++) {
-					if (CoreModel.hasCNature(projects[i])) {
+					if (CoreModel.getDefault().hasCNature(projects[i])) {
 						// Do not show the actual project being look at
 						if ((project != null) && project.equals(projects[i])) {
 							continue;
Index: src/org/eclipse/cdt/ui/wizards/StdMakeProjectWizard.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/StdMakeProjectWizard.java,v
retrieving revision 1.5
diff -u -r1.5 StdMakeProjectWizard.java
--- src/org/eclipse/cdt/ui/wizards/StdMakeProjectWizard.java	13 Nov 2002 20:39:29 -0000	1.5
+++ src/org/eclipse/cdt/ui/wizards/StdMakeProjectWizard.java	27 Nov 2002 04:41:03 -0000
@@ -29,6 +29,7 @@
 
 	private ReferenceBlock referenceBlock;
 	private SettingsBlock settingsBlock;
+	private BinaryParserBlock binaryParserBlock;
 
 	public StdMakeProjectWizard() {
 		this(CUIPlugin.getResourceString(WZ_TITLE), CUIPlugin.getResourceString(WZ_DESC));
@@ -61,6 +62,16 @@
 		item2.setData(settingsBlock);
 		item2.setControl(settingsBlock.getControl(folder));
 		addTabItem(settingsBlock);
+		
+		binaryParserBlock = new BinaryParserBlock(getValidation());
+		TabItem item3 = new TabItem(folder, SWT.NONE);
+		item3.setText(binaryParserBlock.getLabel());
+		Image img3 = binaryParserBlock.getImage();
+		if (img3 != null)
+			item3.setImage(img3);
+		item3.setData(binaryParserBlock);
+		item3.setControl(binaryParserBlock.getControl(folder));
+		addTabItem(binaryParserBlock);
 	}
 
 	protected void doRunPrologue(IProgressMonitor monitor) {
@@ -86,6 +97,10 @@
 			// Update the settings.
 			if (settingsBlock != null) {
 				settingsBlock.doRun(newProject, new SubProgressMonitor(monitor, 1));
+			}
+			// Update the binary parser
+			if (binaryParserBlock != null) {
+				binaryParserBlock.doRun(newProject, new SubProgressMonitor(monitor, 1));
 			}
 		}
 	}



Back to the top