public static NavigationResultBuilder navigationBuilder() { NavigationResultBuilder builder = NavigationResultBuilder.create(); return builder; }
/** * Create a new instance of a NavigationResultBuilder * * @return A NavigationResultBuilder instance */ public static NavigationResultBuilder create() { return new NavigationResultBuilder(); }
/** * Create a {@link NavigationResult} using the given {@link UICommand} type as the target. */ public static final NavigationResult navigateTo(Class<? extends UICommand> next) { if (next == null) { return null; } NavigationResultBuilder builder = navigationBuilder(); builder.add(next); return builder.build(); }
/** * Add multiple UICommand types to create a single navigation entry. Every invocation of this method creates a * separate navigation entry. UIWizard types must not be provided as arguments since wizards and wizard steps cannot * be combined with other UICommand types in the same navigation entry. * * Use the other add(...) methods to add UIWizard types. * * @param metadata The command metadata * @param types The UICommand types to add as a single navigation entry * @return This NavigationResultBuilder instance */ public NavigationResultBuilder add(UICommandMetadata metadata, Iterable<Class<? extends UICommand>> types) { List<NavigationResultEntry> internalEntries = new ArrayList<>(); for (Class<? extends UICommand> type : types) { if (UIWizard.class.isAssignableFrom(type)) { throw new IllegalArgumentException("A UICommand of type " + type + " was added. " + UIWizard.class.getSimpleName() + " instances should be added individually."); } else { internalEntries.add(new ClassNavigationResultEntry(type)); } } entries.add(new CompositeNavigationResultEntry(metadata, internalEntries)); return this; }
/** * Add a UICommand instance to create a single navigation entry. * * @param command The UICommand to add * @return This NavigationResultBuilder instance */ public NavigationResultBuilder add(UICommand command) { entries.add(new CommandNavigationResultEntry(command)); return this; }
/** * Add a UICommand type to create a single navigation entry. * * @param type The UICommand type to add * @return This NavigationResultBuilder instance */ public NavigationResultBuilder add(Class<? extends UICommand> type) { entries.add(new ClassNavigationResultEntry(type)); return this; }
/** * Create a NavigationResult instance representing the entries that have been added. * * @return A NavigationResult instance */ public NavigationResult build() { if (entries.isEmpty()) { return null; } else { return new NavigationResultImpl(entries); } } }
@Override public UICommand getCommand(AddonRegistry addonRegistry, UIContext context) { if (command == null) { List<UICommand> commands = new ArrayList<>(); for (NavigationResultEntry entry : entries) { UICommand command = entry.getCommand(addonRegistry, context); commands.add(command); } command = new CompositeCommand(metadata, commands); } return command; }
/** * Create a {@link NavigationResult} using the given {@link UICommand} types as the targets. */ @SuppressWarnings("unchecked") public static final NavigationResult navigateTo(Class<? extends UICommand> next, Class<? extends UICommand>... additional) { if (next == null) return null; NavigationResultBuilder builder = navigationBuilder(); builder.add(next); for (Class<? extends UICommand> type : additional) { builder.add(type); } return builder.build(); }
/** * Create a new instance of a NavigationResultBuilder using the provided NavigationResult instance as a base. * * @param result A NavigationResult whose entries are used as the basis to eventually construct a new * NavigationResult through this NavigationResultBuilder. * @return A NavigationResultBuilder instance */ public static NavigationResultBuilder create(NavigationResult result) { NavigationResultBuilder builder = new NavigationResultBuilder(); if (result != null && result.getNext() != null) { builder.entries.addAll(Arrays.asList(result.getNext())); } return builder; }
/** * Create a {@link NavigationResult} using the given {@link UICommand} array as the target. */ public static final NavigationResult navigateTo(Class<? extends UICommand>[] next) { if (next == null) { return null; } NavigationResultBuilder builder = navigationBuilder(); for (Class<? extends UICommand> type : next) { builder.add(type); } return builder.build(); }
@Override public NavigationResult next(UINavigationContext context) throws Exception { NavigationResultBuilder builder = NavigationResultBuilder.create(); if (needFabric8Setup) { builder.add(Fabric8SetupStep.class); } if (needOptionalStep) { builder.add(DevOpsEditOptionalStep.class); } builder.add(DevOpsEditStep.class); return builder.build(); }
@Override public NavigationResult next(UINavigationContext context) throws Exception { NavigationResultBuilder builder = NavigationResultBuilder.create(); builder.add(Metadata.forCommand(SetupCommand.class).name("WildFly Swarm: Setup") .description("Setup WildFly Swarm in your web application"), Arrays.asList(SetupCommand.class, AddFractionCommand.class)); builder.add(SetupFractionsStep.class); return builder.build(); }
@Override public NavigationResult next(UINavigationContext context) { NavigationResultBuilder builder = NavigationResultBuilder.create(); builder.add( Metadata.forCommand(SetupVertxCommand.class).name("Vert.x: Setup").description("Setup Vert.x") .category(Categories.create("vert.x")), Arrays.asList(SetupVertxCommand.class, AddDependencyCommand.class)); return builder.build(); }
@Override public NavigationResult next(UINavigationContext context) throws Exception { UIContext uiContext = context.getUIContext(); Map<Object, Object> attributeMap = uiContext.getAttributeMap(); ScaffoldProvider selectedProvider = provider.getValue(); ScaffoldSetupContext setupContext = createSetupContext(uiContext); attributeMap.put(ScaffoldProvider.class, selectedProvider); attributeMap.put(ScaffoldSetupContext.class, setupContext); // Get the navigation result entries from the selected scaffold provider NavigationResult setupFlow = selectedProvider.getSetupFlow(setupContext); // Add the execution logic step in the end so that the scaffold setup step is executed last after all other steps NavigationResultBuilder builder = NavigationResultBuilder.create(setupFlow); NavigationResult navigationResult = builder.add(ScaffoldExecuteSetupStep.class).build(); return navigationResult; }