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

Populate services of cards #66

Draft
wants to merge 2 commits into
base: split_Panel
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/bdv/ui/Card.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface Card
*
* @return is visible
*/
default boolean getDefaultVisibilty()
default boolean getDefaultVisibility()
{
return true;
}
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/bdv/ui/CardPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
import org.scijava.command.CommandService;
import org.scijava.module.ModuleException;
import org.scijava.module.ModuleItem;
import org.scijava.module.process.ServicePreprocessor;
import org.scijava.plugin.PluginInfo;
import org.scijava.plugin.SciJavaPlugin;

/**
* CardPanel handles components in named {@link CardWrapper}s which can be opened or closed.
Expand Down Expand Up @@ -73,9 +76,11 @@ public void addAll( final Class< ? extends DiscoverableCard > type, final Map< C
try
{
final CommandModule cardModule = new CommandModule( cardInfo );
populateServices(cardModule, commandService);
boolean allInputsResolved = true;
for ( final ModuleItem< ? > item : cardInfo.inputs() )
{
if(cardModule.isInputResolved(item.getName())) continue;
final Class< ? > inputKlass = item.getType();

if ( parameterMap.containsKey( inputKlass ) )
Expand All @@ -92,7 +97,7 @@ public void addAll( final Class< ? extends DiscoverableCard > type, final Map< C
if ( allInputsResolved )
{
final Card card = ( ( DiscoverableCard ) cardModule.getCommand() ).getCard();
addCard( card.getName(), card.getComponent(), card.getDefaultVisibilty() );
addCard( card.getName(), card.getComponent(), card.getDefaultVisibility() );
}
}
catch ( ModuleException e )
Expand All @@ -102,6 +107,12 @@ public void addAll( final Class< ? extends DiscoverableCard > type, final Map< C
} );
}

private void populateServices(CommandModule module, CommandService commandService) {
PluginInfo<SciJavaPlugin> preprocessorInfo = commandService.pluginService().getPlugin(ServicePreprocessor.class);
ServicePreprocessor preprocessor = (ServicePreprocessor) commandService.pluginService().createInstance(preprocessorInfo);
preprocessor.process(module);
}

/**
* Add a new {@link JComponent} to the card panel.
*
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/bdv/ui/ExampleCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public JComponent getComponent()
}

@Override
public boolean getDefaultVisibilty()
public boolean getDefaultVisibility()
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/bdv/ui/ExampleCardHighPriority.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public JComponent getComponent()
}

@Override
public boolean getDefaultVisibilty()
public boolean getDefaultVisibility()
{
return true;
}
Expand Down