diff --git a/build/org.eclipse.cdt.make.ui/.classpath b/build/org.eclipse.cdt.make.ui/.classpath
new file mode 100644
index 00000000000..c5cfc924bbd
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/.classpath
@@ -0,0 +1,7 @@
+
+
10th July, 2002
+Eclipse.org makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the +Common Public License Version 1.0 ("CPL"). A copy of the CPL is available at http://www.eclipse.org/legal/cpl-v10.html. +For purposes of the CPL, "Program" will mean the Content.
+ +If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise +made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such +Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.
+ +If this Content is licensed to you under license terms and conditions other than the CPL ("Other License"), any modifications, enhancements and/or +other code and/or documentation ("Modifications") uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the +host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available +to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also +providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of +the CPL.
+ + + \ No newline at end of file diff --git a/build/org.eclipse.cdt.make.ui/build.properties b/build/org.eclipse.cdt.make.ui/build.properties new file mode 100644 index 00000000000..78f2a27e790 --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/build.properties @@ -0,0 +1,4 @@ +source.cdtmakeui.jar = src/ +bin.includes = plugin.xml,\ + *.jar,\ + cdtmakeui.jar diff --git a/build/org.eclipse.cdt.make.ui/icons/actions/build_menu.gif b/build/org.eclipse.cdt.make.ui/icons/actions/build_menu.gif new file mode 100644 index 00000000000..3fc40d6a13a Binary files /dev/null and b/build/org.eclipse.cdt.make.ui/icons/actions/build_menu.gif differ diff --git a/build/org.eclipse.cdt.make.ui/icons/ctool16/convert-normal.gif b/build/org.eclipse.cdt.make.ui/icons/ctool16/convert-normal.gif new file mode 100644 index 00000000000..80c3f8cbc5c Binary files /dev/null and b/build/org.eclipse.cdt.make.ui/icons/ctool16/convert-normal.gif differ diff --git a/build/org.eclipse.cdt.make.ui/icons/ctool16/make.gif b/build/org.eclipse.cdt.make.ui/icons/ctool16/make.gif new file mode 100644 index 00000000000..3fc40d6a13a Binary files /dev/null and b/build/org.eclipse.cdt.make.ui/icons/ctool16/make.gif differ diff --git a/build/org.eclipse.cdt.make.ui/icons/ctool16/newc_app.gif b/build/org.eclipse.cdt.make.ui/icons/ctool16/newc_app.gif new file mode 100644 index 00000000000..6c2d75db2e6 Binary files /dev/null and b/build/org.eclipse.cdt.make.ui/icons/ctool16/newc_app.gif differ diff --git a/build/org.eclipse.cdt.make.ui/icons/ctool16/newcc_app.gif b/build/org.eclipse.cdt.make.ui/icons/ctool16/newcc_app.gif new file mode 100644 index 00000000000..86d78df150f Binary files /dev/null and b/build/org.eclipse.cdt.make.ui/icons/ctool16/newcc_app.gif differ diff --git a/build/org.eclipse.cdt.make.ui/icons/cview16/make.gif b/build/org.eclipse.cdt.make.ui/icons/cview16/make.gif new file mode 100644 index 00000000000..3fc40d6a13a Binary files /dev/null and b/build/org.eclipse.cdt.make.ui/icons/cview16/make.gif differ diff --git a/build/org.eclipse.cdt.make.ui/icons/wizban/newcprj_wiz.gif b/build/org.eclipse.cdt.make.ui/icons/wizban/newcprj_wiz.gif new file mode 100644 index 00000000000..60ccf9c7c6a Binary files /dev/null and b/build/org.eclipse.cdt.make.ui/icons/wizban/newcprj_wiz.gif differ diff --git a/build/org.eclipse.cdt.make.ui/plugin.properties b/build/org.eclipse.cdt.make.ui/plugin.properties new file mode 100644 index 00000000000..f56a3aefb33 --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/plugin.properties @@ -0,0 +1,30 @@ +pluginName=C/C++ Standard make Build UI +providerName=Eclipse.org + +WizardNewCMakeProject.name=Standard Make C Project +WizardNewCMakeProject.description=Create a new C Project which uses a simple makefile. + +WizardNewCCMakeProject.name=Standard Make C++ Project +WizardNewCCMakeProject.description=Create a new C++ Project which uses a simple makefile. + +WizardConvertMakeProject.name=Convert to Make Project +WizardConvertMakeProject.description=Convert a C/C++ Project to use a simple makefile + +MenuMakeNew.label=Make Builds + +ActionMakeBuildCreate.label=Build/Create Make Target... +ActionMakeAll.label=Make all +ActionMakeClean.label=Make clean +ActionMakeRebuild.label=Make rebuild +ActionMakeUpdate.label=Update Old Make Project... + +CommandMakeBuildCreate.name=Build/Create Make Target +CommandMakeBuildCreate.description=Build or create a new make build target + +PreferenceMake.name=New Make Projects +PropertyMakeProject.name= C/C++ Make Project + +ViewCatagoryMake.name=Make +ViewMake.name=Make Targets + +ActionSetMake.label=Make Action Set \ No newline at end of file diff --git a/build/org.eclipse.cdt.make.ui/plugin.xml b/build/org.eclipse.cdt.make.ui/plugin.xml new file mode 100644 index 00000000000..f6496d42d3e --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/plugin.xml @@ -0,0 +1,229 @@ + +null
is returned.
+ *
+ * @return the shell for the given widget
+ */
+ public static Shell getShell(Widget widget) {
+ if (widget instanceof Control)
+ return ((Control)widget).getShell();
+ if (widget instanceof Caret)
+ return ((Caret)widget).getParent().getShell();
+ if (widget instanceof DragSource)
+ return ((DragSource)widget).getControl().getShell();
+ if (widget instanceof DropTarget)
+ return ((DropTarget)widget).getControl().getShell();
+ if (widget instanceof Menu)
+ return ((Menu)widget).getParent().getShell();
+ if (widget instanceof ScrollBar)
+ return ((ScrollBar)widget).getParent().getShell();
+
+ return null;
+ }
+
+
+ /**
+ * Returns a width hint for a button control.
+ */
+ public static int getButtonWidthHint(Button button) {
+ if (button.getFont().equals(JFaceResources.getDefaultFont()))
+ button.setFont(JFaceResources.getDialogFont());
+ PixelConverter converter= new PixelConverter(button);
+ int widthHint= converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+ return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
+ }
+
+ /**
+ * Returns a height hint for a button control.
+ */
+ public static int getButtonHeigthHint(Button button) {
+ if (button.getFont().equals(JFaceResources.getDefaultFont()))
+ button.setFont(JFaceResources.getDialogFont());
+ PixelConverter converter= new PixelConverter(button);
+ return converter.convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
+ }
+
+
+ /**
+ * Sets width and height hint for the button control.
+ * Note: This is a NOP if the button's layout data is not
+ * an instance of GridData
.
+ *
+ * @param the button for which to set the dimension hint
+ */
+ public static void setButtonDimensionHint(Button button) {
+ Assert.isNotNull(button);
+ Object gd= button.getLayoutData();
+ if (gd instanceof GridData) {
+ ((GridData)gd).heightHint= getButtonHeigthHint(button);
+ ((GridData)gd).widthHint= getButtonWidthHint(button);
+ }
+ }
+
+ public static int getTableHeightHint(Table table, int rows) {
+ if (table.getFont().equals(JFaceResources.getDefaultFont()))
+ table.setFont(JFaceResources.getDialogFont());
+ int result= table.getItemHeight() * rows + table.getHeaderHeight();
+ if (table.getLinesVisible())
+ result+= table.getGridLineWidth() * (rows - 1);
+ return result;
+ }
+
+
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/part/CheckboxTablePart.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/part/CheckboxTablePart.java
new file mode 100644
index 00000000000..76313520b3f
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/part/CheckboxTablePart.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+package org.eclipse.cdt.make.internal.ui.part;
+
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @version 1.0
+ * @author
+ */
+public class CheckboxTablePart extends StructuredViewerPart {
+ public CheckboxTablePart(String[] buttonLabels) {
+ super(buttonLabels);
+ }
+
+ /*
+ * @see StructuredViewerPart#createStructuredViewer(Composite, FormWidgetFactory)
+ */
+ protected StructuredViewer createStructuredViewer(Composite parent, int style) {
+ style |= SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
+ CheckboxTableViewer tableViewer = CheckboxTableViewer.newCheckList(parent, style);
+ tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent e) {
+ CheckboxTablePart.this.selectionChanged((IStructuredSelection) e.getSelection());
+ }
+ });
+ tableViewer.addCheckStateListener(new ICheckStateListener() {
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ elementChecked(event.getElement(), event.getChecked());
+ }
+ });
+ return tableViewer;
+ }
+
+ public CheckboxTableViewer getTableViewer() {
+ return (CheckboxTableViewer) getViewer();
+ }
+
+ /*
+ * @see SharedPartWithButtons#buttonSelected(int)
+ */
+ protected void buttonSelected(Button button, int index) {
+ }
+
+ protected void elementChecked(Object element, boolean checked) {
+ }
+ protected void selectionChanged(IStructuredSelection selection) {
+ }
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/part/SharedPart.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/part/SharedPart.java
new file mode 100644
index 00000000000..b903e987e17
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/part/SharedPart.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+package org.eclipse.cdt.make.internal.ui.part;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * @version 1.0
+ * @author
+ */
+public abstract class SharedPart {
+ private boolean enabled = true;
+
+ public void setEnabled(boolean enabled) {
+ if (enabled != this.enabled) {
+ this.enabled = enabled;
+ updateEnabledState();
+ }
+ }
+
+ public abstract void createControl(Composite parent, int style, int span);
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ protected void updateEnabledState() {
+ }
+
+ protected Composite createComposite(Composite parent) {
+ return new Composite(parent, SWT.NULL);
+ }
+
+ protected Label createEmptySpace(Composite parent, int span) {
+ Label label = new Label(parent, SWT.NULL);
+ GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
+ gd.horizontalSpan = span;
+ gd.widthHint = 0;
+ gd.heightHint = 0;
+ label.setLayoutData(gd);
+ return label;
+ }
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/part/SharedPartWithButtons.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/part/SharedPartWithButtons.java
new file mode 100644
index 00000000000..74bf5032f2c
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/part/SharedPartWithButtons.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+package org.eclipse.cdt.make.internal.ui.part;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * @version 1.0
+ * @author
+ */
+public abstract class SharedPartWithButtons extends SharedPart {
+ private String[] buttonLabels;
+ private Control[] controls;
+ private Composite buttonContainer;
+
+ private class SelectionHandler implements SelectionListener {
+ public void widgetSelected(SelectionEvent e) {
+ buttonSelected(e);
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ buttonSelected(e);
+ }
+ private void buttonSelected(SelectionEvent e) {
+ Integer index = (Integer) e.widget.getData();
+ SharedPartWithButtons.this.buttonSelected((Button) e.widget, index.intValue());
+ }
+ }
+
+ public SharedPartWithButtons(String[] buttonLabels) {
+ this.buttonLabels = buttonLabels;
+ }
+
+ public void setButtonEnabled(int index, boolean enabled) {
+ if (controls != null && index >= 0 && controls.length > index) {
+ Control c = controls[index];
+ if (c instanceof Button)
+ c.setEnabled(enabled);
+ }
+ }
+
+ protected abstract void createMainControl(Composite parent, int style, int span);
+ protected abstract void buttonSelected(Button button, int index);
+
+ /*
+ * @see SharedPart#createControl(Composite, FormWidgetFactory)
+ */
+ public void createControl(Composite parent, int style, int span) {
+ createMainLabel(parent, span);
+ createMainControl(parent, style, span - 1);
+ if (buttonLabels != null && buttonLabels.length > 0) {
+ buttonContainer = createComposite(parent);
+ GridData gd = new GridData(GridData.FILL_VERTICAL);
+ buttonContainer.setLayoutData(gd);
+ buttonContainer.setLayout(createButtonsLayout());
+
+ controls = new Control[buttonLabels.length];
+ SelectionHandler listener = new SelectionHandler();
+ for (int i = 0; i < buttonLabels.length; i++) {
+ String label = buttonLabels[i];
+ if (label != null) {
+ Button button = createButton(buttonContainer, label, i);
+ button.addSelectionListener(listener);
+ controls[i] = button;
+ } else {
+ createEmptySpace(buttonContainer, 1);
+ }
+ }
+ }
+ }
+
+ protected GridLayout createButtonsLayout() {
+ GridLayout layout = new GridLayout();
+ layout.marginWidth = layout.marginHeight = 0;
+ return layout;
+ }
+
+ protected Button createButton(Composite parent, String label, int index) {
+ Button button = new Button(parent, SWT.PUSH);
+ button.setText(label);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+ button.setLayoutData(gd);
+ button.setData(new Integer(index));
+ return button;
+ }
+
+ protected void updateEnabledState() {
+ for (int i = 0; i < controls.length; i++) {
+ Control c = controls[i];
+ if (c instanceof Button)
+ c.setEnabled(isEnabled());
+ }
+ }
+
+ protected void createMainLabel(Composite parent, int span) {
+ }
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/part/StructuredViewerPart.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/part/StructuredViewerPart.java
new file mode 100644
index 00000000000..0bac65c69b3
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/part/StructuredViewerPart.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+package org.eclipse.cdt.make.internal.ui.part;
+
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+/**
+ * @version 1.0
+ * @author
+ */
+public abstract class StructuredViewerPart extends SharedPartWithButtons {
+ private StructuredViewer viewer;
+ private Point minSize = null;
+
+ public StructuredViewerPart(String[] buttonLabels) {
+ super(buttonLabels);
+ }
+
+ public StructuredViewer getViewer() {
+ return viewer;
+ }
+
+ public Control getControl() {
+ return viewer.getControl();
+ }
+
+ /*
+ * @see SharedPartWithButtons#createMainControl(Composite, int, FormWidgetFactory)
+ */
+ protected void createMainControl(Composite parent, int style, int span) {
+ viewer = createStructuredViewer(parent, style);
+ Control control = viewer.getControl();
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = span;
+ control.setLayoutData(gd);
+ applyMinimumSize();
+ }
+
+ public void setMinimumSize(int width, int height) {
+ minSize = new Point(width, height);
+ if (viewer != null)
+ applyMinimumSize();
+ }
+ private void applyMinimumSize() {
+ if (minSize != null) {
+ GridData gd = (GridData) viewer.getControl().getLayoutData();
+ gd.widthHint = minSize.x;
+ gd.heightHint = minSize.y;
+ }
+ }
+
+ protected void updateEnabledState() {
+ getControl().setEnabled(isEnabled());
+ super.updateEnabledState();
+ }
+
+ protected abstract StructuredViewer createStructuredViewer(Composite parent, int style);
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/part/WizardCheckboxTablePart.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/part/WizardCheckboxTablePart.java
new file mode 100644
index 00000000000..0bbf5467e98
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/part/WizardCheckboxTablePart.java
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+package org.eclipse.cdt.make.internal.ui.part;
+import java.text.MessageFormat;
+
+import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+/**
+ * @version 1.0
+ * @author
+ */
+public class WizardCheckboxTablePart extends CheckboxTablePart {
+ public static final String KEY_SELECT_ALL = MakeUIPlugin.getResourceString("WizardCheckboxTablePart.WizardCheckboxTablePart.selectAll"); //$NON-NLS-1$
+ public static final String KEY_DESELECT_ALL = MakeUIPlugin.getResourceString("WizardCheckboxTablePart.WizardCheckboxTablePart.deselectAll"); //$NON-NLS-1$
+ public static final String KEY_COUNTER = MakeUIPlugin.getResourceString("WizardCheckboxTablePart.WizardCheckboxTablePart.counter"); //$NON-NLS-1$
+
+ private final String EMPTY_STRING = ""; //$NON-NLS-1$
+ private int selectAllIndex = -1;
+ private int deselectAllIndex = -1;
+ private String tableName;
+ private int counter;
+ private Label counterLabel;
+
+ /**
+ * Constructor for WizardCheckboxTablePart.
+ * @param buttonLabels
+ */
+ public WizardCheckboxTablePart(String tableName, String[] buttonLabels) {
+ super(buttonLabels);
+ this.tableName = tableName;
+ }
+
+ public WizardCheckboxTablePart(String mainLabel) {
+ this(
+ mainLabel,
+ new String[] { MakeUIPlugin.getResourceString(KEY_SELECT_ALL), MakeUIPlugin.getResourceString(KEY_DESELECT_ALL)});
+ setSelectAllIndex(0);
+ setDeselectAllIndex(1);
+ }
+
+ public void setSelectAllIndex(int index) {
+ this.selectAllIndex = index;
+ }
+ public void setDeselectAllIndex(int index) {
+ this.deselectAllIndex = index;
+ }
+
+ protected void buttonSelected(Button button, int index) {
+ if (index == selectAllIndex) {
+ handleSelectAll(true);
+ }
+ if (index == deselectAllIndex) {
+ handleSelectAll(false);
+ }
+ }
+
+ public Object[] getSelection() {
+ CheckboxTableViewer viewer = getTableViewer();
+ return viewer.getCheckedElements();
+ }
+
+ public void setSelection(Object[] selected) {
+ CheckboxTableViewer viewer = getTableViewer();
+ viewer.setCheckedElements(selected);
+ updateCounter(selected.length);
+ }
+
+ public void createControl(Composite parent) {
+ createControl(parent, SWT.NULL, 2);
+ counterLabel = new Label(parent, SWT.NULL);
+ GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
+ counterLabel.setLayoutData(gd);
+ updateCounter(0);
+ }
+
+ protected Button createButton(Composite parent, String label, int index) {
+ Button button = super.createButton(parent, label, index);
+ return button;
+ }
+
+ protected StructuredViewer createStructuredViewer(Composite parent, int style) {
+ StructuredViewer viewer = super.createStructuredViewer(parent, style);
+ return viewer;
+ }
+
+ protected void createMainLabel(Composite parent, int span) {
+ if (tableName == null)
+ return;
+ Label label = new Label(parent, SWT.NULL);
+ label.setText(tableName);
+ GridData gd = new GridData();
+ gd.horizontalSpan = span;
+ label.setLayoutData(gd);
+ }
+
+ protected void updateCounter(int amount) {
+ counter = amount;
+ updateCounterLabel();
+ }
+
+ protected void updateCounterLabel() {
+ String number = EMPTY_STRING + getSelectionCount();
+ String totalNumber = EMPTY_STRING + getTotalCount();
+ String message = MessageFormat.format(MakeUIPlugin.getResourceString(KEY_COUNTER), new String[] { number, totalNumber });
+ counterLabel.setText(message);
+ }
+
+ public int getSelectionCount() {
+ return counter;
+ }
+
+ public void selectAll(boolean select) {
+ handleSelectAll(select);
+ }
+
+ private int getTotalCount() {
+ CheckboxTableViewer viewer = getTableViewer();
+ return viewer.getTable().getItemCount();
+ }
+
+ protected void handleSelectAll(boolean select) {
+ CheckboxTableViewer viewer = getTableViewer();
+ viewer.setAllChecked(select);
+ int selected;
+ if (!select) {
+ selected = 0;
+ } else {
+ selected = getTotalCount();
+ }
+ updateCounter(selected);
+ }
+ protected void elementChecked(Object element, boolean checked) {
+ int count = getSelectionCount();
+ updateCounter(checked ? count + 1 : count - 1);
+ }
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/wizards/StatusWizardPage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/wizards/StatusWizardPage.java
new file mode 100644
index 00000000000..660e8cf57c1
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/wizards/StatusWizardPage.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+package org.eclipse.cdt.make.internal.ui.wizards;
+
+import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.wizard.WizardPage;
+
+public abstract class StatusWizardPage extends WizardPage {
+
+ private IStatus fCurrStatus;
+
+ private boolean fPageVisible;
+ private boolean fNoErrorOnStartup;
+
+ public StatusWizardPage(String name, boolean noErrorOnStartup) {
+ super(name);
+ fPageVisible= false;
+ fCurrStatus= createStatus(IStatus.OK, "");
+ fNoErrorOnStartup= noErrorOnStartup;
+ }
+
+ // ---- WizardPage ----------------
+
+ /*
+ * @see WizardPage#becomesVisible
+ */
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ fPageVisible= visible;
+ // policy: wizards are not allowed to come up with an error message
+ if (visible && fNoErrorOnStartup && fCurrStatus.matches(IStatus.ERROR)) {
+ // keep the error state, but remove the message
+ fCurrStatus= createStatus(IStatus.ERROR, "");
+ }
+ updateStatus(fCurrStatus);
+ }
+
+ /**
+ * Updates the status line and the ok button depending on the status
+ */
+ protected void updateStatus(IStatus status) {
+ fCurrStatus= status;
+ setPageComplete(!status.matches(IStatus.ERROR));
+ if (fPageVisible) {
+ applyToStatusLine(this, status);
+ }
+ }
+
+ /**
+ * Applies the status to a dialog page
+ */
+ public static void applyToStatusLine(DialogPage page, IStatus status) {
+ String errorMessage= null;
+ String warningMessage= null;
+ String statusMessage= status.getMessage();
+ if (statusMessage.length() > 0) {
+ if (status.matches(IStatus.ERROR)) {
+ errorMessage= statusMessage;
+ } else if (!status.isOK()) {
+ warningMessage= statusMessage;
+ }
+ }
+ page.setErrorMessage(errorMessage);
+ page.setMessage(warningMessage,status.getSeverity());
+ }
+
+ public static IStatus getMoreSevere(IStatus s1, IStatus s2) {
+ if (s1.getSeverity() >= s2.getSeverity()) {
+ return s1;
+ } else {
+ return s2;
+ }
+ }
+
+
+ public static IStatus createStatus(int severity, String message) {
+ return new Status(severity, MakeUIPlugin.getUniqueIdentifier(), severity, message, null);
+ }
+
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/wizards/UpdateMakeProjectAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/wizards/UpdateMakeProjectAction.java
new file mode 100644
index 00000000000..262aa12c3ce
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/wizards/UpdateMakeProjectAction.java
@@ -0,0 +1,118 @@
+/*
+ * Created on 25-Jul-2003
+ *
+ * Copyright (c) 2002,2003 QNX Software Systems Ltd.
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.make.internal.ui.wizards;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+
+public class UpdateMakeProjectAction implements IWorkbenchWindowActionDelegate {
+
+ private ISelection fSelection;
+
+ public void dispose() {
+ }
+
+ public void init(IWorkbenchWindow window) {
+ }
+
+ public void run(IAction action) {
+ if (fSelection instanceof IStructuredSelection) {
+ Object[] elems = ((IStructuredSelection) fSelection).toArray();
+ ArrayList projects = new ArrayList(elems.length);
+
+ for (int i = 0; i < elems.length; i++) {
+ Object elem = elems[i];
+ IProject project = null;
+
+ if (elem instanceof IFile) {
+ IFile file = (IFile) elem;
+ project = file.getProject();
+ } else if (elem instanceof IProject) {
+ project = (IProject) elem;
+ } else if (elem instanceof ICProject) {
+ project = ((ICProject) elem).getProject();
+ }
+ if (project != null) {
+ }
+ }
+
+ final IProject[] projectArray = (IProject[]) projects.toArray(new IProject[projects.size()]);
+
+ ProgressMonitorDialog pd = new ProgressMonitorDialog(MakeUIPlugin.getActiveWorkbenchShell());
+ run(true, pd, projectArray);
+ UpdateMakeProjectWizard wizard = new UpdateMakeProjectWizard(projectArray);
+ WizardDialog dialog = new WizardDialog(MakeUIPlugin.getActiveWorkbenchShell(), wizard);
+ dialog.open();
+ }
+
+ }
+
+ static public void run(boolean fork, IRunnableContext context, final IProject[] projects) {
+ try {
+ context.run(fork, true, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ try {
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ doMakeProjectUpdate(monitor, projects);
+ }
+ };
+ MakeUIPlugin.getWorkspace().run(runnable, monitor);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ } catch (OperationCanceledException e) {
+ throw new InterruptedException(e.getMessage());
+ }
+ }
+ });
+ } catch (InterruptedException e) {
+ return;
+ } catch (InvocationTargetException e) {
+ MakeUIPlugin.logException(e, "Error", "Error updateing Make Projects");
+ }
+ }
+
+ public static void doMakeProjectUpdate(IProgressMonitor monitor, IProject[] projects) throws CoreException {
+ // dinglis-TODO : Implement Make project updating.
+ monitor.beginTask("Updating make Projects...", projects.length);
+ try {
+ for (int i = 0; i < projects.length; i++) {
+// IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);
+
+ if (monitor.isCanceled())
+ break;
+ }
+ } finally {
+ monitor.done();
+ }
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ fSelection = selection;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/wizards/UpdateMakeProjectWizard.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/wizards/UpdateMakeProjectWizard.java
new file mode 100644
index 00000000000..8639167e0e7
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/wizards/UpdateMakeProjectWizard.java
@@ -0,0 +1,39 @@
+/*
+ * Created on 28-Jul-2003
+ *
+ * Copyright (c) 2002,2003 QNX Software Systems Ltd.
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.make.internal.ui.wizards;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.wizard.Wizard;
+
+public class UpdateMakeProjectWizard extends Wizard {
+
+ private UpdateMakeProjectWizardPage page1;
+ private IProject[] selected;
+
+ public UpdateMakeProjectWizard(IProject[] selected) {
+ setDefaultPageImageDescriptor(null);
+ setWindowTitle("Update Makefile Projects");
+ setNeedsProgressMonitor(true);
+ this.selected = selected;
+ }
+
+ public boolean performFinish() {
+ Object[] finalSelected = page1.getSelected();
+
+ IProject[] projectArray = new IProject[finalSelected.length];
+ System.arraycopy(finalSelected, 0, projectArray, 0, finalSelected.length);
+ UpdateMakeProjectAction.run(true, getContainer(), projectArray);
+ return true;
+ }
+
+ public void addPages() {
+ page1 = new UpdateMakeProjectWizardPage(selected);
+ addPage(page1);
+ }
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/wizards/UpdateMakeProjectWizardPage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/wizards/UpdateMakeProjectWizardPage.java
new file mode 100644
index 00000000000..b29189f80ef
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/wizards/UpdateMakeProjectWizardPage.java
@@ -0,0 +1,128 @@
+/*
+ * Created on 28-Jul-2003
+ *
+ * Copyright (c) 2002,2003 QNX Software Systems Ltd.
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.make.internal.ui.wizards;
+
+import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
+import org.eclipse.cdt.make.internal.ui.part.WizardCheckboxTablePart;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+public class UpdateMakeProjectWizardPage extends StatusWizardPage {
+
+ private IProject[] selected;
+ private CheckboxTableViewer makeProjectListViewer;
+ private TablePart tablePart;
+
+ public class BuildpathContentProvider implements IStructuredContentProvider {
+ public Object[] getElements(Object parent) {
+ return getProjects();
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ }
+
+ class TablePart extends WizardCheckboxTablePart {
+ public TablePart(String mainLabel) {
+ super(mainLabel);
+ }
+ public void updateCounter(int count) {
+ super.updateCounter(count);
+ dialogChanged();
+ }
+ protected StructuredViewer createStructuredViewer(Composite parent, int style) {
+ StructuredViewer viewer = super.createStructuredViewer(parent, style);
+ return viewer;
+ }
+ }
+
+ public UpdateMakeProjectWizardPage(IProject[] selected) {
+ super("UpdateMakeProjectWizardPage", true);
+ setTitle("Make update title");
+ setDescription("Make update description");
+ this.selected = selected;
+ tablePart = new TablePart("project list");
+ }
+
+ public void dispose() {
+ super.dispose();
+ }
+
+ public void createControl(Composite parent) {
+ Composite container = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 0;
+ layout.marginWidth = 5;
+ container.setLayout(layout);
+
+ tablePart.createControl(container);
+ makeProjectListViewer = tablePart.getTableViewer();
+ makeProjectListViewer.setContentProvider(new BuildpathContentProvider());
+ makeProjectListViewer.setLabelProvider(new WorkbenchLabelProvider());
+
+ GridData gd = (GridData) tablePart.getControl().getLayoutData();
+ gd.heightHint = 300;
+ gd.widthHint = 300;
+
+ makeProjectListViewer.setInput(MakeUIPlugin.getWorkspace().getRoot());
+ tablePart.setSelection(selected);
+ setControl(container);
+ Dialog.applyDialogFont(container);
+ }
+
+ public void storeSettings() {
+ }
+
+ public Object[] getSelected() {
+ return tablePart.getSelection();
+ }
+
+ private void dialogChanged() {
+ IStatus genStatus = validatePlugins();
+ updateStatus(genStatus);
+ }
+
+ private IProject[] getProjects() {
+ return MakeUIPlugin.getWorkspace().getRoot().getProjects();
+// Vector result = new Vector();
+// try {
+//
+// } catch (CoreException e) {
+//// MakeUIPlugin.logException(e);
+// }
+
+// return (IProject[])result.toArray(new IProject[result.size()]);
+ }
+
+ private IStatus validatePlugins() {
+ Object[] allModels = getProjects();
+ if (allModels == null || allModels.length == 0) {
+ return createStatus(IStatus.ERROR, "No projects to update");
+ }
+ if (tablePart.getSelectionCount() == 0) {
+ return createStatus(IStatus.ERROR, "No projects selected");
+ }
+ return createStatus(IStatus.OK, "");
+ }
+}
+
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/BuildPathInfoBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/BuildPathInfoBlock.java
new file mode 100644
index 00000000000..df5822f3f0e
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/BuildPathInfoBlock.java
@@ -0,0 +1,607 @@
+package org.eclipse.cdt.make.ui;
+
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+import org.eclipse.cdt.make.core.IMakeBuilderInfo;
+import org.eclipse.cdt.make.core.MakeBuildManager;
+import org.eclipse.cdt.ui.AbstractCOptionPage;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Shell;
+
+/**********************************************************************
+ * 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:
+ * IBM Rational Software - Initial API and implementation
+***********************************************************************/
+
+public class BuildPathInfoBlock extends AbstractCOptionPage {
+
+ private static final String PREFIX = "BuildPathInfoBlock"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String PATHS = PREFIX + ".paths"; //$NON-NLS-1$
+ private static final String SYMBOLS = PREFIX + ".symbols"; //$NON-NLS-1$
+ private static final String BROWSE = PREFIX + ".browse"; //$NON-NLS-1$
+ private static final String PATH_TITLE = BROWSE + ".path"; //$NON-NLS-1$
+ private static final String PATH_LABEL = BROWSE + ".path.label"; //$NON-NLS-1$
+ private static final String SYMBOL_TITLE = BROWSE + ".symbol"; //$NON-NLS-1$
+ private static final String SYMBOL_LABEL = BROWSE + ".symbol.label"; //$NON-NLS-1$
+ private static final String NEW = "BuildPropertyCommon.label.new"; //$NON-NLS-1$
+ private static final String REMOVE = "BuildPropertyCommon.label.remove"; //$NON-NLS-1$
+ private static final String UP = "BuildPropertyCommon.label.up"; //$NON-NLS-1$
+ private static final String DOWN = "BuildPropertyCommon.label.down"; //$NON-NLS-1$
+
+ private List pathList;
+ private List symbolList;
+ private Composite pathButtonComp;
+ private Button addPath;
+ private Button removePath;
+ private Button pathUp;
+ private Button pathDown;
+ private Composite symbolButtonComp;
+ private Button addSymbol;
+ private Button removeSymbol;
+ private Button symbolUp;
+ private Button symbolDown;
+ private Shell shell;
+
+ /**
+ * @param valid
+ */
+ public BuildPathInfoBlock() {
+ super(CUIPlugin.getResourceString(LABEL));
+ setDescription("Set the include paths and preprocessor symbols for this project");
+ }
+
+ /**
+ * @param composite
+ */
+ private void createPathListButtons(Composite parent) {
+ // Create a composite for the buttons
+ pathButtonComp = ControlFactory.createComposite(parent, 1);
+ pathButtonComp.setFont(parent.getFont());
+
+ // Add the buttons
+ addPath = ControlFactory.createPushButton(pathButtonComp, CUIPlugin.getResourceString(NEW));
+ addPath.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleAddPath();
+ }
+ });
+ addPath.setEnabled(true);
+ addPath.setFont(parent.getFont());
+ addPath.setLayoutData(new GridData());
+ SWTUtil.setButtonDimensionHint(addPath);
+
+ removePath = ControlFactory.createPushButton(pathButtonComp, CUIPlugin.getResourceString(REMOVE));
+ removePath.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleRemovePath();
+ }
+ });
+ removePath.setFont(parent.getFont());
+ removePath.setLayoutData(new GridData());
+ SWTUtil.setButtonDimensionHint(removePath);
+
+ pathUp = ControlFactory.createPushButton(pathButtonComp, CUIPlugin.getResourceString(UP));
+ pathUp.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handlePathUp();
+ }
+ });
+ pathUp.setFont(parent.getFont());
+ pathUp.setLayoutData(new GridData());
+ SWTUtil.setButtonDimensionHint(pathUp);
+
+ pathDown = ControlFactory.createPushButton(pathButtonComp, CUIPlugin.getResourceString(DOWN));
+ pathDown.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handlePathDown();
+ }
+ });
+ pathDown.setFont(parent.getFont());
+ pathDown.setLayoutData(new GridData());
+ SWTUtil.setButtonDimensionHint(pathDown);
+
+ }
+
+ /**
+ * @param composite
+ */
+ private void createPathListControl(Composite parent, int numColumns) {
+ // Create the list
+ pathList = new List(parent, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
+ pathList.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ enablePathButtons();
+ }
+ });
+ pathList.addMouseListener(new MouseListener() {
+
+ public void mouseDoubleClick(MouseEvent e) {
+ editPathListItem();
+ }
+
+ public void mouseDown(MouseEvent e) {
+ // Handled by the selection listener
+ }
+
+ public void mouseUp(MouseEvent e) {
+ // Handled by the selection listener
+ }
+
+ });
+
+ // Make it occupy the first 2 columns
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = numColumns - 1;
+ pathList.setLayoutData(gd);
+ pathList.setFont(parent.getFont());
+ }
+
+ /**
+ * @param composite
+ */
+ private void createSymbolListButtons(Composite parent) {
+ // Create a composite for the buttons
+ symbolButtonComp = ControlFactory.createComposite(parent, 1);
+ symbolButtonComp.setFont(parent.getFont());
+
+ // Add the buttons
+ addSymbol = ControlFactory.createPushButton(symbolButtonComp, CUIPlugin.getResourceString(NEW));
+ addSymbol.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleAddSymbol();
+ }
+ });
+ addSymbol.setEnabled(true);
+ addSymbol.setFont(parent.getFont());
+ addSymbol.setLayoutData(new GridData());
+ SWTUtil.setButtonDimensionHint(addSymbol);
+
+ removeSymbol = ControlFactory.createPushButton(symbolButtonComp, CUIPlugin.getResourceString(REMOVE));
+ removeSymbol.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleRemoveSymbol();
+ }
+ });
+ removeSymbol.setFont(parent.getFont());
+ removeSymbol.setLayoutData(new GridData());
+ SWTUtil.setButtonDimensionHint(removeSymbol);
+
+ symbolUp = ControlFactory.createPushButton(symbolButtonComp, CUIPlugin.getResourceString(UP));
+ symbolUp.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleSymbolUp();
+ }
+ });
+ symbolUp.setFont(parent.getFont());
+ symbolUp.setLayoutData(new GridData());
+ SWTUtil.setButtonDimensionHint(symbolUp);
+
+ symbolDown = ControlFactory.createPushButton(symbolButtonComp, CUIPlugin.getResourceString(DOWN));
+ symbolDown.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleSymbolDown();
+ }
+ });
+ symbolDown.setFont(parent.getFont());
+ symbolDown.setLayoutData(new GridData());
+ SWTUtil.setButtonDimensionHint(symbolDown);
+ }
+
+ /**
+ * @param composite
+ */
+ private void createSymbolListControl(Composite parent, int numColumns) {
+ // Create the list
+ symbolList = new List(parent, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
+ symbolList.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ enableSymbolButtons();
+ }
+ });
+ symbolList.addMouseListener(new MouseListener() {
+
+ public void mouseDoubleClick(MouseEvent e) {
+ editSymbolListItem();
+ }
+
+ public void mouseDown(MouseEvent e) {
+ // Handled by the selection event
+ }
+
+ public void mouseUp(MouseEvent e) {
+ // Handled by the selection event
+ }
+ });
+
+ // Make it occupy the first n-1 columns
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = numColumns - 1;
+ symbolList.setLayoutData(gd);
+ symbolList.setFont(parent.getFont());
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.wizards.IWizardTab#doRun(org.eclipse.core.resources.IProject, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void performApply(IProgressMonitor monitor) throws CoreException {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ if (getContainer().getProject() != null) {
+ // Store the paths and symbols
+ monitor.beginTask("Setting Include Paths", 1);
+ MakeBuildManager.setIncludePaths(getContainer().getProject(), getPathListContents());
+
+ monitor.beginTask("Setting Defined Symbols", 1);
+ MakeBuildManager.setPreprocessorSymbols(getContainer().getProject(), getSymbolListContents());
+
+ MakeBuildManager.saveBuildInfo(getContainer().getProject());
+ }
+ }
+
+ public void performDefaults() {
+ pathList.removeAll();
+ symbolList.removeAll();
+ if (getContainer().getProject() != null) {
+ // dinglis-TODO: set list to preference settings
+ }
+ }
+
+ /*
+ * Double-click handler to allow edit of path information
+ */
+ protected void editPathListItem() {
+ // Edit the selection index
+ int index = pathList.getSelectionIndex();
+ if (index != -1) {
+ String selItem = pathList.getItem(index);
+ if (selItem != null) {
+ InputDialog dialog =
+ new InputDialog(
+ shell,
+ CUIPlugin.getResourceString(PATH_TITLE),
+ CUIPlugin.getResourceString(PATH_LABEL),
+ selItem,
+ null);
+ String newItem = null;
+ if (dialog.open() == InputDialog.OK) {
+ newItem = dialog.getValue();
+ if (newItem != null && !newItem.equals(selItem)) {
+ pathList.setItem(index, newItem);
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * Double-click handler to allow edit of symbol information
+ */
+ protected void editSymbolListItem() {
+ // Edit the selection index
+ int index = symbolList.getSelectionIndex();
+ if (index != -1) {
+ String selItem = symbolList.getItem(index);
+ if (selItem != null) {
+ InputDialog dialog =
+ new InputDialog(
+ shell,
+ CUIPlugin.getResourceString(SYMBOL_TITLE),
+ CUIPlugin.getResourceString(SYMBOL_LABEL),
+ selItem,
+ null);
+ String newItem = null;
+ if (dialog.open() == InputDialog.OK) {
+ newItem = dialog.getValue();
+ if (newItem != null && !newItem.equals(selItem)) {
+ symbolList.setItem(index, newItem);
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * Enables the buttons on the path control if the right conditions are met
+ */
+ private void enablePathButtons() {
+ // Enable the remove button if there is at least 1 item in the list
+ int items = pathList.getItemCount();
+ if (items > 0) {
+ removePath.setEnabled(true);
+ // Enable the up/down buttons depending on what item is selected
+ int index = pathList.getSelectionIndex();
+ pathUp.setEnabled(items > 1 && index > 0);
+ pathDown.setEnabled(items > 1 && index < (items - 1));
+ } else {
+ removePath.setEnabled(false);
+ pathUp.setEnabled(false);
+ pathDown.setEnabled(false);
+ }
+ }
+
+ private void enableSymbolButtons() {
+ // Enable the remove button if there is at least 1 item in the list
+ int items = symbolList.getItemCount();
+ if (items > 0) {
+ removeSymbol.setEnabled(true);
+ // Enable the up/down buttons depending on what item is selected
+ int index = symbolList.getSelectionIndex();
+ symbolUp.setEnabled(items > 1 && index > 0);
+ symbolDown.setEnabled(items > 1 && index < (items - 1));
+ } else {
+ removeSymbol.setEnabled(false);
+ symbolUp.setEnabled(false);
+ symbolDown.setEnabled(false);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.wizards.IWizardTab#getControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ this.shell = parent.getShell();
+
+ // Create the composite control for the tab
+ int tabColumns = 3;
+ Font font = parent.getFont();
+ Composite composite = ControlFactory.createComposite(parent, tabColumns);
+ composite.setFont(font);
+ GridData gd;
+
+ // Create a label for the include paths control
+ Label paths = ControlFactory.createLabel(composite, CUIPlugin.getResourceString(PATHS));
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = tabColumns;
+ paths.setLayoutData(gd);
+ paths.setFont(font);
+
+ //Create the list and button controls
+ createPathListControl(composite, tabColumns);
+ createPathListButtons(composite);
+ enablePathButtons();
+
+ // Create a label for the symbols control
+ Label symbols = ControlFactory.createLabel(composite, CUIPlugin.getResourceString(SYMBOLS));
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = tabColumns;
+ symbols.setLayoutData(gd);
+ symbols.setFont(font);
+
+ // Create list and button controls for symbols
+ createSymbolListControl(composite, tabColumns);
+ createSymbolListButtons(composite);
+ enableSymbolButtons();
+
+ setPathListContents();
+ pathList.select(0);
+ enablePathButtons();
+ setSymbolListContents();
+ symbolList.select(0);
+ enableSymbolButtons();
+ setControl(composite);
+ }
+
+ /**
+ * @return
+ */
+ private String[] getPathListContents() {
+ return pathList.getItems();
+ }
+
+ /**
+ * @return
+ */
+ private String[] getSymbolListContents() {
+ return symbolList.getItems();
+ }
+
+ /**
+ *
+ */
+ protected void handleAddPath() {
+ // Popup an entry dialog
+ InputDialog dialog =
+ new InputDialog(shell, CUIPlugin.getResourceString(PATH_TITLE), CUIPlugin.getResourceString(PATH_LABEL), "", null);
+ String path = null;
+ if (dialog.open() == InputDialog.OK) {
+ path = dialog.getValue();
+ }
+ if (path != null && path.length() > 0) {
+ pathList.add(path);
+ pathList.select(pathList.getItemCount() - 1);
+ enablePathButtons();
+ }
+ }
+
+ /**
+ *
+ */
+ protected void handleAddSymbol() {
+ // Popup an entry dialog
+ InputDialog dialog =
+ new InputDialog(shell, CUIPlugin.getResourceString(SYMBOL_TITLE), CUIPlugin.getResourceString(SYMBOL_LABEL), "", null);
+ String symbol = null;
+ if (dialog.open() == InputDialog.OK) {
+ symbol = dialog.getValue();
+ }
+ if (symbol != null && symbol.length() > 0) {
+ symbolList.add(symbol);
+ symbolList.select(symbolList.getItemCount() - 1);
+ enableSymbolButtons();
+ }
+ }
+
+ /**
+ *
+ */
+ protected void handlePathDown() {
+ // Get the selection index
+ int index = pathList.getSelectionIndex();
+ int items = pathList.getItemCount();
+ if (index == -1 || index == items - 1) {
+ return;
+ }
+ // Swap the items in the list
+ String selItem = pathList.getItem(index);
+ pathList.remove(index);
+ if (index + 1 == items) {
+ pathList.add(selItem);
+ } else {
+ pathList.add(selItem, ++index);
+ }
+
+ // Keep the swapped item selected
+ pathList.select(index);
+ enablePathButtons();
+ }
+
+ /**
+ *
+ */
+ protected void handlePathUp() {
+ // Get the selection index
+ int index = pathList.getSelectionIndex();
+ if (index == -1 || index == 0) {
+ return;
+ }
+ // Swap the items in the list
+ String selItem = pathList.getItem(index);
+ pathList.remove(index);
+ pathList.add(selItem, --index);
+
+ // Keep the index selected
+ pathList.select(index);
+ enablePathButtons();
+ }
+
+ /**
+ *
+ */
+ protected void handleRemovePath() {
+ // Get the selection index
+ int index = pathList.getSelectionIndex();
+ if (index == -1) {
+ return;
+ }
+
+ // Remove the element at that index
+ pathList.remove(index);
+ index = index - 1 < 0 ? 0 : index - 1;
+ pathList.select(index);
+
+ // Check if the buttons should still be enabled
+ enablePathButtons();
+ }
+
+ /**
+ *
+ */
+ protected void handleRemoveSymbol() {
+ // Get the selection index
+ int index = symbolList.getSelectionIndex();
+ if (index == -1) {
+ return;
+ }
+ // Remove the item at that index
+ symbolList.remove(index);
+ index = index - 1 < 0 ? 0 : index - 1;
+ symbolList.select(index);
+ // Check if the button state should be toggled
+ enableSymbolButtons();
+ }
+
+ /**
+ *
+ */
+ protected void handleSymbolDown() {
+ // Get the selection index
+ int index = symbolList.getSelectionIndex();
+ int items = symbolList.getItemCount();
+ if (index == -1 || index == items - 1) {
+ return;
+ }
+ // Swap the items in the list
+ String selItem = symbolList.getItem(index);
+ symbolList.remove(index);
+ if (index + 1 == items) {
+ symbolList.add(selItem);
+ } else {
+ symbolList.add(selItem, ++index);
+ }
+
+ // Keep the swapped item selected
+ symbolList.select(index);
+ enableSymbolButtons();
+ }
+
+ /**
+ *
+ */
+ protected void handleSymbolUp() {
+ // Get the selection index
+ int index = symbolList.getSelectionIndex();
+ if (index == -1 || index == 0) {
+ return;
+ }
+ // Swap the items in the list
+ String selItem = symbolList.getItem(index);
+ symbolList.remove(index);
+ symbolList.add(selItem, --index);
+
+ // Keep the index selected
+ symbolList.select(index);
+ enableSymbolButtons();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.ui.wizards.IWizardTab#isValid()
+ */
+ public boolean isValid() {
+ // Info on this page is not critical
+ return true;
+ }
+
+ private void setPathListContents() {
+ if (getContainer().getProject() != null) {
+ try {
+ IMakeBuilderInfo info = MakeBuildManager.getBuildInfo(getContainer().getProject());
+ pathList.setItems(info.getIncludePaths());
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ private void setSymbolListContents() {
+ if (getContainer().getProject() != null) {
+ try {
+ IMakeBuilderInfo info = MakeBuildManager.getBuildInfo(getContainer().getProject());
+ symbolList.setItems(info.getPreprocessorSymbols());
+ } catch (CoreException e) {
+ }
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/SettingsBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/SettingsBlock.java
new file mode 100644
index 00000000000..610a2c376d5
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/SettingsBlock.java
@@ -0,0 +1,331 @@
+package org.eclipse.cdt.make.ui;
+
+/*
+ * (c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.cdt.make.core.BuildInfoFactory;
+import org.eclipse.cdt.make.core.IMakeBuilderInfo;
+import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
+import org.eclipse.cdt.ui.AbstractCOptionPage;
+import org.eclipse.cdt.ui.ICOptionContainer;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.cdt.utils.ui.controls.RadioButtonsArea;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+
+public class SettingsBlock extends AbstractCOptionPage {
+
+ private static final String PREFIX = "SettingsBlock"; //$NON-NLS-1$
+ private static final String MAKE_LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String MAKE_MESSAGE = PREFIX + ".message"; //$NON-NLS-1$
+
+ private static final String MAKE_SETTING_GROUP = PREFIX + ".makeSetting.group_label"; //$NON-NLS-1$
+ private static final String MAKE_SETTING_KEEP_GOING = PREFIX + ".makeSetting.keepOnGoing"; //$NON-NLS-1$
+ private static final String MAKE_SETTING_STOP_ERROR = PREFIX + ".makeSetting.stopOnError"; //$NON-NLS-1$
+
+ private static final String MAKE_CMD_GROUP = PREFIX + ".makeCmd.group_label"; //$NON-NLS-1$
+ private static final String MAKE_CMD_USE_DEFAULT = PREFIX + ".makeCmd.use_default"; //$NON-NLS-1$
+ private static final String MAKE_CMD_LABEL = PREFIX + ".makeCmd.label";
+
+ private static final String MAKE_WORKBENCH_BUILD_GROUP = PREFIX + ".makeWorkbench.group_label";
+ private static final String MAKE_WORKBENCH_BUILD_TYPE = PREFIX + ".makeWorkbench.type";
+ private static final String MAKE_WORKBENCH_BUILD_TARGET = PREFIX + ".makeWorkbench.target";
+ private static final String MAKE_WORKBENCH_BUILD_AUTO = PREFIX + ".makeWorkbench.auto";
+ private static final String MAKE_WORKBENCH_BUILD_INCR = PREFIX + ".makeWorkbench.incremental";
+ private static final String MAKE_WORKBENCH_BUILD_FULL = PREFIX + ".makeWorkbench.full";
+
+ private static final String MAKE_BUILD_DIR_GROUP = PREFIX + ".makeDir.group_label";
+ private static final String MAKE_BUILD_DIR_LABEL = PREFIX + ".makeDir.label";
+ private static final String MAKE_BUILD_DIR_BROWSE = PREFIX + ".makeDir.browse";
+
+ private static final String KEEP_ARG = "keep"; //$NON-NLS-1$
+ private static final String STOP_ARG = "stop"; //$NON-NLS-1$
+
+ protected RadioButtonsArea stopRadioButtons;
+ protected Button defButton;
+ protected Text cmdText;
+ protected Text makeDirText;
+
+ private Text targetFull;
+ private Text targetIncr;
+ private Text targetAuto;
+ private Button fFullButton;
+ private Button fIncrButton;
+ private Button fAutoButton;
+
+ private IMakeBuilderInfo fBuildInfo;
+ private Preferences fPrefs;
+ private String fBuilderID;
+
+ public SettingsBlock(Preferences prefs, String builderID) {
+ super(MakeUIPlugin.getResourceString(MAKE_LABEL));
+ setDescription(MakeUIPlugin.getResourceString(MAKE_MESSAGE));
+ fPrefs = prefs;
+ fBuilderID = builderID;
+ }
+
+ protected void createSettingControls(Composite parent) {
+ String[][] radios = new String[][] { { MakeUIPlugin.getResourceString(MAKE_SETTING_STOP_ERROR), STOP_ARG }, {
+ MakeUIPlugin.getResourceString(MAKE_SETTING_KEEP_GOING), KEEP_ARG }
+ };
+ stopRadioButtons = new RadioButtonsArea(parent, MakeUIPlugin.getResourceString(MAKE_SETTING_GROUP), 1, radios);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ stopRadioButtons.setLayout(layout);
+ if (fBuildInfo.isStopOnError())
+ stopRadioButtons.setSelectValue(STOP_ARG);
+ else
+ stopRadioButtons.setSelectValue(KEEP_ARG);
+ }
+
+ protected void createBuildCmdControls(Composite parent) {
+ Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_CMD_GROUP), 1);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.makeColumnsEqualWidth = false;
+ layout.horizontalSpacing = 0;
+ group.setLayout(layout);
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ defButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_CMD_USE_DEFAULT));
+ defButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (defButton.getSelection() == true) {
+ cmdText.setEnabled(false);
+ stopRadioButtons.setEnabled(true);
+ getContainer().updateContainer();
+ } else {
+ cmdText.setEnabled(true);
+ stopRadioButtons.setEnabled(false);
+ getContainer().updateContainer();
+ }
+ }
+ });
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ defButton.setLayoutData(gd);
+ Label label = ControlFactory.createLabel(group, MakeUIPlugin.getResourceString(MAKE_CMD_LABEL));
+ ((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING;
+ ((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false;
+ cmdText = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
+ ((GridData) (cmdText.getLayoutData())).horizontalAlignment = GridData.FILL;
+ ((GridData) (cmdText.getLayoutData())).grabExcessHorizontalSpace = true;
+ cmdText.addListener(SWT.Modify, new Listener() {
+ public void handleEvent(Event e) {
+ getContainer().updateContainer();
+ }
+ });
+ if (fBuildInfo.getBuildCommand() != null) {
+ StringBuffer cmd = new StringBuffer(fBuildInfo.getBuildCommand().toOSString());
+ String args = fBuildInfo.getBuildArguments();
+ if ( args != null && !args.equals("")) {
+ cmd.append(" ");
+ cmd.append(args);
+ }
+ cmdText.setText(cmd.toString());
+ }
+ if (fBuildInfo.isDefaultBuildCmd()) {
+ cmdText.setEnabled(false);
+ } else {
+ stopRadioButtons.setEnabled(false);
+ }
+ defButton.setSelection(fBuildInfo.isDefaultBuildCmd());
+ }
+
+ protected void createWorkBenchBuildControls(Composite parent) {
+ SelectionAdapter selectionAdapter = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ targetAuto.setEnabled(fAutoButton.getSelection());
+ targetFull.setEnabled(fFullButton.getSelection());
+ targetIncr.setEnabled(fIncrButton.getSelection());
+ getContainer().updateContainer();
+ }
+
+ };
+ Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_GROUP), 1);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.makeColumnsEqualWidth = false;
+ group.setLayout(layout);
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ Label label = new Label(group, SWT.NONE);
+ label.setText(MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_TYPE));
+ label = new Label(group, SWT.NONE);
+ label.setText(MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_TARGET));
+ fAutoButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_AUTO));
+ fAutoButton.addSelectionListener(selectionAdapter);
+ fAutoButton.setSelection(fBuildInfo.isAutoBuildEnable());
+ targetAuto = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
+ targetAuto.setText(fBuildInfo.getAutoBuildTarget());
+ ((GridData) (targetAuto.getLayoutData())).horizontalAlignment = GridData.FILL;
+ ((GridData) (targetAuto.getLayoutData())).grabExcessHorizontalSpace = true;
+ fIncrButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_INCR));
+ fIncrButton.addSelectionListener(selectionAdapter);
+ fIncrButton.setSelection(fBuildInfo.isIncrementalBuildEnabled());
+ targetIncr = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
+ targetIncr.setText(fBuildInfo.getIncrementalBuildTarget());
+ ((GridData) (targetIncr.getLayoutData())).horizontalAlignment = GridData.FILL;
+ ((GridData) (targetIncr.getLayoutData())).grabExcessHorizontalSpace = true;
+ fFullButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_FULL));
+ fFullButton.addSelectionListener(selectionAdapter);
+ fFullButton.setSelection(fBuildInfo.isFullBuildEnabled());
+ targetFull = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
+ targetFull.setText(fBuildInfo.getFullBuildTarget());
+ ((GridData) (targetFull.getLayoutData())).horizontalAlignment = GridData.FILL;
+ ((GridData) (targetFull.getLayoutData())).grabExcessHorizontalSpace = true;
+ selectionAdapter.widgetSelected(null);
+ }
+
+ protected void createBuilderWorkingDirControls(Composite parent) {
+ Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_BUILD_DIR_GROUP), 1);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ layout.makeColumnsEqualWidth = false;
+ group.setLayout(layout);
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ Label label = ControlFactory.createLabel(group, MakeUIPlugin.getResourceString(MAKE_BUILD_DIR_LABEL));
+ ((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING;
+ ((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false;
+ makeDirText = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
+ ((GridData) (makeDirText.getLayoutData())).horizontalAlignment = GridData.FILL;
+ ((GridData) (makeDirText.getLayoutData())).grabExcessHorizontalSpace = true;
+ makeDirText.addListener(SWT.Modify, new Listener() {
+ public void handleEvent(Event e) {
+ getContainer().updateContainer();
+ }
+ });
+ Button browse = new Button(group, SWT.NONE);
+ browse.setText(MakeUIPlugin.getResourceString(MAKE_BUILD_DIR_BROWSE));
+ browse.addSelectionListener(new SelectionListener() {
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ public void widgetSelected(SelectionEvent e) {
+ }
+ });
+ makeDirText.setText(fBuildInfo.getBuildLocation().toOSString());
+ }
+
+ public void createControl(Composite parent) {
+ Composite composite = ControlFactory.createComposite(parent, 1);
+
+ createSettingControls(composite);
+ createBuildCmdControls(composite);
+ createWorkBenchBuildControls(composite);
+
+ if (getContainer().getProject() != null) {
+ createBuilderWorkingDirControls(composite);
+ }
+
+ setControl(composite);
+ }
+
+ public boolean isValid() {
+ if (defButton.getSelection() != true) {
+ String cmd = getBuildLine();
+ if (cmd == null || cmd.length() == 0) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public void performApply(IProgressMonitor monitor) throws CoreException {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ monitor.beginTask("Settings", 1);
+ IMakeBuilderInfo info;
+ if (getContainer().getProject() != null) {
+ info = BuildInfoFactory.create(getContainer().getProject(), fBuilderID);
+ } else {
+ info = BuildInfoFactory.create(fPrefs, fBuilderID);
+ }
+ info.setStopOnError(isStopOnError());
+ info.setUseDefaultBuildCmd(useDefaultBuildCmd());
+ if (!useDefaultBuildCmd()) {
+ String bldLine = getBuildLine();
+ int start = 0;
+ int end = -1;
+ if (!bldLine.startsWith("\"")) {
+ end = bldLine.indexOf(' ');
+ } else {
+ start = 1;
+ end = bldLine.indexOf('"', 1);
+ }
+ IPath path;
+ if (end == -1) {
+ path = new Path(bldLine);
+ } else {
+ path = new Path(bldLine.substring(start, end));
+ }
+ info.setBuildCommand(path);
+ String args = "";
+ if (end != -1) {
+ args = bldLine.substring(end + 1);
+ }
+ info.setBuildArguments(args);
+ }
+ }
+
+ public void performDefaults() {
+ if (getContainer().getProject() != null) {
+ } else {
+
+ }
+ }
+
+ private boolean isStopOnError() {
+ return stopRadioButtons.getSelectedValue().equals(STOP_ARG);
+ }
+
+ private boolean useDefaultBuildCmd() {
+ return defButton.getSelection();
+ }
+
+ private String getBuildLine() {
+ if (cmdText != null) {
+ String cmd = cmdText.getText();
+ if (cmd != null)
+ return cmd.trim();
+ }
+ return null;
+ }
+
+ public void setContainer(ICOptionContainer container) {
+ super.setContainer(container);
+ if (getContainer().getProject() != null) {
+ fBuildInfo = BuildInfoFactory.create(getContainer().getProject(), fBuilderID);
+ } else {
+ fBuildInfo = BuildInfoFactory.create(fPrefs, fBuilderID);
+ }
+ }
+
+ public String getErrorMessage() {
+ if (defButton.getSelection() != true) {
+ String cmd = getBuildLine();
+ if (cmd == null || cmd.length() == 0) {
+ return "Must enter a build command";
+ }
+ }
+ return null;
+ }
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/CreateBuildAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/CreateBuildAction.java
new file mode 100644
index 00000000000..ee1541bbb63
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/CreateBuildAction.java
@@ -0,0 +1,14 @@
+/*
+ * Created on 25-Jul-2003
+ *
+ * Copyright (c) 2002,2003 QNX Software Systems Ltd.
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.make.ui.actions;
+
+public class CreateBuildAction extends MakeAction {
+
+
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/MakeAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/MakeAction.java
new file mode 100644
index 00000000000..f3ec3cb570a
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/MakeAction.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+package org.eclipse.cdt.make.ui.actions;
+
+import org.eclipse.cdt.make.ui.views.MakeTarget;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.actions.ActionDelegate;
+
+public class MakeAction extends ActionDelegate implements IObjectActionDelegate {
+ ISelection fSelection;
+ IWorkbenchPart part;
+
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ part = targetPart;
+ }
+
+ /**
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(IAction action) {
+ if (fSelection instanceof IStructuredSelection
+ && ((IStructuredSelection) fSelection).getFirstElement() instanceof IProject) {
+ IProject project = (IProject) ((IStructuredSelection) fSelection).getFirstElement();
+ MakeBuildAction build = null;
+ if (action.getId().equals("org.eclipse.cdt.make.ui.makeAction.all")) {
+ build = new MakeBuildAction(new org.eclipse.cdt.make.ui.views.MakeTarget[] { new MakeTarget(project, "all")}, part.getSite().getShell(), "all");
+ } else if (action.getId().equals("org.eclipse.cdt.make.ui.makeAction.clean")) {
+ build = new MakeBuildAction(new MakeTarget[] { new MakeTarget(project, "all")}, part.getSite().getShell(), "all");
+ } else if (action.getId().equals("org.eclipse.cdt.make.ui.makeAction.rebuild")) {
+ build = new MakeBuildAction(new MakeTarget[] { new MakeTarget(project, "all")}, part.getSite().getShell(), "all");
+ }
+ if ( build != null ) {
+ build.run();
+ }
+ }
+ }
+ /**
+ * @see IActionDelegate#selectionChanged(IAction, ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ fSelection = selection;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/MakeBuildAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/MakeBuildAction.java
new file mode 100644
index 00000000000..3e908dcfe7e
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/MakeBuildAction.java
@@ -0,0 +1,110 @@
+package org.eclipse.cdt.make.ui.actions;
+
+/*
+ * (c) Copyright QNX Software Systems Ltd. 2002.
+ * All Rights Reserved.
+ */
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.make.ui.views.MakeTarget;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.BuildAction;
+
+
+public class MakeBuildAction extends Action {
+ static final String PREFIX = "BuildAction.";
+
+ MakeTarget[] targets;
+ Shell shell;
+
+ public MakeBuildAction (MakeTarget[] targets, Shell shell, String s) {
+ super (s);
+ this.shell = shell;
+ this.targets = targets;
+
+ setToolTipText(PREFIX);
+ setImageDescriptor(CPluginImages.DESC_BUILD_MENU);
+ }
+
+ /**
+ * Causes all editors to save any modified resources depending on the user's
+ * preference.
+ */
+ void saveAllResources() {
+
+ if (!BuildAction.isSaveAllSet())
+ return;
+
+ List projects = new ArrayList();
+ for (int i = 0; i < targets.length; ++i ) {
+ MakeTarget target = targets[i];
+ projects.add(target.getResource().getProject());
+ }
+
+ IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
+ for (int i = 0; i < windows.length; i++) {
+ IWorkbenchPage [] pages = windows[i].getPages();
+ for (int j = 0; j < pages.length; j++) {
+ IWorkbenchPage page = pages[j];
+ IEditorReference[] editorReferences = page.getEditorReferences();
+ for (int k = 0; k < editorReferences.length; k++) {
+ IEditorPart editor = editorReferences[k].getEditor(false);
+ if (editor != null && editor.isDirty()) {
+ IEditorInput input = editor.getEditorInput();
+ if (input instanceof IFileEditorInput) {
+ IFile inputFile = ((IFileEditorInput)input).getFile();
+ if (projects.contains(inputFile.getProject())) {
+ page.saveEditor(editor, false);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void run() {
+ try {
+ saveAllResources();
+ IRunnableWithProgress op = new IRunnableWithProgress () {
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ for (int i = 0; i < targets.length; ++i ) {
+// MakeTarget target = targets[i];
+// IResource res = target.getResource();
+// IProject project = res.getProject();
+
+// try {
+// if (! project.equals(res) || target.isLeaf()) {
+// String dir = res.getLocation().toOSString();
+// }
+// project.build (IncrementalProjectBuilder.FULL_BUILD, MakeBuilder.BUILDER_ID, monitor);
+// } catch (CoreException e) {
+// }
+ }
+ }
+ };
+ new ProgressMonitorDialog(shell).run(true, true, op);
+ } catch (InvocationTargetException e) {
+ // handle exception
+ } catch (InterruptedException e) {
+ // handle cancelation
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/preferences/MakePreferencePage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/preferences/MakePreferencePage.java
new file mode 100644
index 00000000000..7055ac68100
--- /dev/null
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/preferences/MakePreferencePage.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+package org.eclipse.cdt.make.ui.preferences;
+
+import org.eclipse.cdt.make.internal.ui.MakeProjectOptionBlock;
+import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
+import org.eclipse.cdt.ui.ICOptionContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * This class represents a preference page that
+ * is contributed to the Preferences dialog. By
+ * subclassing FieldEditorPreferencePage, we
+ * can use the field support built into JFace that allows
+ * us to create a page that is small and knows how to
+ * save, restore and apply itself.
+ * + * This page is used to modify preferences only. They + * are stored in the preference store that belongs to + * the main plug-in class. That way, preferences can + * be accessed directly via the preference store. + */ + +public class MakePreferencePage extends PreferencePage implements IWorkbenchPreferencePage, ICOptionContainer { + + private MakeProjectOptionBlock fOptionBlock; + + public MakePreferencePage() { + setPreferenceStore(MakeUIPlugin.getDefault().getPreferenceStore()); + setDescription("Make Project Preferences"); + fOptionBlock = new MakeProjectOptionBlock(this); + } + + /* + * @see PreferencePage#createControl(Composite) + */ + public void createControl(Composite parent) { + super.createControl(parent); + // WorkbenchHelp.setHelp(parent, ICMakeHelpContextIds.PROJECT_PROPERTY_PAGE); + } + + protected Control createContents(Composite parent) { + return fOptionBlock.createContents(parent); + } + + + public void init(IWorkbench workbench) { + } + + public boolean performOk() { + return fOptionBlock.performOk(null); + } + + /** + * @see DialogPage#setVisible(boolean) + */ + public void setVisible(boolean visible) { + super.setVisible(visible); + fOptionBlock.setVisible(visible); + } + + public void updateContainer() { + fOptionBlock.update(); + boolean ok = fOptionBlock.isValid(); + if (!ok) { + setErrorMessage(fOptionBlock.getErrorMessage()); + } + if (ok) { + setErrorMessage(null); + } + setValid(ok); + } + + public IProject getProject() { + return null; + } + + public boolean isValid() { + updateContainer(); + return super.isValid(); + } + + protected void performDefaults() { + fOptionBlock.performDefaults(); + super.performDefaults(); + } + +} \ No newline at end of file diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/properties/MakePropertyPage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/properties/MakePropertyPage.java new file mode 100644 index 00000000000..857b98f3fb2 --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/properties/MakePropertyPage.java @@ -0,0 +1,125 @@ +/******************************************************************************* + * 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 + *******************************************************************************/ +package org.eclipse.cdt.make.ui.properties; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.cdt.make.internal.ui.MakeProjectOptionBlock; +import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; +import org.eclipse.cdt.ui.ICOptionContainer; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +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.swt.widgets.Shell; +import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation; +import org.eclipse.ui.dialogs.PropertyPage; + +public class MakePropertyPage extends PropertyPage implements ICOptionContainer { + + private MakeProjectOptionBlock fOptionBlock; + + private static final String MSG_CLOSEDPROJECT = "MakeProjectPropertyPage.closedproject"; + + public MakePropertyPage() { + super(); + fOptionBlock = new MakeProjectOptionBlock(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(MakeUIPlugin.getResourceString(MSG_CLOSEDPROJECT)); + label.setFont(parent.getFont()); + + noDefaultAndApplyButton(); + } + + /** + * @see PreferencePage#performOk + */ + public boolean performOk() { + Shell shell = getControl().getShell(); + IRunnableWithProgress runnable = new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + fOptionBlock.performOk(monitor); + } + }; + IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable); + try { + new ProgressMonitorDialog(shell).run(false, true, op); + } catch (InvocationTargetException e) { + // dinglis-TODO show/log errors + return false; + } catch (InterruptedException e) { + // cancelled + return 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); + } + + 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(); + } + +} diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeContentProvider.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeContentProvider.java new file mode 100644 index 00000000000..77848aa5977 --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeContentProvider.java @@ -0,0 +1,168 @@ +package org.eclipse.cdt.make.ui.views; + +/* + * (c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + */ + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.widgets.Control; + +public class MakeContentProvider implements ITreeContentProvider, IResourceChangeListener { + + protected Viewer viewer; + + /** + * Constructor for MakeContentProvider + */ + public MakeContentProvider() { + super(); + } + + /** + * @see ITreeContentProvider#getChildren(Object) + */ + public Object[] getChildren(Object obj) { + if (obj instanceof MakeTarget) { + MakeTarget md = (MakeTarget)obj; + return (Object[])md.getChildren(); + } + return new Object[0]; + } + + /** + * @see ITreeContentProvider#getParent(Object) + */ + public Object getParent(Object obj) { + if (obj instanceof MakeTarget) { + MakeTarget directives = (MakeTarget)obj; + return directives.getParent(); + } + return null; + } + + /** + * @see ITreeContentProvider#hasChildren(Object) + */ + public boolean hasChildren(Object obj) { + return getChildren(obj).length > 0; + } + + /** + * @see IStructuredContentProvider#getElements(Object) + */ + public Object[] getElements(Object obj) { + return getChildren(obj); + } + + /** + * @see IContentProvider#dispose() + */ + public void dispose() { + if (viewer != null) { + Object obj = viewer.getInput(); + if (obj instanceof MakeTarget) { + MakeTarget target = (MakeTarget)obj; + IWorkspace workspace = target.getResource().getWorkspace(); + workspace.removeResourceChangeListener(this); + } + } + } + + /** + * @see IContentProvider#inputChanged(Viewer, Object, Object) + */ + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + this.viewer = viewer; + if (oldInput != null) { + if (oldInput instanceof MakeTarget) { + IResource res = ((MakeTarget)oldInput).getResource(); + if (res instanceof IWorkspaceRoot) { + IWorkspace workspace = res.getWorkspace(); + workspace.removeResourceChangeListener(this); + } + } + } + if (newInput != null) { + if (newInput instanceof MakeTarget) { + IResource res = ((MakeTarget)newInput).getResource(); + if (res instanceof IWorkspaceRoot) { + IWorkspace workspace = res.getWorkspace(); + workspace.addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE); + } + } + } + } + + public void resourceChanged (final IResourceChangeEvent event) { + final IResourceDelta deltas = event.getDelta(); + Control ctrl = viewer.getControl(); + if (ctrl != null && !ctrl.isDisposed()) { + // Get the affected resource + ctrl.getDisplay().syncExec(new Runnable() { + public void run() { + processDelta (deltas); + } + }); + } + } + + void processDelta (IResourceDelta delta) { + // Bail out if the widget was disposed. + Control ctrl = viewer.getControl(); + if (ctrl == null || ctrl.isDisposed()) { + return; + } + + if (delta == null) { + return; + } + + int changeFlags = delta.getFlags(); + + IResourceDelta[] affectedChildren = + delta.getAffectedChildren(IResourceDelta.CHANGED); + + // Not interested in Content changes. + for (int i = 0; i < affectedChildren.length; i++) { + if ((affectedChildren[i].getFlags() & IResourceDelta.TYPE) != 0) { + return; + } + } + + // handle open and closing. + if ((changeFlags & (IResourceDelta.OPEN | IResourceDelta.SYNC)) != 0) { + ctrl.setRedraw(false); + viewer.refresh(); + ctrl.setRedraw(true); + return; + } + + // Handle changed children recursively. + for (int i = 0; i < affectedChildren.length; i++) { + processDelta(affectedChildren[i]); + } + + // We are only interested in creation and deletion of folders. + affectedChildren = delta.getAffectedChildren(IResourceDelta.REMOVED | IResourceDelta.ADDED); + if (affectedChildren.length > 0) { + for (int i = 0; i < affectedChildren.length; i++) { + IResource r = affectedChildren[i].getResource(); + if (r instanceof IContainer) { + ctrl.setRedraw(false); + viewer.refresh(); + ctrl.setRedraw(true); + break; + } + } + } + } +} diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeLabelProvider.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeLabelProvider.java new file mode 100644 index 00000000000..3da97ecd610 --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeLabelProvider.java @@ -0,0 +1,78 @@ +package org.eclipse.cdt.make.ui.views; + +/* + * (c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + */ + +import java.util.Hashtable; +import java.util.Map; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.swt.graphics.Image; + +public class MakeLabelProvider implements ILabelProvider { + + /** + * The cache of images that have been dispensed by this provider. + * Maps ImageDescriptor->Image. + */ + private Map imageTable = null; + + /** + * @see ILabelProvider#getImage(Object) + */ + public Image getImage(Object obj) { + Image image = null; + //obtain the cached image corresponding to the descriptor + if (imageTable == null) { + imageTable = new Hashtable(4); + } + if (obj instanceof MakeTarget) { + ImageDescriptor descriptor = ((MakeTarget)obj).getImageDescriptor(); + image = (Image) imageTable.get(descriptor); + if (image == null) { + image = descriptor.createImage(); + imageTable.put(descriptor, image); + } + } + return image; + } + + /** + * @see ILabelProvider#getText(Object) + */ + public String getText(Object obj) { + if (obj instanceof MakeTarget) { + return ((MakeTarget)obj).toString(); + } + return ""; + } + + /** + * @see IBaseLabelProvider#addListener(ILabelProviderListener) + */ + public void addListener(ILabelProviderListener arg0) { + } + + /** + * @see IBaseLabelProvider#dispose() + */ + public void dispose() { + } + + /** + * @see IBaseLabelProvider#isLabelProperty(Object, String) + */ + public boolean isLabelProperty(Object arg0, String arg1) { + return false; + } + + /** + * @see IBaseLabelProvider#removeListener(ILabelProviderListener) + */ + public void removeListener(ILabelProviderListener arg0) { + } +} diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeTarget.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeTarget.java new file mode 100644 index 00000000000..2fb19c0734a --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeTarget.java @@ -0,0 +1,139 @@ +package org.eclipse.cdt.make.ui.views; + +/* + * (c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + */ + +import java.util.ArrayList; + +import org.eclipse.cdt.core.CProjectNature; +import org.eclipse.cdt.internal.ui.CPluginImages; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.model.IWorkbenchAdapter; + + +/** + * A leaf is a IResource with a Make Directive. + * We use the term Directive instead of Make Targets + * to not confuse with remote targets. + */ + +public class MakeTarget implements IAdaptable { + + private static final MakeTarget[] emptyArray= new MakeTarget[0]; + private IResource resource; + private String target; + + public MakeTarget(IResource res) { + this(res, ""); + } + + public MakeTarget(IResource res, String goals) { + resource = res; + target = (goals == null) ? "" : goals; + } + + /** + * @see IAdaptable#getAdapter(Object) + */ + public Object getAdapter(Class adapter) { + if (adapter == IResource.class) { + return resource; + } + return null; + } + + /** + */ + public MakeTarget[] getChildren() { + if (resource != null && target.length() == 0) { + ArrayList list = new ArrayList(); + if (resource instanceof IWorkspaceRoot) { + IWorkspaceRoot root = (IWorkspaceRoot)resource; + IProject [] projects = root.getProjects(); + for (int i = 0; i < projects.length; i++) { + if (projects[i].isOpen()) { + try { + if (projects[i].hasNature(CProjectNature.C_NATURE_ID)) { + list.add (new MakeTarget(projects[i])); + } + } catch (CoreException e) { + } + } + } + } else if (resource instanceof IContainer) { + IContainer container = (IContainer)resource; + try { + IResource[] resources = container.members(); + for (int i = 0; i < resources.length; i++) { + if (resources[i] instanceof IContainer) { + list.add (new MakeTarget(resources[i])); + } + } + } catch (CoreException e) { + } +// String [] targets = MakeUtil.getPersistentTargets(resource); +// for (int i = 0; i < targets.length; i++) { +// if (targets[i] == null) +// targets[i] = ""; +// list.add (new MakeTarget(resource, targets[i])); +// } + } + return (MakeTarget[])list.toArray(emptyArray); + } + return emptyArray; + } + + /** + */ + public MakeTarget getParent() { + if (target.length() == 0) + return new MakeTarget(resource.getParent()); + return new MakeTarget(resource); + } + + public String toString() { + if (target.length() == 0) + return resource.getName(); + return target; + } + + public ImageDescriptor getImageDescriptor() { + if (isLeaf()) { + return CPluginImages.DESC_BUILD_MENU; + } + IWorkbenchAdapter adapter = (IWorkbenchAdapter)((IAdaptable)resource).getAdapter(IWorkbenchAdapter.class); + if (adapter == null) + return null; + return adapter.getImageDescriptor(resource); + } + + public IResource getResource () { + return resource; + } + + public boolean isLeaf () { + return (target.length() != 0); + } + + /** + * @see Object#equals(Object) + */ + public boolean equals(Object obj) { + if (null == obj) + return false; + + if (!(obj instanceof MakeTarget)) + return false; + + MakeTarget other = (MakeTarget)obj; + return (resource.equals(other.resource) && target.equals(other.target)); + } +} diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeTargetAction.java new file mode 100644 index 00000000000..c837d63816c --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeTargetAction.java @@ -0,0 +1,47 @@ +package org.eclipse.cdt.make.ui.views; + +/* + * (c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + */ + +import org.eclipse.cdt.internal.ui.CPluginImages; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Shell; + + +public class MakeTargetAction extends Action { + + Shell shell; + IResource resource; + + public MakeTargetAction (Shell shell) { + super("Add Make Targets"); + this.shell = shell; + + setToolTipText("BuildAction"); + setImageDescriptor(CPluginImages.DESC_BUILD_MENU); + } + + public void run() { + InputDialog dialog = new InputDialog(shell, "Target Dialog: ", "Enter Target(s): ", null, null); + dialog.open(); + //String value = dialog.getValue(); +// if (value != null && value.length() > 0) { +// if (resource != null) +// MakeUtil.addPersistentTarget(resource, value); +// } + } + + public void selectionChanged(IStructuredSelection selection) { + Object obj = (IAdaptable)selection.getFirstElement(); + if (obj instanceof IAdaptable) { + IAdaptable element = (IAdaptable)obj; + resource = (IResource)element.getAdapter(IResource.class); + } + } +} diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeView.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeView.java new file mode 100644 index 00000000000..200325d9687 --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeView.java @@ -0,0 +1,182 @@ +package org.eclipse.cdt.make.ui.views; + +/* + * (c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + */ + +import org.eclipse.cdt.make.ui.actions.MakeBuildAction; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IMenuListener; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.dialogs.InputDialog; +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.part.ViewPart; + +public class MakeView extends ViewPart { + + TreeViewer viewer; + + public MakeView() { + super(); + } + + /** + * @see IWorkbenchPart#setFocus() + */ + public void setFocus() { + viewer.getTree().setFocus(); + } + + /** + * Handles double clicks in viewer. + * Opens editor if file double-clicked. + */ + protected void handleDoubleClick(DoubleClickEvent event) { + IStructuredSelection s = (IStructuredSelection) event.getSelection(); + Object element = s.getFirstElement(); + //System.out.println ("Double click on " + element); + if (element instanceof MakeTarget) { + MakeTarget ta = (MakeTarget) element; + Action build = new MakeBuildAction(new MakeTarget[] { ta }, getViewSite().getShell(), "Build"); + build.run(); + } + //if (viewer.isExpandable(element)) { + // viewer.setExpandedState(element, !viewer.getExpandedState(element)); + //} + } + + /** + * called to create the context menu of the outline + */ + protected void contextMenuAboutToShow(IMenuManager menu) { + IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); + Object element = selection.getFirstElement(); + if (element instanceof MakeTarget) { + final MakeTarget ta = (MakeTarget) element; + Action add = new Action("Add...") { + public void run() { + InputDialog dialog = + new InputDialog(getViewSite().getShell(), "Target Dialog: ", "Enter Target(s): ", null, null); + dialog.open(); + String value = dialog.getValue(); + if (value != null && value.length() > 0) { +// IResource res = ta.getResource(); +// MakeUtil.addPersistentTarget(res, value); + viewer.getControl().setRedraw(false); + viewer.refresh(); + viewer.getControl().setRedraw(true); + viewer.expandToLevel(ta, 2); + } + } + }; + Action edit = new Action("Edit...") { + public void run() { + String oldtarget = ta.toString(); + InputDialog dialog = + new InputDialog(getViewSite().getShell(), "Target Dialog: ", "Enter Target(s): ", oldtarget, null); + dialog.open(); + String value = dialog.getValue(); + if (value != null && value.length() > 0 && !value.equals(oldtarget)) { +// IResource res = ta.getResource(); +// MakeUtil.replacePersistentTarget(res, oldtarget, value); + viewer.getControl().setRedraw(false); + viewer.refresh(); + viewer.getControl().setRedraw(true); + viewer.expandToLevel(ta, 2); + } + } + }; + + Action del = new Action("Delete") { + public void run() { + String target = ta.toString(); + if (target != null) { +// IResource res = ta.getResource(); +// MakeUtil.removePersistentTarget(res, target); + viewer.getControl().setRedraw(false); + viewer.refresh(); + viewer.getControl().setRedraw(true); + } + } + }; + + Action build = new MakeBuildAction(new MakeTarget[] { ta }, getViewSite().getShell(), "Build"); + + menu.add(add); + menu.add(edit); + menu.add(del); + //menu.add (new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + menu.add(build); + if (ta.isLeaf()) { + add.setEnabled(false); + } else { + edit.setEnabled(false); + del.setEnabled(false); + } + } + //menu.add (new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end")); + } + + private void contributeToActionBars() { + IActionBars bars = getViewSite().getActionBars(); +// fillLocalPullDown(bars.getMenuManager()); + fillLocalToolBar(bars.getToolBarManager()); + } + + private void fillLocalToolBar(IToolBarManager toolBar) { + Action refreshAllAction = new Action("Refresh") { + public void run() { + viewer.refresh(); + } + + }; + toolBar.add(refreshAllAction); + } + + /** + * @see ContentOutlinePage#createControl + */ + public void createPartControl(Composite parent) { + + viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); + viewer.setUseHashlookup(true); + viewer.setContentProvider(new MakeContentProvider()); + viewer.setLabelProvider(new MakeLabelProvider()); + + MenuManager manager = new MenuManager("#PopUp"); + manager.setRemoveAllWhenShown(true); + manager.addMenuListener(new IMenuListener() { + public void menuAboutToShow(IMenuManager manager) { + contextMenuAboutToShow(manager); + } + }); + + Control control = viewer.getControl(); + Menu menu = manager.createContextMenu(control); + control.setMenu(menu); + + viewer.setInput(new MakeTarget(ResourcesPlugin.getWorkspace().getRoot())); + + viewer.addDoubleClickListener(new IDoubleClickListener() { + public void doubleClick(DoubleClickEvent event) { + handleDoubleClick(event); + } + }); + + contributeToActionBars(); + + getSite().setSelectionProvider(viewer); + } +} diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/ConvertToMakeProjectWizard.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/ConvertToMakeProjectWizard.java new file mode 100644 index 00000000000..b25697c6a26 --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/ConvertToMakeProjectWizard.java @@ -0,0 +1,104 @@ +package org.eclipse.cdt.make.ui.wizards; + +/* + * (c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + */ + +import org.eclipse.cdt.make.core.MakeCorePlugin; +import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; +import org.eclipse.cdt.ui.wizards.conversion.ConversionWizard; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.SubProgressMonitor; + +/** + * This wizard provides a method by which the user can + * add a C nature to a project that previously had no nature associated with it. + */ +public class ConvertToMakeProjectWizard extends ConversionWizard { + + private MakeProjectWizardOptionPage optionsPage; + private static final String WZ_TITLE = "WizardMakeProjectConversion.title"; //$NON-NLS-1$ + private static final String WZ_DESC = "WizardMakeProjectConversion.description"; //$NON-NLS-1$ + private static final String PREFIX = "WizardMakeConversion"; //$NON-NLS-1$ + private static final String WINDOW_TITLE = "WizardMakeConversion.windowTitle"; //$NON-NLS-1$ + + private static final String WZ_SETTINGS_TITLE = "WizardMakeProjectConversionSettings.title"; //$NON-NLS-1$ + private static final String WZ_SETTINGS_DESC = "WizardMakeProjectConversionSettings.description"; //$NON-NLS-1$ + + /** + * ConvertToStdMakeConversionWizard Wizard constructor + */ + public ConvertToMakeProjectWizard() { + this(getWindowTitleResource(), getWzDescriptionResource()); + } + /** + * ConvertToStdMakeConversionWizard Wizard constructor + * + * @param title + * @param desc + */ + public ConvertToMakeProjectWizard(String title, String desc) { + super(title, desc); + } + + /** + * Method getWzDescriptionResource, allows Wizard description label value + * to be changed by subclasses + * + * @return String + */ + protected static String getWzDescriptionResource() { + return MakeUIPlugin.getResourceString(WZ_DESC); + } + + /** + * Method getWzTitleResource, allows Wizard description label value + * to be changed by subclasses + * + * @return String + */ + protected static String getWzTitleResource() { + return MakeUIPlugin.getResourceString(WZ_TITLE); + } + + /** + * Method getWindowTitleResource, allows Wizard Title label value to be + * changed by subclasses + * + * @return String + */ + protected static String getWindowTitleResource() { + return MakeUIPlugin.getResourceString(WINDOW_TITLE); + } + + /** + * Method getPrefix, allows prefix value to be changed by subclasses + * + * @return String + */ + protected static String getPrefix() { + return PREFIX; + } + + /** + * Method addPages adds our Simple to C conversion Wizard page. + * + * @see Wizard#createPages + */ + public void addPages() { + addPage(mainPage = new ConvertToMakeProjectWizardPage(getPrefix())); + addPage(optionsPage = new MakeProjectWizardOptionPage(MakeUIPlugin.getResourceString(WZ_SETTINGS_TITLE), MakeUIPlugin.getResourceString(WZ_SETTINGS_DESC))); + } + + public String getProjectID() { + return MakeCorePlugin.getUniqueIdentifier() + ".make"; //$NON-NLS-1$ + } + + protected void doRun(IProgressMonitor monitor) throws CoreException { + monitor.beginTask("Converting to Make Project", 2); + super.doRun(new SubProgressMonitor(monitor, 1)); + optionsPage.performApply(new SubProgressMonitor(monitor, 1)); + } +} diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/ConvertToMakeProjectWizardPage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/ConvertToMakeProjectWizardPage.java new file mode 100644 index 00000000000..70a69ac9312 --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/ConvertToMakeProjectWizardPage.java @@ -0,0 +1,67 @@ +package org.eclipse.cdt.make.ui.wizards; + +/* + * (c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + */ + +import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; +import org.eclipse.cdt.ui.wizards.conversion.ConvertProjectWizardPage; +import org.eclipse.core.resources.IProject; + +/** + * + * ConvertToStdMakeProjectWizardPage + * Standard main page for a wizard that adds a C project Nature to a project with no nature associated with it. + * This conversion is one way in that the project cannot be converted back (i.e have the nature removed). + * + * @author Judy N. Green + * @since Aug 6, 2002 + *
+ * Example useage: + *
+ * mainPage = new ConvertToStdMakeProjectWizardPage("ConvertProjectPage"); + * mainPage.setTitle("Project Conversion"); + * mainPage.setDescription("Add C or C++ a Nature to a project."); + *+ * + */ +public class ConvertToMakeProjectWizardPage extends ConvertProjectWizardPage { + + private static final String WZ_TITLE = "WizardMakeProjectConversion.title"; //$NON-NLS-1$ + private static final String WZ_DESC = "WizardMakeProjectConversion.description"; //$NON-NLS-1$ + + /** + * Constructor for ConvertToStdMakeProjectWizardPage. + * @param pageName + */ + public ConvertToMakeProjectWizardPage(String pageName) { + super(pageName); + } + + /** + * Method getWzTitleResource returns the correct Title Label for this class + * overriding the default in the superclass. + */ + protected String getWzTitleResource(){ + return MakeUIPlugin.getResourceString(WZ_TITLE); + } + + /** + * Method getWzDescriptionResource returns the correct description + * Label for this class overriding the default in the superclass. + */ + protected String getWzDescriptionResource(){ + return MakeUIPlugin.getResourceString(WZ_DESC); + } + + /** + * Method isCandidate returns true for all projects. + * + * @param project + * @return boolean + */ + public boolean isCandidate(IProject project) { + return true; // all + } +} diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/MakeProjectWizardOptionPage.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/MakeProjectWizardOptionPage.java new file mode 100644 index 00000000000..8db21ed415f --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/MakeProjectWizardOptionPage.java @@ -0,0 +1,59 @@ +package org.eclipse.cdt.make.ui.wizards; + +/* + * (c) Copyright IBM Corp. 2000, 2001. + * All Rights Reserved. + */ + +import org.eclipse.cdt.make.internal.ui.MakeProjectOptionBlock; +import org.eclipse.cdt.ui.TabFolderOptionBlock; +import org.eclipse.cdt.ui.ICOptionContainer; +import org.eclipse.cdt.ui.ReferenceBlock; +import org.eclipse.cdt.ui.wizards.CProjectWizard; +import org.eclipse.cdt.ui.wizards.CProjectWizardOptionPage; +import org.eclipse.core.resources.IProject; +import org.eclipse.swt.widgets.TabItem; + +/** + * Standard main page for a wizard that is creates a project resource. + *
+ * This page may be used by clients as-is; it may be also be subclassed to suit. + *
+ *+ * Example useage: + *
+ * mainPage = new CProjectWizardPage("basicCProjectPage"); + * mainPage.setTitle("Project"); + * mainPage.setDescription("Create a new project resource."); + *+ * + */ +public class MakeProjectWizardOptionPage extends CProjectWizardOptionPage { + + public class WizardOptionBlock extends MakeProjectOptionBlock { + + public WizardOptionBlock(ICOptionContainer parent) { + super(parent); + } + + protected TabItem addTabs() { + TabItem item = addTab(new ReferenceBlock()); + super.addTabs(); + return item; + } + } + + public MakeProjectWizardOptionPage(String title, String description) { + super("MakeProjectSettingsPage"); + setTitle(title); + setDescription(description); + } + + protected TabFolderOptionBlock createOptionBlock() { + return new WizardOptionBlock(this); + } + + public IProject getProject() { + return ((CProjectWizard)getWizard()).getNewProject(); + } +} diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/NewMakeCCProjectWizard.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/NewMakeCCProjectWizard.java new file mode 100644 index 00000000000..90147413725 --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/NewMakeCCProjectWizard.java @@ -0,0 +1,51 @@ +package org.eclipse.cdt.make.ui.wizards; + +/* + * (c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + */ + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.SubProgressMonitor; + +/** + */ +public class NewMakeCCProjectWizard extends NewMakeProjectWizard { + + private static final String WZ_TITLE = "MakeCCWizard.title"; //$NON-NLS-1$ + private static final String WZ_DESC = "MakeCCWizard.description"; //$NON-NLS-1$ + + private static final String WZ_SETTINGS_TITLE = "MakeCCWizard.title"; //$NON-NLS-1$ + private static final String WZ_SETTINGS_DESC = "MakeCCWizard.description"; //$NON-NLS-1$ + + public NewMakeCCProjectWizard() { + super(MakeUIPlugin.getResourceString(WZ_TITLE), MakeUIPlugin.getResourceString(WZ_DESC)); + } + + public void addPages() { + super.addPages(); + addPage( + fOptionPage = + new MakeProjectWizardOptionPage( + MakeUIPlugin.getResourceString(WZ_SETTINGS_TITLE), + MakeUIPlugin.getResourceString(WZ_SETTINGS_DESC))); + } + + protected void doRun(IProgressMonitor monitor) throws CoreException { + if (monitor == null) { + monitor = new NullProgressMonitor(); + } + monitor.beginTask(MakeUIPlugin.getResourceString("MakeCCWizard.task_name"), 10); //$NON-NLS-1$ + super.doRun(new SubProgressMonitor(monitor, 9)); + // Add C++ Nature. + if (newProject != null) { + // Add C++ Nature to the newly created project. + CCorePlugin.getDefault().convertProjectFromCtoCC(newProject, new SubProgressMonitor(monitor, 1)); + } + monitor.done(); + } +} diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/NewMakeCProjectWizard.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/NewMakeCProjectWizard.java new file mode 100644 index 00000000000..dc55fddf9e0 --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/NewMakeCProjectWizard.java @@ -0,0 +1,33 @@ +package org.eclipse.cdt.make.ui.wizards; + +/* + * (c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + */ + +import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; + +/** + */ +public class NewMakeCProjectWizard extends NewMakeProjectWizard { + + private static final String WZ_TITLE = "MakeCWizard.title"; //$NON-NLS-1$ + private static final String WZ_DESC = "MakeCWizard.description"; //$NON-NLS-1$' + + private static final String WZ_SETTINGS_TITLE = "MakeCWizardSettings.title"; //$NON-NLS-1$ + private static final String WZ_SETTINGS_DESC = "MakeCWizardSettings.description"; //$NON-NLS-1$' + + public NewMakeCProjectWizard() { + super(MakeUIPlugin.getResourceString(WZ_TITLE), MakeUIPlugin.getResourceString(WZ_DESC)); + } + + public void addPages() { + super.addPages(); + addPage( + fOptionPage = + new MakeProjectWizardOptionPage( + MakeUIPlugin.getResourceString(WZ_SETTINGS_TITLE), + MakeUIPlugin.getResourceString(WZ_SETTINGS_DESC))); + } + +} diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/NewMakeProjectWizard.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/NewMakeProjectWizard.java new file mode 100644 index 00000000000..279deebc2b9 --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/wizards/NewMakeProjectWizard.java @@ -0,0 +1,54 @@ +package org.eclipse.cdt.make.ui.wizards; + +/* + * (c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + */ + +import org.eclipse.cdt.make.core.MakeCorePlugin; +import org.eclipse.cdt.make.core.MakeProjectNature; +import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; +import org.eclipse.cdt.ui.wizards.CProjectWizard; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.SubProgressMonitor; + +/** + */ +public abstract class NewMakeProjectWizard extends CProjectWizard { + + protected MakeProjectWizardOptionPage fOptionPage; + + public NewMakeProjectWizard(String title, String desc) { + super(title, desc); + } + + protected void doRunPrologue(IProgressMonitor monitor) { + } + + protected void doRunEpilogue(IProgressMonitor monitor) { + } + + protected void doRun(IProgressMonitor monitor) throws CoreException { + if (monitor == null) { + monitor = new NullProgressMonitor(); + } + monitor.beginTask(MakeUIPlugin.getResourceString("MakeCWizard.task_name"), 10); //$NON-NLS-1$ + + // super.doRun() just creates the project and does not assign a builder to it. + super.doRun(new SubProgressMonitor(monitor, 5)); + + MakeProjectNature.addNature(getProjectHandle(), new SubProgressMonitor(monitor, 1)); + + // Modify the project based on what the user has selected + if (newProject != null) { + fOptionPage.performApply(new SubProgressMonitor(monitor, 4)); + monitor.done(); + } + } + + public String getProjectID() { + return MakeCorePlugin.getUniqueIdentifier() + ".make"; + } +}