Skip to content

Commit

Permalink
Addon Manager is now categorized
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Jun 1, 2013
1 parent b87efe2 commit f110af9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

public interface AddonCommandConstants
{
String[] ADDON_MANAGER_CATEGORIES = { "Addon", "Manage" };
String ADDON_INSTALL_COMMAND_NAME = "Install an Addon";
String ADDON_INSTALL_COMMAND_DESCRIPTION = "Command to install a Furnace 2 addon.";
String ADDON_REMOVE_COMMAND_NAME = "Remove an Addon";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
package org.jboss.forge.addon.manager.impl.commands;

import javax.inject.Inject;
import javax.inject.Singleton;

import org.jboss.forge.addon.manager.AddonManager;
import org.jboss.forge.addon.projects.Project;
import org.jboss.forge.addon.projects.ProjectFactory;
import org.jboss.forge.addon.projects.facets.MetadataFacet;
import org.jboss.forge.addon.resource.FileResource;
import org.jboss.forge.addon.ui.UICommand;
import org.jboss.forge.addon.ui.AbstractUICommand;
import org.jboss.forge.addon.ui.context.UIBuilder;
import org.jboss.forge.addon.ui.context.UIContext;
import org.jboss.forge.addon.ui.context.UISelection;
import org.jboss.forge.addon.ui.context.UIValidationContext;
import org.jboss.forge.addon.ui.input.UIInput;
import org.jboss.forge.addon.ui.metadata.UICommandMetadata;
import org.jboss.forge.addon.ui.metadata.WithAttributes;
import org.jboss.forge.addon.ui.result.Result;
import org.jboss.forge.addon.ui.result.Results;
import org.jboss.forge.addon.ui.util.Categories;
import org.jboss.forge.addon.ui.util.Metadata;
import org.jboss.forge.furnace.addons.AddonId;

@Singleton
public class AddonInstallCommand implements UICommand
public class AddonInstallCommand extends AbstractUICommand implements AddonCommandConstants
{

@Inject
Expand All @@ -44,16 +41,11 @@ public class AddonInstallCommand implements UICommand
private ProjectFactory projectFactory;

@Override
public UICommandMetadata getMetadata()
public Metadata getMetadata()
{
return Metadata.forCommand(getClass()).name(AddonCommandConstants.ADDON_INSTALL_COMMAND_NAME)
.description(AddonCommandConstants.ADDON_INSTALL_COMMAND_DESCRIPTION);
}

@Override
public boolean isEnabled(UIContext context)
{
return true;
return super.getMetadata().name(ADDON_INSTALL_COMMAND_NAME)
.description(ADDON_INSTALL_COMMAND_DESCRIPTION)
.category(Categories.create(ADDON_MANAGER_CATEGORIES));
}

@Override
Expand All @@ -70,11 +62,6 @@ public void initializeUI(UIBuilder builder) throws Exception
builder.add(groupId).add(name).add(version);
}

@Override
public void validate(UIValidationContext context)
{
}

@Override
public Result execute(UIContext context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,22 @@
import org.jboss.forge.addon.projects.ProjectFactory;
import org.jboss.forge.addon.projects.facets.MetadataFacet;
import org.jboss.forge.addon.resource.FileResource;
import org.jboss.forge.addon.ui.UICommand;
import org.jboss.forge.addon.ui.AbstractUICommand;
import org.jboss.forge.addon.ui.context.UIBuilder;
import org.jboss.forge.addon.ui.context.UIContext;
import org.jboss.forge.addon.ui.context.UISelection;
import org.jboss.forge.addon.ui.context.UIValidationContext;
import org.jboss.forge.addon.ui.input.UISelectMany;
import org.jboss.forge.addon.ui.metadata.UICommandMetadata;
import org.jboss.forge.addon.ui.metadata.WithAttributes;
import org.jboss.forge.addon.ui.result.Result;
import org.jboss.forge.addon.ui.result.Results;
import org.jboss.forge.addon.ui.util.Categories;
import org.jboss.forge.addon.ui.util.Metadata;
import org.jboss.forge.furnace.Furnace;
import org.jboss.forge.furnace.addons.AddonId;
import org.jboss.forge.furnace.repositories.AddonRepository;
import org.jboss.forge.furnace.repositories.MutableAddonRepository;

public class AddonRemoveCommand implements UICommand, AddonCommandConstants
public class AddonRemoveCommand extends AbstractUICommand implements AddonCommandConstants
{

@Inject
Expand All @@ -45,16 +44,10 @@ public class AddonRemoveCommand implements UICommand, AddonCommandConstants
private ProjectFactory projectFactory;

@Override
public boolean isEnabled(UIContext context)
public Metadata getMetadata()
{
return true;
}

@Override
public UICommandMetadata getMetadata()
{
return Metadata.forCommand(getClass()).name(ADDON_REMOVE_COMMAND_NAME)
.description(ADDON_REMOVE_COMMAND_DESCRIPTION);
return super.getMetadata().name(ADDON_REMOVE_COMMAND_NAME)
.description(ADDON_REMOVE_COMMAND_DESCRIPTION).category(Categories.create(ADDON_MANAGER_CATEGORIES));
}

@Override
Expand Down Expand Up @@ -87,11 +80,6 @@ public void initializeUI(UIBuilder builder) throws Exception
builder.add(addons);
}

@Override
public void validate(UIValidationContext context)
{
}

@Override
public Result execute(UIContext context) throws Exception
{
Expand Down

0 comments on commit f110af9

Please sign in to comment.