2

I looked at several places but can't seem to understand why my code isn't working. Every single tutorial I've followed does the same and to me, it looks like I'm doing what I need to do...

I don't get any warnings or errors too, so one would guess it works.

What I'm trying to do: adding a wizard in Eclipse when you click on "New". As far as I know (I'm pretty new to it), I need to create a new Plugin Project and I need to define some extensions in my plugin.xml file. I also need to add all my dependencies.

This is what is in my plugin.xml:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
    <extension point="org.eclipse.ui.actionSets">
    </extension>
    <extension point="org.eclipse.ui.newWizards">
        <category
            id="test.myNewWizard"
            name="Custom false new wizard">
        </category>
        <wizard
            category="test.myNewWizard"
            class="test.NewAppWizard"
            icon="icons/logo_16px.png"
            id="test.NewAppWizard"
            name="New Testing Test">
        </wizard>
    </extension>
</plugin>

As said: I've got no warnings or errors (console even doesn't print anything) so that means class and icon should all be found. They also all exist in the very same project.

My MANIFEST.MF:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: NewAppwizard
Bundle-SymbolicName: test.myNewWizard;singleton:=true
Bundle-Version: 1.0.0.qualifier
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.resources,
 org.eclipse.ui.ide,
 org.eclipse.core.runtime,
 org.eclipse.core.databinding,
 org.eclipse.core.databinding.beans,
 org.eclipse.core.databinding.observable,
 org.eclipse.core.databinding.property,
 org.eclipse.jface.databinding,
 com.ibm.icu
Bundle-RequiredExecutionEnvironment: JavaSE-1.6

Anyone that has any clue as to why

  • I get no warnings or errors at all
  • I have no output in my console when running at all
  • I also can't find the Wizard under "File > New > Other..." in that screen at all?

I also tried creating a new sample project, "File > New > Plug-in Project", using these settings:

  • Generate an activator: no
  • This plugin will make contributions to the UI: yes
  • Would you like to create a rich client application: no

"Next", "Create a plug-in using one of the templates:" and using the template "Plug-in with a multi-page editor". That one also makes use of a Sample New Wizard, but even this one doesn't show the Wizard option when I run it right after creating it.

Final note: I run the application by opening the "plugin.xml" file, "Overview", "Launch an Eclipse application".

Thanks!


EDIT: as asked, here the contents of my test.NewAppWizard class:

package test;

import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;

public class NewAppWizard extends Wizard implements INewWizard {
    private CreateAppPage firstPage;

    public NewAppWizard() {
        super();
        setNeedsProgressMonitor(true);
        setWindowTitle("Test");
    }

    @Override
    public void addPages() {
        firstPage = new CreateAppPage();
        addPage(firstPage);
    }

    @Override
    public void init(IWorkbench workbench, IStructuredSelection selection) {}

    @Override
    public boolean performFinish() {
        return false;
    }

    @Override
    public boolean canFinish() {
        return false;
    }
}

To be complete, here also my CreateAppPage class:

package test;

import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
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.Label;
import org.eclipse.swt.widgets.Text;

public class CreateAppPage extends WizardPage {
    private Text testName;
    private Composite container;
    private KeyListener pageComplete;

    public CreateAppPage() {
        super("Create a new application");
        setTitle("Create a new application");
        pageComplete = new PageCompleteKeyListener();
    }

    @Override
    public void createControl(Composite parent) {
        container = new Composite(parent, SWT.NONE);
        GridLayout layout = new GridLayout();
        container.setLayout(layout);
        layout.numColumns = 2;
        Label lblTestName = new Label(container, SWT.NONE);
        lblTestName.setText("Application name:");
        testName = new Text(container, SWT.BORDER | SWT.SINGLE | SWT.FILL);
        testName.addKeyListener(pageComplete);
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        testName.setLayoutData(gd);
        setControl(container);
        setPageComplete(false);
    }

    public String getName() {
        return testName.getText();
    }

    private class PageCompleteKeyListener implements KeyListener {
        public void keyPressed(KeyEvent e) {}
        public void keyReleased(KeyEvent e) {
            if (testName.getText().isEmpty()) {
                setErrorMessage("Name cannot be empty");
                setPageComplete(false);
            } else {
                setErrorMessage(null);
                setPageComplete(true);
            }
        }
    }
}
4

1 回答 1

1

问题

Eclipse 运行时,您的插件似乎未激活。因此,您的向导不会显示在列表中。

解决方案

  1. 打开您的插件清单(MANIFEST.MF)。
  2. 在“概述”页面的“常规信息”部分中选中“当插件的类之一加载时激活插件”。
于 2013-10-10T09:34:45.257 回答