-
Notifications
You must be signed in to change notification settings - Fork 48
plugin.xml for eclipse bundle
Let's create eclipse bundle and program "plugin.xml" for it.
- Create folder "tutorials/MyEclipseplugin", create file "build.gradle" in it, insert code:
buildscript {
repositories {
mavenLocal()
jcenter()
}
dependencies {
classpath 'org.akhikhl.wuff:wuff-plugin:0.0.1'
}
}
apply plugin: 'java'
apply plugin: 'eclipse-bundle'
repositories {
mavenLocal()
jcenter()
}-
Invoke on command line:
build gradle -
Open file "tutorials/MyEclipsePlugin/build/libs/MyEclipsePlugin-1.0.0.0.jar" - it does not contain "plugin.xml". Explanation: Wuff skips default "plugin.xml" generation, because it does not "know" what to write there.
-
Create folder "tutorials/MyEclipsePlugin/src/main/java/myeclipseplugin", create file "MyView.java" in it, insert code:
package myeclipseplugin;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;
public class MyView extends ViewPart {
@Override
public void createPartControl(final Composite parent) {
}
@Override
public void setFocus() {
}
}-
Invoke on command line:
build gradle -
Open file "tutorials/MyEclipsePlugin/build/libs/MyEclipsePlugin-1.0.0.0.jar" - it contains "plugin.xml" with the following code:
<plugin>
<extension point="org.eclipse.ui.views">
<view id="MyEclipsePlugin.MyView" name="MyEclipsePlugin MyView" class="myeclipseplugin.MyView"/>
</extension>
</plugin>We see that Wuff recognized our file as view and that it automatically inserted extension-point for it. In general, Wuff recognizes any files matching to patterns '**/*View.groovy', '**/*View.java', '**/View*.groovy', '**/View*.java' as view files.
Explanation of attributes:
- id="MyEclipsePlugin.MyView": synthesized from project name and view class name
- name="MyEclipsePlugin MyView": synthesized from project name and view class name
- class="myeclipseplugin.MyView": points to qualified class name of the view file.
- What should we do to change the view name or view id? Very simple: give our own view definition. Create folder "tutorials/MyEclipsePlugin/src/main/resources", create file "plugin.xml" in it, insert code:
<plugin>
<extension point="org.eclipse.ui.views">
<view id="myviewid" name="Very nice view" class="myeclipseplugin.MyView"/>
</extension>
</plugin>Invoke build gradle again and look into JAR/plugin.xml: it contains our view definition, not the generated one.
- Create file "tutorials/MyEclipsePlugin/src/main/java/myeclipseplugin/MyPerspective.java", insert code:
package myeclipseplugin;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;
public class MyPerspective implements IPerspectiveFactory {
public void createInitialLayout(IPageLayout layout) {
}
}- Invoke on command line:
build gradle, then open JAR/plugin.xml, it contains:
<plugin>
<extension point="org.eclipse.ui.views">
<view id="myviewid" name="Very nice view" class="myeclipseplugin.MyView"/>
</extension>
<extension point="org.eclipse.ui.perspectives">
<perspective id="MyEclipsePlugin.MyPerspective" name="MyEclipsePlugin MyPerspective" class="myeclipseplugin.MyPerspective"/>
</extension>
<extension point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension targetID="MyEclipsePlugin.MyPerspective">
<view id="myviewid" standalone="true" minimized="false" relative="org.eclipse.ui.editorss" relationship="left"/>
</perspectiveExtension>
</extension>
</plugin>We see that Wuff recognized "MyPerspective.java" file as perspective and that it automatically inserted extension-points for it. In general, Wuff recognizes any files matching to patterns '**/*Perspective.groovy', '**/*Perspective.java', '**/Perspective*.groovy', '**/Perspective*.java' as perspective files.
Explanation of attributes in "org.eclipse.ui.perspectives":
- id="MyEclipsePlugin.MyPerspective": synthesized from project name and perspective class name.
- name="MyEclipsePlugin MyPerspective": synthesized from project name and perspective class name.
- class="myeclipseplugin.MyPerspective": points to qualified class name of the perspective file.
As we see, extension-point "org.eclipse.ui.perspectiveExtensions" links perspective and view. This is special case: our plugin contains exactly one perspective and one view, so Wuff decides that they must be linked to each other.
- Let's customize our perspective as well. Edit the file "tutorials/MyEclipsePlugin/src/main/resources/plugin.xml", insert code:
<plugin>
<extension point="org.eclipse.ui.views">
<view id="myviewid" name="Very nice view" class="myeclipseplugin.MyView"/>
</extension>
<extension point="org.eclipse.ui.perspectives">
<perspective id="myperspectiveid" name="Very nice perspective" class="myeclipseplugin.MyPerspective"/>
</extension>
</plugin>- Invoke on command line:
build gradle, then open JAR/plugin.xml, it contains:
<plugin>
<extension point="org.eclipse.ui.views">
<view id="myviewid" name="Very nice view" class="myeclipseplugin.MyView"/>
</extension>
<extension point="org.eclipse.ui.perspectives">
<perspective id="myperspectiveid" name="Very nice perspective" class="myeclipseplugin.MyPerspective"/>
</extension>
<extension point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension targetID="myperspectiveid">
<view id="myviewid" standalone="true" minimized="false" relative="org.eclipse.ui.editorss" relationship="left"/>
</perspectiveExtension>
</extension>
</plugin>As we see, now Wuff recognizes that "plugin.xml" already contains extension-point for perspective and does not generate the default one. We also see that Wuff still links perspective and view, because it is a special case: one perspective and one view.