-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #543 from agoncal/FORGE-2265
FORGE-2265: Refactoring the CDI Commands
- Loading branch information
Showing
19 changed files
with
225 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
javaee/impl/src/main/java/org/jboss/forge/addon/javaee/cdi/ui/AbstractCDICommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package org.jboss.forge.addon.javaee.cdi.ui; | ||
|
||
import static org.jboss.forge.addon.javaee.JavaEEFacet.DEFAULT_CDI_PACKAGE; | ||
import static org.jboss.forge.addon.javaee.JavaEEFacet.DEFAULT_CONSTRAINT_PACKAGE; | ||
|
||
import org.jboss.forge.addon.javaee.JavaEEFacet; | ||
import org.jboss.forge.addon.javaee.cdi.CDIFacet; | ||
import org.jboss.forge.addon.javaee.validation.ValidationFacet; | ||
import org.jboss.forge.addon.javaee.validation.ui.ValidationProviderSetupCommand; | ||
import org.jboss.forge.addon.parser.java.facets.JavaSourceFacet; | ||
import org.jboss.forge.addon.parser.java.ui.AbstractJavaSourceCommand; | ||
import org.jboss.forge.addon.projects.Project; | ||
import org.jboss.forge.addon.ui.command.PrerequisiteCommandsProvider; | ||
import org.jboss.forge.addon.ui.context.UIContext; | ||
import org.jboss.forge.addon.ui.result.NavigationResult; | ||
import org.jboss.forge.addon.ui.result.navigation.NavigationResultBuilder; | ||
import org.jboss.forge.addon.ui.util.Categories; | ||
import org.jboss.forge.addon.ui.util.Metadata; | ||
import org.jboss.forge.roaster.model.source.JavaSource; | ||
|
||
/** | ||
* @author <a href="antonio.goncalves@gmail.com">Antonio Goncalves</a> | ||
*/ | ||
public abstract class AbstractCDICommand<T extends JavaSource<?>> extends AbstractJavaSourceCommand<T> | ||
implements PrerequisiteCommandsProvider | ||
{ | ||
|
||
@Override | ||
public Metadata getMetadata(UIContext context) | ||
{ | ||
return Metadata.from(super.getMetadata(context), getClass()) | ||
.category(Categories.create(Categories.create("Java EE"), "CDI")); | ||
} | ||
|
||
@Override | ||
protected boolean isProjectRequired() | ||
{ | ||
return true; | ||
} | ||
|
||
@Override | ||
protected String calculateDefaultPackage(UIContext context) | ||
{ | ||
return getSelectedProject(context).getFacet(JavaSourceFacet.class).getBasePackage() + "." | ||
+ DEFAULT_CDI_PACKAGE; | ||
} | ||
|
||
@Override | ||
public NavigationResult getPrerequisiteCommands(UIContext context) | ||
{ | ||
NavigationResultBuilder builder = NavigationResultBuilder.create(); | ||
Project project = getSelectedProject(context); | ||
if (project != null) | ||
{ | ||
if (!project.hasFacet(CDIFacet.class)) | ||
{ | ||
builder.add(CDISetupCommand.class); | ||
} | ||
} | ||
return builder.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.