Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a feature out of a maven-target location #280 #376

Closed
wants to merge 12 commits into from
4 changes: 2 additions & 2 deletions m2e-maven-runtime/org.eclipse.m2e.archetype.common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</parent>

<artifactId>org.eclipse.m2e.archetype.common</artifactId>
<version>1.18.1-SNAPSHOT</version>
<version>1.19.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

<name>M2E Maven Archetype Common</name>
Expand Down Expand Up @@ -99,7 +99,7 @@
org.apache.maven.archetype.*;provider=m2e;mandatory:=provider;x-internal:=true,
org.codehaus.plexus.velocity;provider=m2e;mandatory:=provider;x-internal:=true,
</_exportcontents>
<Require-Bundle>org.eclipse.m2e.maven.runtime;bundle-version="[1.18.0,1.19.0)"</Require-Bundle>
<Require-Bundle>org.eclipse.m2e.maven.runtime;bundle-version="[1.18.0,2)"</Require-Bundle>
</instructions>
</configuration>
</plugin>
Expand Down
6 changes: 3 additions & 3 deletions m2e-maven-runtime/org.eclipse.m2e.maven.indexer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</parent>

<artifactId>org.eclipse.m2e.maven.indexer</artifactId>
<version>1.18.1-SNAPSHOT</version>
<version>1.19.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

<name>M2E Maven/Nexus Indexer</name>
Expand Down Expand Up @@ -114,8 +114,8 @@
javax.inject;version="1.0.0"
</Import-Package>
<Require-Bundle>
org.eclipse.m2e.maven.runtime;bundle-version="[1.18.0,1.19.0)",
org.eclipse.m2e.archetype.common;bundle-version="[1.18.0,1.19.0)",
org.eclipse.m2e.maven.runtime;bundle-version="[1.18.0,2)",
org.eclipse.m2e.archetype.common;bundle-version="[1.18.0,2)",
com.google.guava
</Require-Bundle>
</instructions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</parent>

<artifactId>org.eclipse.m2e.maven.runtime.slf4j.simple</artifactId>
<version>1.18.1-SNAPSHOT</version>
<version>1.19.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

<name>M2E SLF4J-Simple Binding for Embedded Maven Runtime</name>
Expand Down
4 changes: 2 additions & 2 deletions m2e-maven-runtime/org.eclipse.m2e.maven.runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</parent>

<artifactId>org.eclipse.m2e.maven.runtime</artifactId>
<version>1.18.2-SNAPSHOT</version>
<version>1.19.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

<name>M2E Embedded Maven Runtime (includes Incubating components)</name>
Expand Down Expand Up @@ -155,7 +155,7 @@
javax.inject;version="1.0.0"
</Import-Package>
<Require-Bundle>
org.eclipse.m2e.maven.runtime.slf4j.simple;bundle-version="[1.18.0,1.19.0)",
org.eclipse.m2e.maven.runtime.slf4j.simple;bundle-version="[1.18.0,2)",
com.google.guava
</Require-Bundle>
<!-- All direct dependencies specified as Require-Bundle or Import-package are added to the classpath of a launched
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.m2e.pde.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.19.0",
org.eclipse.m2e.maven.runtime,
org.eclipse.m2e.core,
org.eclipse.m2e.pde,
org.eclipse.pde;bundle-version="3.13.1200",
org.eclipse.pde;bundle-version="3.13.300",
org.eclipse.core.databinding;bundle-version="1.10.100",
org.eclipse.core.databinding.observable;bundle-version="1.10.0",
org.eclipse.jface.databinding;bundle-version="1.12.200",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/*******************************************************************************
* Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
* Christoph Läubrich - adjust for m2e-pde usage
*******************************************************************************/

package org.eclipse.m2e.pde.ui.editor;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.pde.internal.core.util.IdUtil;
import org.eclipse.pde.internal.core.util.VersionUtil;
import org.eclipse.pde.internal.ui.PDEUIMessages;
import org.eclipse.pde.internal.ui.wizards.feature.FeatureData;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;

//derived from org.eclipse.pde.internal.ui.wizards.feature.AbstractFeatureSpecPage
@SuppressWarnings("restriction")
public abstract class AbstractFeatureSpecPage extends WizardPage {

protected Text fFeatureNameText;
protected Text fFeatureVersionText;
protected Text fLibraryText;
protected String fInitialId;
protected String fInitialName;

public AbstractFeatureSpecPage() {
super("specPage"); //$NON-NLS-1$
}

@Override
public void createControl(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
comp.setLayout(GridLayoutFactory.fillDefaults().create());
setControl(comp);
createContents(comp);

initialize();
attachListeners();

Dialog.applyDialogFont(comp);
PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, getHelpId());
setPageComplete(validatePage());
}

protected abstract void createContents(Composite container);

protected abstract void initialize();

protected abstract void attachListeners(ModifyListener listener);

protected abstract String getHelpId();

protected abstract void saveSettings(IDialogSettings settings);

protected void createCommonInput(Composite common) {
Label label = new Label(common, SWT.NULL);
label.setText(PDEUIMessages.NewFeatureWizard_SpecPage_name);
fFeatureNameText = new Text(common, SWT.BORDER);
fFeatureNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

label = new Label(common, SWT.NULL);
label.setText(PDEUIMessages.NewFeatureWizard_SpecPage_version);
fFeatureVersionText = new Text(common, SWT.BORDER);
fFeatureVersionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}

protected void createInstallHandlerText(Composite parent) {
Label libraryLabel = new Label(parent, SWT.NULL);
libraryLabel.setText(PDEUIMessages.NewFeatureWizard_SpecPage_library);
fLibraryText = new Text(parent, SWT.SINGLE | SWT.BORDER);
fLibraryText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}

protected boolean validatePage() {
if (!setValidationMessage(verifyIdRules()))
return false;
if (!setValidationMessage(verifyVersion()))
return false;
if (!setValidationMessage(validateContent()))
return false;

setPageComplete(true);
setErrorMessage(null);
return true;
}

private boolean setValidationMessage(String message) {
if (message == null)
return true;
setPageComplete(false);
setErrorMessage(message);
return false;
}

protected abstract String validateContent();

public String getInitialName() {
return fInitialName;
}

public void setInitialName(String initialName) {
fInitialName = initialName;
}

public void setInitialId(String initialId) {
fInitialId = initialId;
}

public String getInitialId() {
return fInitialId;
}

protected String verifyVersion() {
String value = fFeatureVersionText.getText();
if (VersionUtil.validateVersion(value).getSeverity() != IStatus.OK)
return PDEUIMessages.NewFeatureWizard_SpecPage_versionFormat;
return null;
}

protected abstract String getFeatureId();

protected String verifyIdRules() {
String id = getFeatureId();
if (id == null || id.length() == 0)
return PDEUIMessages.NewFeatureWizard_SpecPage_missing;
if (!IdUtil.isValidCompositeID(id)) {
return PDEUIMessages.NewFeatureWizard_SpecPage_invalidId;
}
return null;
}

protected String getInstallHandlerLibrary() {
String library = fLibraryText.getText();
if (library == null || library.length() == 0)
return null;
if (!library.endsWith(".jar") && !library.endsWith("/") && !library.equals(".")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
library += "/"; //$NON-NLS-1$
return library;
}

private void attachListeners() {
ModifyListener listener = e -> {
setPageComplete(validatePage());
};
attachListeners(listener);
fFeatureNameText.addModifyListener(listener);
fFeatureVersionText.addModifyListener(listener);
fLibraryText.addModifyListener(listener);
}

public abstract FeatureData getFeatureData();
}
Loading