Boost logo

Boost-Commit :

From: frank.birbacher_at_[hidden]
Date: 2008-05-26 10:41:20


Author: birbacher
Date: 2008-05-26 10:41:19 EDT (Mon, 26 May 2008)
New Revision: 45770
URL: http://svn.boost.org/trac/boost/changeset/45770

Log:
Added free-text options field to specify BJam options directly.
Text files modified:
   sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/system/JamTarget.java | 10 +++++++
   sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/system/JamTargetInfo.java | 11 ++++++++
   sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/system/JamfileScanner.java | 7 +++-
   sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/views/JamfileTargetsView.java | 52 ++++++++++++++++++++++++++++++++++++---
   sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/views/MakeTargetAction.java | 16 +++++++++---
   sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/views/ViewContentProvider.java | 17 +++++++-----
   6 files changed, 95 insertions(+), 18 deletions(-)

Modified: sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/system/JamTarget.java
==============================================================================
--- sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/system/JamTarget.java (original)
+++ sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/system/JamTarget.java 2008-05-26 10:41:19 EDT (Mon, 26 May 2008)
@@ -7,6 +7,7 @@
 package org.boost.eclipse.bjam.system;
 
 import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
 
 public class JamTarget {
     private final JamTargetInfo targetInfo;
@@ -15,6 +16,11 @@
      */
     private IContainer container;
 
+ public JamTarget(final IContainer container, final JamTargetInfo info) {
+ this.targetInfo = info;
+ this.container = container;
+ }
+
     public JamTarget(IContainer container, String name, String targetName) {
         this.targetInfo = new JamTargetInfo(name, targetName);
         this.container = container;
@@ -35,4 +41,8 @@
     public String getTargetName() {
         return targetInfo.getTargetName();
     }
+
+ public IFile getResource() {
+ return targetInfo.getResource();
+ }
 }

Modified: sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/system/JamTargetInfo.java
==============================================================================
--- sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/system/JamTargetInfo.java (original)
+++ sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/system/JamTargetInfo.java 2008-05-26 10:41:19 EDT (Mon, 26 May 2008)
@@ -6,6 +6,8 @@
  */
 package org.boost.eclipse.bjam.system;
 
+import org.eclipse.core.resources.IFile;
+
 public class JamTargetInfo {
     /**
      * Name of this target which is shown in the UI.
@@ -15,6 +17,7 @@
      * The commandline string which will be appended to the bjam invocation.
      */
     private String targetName;
+ private IFile resource;
 
     public JamTargetInfo(String name, String targetName) {
         this.name = name;
@@ -32,4 +35,12 @@
     public String getTargetName() {
         return targetName;
     }
+
+ public void setResource(final IFile file) {
+ resource = file;
+ }
+
+ public IFile getResource() {
+ return resource;
+ }
 }

Modified: sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/system/JamfileScanner.java
==============================================================================
--- sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/system/JamfileScanner.java (original)
+++ sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/system/JamfileScanner.java 2008-05-26 10:41:19 EDT (Mon, 26 May 2008)
@@ -19,14 +19,17 @@
             if (!file.exists())
                 break abort;
             final Reader reader = new InputStreamReader(file.getContents());
- return getTargets(new BufferedReader(reader));
+ final JamTargetInfo[] result = getTargets(new BufferedReader(reader));
+ for (JamTargetInfo info : result)
+ info.setResource(file);
+ return result;
         } catch (Exception t) {
             throw new RuntimeException(t);
         }
         return new JamTargetInfo[0];
     }
 
- static public JamTargetInfo[] getTargets(final BufferedReader reader) {
+ static private JamTargetInfo[] getTargets(final BufferedReader reader) {
         final ArrayList<JamTargetInfo> targets = new ArrayList<JamTargetInfo>();
         try {
             while (true) {

Modified: sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/views/JamfileTargetsView.java
==============================================================================
--- sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/views/JamfileTargetsView.java (original)
+++ sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/views/JamfileTargetsView.java 2008-05-26 10:41:19 EDT (Mon, 26 May 2008)
@@ -26,8 +26,11 @@
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.IActionBars;
 import org.eclipse.ui.IWorkbenchActionConstants;
 import org.eclipse.ui.part.DrillDownAdapter;
@@ -49,6 +52,7 @@
  */
 
 public class JamfileTargetsView extends ViewPart {
+ private org.eclipse.swt.widgets.Text optionsField;
     private TreeViewer viewer;
     private DrillDownAdapter drillDownAdapter;
     private Action rebuildAction;
@@ -73,9 +77,12 @@
      * This is a callback that will allow us to create the viewer and initialize
      * it.
      */
- public void createPartControl(Composite parent) {
- viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ public void createPartControl(final Composite parent) {
+ createTextField(parent);
+ createTreeView(parent);
         drillDownAdapter = new DrillDownAdapter(viewer);
+ parent.setLayout(new org.eclipse.swt.layout.GridLayout(1, true));
+
         viewer.setContentProvider(new ViewContentProvider());
         viewer.setLabelProvider(new ViewLabelProvider());
         viewer.setSorter(new NameSorter());
@@ -86,6 +93,30 @@
         contributeToActionBars();
     }
 
+ private void createTreeView(final Composite parent) {
+ final Composite viewerParent = new Composite(parent, 0);
+ viewerParent.setLayout(new FillLayout());
+ final GridData data2 = new GridData();
+ data2.horizontalAlignment = GridData.FILL;
+ data2.grabExcessHorizontalSpace = true;
+ data2.verticalAlignment = GridData.FILL;
+ data2.grabExcessVerticalSpace = true;
+ viewerParent.setLayoutData(data2);
+
+ viewer = new TreeViewer(viewerParent, SWT.MULTI | SWT.H_SCROLL
+ | SWT.V_SCROLL);
+ }
+
+ private void createTextField(final Composite parent) {
+ optionsField = new Text(parent, SWT.SINGLE);
+ optionsField
+ .setToolTipText("Specify additional options here. They will be passed to BJam.");
+ final GridData data1 = new GridData();
+ data1.horizontalAlignment = GridData.FILL;
+ data1.grabExcessHorizontalSpace = true;
+ optionsField.setLayoutData(data1);
+ }
+
     private void hookContextMenu() {
         MenuManager menuMgr = new MenuManager("#PopupMenu");
         menuMgr.setRemoveAllWhenShown(true);
@@ -130,24 +161,35 @@
     }
 
     private void makeActions() {
- buildAction = new MakeTargetAction(viewer);
+ final Object dynamicOptions = new Object() {
+ @Override
+ public String toString() {
+ return getOptions();
+ }
+ };
+
+ buildAction = new MakeTargetAction(viewer, dynamicOptions);
         buildAction.setText("build");
         buildAction.setToolTipText("update target as needed");
         buildAction.setImageDescriptor(MakeUIImages.DESC_BUILD_TARGET);
 
- rebuildAction = new MakeTargetAction(viewer, "-a");
+ rebuildAction = new MakeTargetAction(viewer, "-a", dynamicOptions);
         rebuildAction.setText("rebuild");
         rebuildAction.setToolTipText("forces a rebuild of all files");
         MakeUIImages.setImageDescriptors(rebuildAction, "tool16",
                 MakeUIImages.IMG_TOOLS_MAKE_TARGET_BUILD);
 
- cleanAction = new MakeTargetAction(viewer, "--clean");
+ cleanAction = new MakeTargetAction(viewer, "--clean", dynamicOptions);
         cleanAction.setText("clean");
         cleanAction.setToolTipText("clean this target");
         MakeUIImages.setImageDescriptors(cleanAction, "tool16",
                 MakeUIImages.IMG_TOOLS_MAKE_TARGET_DELETE);
     }
 
+ public String getOptions() {
+ return optionsField.getText();
+ }
+
     private void hookDoubleClickAction() {
         viewer.addDoubleClickListener(new IDoubleClickListener() {
             public void doubleClick(DoubleClickEvent event) {

Modified: sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/views/MakeTargetAction.java
==============================================================================
--- sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/views/MakeTargetAction.java (original)
+++ sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/views/MakeTargetAction.java 2008-05-26 10:41:19 EDT (Mon, 26 May 2008)
@@ -6,7 +6,6 @@
  */
 package org.boost.eclipse.bjam.views;
 
-
 import org.boost.eclipse.bjam.system.JamTarget;
 import org.eclipse.cdt.make.core.IMakeTarget;
 import org.eclipse.cdt.make.core.IMakeTargetManager;
@@ -27,14 +26,21 @@
 class MakeTargetAction extends Action {
     private final TreeViewer viewer;
     private final String arguments;
+ /**
+ * Using the toString() method just when a target is built. That way this
+ * object can pass additional options to bjam.
+ */
+ private final Object dynamicOptions;
 
- MakeTargetAction(final TreeViewer viewer) {
- this(viewer, null);
+ MakeTargetAction(final TreeViewer viewer, final Object dynamicOptions) {
+ this(viewer, null, dynamicOptions);
     }
 
- MakeTargetAction(final TreeViewer viewer, final String arguments) {
+ MakeTargetAction(final TreeViewer viewer, final String arguments,
+ final Object dynamicOptions) {
         this.viewer = viewer;
         this.arguments = arguments;
+ this.dynamicOptions = dynamicOptions;
     }
 
     private class RecursiveBuilder {
@@ -87,6 +93,8 @@
             if (arguments != null)
                 makeTarget.setBuildArguments(makeTarget.getBuildArguments()
                         + " " + arguments);
+ makeTarget.setBuildArguments(makeTarget.getBuildArguments() + " "
+ + dynamicOptions);
             makeTarget.setBuildTarget(target.getTargetName());
             TargetBuild.buildTargets(shell, new IMakeTarget[] { makeTarget });
         } catch (CoreException e) {

Modified: sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/views/ViewContentProvider.java
==============================================================================
--- sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/views/ViewContentProvider.java (original)
+++ sandbox-branches/birbacher/eclipse_contrib/JamfileTargets/src/org/boost/eclipse/bjam/views/ViewContentProvider.java 2008-05-26 10:41:19 EDT (Mon, 26 May 2008)
@@ -6,7 +6,7 @@
  */
 package org.boost.eclipse.bjam.views;
 
-
+import java.io.File;
 import java.util.ArrayList;
 
 import org.boost.eclipse.bjam.system.JamTarget;
@@ -82,14 +82,10 @@
                         result.add(resource);
                     if (resource instanceof IFile) {
                         final IFile file = (IFile) resource;
- final String name = file.getName();
- if (name.equalsIgnoreCase("jamfile")
- || name.equalsIgnoreCase("jamfile.v2")
- || name.equalsIgnoreCase("jamroot")) {
+ if (isProperJamfile(file)) {
                             for (final JamTargetInfo info : JamfileScanner
                                     .getTargets(file))
- result.add(new JamTarget(container, info
- .getName(), info.getTargetName()));
+ result.add(new JamTarget(container, info));
                         }
                     }
                 }
@@ -100,6 +96,13 @@
         return result.toArray();
     }
 
+ private boolean isProperJamfile(final IFile file) {
+ final String name = file.getName();
+ return name.equalsIgnoreCase("jamfile")
+ || name.equalsIgnoreCase("jamfile.v2")
+ || name.equalsIgnoreCase("jamroot");
+ }
+
     public boolean hasChildren(Object parent) {
         return getChildren(parent).length > 0;
     }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk