Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Using the MBSCustomPage Class

This is how I got it to work:

Here is a portion of my plugin.xml file with comments:


<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension point="org.eclipse.cdt.managedbuilder.ui.newWizardPages">
       <wizardPage
             ID="addProjectWizards.wizardPage1"
            
             operationClass="addProjectRunnables.AIMWizardPageRunnable"    
             <!-- you must write this class which is called when you press "Finish"
             on the last page of the wizard. Use this to read the options entered on each wizard page
             and to generate your project
             This class must implement the IRunnableWithProgress interface:
             public class AIMWizardPageRunnable implements IRunnableWithProgress {
                  ......
                  ......
                  ......
                  /***
                 * createFolder
                 * Create a folder in the project
                 * @folder is the folder to create
                 */
                 private static void createFolder(IFolder folder) throws CoreException {
                    IContainer parent = folder.getParent();
                    if (parent instanceof IFolder) {
                        createFolder((IFolder) parent);
                    }
                    if (!folder.exists()) {
                        folder.create(false, true, null);
                    }
                }
       
                /**
                 * Create the desired folder structure.
                 *
                 * @newProject is the handle to the project being created
                 * @param paths is an array of strings describing the folders to create
                 */
                private static void addToProjectStructure(IProject newProject, String[] paths) throws CoreException {
                    for (String path : paths) {
                        IFolder etcFolders = newProject.getFolder(path);
                        createFolder(etcFolders);
                    }
                }
       
              @Override
                   public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                 // write code here which reads widgets from your wizard and creates the project)
                        
                   // Create project structure in workspace...
                       String[] paths = new String[2];
                       paths[0] = "src";
                       paths[1] = "src/folder1";
                 addToProjectStructure(project, paths);
                      
                       // it's probably not how it should be done, but I modify a .cproject file based on the user choices and copy it into the project
                       modifyFile(tempFolderPath+".cproject");
                  copyFile(tempFolderPath+".cproject", ".cproject", project);
             }
             -->
            
             pageClass="addProjectWizards.AIMWizardPage">
             <!-- you must write this class which is your wizard page (here there is only one)
             This class must extend the MBSCustomPage class:
             public class AIMWizardPage extends MBSCustomPage implements org.eclipse.jface.wizard.IWizardPage {
                      ......
                      ......
                      ......
                      public boolean canFlipToNextPage() {
                            return false;   // true if there's another page -> must manage this
                        }
                       
                        @Override
                        public void createControl(Composite parent) {
                           // here you must display widgets (text zones, radio buttons etc. within a composite
                        }
                     
                      // this is how I display a header image. The image is in the icons folder in the root of your plugin
                      @Override
                        public Image getImage() {
                            return new Image(null, AIMWizardPage.class.getResourceAsStream("/icons/"+headerImage.png));
                        }
                       
                        // to display a title
                        @Override
                        public String getTitle() {
                            return new String("Hardware Manager");
                        }
                       
                       // etc...
             }
            
             -->
          <toolchain
                toolchainID="addProject.cdt.managedbuild.toolchain.gnu.cross.exe.debug2">
          </toolchain>
       </wizardPage>
   </extension>
   <extension
         id="addProject.buildDefinitions2"
         name="Build Definitions"
         point="org.eclipse.cdt.managedbuilder.core.buildDefinitions">
      <projectType  <!-- this defines your project type which will appear on the first page of the wizard-->
            id="addProject.projectType2"
            isAbstract="false"
            isTest="false"
            name="My Project">
         <configuration
               cleanCommand="rm –f"
               id="addProject.configuration2"
               name="Debug2">
            <toolChain
                  id="addProject.cdt.managedbuild.toolchain.gnu.cross.exe.debug2"
                  isAbstract="false"
                  name="Cross GCC"
                  osList="win32">
               <tool
                     id="addProject.tool2"
                     isAbstract="false"
                     name="gcc"
                     outputFlag="-o">
                  <inputType
                        dependencyContentType="org.eclipse.cdt.core.cHeader"
                        id="addProject.inputType2"
                        name="compiler input"
                        primaryInput="true"
                        sourceContentType="org.eclipse.cdt.core.cSource">
                  </inputType>
                  <outputType
                        buildVariable="OBJS"
                        id="addProject.outputType2"
                        name="output type"
                        outputs="o"
                        primaryOutput="true">
                  </outputType>
               </tool>
               <builder
                     command="aim-make"
                     id="addProject.builder2"
                     isAbstract="false"
                     isVariableCaseSensitive="false"
                     name="My Builder">
               </builder>
               <targetPlatform
                     binaryParser="org.eclipse.cdt.core.ELF"
                     id="addProject.targetPlatform2"
                     isAbstract="false"
                     name="My Target Platform"
                     osList="win32">
               </targetPlatform>
            </toolChain>
         </configuration>
         <!-- You may define other configurations which can be chosen on the second page of the wizard-->
      </projectType>
   </extension>
</plugin>

I hope this helps,

Antony


On 15/04/2014 15:16, Chris Recoskie wrote:

Maybe you meant MBSCustomPage?  MBSCustomPageManager is a singleton and you are not meant to subclass it as it is the entity in CDT that manages all the pages.


===========================
Chris Recoskie
Team Lead
Rational Developer For AIX & Linux C/C++
Rational Developer For System z C/C++
IBM Eclipse CDT and RDT
IBM Toronto


Inactive
          hide details for charleytims ---04/14/2014 06:54:19 PM---If I
          take the function "public boolean
          canFlipToNextPage()" charleytims ---04/14/2014 06:54:19 PM---If I take the function  "public boolean canFlipToNextPage()" there is actually no implementation of

From: charleytims <pwdavari@xxxxxxxx>
To: cdt-dev@xxxxxxxxxxx
Date: 04/14/2014 06:54 PM
Subject: Re: [cdt-dev] Using the MBSCustomPage Class
Sent by: cdt-dev-bounces@xxxxxxxxxxx





If I take the function  "public boolean canFlipToNextPage()" there is
actually no implementation of MBSCustomPageManager in my wizardPage. Is this
a problem?

The import is still there but I get the warning that it is not used. I did
the -clean command but did not see any different results when running the
application. Is there any implementations of MBSCustomPageManager that have
to be in my wizard page class?






I would suggest you step through the code in MBSCustomPageManager that
loads the extensions and confirm that your contributions are being properly
loaded.  If that holds true then run the wizard and step through the code
and see if your page gets called at all.

There can be a lot of reasons why your contribution may not work... are the
IDs correct?  Did you export the packages that your page class requires so
other plugins can access them?  Are the dependencies for your plugin
satisfied?  Did you drop in a new version of your plugin but not change the
version number or launch eclipse with the -clean option so it would pick it
up?  etc.  Without all the information it's difficult to track down your
problem.


===========================
Chris Recoskie
Team Lead
Rational Developer For AIX & Linux C/C++
Rational Developer For System z C/C++
IBM Eclipse CDT and RDT
IBM Toronto



From: charleytims &lt;pwdavari@&gt;
To: cdt-dev@
Date: 04/13/2014 10:51 PM
Subject: [cdt-dev] Using the MBSCustomPage Class
Sent by: cdt-dev-bounces@



I'm currently trying to implement a custom page to the new project wizard
by
using the org.eclipse.cdt.managedbuilder.ui.newWizardPages. I want the
custom page to be added to the wizard when a particular projectType has
been
selected.

I have set the new wizardPage (id=Testing.wizardPage2) to have the child
element of projectType with id= Testing.projectType1.

I then create the pageClass and operationClass for the corresponding wizard
page.

In the newly created pageClass I extend MBSCustomPage.

I found an example of a custom wizard page (AlwaysPresentWizardPage) that
also extended this class and used this already functioning code to test out
my implementation.

When I run the plugin application, I see the custom project type and the
custom toolchain that corresponds with it, but when I go to the end of the
wizard my custom page never shows up.

Here is the code for the created pageClass:



public class CustomPageImplementation2 extends MBSCustomPage {

 private Composite composite;

 public CustomPageImplementation2()
 {
   pageID = "Testing.wizardPage2";
 }

 @Override
 public boolean canFlipToNextPage()
 {

   return (MBSCustomPageManager.getNextPage
(pageID) != null);
 }

 @Override
 public String getName()
 {
   return new String("Custom Page Test");
 }


 @Override
 public void createControl(Composite parent)
 {

   composite = new Composite(parent, SWT.NULL);
   composite.setLayout(new GridLayout());
   composite.setLayoutData(new GridData
(GridData.FILL_BOTH));

   Text pageText = new Text(composite, SWT.CENTER);
   pageText.setBounds(composite.getBounds());
   pageText.setText("This page is a test page
provided by the
org.eclipse.cdt.managedbuilder.ui.tests plugin.");
   pageText.setVisible(true);

 }

 @Override
 public void dispose()
 {
   composite.dispose();

 }

 @Override
 public Control getControl()
 {
   return composite;
 }

 @Override
 public String getDescription()
 {
   return new String("This page is for testing,
please ignore it.");
 }

 @Override
 public String getErrorMessage()
 {
   return null;
 }

 @Override
 public Image getImage()
 {
   return wizard.getDefaultPageImage();
 }

 @Override
 public String getMessage()
 {
   // TODO Auto-generated method stub
   return null;
 }

 @Override
 public String getTitle()
 {
   return new String("Test Page");
 }

 @Override
 public void performHelp()
 {
   // do nothing

 }

 @Override
 public void setDescription(String description)
 {
   // do nothing

 }

 @Override
 public void setImageDescriptor(ImageDescriptor image)
 {
   // do nothing

 }

 @Override
 public void setTitle(String title)
 {
   // do nothing

 }

 @Override
 public void setVisible(boolean visible)
 {
   composite.setVisible(visible);

 }

 @Override
 protected boolean isCustomPageComplete()
 {
   return true;
 }


I'm not sure how I am supposed to implement the CustomPageManager even
after
reading the documentation. Could anybody lead me in the right direction
from
here on how to implement custom pages and manage them with my wizard?

Any help would be appreciated. Thanks







--
View this message in context:
http://eclipse.1072660.n5.nabble.com/Using-the-MBSCustomPage-Class-tp166748p166773.html
Sent from the Eclipse CDT - Development mailing list archive at Nabble.com.
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev




_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev


Back to the top