Skip to content

Commit

Permalink
Merge pull request #210 from eclipse-passage/561553
Browse files Browse the repository at this point in the history
561553
  • Loading branch information
eparovyshnaya authored May 14, 2020
2 parents 6e02370 + a836bcf commit bfece37
Show file tree
Hide file tree
Showing 24 changed files with 606 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
Manifest-Version: 1.0
Automatic-Module-Name: org.eclipse.passage.ldc.pde.ui.templates
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.passage.ldc.pde.ui.templates;singleton:=true
Bundle-Version: 0.5.200.qualifier
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
Bundle-Copyright: %Bundle-Copyright
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.eclipse.passage.ldc.internal.pde.ui.templates;x-internal:=true,
org.eclipse.passage.ldc.internal.pde.ui.templates.i18n;x-internal:=true
Require-Bundle: org.eclipse.core.runtime;bundle-version="0.0.0",
org.eclipse.core.resources;bundle-version="0.0.0",
org.eclipse.jface;bundle-version="0.0.0",
org.eclipse.pde.ui;bundle-version="0.0.0",
org.eclipse.pde.ui.templates;bundle-version="0.0.0",
org.eclipse.passage.lic.equinox;bundle-version="0.0.0"
Export-Package: org.eclipse.passage.ldc.internal.pde.ui.templates;x-internal:=true,
org.eclipse.passage.ldc.internal.pde.ui.templates.i18n;x-internal:=true
org.eclipse.passage.lic.equinox;bundle-version="0.0.0",
org.eclipse.e4.core.contexts;bundle-version="0.0.0",
org.eclipse.e4.core.di;bundle-version="0.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Copyright: %Bundle-Copyright
Automatic-Module-Name: org.eclipse.passage.ldc.pde.ui.templates
Import-Package: javax.annotation;version="1.0.0";resolution:=optional,
javax.inject;version="1.0.0"
Bundle-ActivationPolicy: lazy
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ protected List<String> getRCP4Dependencies() {
"org.eclipse.e4.ui.workbench", //$NON-NLS-1$
"org.eclipse.e4.core.contexts", //$NON-NLS-1$
"org.eclipse.passage.lic.equinox", //$NON-NLS-1$
"org.eclipse.passage.lic.e4.ui"); //$NON-NLS-1$
"org.eclipse.passage.lic.e4.ui", //$NON-NLS-1$
"org.slf4j.api"); //$NON-NLS-1$
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@

public final class LicensedE4FullFeatherProductTemplateSection extends BaseLicensedTemplateSection {

private static final String LICENSED_E4_PRODUCT = "LicensedE4FullFeatherProduct"; //$NON-NLS-1$
private static final String E4_SWT_APPLICATION_ID = "org.eclipse.e4.ui.workbench.swt.E4Application"; //$NON-NLS-1$

public LicensedE4FullFeatherProductTemplateSection() {
setPageCount(1);
createOptions();
Expand All @@ -43,13 +40,6 @@ public void addPages(Wizard wizard) {
markPagesAdded();
}

private void createOptions() {
addOption(KEY_WINDOW_TITLE, PdeUiTemplatesMessages.LicensedE4ProductTemplateSection_key_window_title_label,
"Licensed E4 RCP", 0); //$NON-NLS-1$
addOption(KEY_PACKAGE_NAME, PdeUiTemplatesMessages.LicensedE4ProductTemplateSection_key_package_name_label,
(String) null, 0);
}

@Override
protected void initializeFields(IFieldData data) {
// In a new project wizard, we don't know this yet - the
Expand All @@ -66,49 +56,77 @@ public void initializeFields(IPluginModelBase modelBase) {

@Override
public String getSectionId() {
return LICENSED_E4_PRODUCT;
return "LicensedE4FullFeatherProduct"; //$NON-NLS-1$
}

@Override
protected void updateModel(IProgressMonitor monitor) throws CoreException {
setManifestHeader("Bundle-ActivationPolicy", "lazy"); //$NON-NLS-1$ //$NON-NLS-2$
setManifestHeader("Service-Component", "OSGI-INF/*"); //$NON-NLS-1$ //$NON-NLS-2$
String productFqn = model.getPluginBase().getId() + '.' + VALUE_PRODUCT_ID;
createLicensingCapability(productFqn);
createProductExtension();
}

@Override
public IPluginReference[] getDependencies(String schemaVersion) {
return getDependencies(getRCP4Dependencies());
}

@Override
public String[] getNewFiles() {
return new String[] { //
"css/default.css", //$NON-NLS-1$
"e4xmi/Application.e4xmi", //$NON-NLS-1$
"OSGI-INF/" }; //$NON-NLS-1$
}

private void createOptions() {
addOption(KEY_WINDOW_TITLE, PdeUiTemplatesMessages.LicensedE4ProductTemplateSection_key_window_title_label,
"Full Feather Passage Licensed Product", 0); //$NON-NLS-1$
addOption(KEY_PACKAGE_NAME, PdeUiTemplatesMessages.LicensedE4ProductTemplateSection_key_package_name_label,
(String) null, 0);
}

private void createProductExtension() throws CoreException {
IPluginBase plugin = model.getPluginBase();
IPluginExtension extension = productRuntime();
IPluginElement product = product(extension);
addCssProperty(product);
addApplicationProperty(product);
extension.add(product);
plugin.add(extension);
}

private IPluginExtension productRuntime() throws CoreException {
IPluginExtension extension = createExtension("org.eclipse.core.runtime.products", true); //$NON-NLS-1$
extension.setId(VALUE_PRODUCT_ID);
return extension;
}

IPluginElement element = model.getFactory().createElement(extension);
element.setName("product"); //$NON-NLS-1$
element.setAttribute("application", E4_SWT_APPLICATION_ID); //$NON-NLS-1$
element.setAttribute("name", getStringOption(KEY_PACKAGE_NAME)); //$NON-NLS-1$

private void addApplicationProperty(IPluginElement element) throws CoreException {
IPluginElement property;

property = model.getFactory().createElement(element);
property.setName("property"); //$NON-NLS-1$
property.setAttribute("name", "applicationCSS");//$NON-NLS-1$ //$NON-NLS-2$
property.setAttribute("value", "platform:/plugin/" + getValue(KEY_PLUGIN_ID) + "/css/default.css"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
property.setAttribute("name", "applicationXMI");//$NON-NLS-1$ //$NON-NLS-2$
property.setAttribute("value", "platform:/plugin/" + getValue(KEY_PLUGIN_ID) + "/e4xmi/Application.e4xmi"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
element.add(property);

extension.add(element);

if (!extension.isInTheModel())
plugin.add(extension);
}

@Override
public IPluginReference[] getDependencies(String schemaVersion) {
return getDependencies(getRCP4Dependencies());
private void addCssProperty(IPluginElement element) throws CoreException {
IPluginElement property = model.getFactory().createElement(element);
property.setName("property"); //$NON-NLS-1$
property.setAttribute("name", "applicationCSS");//$NON-NLS-1$ //$NON-NLS-2$
property.setAttribute("value", "platform:/plugin/" + getValue(KEY_PLUGIN_ID) + "/css/default.css"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
element.add(property);
}

@Override
public String[] getNewFiles() {
return new String[] { "css/default.css", "Application.e4xmi" }; //$NON-NLS-1$ //$NON-NLS-2$
private IPluginElement product(IPluginExtension extension) throws CoreException {
IPluginElement element = model.getFactory().createElement(extension);
element.setName("product"); //$NON-NLS-1$
element.setAttribute("application", "org.eclipse.e4.ui.workbench.swt.E4Application"); //$NON-NLS-1$ //$NON-NLS-2$
element.setAttribute("name", getStringOption(KEY_PACKAGE_NAME)); //$NON-NLS-1$
return element;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
<plugin id="org.eclipse.passage.lic.equinox"/>
<plugin id="org.eclipse.passage.lic.jface"/>
<plugin id="org.eclipse.passage.lic.e4.ui"/>
<plugin id="org.slf4j.api"/>
</plugins>

<configurations>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="$packageName$.magic.Universe">
<service>
<provide interface="$packageName$.magic.Creatures"/>
<provide interface="$packageName$.magic.service.MagicForces"/>
</service>
<implementation class="$packageName$.magic.Universe"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="$packageName$.magic.service.EvilWitch">
<property name="licensing.feature.identifier" value="EvilWitch"/>
<property name="licensing.feature.name" value="Evil Witch"/>
<property name="licensing.restriction.level" value="info"/>
<property name="licensing.feature.version" value="13.4.1"/>
<property name="licensing.feature.provider" value="Universe"/>
<service>
<provide interface="$packageName$.magic.service.PrinceToFrogMagic"/>
</service>
<reference bind="contractWithMagicForces" interface="$packageName$.magic.service.MagicForces" name="contractWithMagicForces"/>
<implementation class="$packageName$.magic.service.EvilWitch"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="$packageName$.magic.service.GoodWitch">
<property name="licensing.feature.identifier" value="GoodWitch"/>
<property name="licensing.restriction.level" value="fatal"/>
<service>
<provide interface="$packageName$.magic.service.FrogToPrinceMagic"/>
</service>
<reference bind="contractWithForces" interface="$packageName$.magic.service.MagicForces" name="contractWithForces"/>
<implementation class="$packageName$.magic.service.GoodWitch"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<application:Application xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:application="http://www.eclipse.org/ui/2010/UIModel/application" xmlns:basic="http://www.eclipse.org/ui/2010/UIModel/application/ui/basic" xmi:id="_c3AF0MjYEeSyMNYR5xypkQ" elementId="org.eclipse.e4.application" bindingContexts="_c3AF2cjYEeSyMNYR5xypkQ">
<children xsi:type="basic:TrimmedWindow" xmi:id="_c3AF0cjYEeSyMNYR5xypkQ" elementId="org.eclipse.e4.window.main" label="Empty E4 Application" width="500" height="400"/>
<children xsi:type="basic:TrimmedWindow" xmi:id="_c3AF0cjYEeSyMNYR5xypkQ" elementId="org.eclipse.e4.window.main" selectedElement="__mq34I6rEeqezOuVdHH1Yg" label="Passage E4 Application" width="500" height="400">
<children xsi:type="basic:PartSashContainer" xmi:id="__mq34I6rEeqezOuVdHH1Yg" elementId="org.eclipse.passage.ldc.pde.ui.templates.partsashcontainer.magic" horizontal="true">
<children xsi:type="basic:Part" xmi:id="_Aj-NoI6sEeqezOuVdHH1Yg" elementId="org.eclipse.passage.ldc.pde.ui.templates.part.frogs" contributionURI="bundleclass://$pluginId$/$packageName$.FrogsPart" label="frogs">
<toolbar xmi:id="_BiwxII6sEeqezOuVdHH1Yg" elementId="org.eclipse.passage.ldc.pde.ui.templates.toolbar.0"/>
</children>
<children xsi:type="basic:Part" xmi:id="_D4TFII6sEeqezOuVdHH1Yg" elementId="org.eclipse.passage.ldc.pde.ui.templates.part.princes" contributionURI="bundleclass://$pluginId$/$packageName$.PrincesPart" label="princes">
<toolbar xmi:id="_GFcSII6sEeqezOuVdHH1Yg" elementId="org.eclipse.passage.ldc.pde.ui.templates.toolbar.1"/>
</children>
</children>
</children>
<rootContext xmi:id="_c3AF2cjYEeSyMNYR5xypkQ" elementId="org.eclipse.ui.contexts.dialogAndWindow" name="In Dialog and Windows">
<children xmi:id="_c3AF2sjYEeSyMNYR5xypkQ" elementId="org.eclipse.ui.contexts.window" name="In Windows"/>
<children xmi:id="_c3AF28jYEeSyMNYR5xypkQ" elementId="org.eclipse.ui.contexts.dialog" name="In Dialogs"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package $packageName$;

import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import $packageName$.magic.service.Creature;
import org.eclipse.swt.graphics.Image;

final class CreatureLabelProvider implements ILabelProvider {

@Override
public void addListener(ILabelProviderListener listener) {
// do nothing
}

@Override
public void removeListener(ILabelProviderListener listener) {
// do nothing
}

@Override
public void dispose() {
// do nothing
}

@Override
public boolean isLabelProperty(Object element, String property) {
return false; // do nothing
}

@Override
public Image getImage(Object element) {
return null; // FIXME: !
}

@Override
public String getText(Object element) {
return ((Creature) element).name();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package $packageName$;

import java.util.Comparator;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import org.eclipse.jface.viewers.IStructuredContentProvider;
import $packageName$.magic.Creatures;
import $packageName$.magic.service.Creature;
import $packageName$.magic.service.Shape;

final class CreaturesContentProvider implements IStructuredContentProvider {

private final Predicate<Creature> shape;
private final Comparator<Creature> comparator;

CreaturesContentProvider(Shape shape) {
this.shape = new Shape.Of(shape);
this.comparator = (first, second) -> first.name().compareTo(second.name());
}

@Override
public Object[] getElements(Object input) {
return ((Creatures) input).creatures().stream() //
.filter(shape) //
.sorted(comparator) //
.collect(Collectors.toList()) //
.toArray();
}

}
Loading

0 comments on commit bfece37

Please sign in to comment.