Eclipse添加了一个新的向导:扩展点无效

时间:2023-01-12 14:26:13

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.

我要做的是:单击“New”时在Eclipse中添加一个向导。就我所知(我对它很陌生),我需要创建一个新的插件项目,我需要在我的插件中定义一些扩展。xml文件。我还需要添加所有依赖项。

This is what is in my plugin.xml:

这就是我的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 . 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?
  • 我在那个屏幕上也找不到“File > New > Other…”下的向导?

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

我还尝试使用以下设置创建一个新的示例项目“File > new >插件项目”:

  • Generate an activator: no
  • 生成一个活化剂:没有
  • This plugin will make contributions to the UI: yes
  • 这个插件将对UI做出贡献:是的
  • 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.

“Next”,“使用其中一个模板创建插件:”并使用模板“带有多页面编辑器的插件”。它还使用了一个示例New Wizard,但是即使是这个,当我在创建它之后运行它时也没有显示向导选项。

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

最后注意:我通过打开“插件”来运行应用程序。xml“文件”、“概述”、“启动Eclipse应用程序”。

Thanks!

谢谢!


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

编辑:如问,这里是我的测试内容。NewAppWizard类:

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:

为了完整,这里还有我的CreateAppPage类:

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);
            }
        }
    }
}

1 个解决方案

#1


1  

The Problem

这个问题

It seems your plug-in is not activated when the Eclipse is running. Therefore, your wizards are not showing in the list.

当Eclipse正在运行时,您的插件似乎没有被激活。因此,您的向导不在列表中显示。

The Solution

解决方案

  1. Open your plugin manifest (MANIFEST.MF).
  2. 打开你的插件清单(manifest . mf)。
  3. Check Activate the plug-in when one of its classes is loaded in the General Information section on the Overview page.
  4. 在Overview页面上的General Information部分中装载插件的一个类时,检查是否激活该插件。

#1


1  

The Problem

这个问题

It seems your plug-in is not activated when the Eclipse is running. Therefore, your wizards are not showing in the list.

当Eclipse正在运行时,您的插件似乎没有被激活。因此,您的向导不在列表中显示。

The Solution

解决方案

  1. Open your plugin manifest (MANIFEST.MF).
  2. 打开你的插件清单(manifest . mf)。
  3. Check Activate the plug-in when one of its classes is loaded in the General Information section on the Overview page.
  4. 在Overview页面上的General Information部分中装载插件的一个类时,检查是否激活该插件。