/** * Any write activity to the project's config property should be synchronized. */ private synchronized void setSwitchYardConfig(SwitchYardModel config) { _shell.getCurrentProject().setAttribute(CONFIG_ATTR, config); }
@Override public List<Object> getCompletionTokens() { List<Object> result = new ArrayList<Object>(); Project project = shell.getCurrentProject(); for (Class<? extends Facet> type : factory.getFacetTypes()) { if (project.hasFacet(type)) { result.add(ConstraintInspector.getName(type)); } } return result; }
@Override public List<Object> getCompletionTokens() { List<Object> result = new ArrayList<Object>(); Project project = shell.getCurrentProject(); for (Class<? extends Facet> type : factory.getFacetTypes()) { if (!project.hasFacet(type)) { result.add(ConstraintInspector.getName(type)); } } return result; }
private void completeJavaPaths(final PluginCommandCompleterState state, final OptionMetadata option, final Map<OptionMetadata, Object> valueMap, final ResourceFilter filter) Project project = shell.getCurrentProject(); if ((project != null) && project.hasFacet(JavaSourceFacet.class))
@Override public boolean constrantsSatisfied(final Shell shell) { try { ConstraintEnforcer enforcer = new ConstraintEnforcer(); enforcer.verifyAvailable(shell.getCurrentProject(), this); return this.usableWithScope(shell.getCurrentResourceScope()); } catch (ConstraintException e) { return false; } }
@DefaultCommand public void run(@Option(description = "The new directory", defaultValue = "~") Resource<?> r) { if (r != null) { Project currentProject = shell.getCurrentProject(); if (!r.exists()) { if ("~".equals(r.getName()) && currentProject.exists()) { r = currentProject.getProjectRoot(); } else throw new RuntimeException("no such resource: " + r.toString()); } String fullyQualifiedName = r.getFullyQualifiedName(); String userHomePath = OSUtils.getUserHomePath(); if (fullyQualifiedName.startsWith(userHomePath) && "~".equals(r.getFullyQualifiedName().substring(userHomePath.length()))) { r = currentProject.getProjectRoot(); } shell.setCurrentResource(r); } } }
/** * Returns the editable SwitchYard configuration for the current project. * The configuration is loaded if a config property has not been associated * with the project, so this method must be synchronized to prevent phantom * config references due to concurrent loading. * @return switchyard configuration */ public synchronized SwitchYardModel getSwitchYardConfig() { SwitchYardModel config = (SwitchYardModel) _shell.getCurrentProject().getAttribute(CONFIG_ATTR); if (config == null) { try { config = readSwitchYardConfig(getSwitchYardConfigFile()); setSwitchYardConfig(config); } catch (java.io.IOException ioEx) { _shell.println("Error while reading SwitchYard configuration: " + ioEx.getMessage()); } } config.orderModelChildren(); return config; }
/** * Returns a project-scoped configuration (if a project is in scope). Falls back to the user scope configuration if * no project is set in the shell * * @return * @throws ConfigurationException */ @Produces public Configuration getConfiguration(Shell shell) throws ConfigurationException { Project project = shell.getCurrentProject(); if (project == null) { return factory.getUserConfig(); } if (!project.hasFacet(ConfigurationFacet.class)) { // Installing manually ConfigurationFacet facet = new ConfigurationFacet(factory); project.installFacet(facet); } return project.getFacet(ConfigurationFacet.class).getConfiguration(); } }
public void verifyConstraints(final Shell shell) { ConstraintEnforcer enforcer = new ConstraintEnforcer(); if (command != null) { try { // TODO this is where more complex constraints could be handled on individual commands if (!command.isSetup()) enforcer.verifyAvailable(shell.getCurrentProject(), command.getParent()); } catch (ConstraintException e) { throw new CommandExecutionException(command, e); } } }
if (showAll || enforcer.isAvailable(shell.getCurrentProject(), pluginMetadata))
@Override public boolean isSetupAvailable(final Shell shell) { if (hasSetupCommand()) { if (!ConstraintInspector.requiresProject(getType()) || (ConstraintInspector.requiresProject(getType()) && (shell.getCurrentProject() != null))) { CommandMetadata setupCommand = getSetupCommand(); return setupCommand.usableWithResource(shell.getCurrentResourceScope()); } } return false; } }
private void printGeneralHelp(final PipeOut out) { out.println("Welcome to " + out.renderColor(ShellColor.YELLOW, "JBoss Forge") + ", a next-generation " + "interactive Shell and project-generation tool. If you find yourself lost, or uncertain how " + "to complete an operation, you may press the " + out.renderColor(ShellColor.BOLD, "<TAB>") + " key for command-completion, or " + out.renderColor(ShellColor.BOLD, "<TAB><TAB>") + " for hints while typing a command."); out.println(); out.println("Type " + out.renderColor(ShellColor.BOLD, "'list-commands'") + " for a list of available " + "commands in the current Resource context."); out.println(); Project currentProject = shell.getCurrentProject(); if (currentProject != null) { out.println("Currently operating on the Project located at [" + currentProject.getProjectRoot().getFullyQualifiedName() + "]"); } else { out.println("You are not working on a project. Type " + out.renderColor(ShellColor.BOLD, "'help new-project'") + " to get started."); } }
PathspecParser parser = new PathspecParser(resources, shell.getCurrentProject().getProjectRoot(), relativePath); List<Resource<?>> resolvedResources = parser.resolve(); if (!resolvedResources.isEmpty()