GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add NameService and NameProvider by imagejan · Pull Request #425 · scijava/scijava-common

Conversation

@imagejan

@imagejan imagejan commented Jun 22, 2021

Copy link
Copy Markdown
Member

This allows to define a way to derive names from objects of third party libraries, e.g. for use in ObjectService, where objects are registered with a name and can be provided e.g. in a drop-down choice in the UI.

This pull request, together with imagej/imagej-legacy#263, will resolve this forum discussion about being able to automatically populate ij.measure.ResultsTable inputs, provided we implement the following ResultsTableNameProvider in a follow-up pull request to imagej-legacy:

package net.imagej.legacy.plugin;

import org.scijava.names.NameProvider;
import org.scijava.plugin.AbstractHandlerPlugin;
import org.scijava.plugin.Plugin;

import ij.measure.ResultsTable;

@Plugin(type=NameProvider.class)
public class ResultsTableNameProvider extends AbstractHandlerPlugin<Object> implements NameProvider {

	@Override
	public String getName(Object thing) {
		return ((ResultsTable) thing).getTitle();
	}

	@Override
	public boolean supports(Object thing) {
		return ResultsTable.class.isAssignableFrom(thing.getClass());
	}
}

(Suggestions welcome to make this even more concise!)

image

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

NicoKiaru reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@imagejan
Add NameService and NameProvider
bbd91e9
This change allows to define a way to derive names from objects of third party libraries, e.g. for use in ObjectService, where objects are registered with a name and can be provided e.g. in a drop-down choice in the UI.
@imagejan
imagejan requested a review from ctrueden June 22, 2021 18:55
@NicoKiaru

NicoKiaru commented Jun 23, 2021

Copy link
Copy Markdown
Contributor

Hi @imagejan ,

Could this provide a mechanism to solve imagej/imagej-legacy#243 as well ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@imagejan

imagejan commented Jun 23, 2021

Copy link
Copy Markdown
Member Author

@NicoKiaru absolutely, it could solve the problem of having Pet@57a3e26a instead of Felix as a name in your example. In general, this allows giving names to any object of a third-party library (i.e. not under your control) by adding a NameProvider plugin that can be discovered at runtime.

NicoKiaru reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@NicoKiaru

NicoKiaru commented Jun 23, 2021

Copy link
Copy Markdown
Contributor

Then it could be adde in the ij1 macro engine I guess ?

https://github.com/imagej/imagej-legacy/blob/5c46549e765b3148d767a8c90d15b6be03b4c154/src/main/java/net/imagej/legacy/plugin/IJ1MacroEngine.java#L251

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@imagejan

imagejan commented Jun 23, 2021

Copy link
Copy Markdown
Member Author

@NicoKiaru iff the change proposed here gets merged and included in a release, and then the change from v.toString() to objectService.getName(v) you proposed in https://github.com/imagej/imagej-legacy/pull/243/files#diff-de04251535e202b6132a0485276551de8ec4b1e86a639a9b54c67d63527ef5e1R251 is indeed sufficient to have the desired recording behavior (for objects where you also implement a NameProvider).

The remaining issue would then be the other direction, determining the object from the given name, which is potentially ambiguous, but let's discuss this on the imagej-legacy issue.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@NicoKiaru

NicoKiaru commented Jun 23, 2021

Copy link
Copy Markdown
Contributor

The remaining issue would then be the other direction, determining the object from the given name, which is potentially ambiguous

Getting a converter from String to an object can be handled quite correctly by converter I find, but ok, let's keep this as a discussion in imagej-legacy.

For this PR, I have a question regarding the following use case:

Imagine you have 5 different objects in the object service of a certain class Image. Would the mechanism you suggest assign a name to an array of such objects ? This could be convenient for an Image[] input parameter for instance.

If yes, could we make this modular ? Like can Object in your example, be of class Image[] ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ctrueden ctrueden self-assigned this May 3, 2023
@ctrueden
ctrueden force-pushed the master branch 3 times, most recently from 53b6733 to 3dc99c9 Compare November 7, 2023 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ctrueden ctrueden Awaiting requested review from ctrueden

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@ctrueden ctrueden

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@imagejan @NicoKiaru @ctrueden
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.