Skip to content

Commit

Permalink
Merge pull request #5728 from DataInMotion/fix_deprecated_target
Browse files Browse the repository at this point in the history
Replaces deprecated interfaces in BndTargetLocation
  • Loading branch information
pkriens authored Sep 1, 2023
2 parents a7a2181 + 7d64ddb commit 1270892
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
22 changes: 8 additions & 14 deletions bndtools.pde/src/bndtools/pde/target/BndTargetLocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.pde.core.target.ITargetDefinition;
import org.eclipse.pde.core.target.ITargetLocation;
import org.eclipse.pde.core.target.TargetFeature;
import org.eclipse.pde.internal.core.PDECore;
import org.eclipse.pde.internal.core.target.AbstractBundleContainer;
import org.eclipse.pde.internal.core.target.TargetDefinition;
import org.eclipse.pde.ui.target.ITargetLocationEditor;
import org.eclipse.pde.ui.target.ITargetLocationUpdater;
import org.eclipse.pde.ui.target.ITargetLocationHandler;
import org.eclipse.swt.graphics.Image;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
Expand All @@ -32,7 +31,7 @@

@SuppressWarnings("deprecation")
public abstract class BndTargetLocation extends AbstractBundleContainer
implements ITargetLocationUpdater, ITargetLocationEditor, ILabelProvider {
implements ITargetLocationHandler, ILabelProvider {
static final String PLUGIN_ID = "bndtools.pde";

static final String MESSAGE_UNABLE_TO_LOCATE_WORKSPACE = "Unable to locate the Bnd workspace";
Expand All @@ -52,32 +51,27 @@ public BndTargetLocation(String type, String containerIconName) {
@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Class<T> adapter) {
if (adapter == ITargetLocationEditor.class) {
return (T) this;

} else if (adapter == ITargetLocationUpdater.class) {
return (T) this;

} else if (adapter == ILabelProvider.class) {
if (adapter == ILabelProvider.class) {
return (T) this;

} else {
return super.getAdapter(adapter);
}
}


@Override
public boolean canEdit(ITargetDefinition target, ITargetLocation targetLocation) {
public boolean canEdit(ITargetDefinition targetLocation, TreePath treePath) {
return targetLocation == this;
}

@Override
public boolean canUpdate(ITargetDefinition target, ITargetLocation targetLocation) {
public boolean canUpdate(ITargetDefinition targetLocation, TreePath treePath) {
return targetLocation == this;
}

@Override
public IStatus update(ITargetDefinition target, ITargetLocation targetLocation, IProgressMonitor monitor) {
public IStatus update(ITargetDefinition target, TreePath[] treePaths, IProgressMonitor monitor) {
clearResolutionStatus();
return Status.OK_STATUS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.pde.core.target.ITargetDefinition;
import org.eclipse.pde.core.target.ITargetLocation;
Expand Down Expand Up @@ -61,8 +62,9 @@ public String getText(Object element) {
return repositoryName;
}


@Override
public IWizard getEditWizard(ITargetDefinition target, ITargetLocation targetLocation) {
public IWizard getEditWizard(ITargetDefinition target, TreePath treePath) {
RepositoryTargetLocationWizard wizard = new RepositoryTargetLocationWizard();
wizard.setTarget(target);
wizard.setTargetLocation(this);
Expand All @@ -82,13 +84,17 @@ protected TargetBundle[] resolveBundles(ITargetDefinition definition, IProgressM

int i = 0;
for (String bsn : bsns) {
if (bsn.contains(":")) {
continue;
}
Version version = repository.versions(bsn)
.last();

File download = repository.get(bsn, version, new HashMap<String, String>());
try {
bundles.add(new TargetBundle(download));
} catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID,
throw new CoreException(new Status(IStatus.WARNING, PLUGIN_ID,
"Invalid plugin in repository: " + bsn + " @ " + getLocation(false), e));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.pde.core.target.ITargetDefinition;
import org.eclipse.pde.core.target.ITargetLocation;
Expand Down Expand Up @@ -68,7 +69,7 @@ public String getText(Object element) {
}

@Override
public IWizard getEditWizard(ITargetDefinition target, ITargetLocation targetLocation) {
public IWizard getEditWizard(ITargetDefinition target, TreePath treePath) {
RunDescriptorTargetLocationWizard wizard = new RunDescriptorTargetLocationWizard();
wizard.setTarget(target);
wizard.setTargetLocation(this);
Expand Down

0 comments on commit 1270892

Please sign in to comment.