Package org.jboss.forge.addon.configuration

Examples of org.jboss.forge.addon.configuration.Configuration


   @Test
   public void testConfigListInProject() throws Exception
   {
      Project project = projectFactory.createTempProject();
      Configuration projectConfig = project.getFacet(ConfigurationFacet.class).getConfiguration();
      addPropsToProjectConfig(projectConfig);
      test.getShell().setCurrentResource(project.getRoot());
      test.execute("config-list", 5, TimeUnit.SECONDS);
      Assert.assertThat(test.getStdOut(), containsString("key2=project: [projectValue2]"));
      Assert.assertThat(test.getStdOut(), containsString("key3=project: [projectValue3]"));
View Full Code Here


   @Test
   public void testMergedConfigList() throws Exception
   {
      addPropsToUserConfig();
      Project project = projectFactory.createTempProject();
      Configuration projectConfig = project.getFacet(ConfigurationFacet.class).getConfiguration();
      addPropsToProjectConfig(projectConfig);
      test.getShell().setCurrentResource(project.getRoot());
      test.execute("config-list", 5, TimeUnit.SECONDS);
      Assert.assertThat(test.getStdOut(), containsString("key1=user: [userValue1]"));
      Assert.assertThat(test.getStdOut(), containsString("key2=user: [userValue2], project: [projectValue2]"));
View Full Code Here

   }

   public static ProxySettings fromForgeConfiguration(Configuration configuration)
   {

      Configuration proxyConfig = configuration.subset("proxy");
      if (proxyConfig != null && !proxyConfig.isEmpty())
      {
         return new ProxySettings(proxyConfig.getString(PROXY_CONFIG_HOST_KEY),
                  proxyConfig.getInt(PROXY_CONFIG_PORT_KEY), proxyConfig.getString(PROXY_CONFIG_USERNAME_KEY),
                  proxyConfig.getString(PROXY_CONFIG_PASSWORD_KEY));
      }
      else
      {
         return null;
      }
View Full Code Here

   {
      Shell shell = (Shell) context.getUIContext().getProvider();
      PrintStream out = shell.getOutput().out();

      Project project = Projects.getSelectedProject(projectFactory, context.getUIContext());
      Configuration projectConfig = null;
     
      if (project != null)
      {
         projectConfig = project.getFacet(ConfigurationFacet.class).getConfiguration();
      }
     
      Iterator<?> userConfigKeys = userConfig.getKeys();

      while (userConfigKeys.hasNext())
      {
         Object key = userConfigKeys.next();

         if (key != null)
         {
            out.print(key.toString());
            out.print("=");
           
            out.print("user: [" + userConfig.getProperty(key.toString()) + "]");
            if (projectConfig != null)
            {
               out.print(", project: ");
               Object value = projectConfig.getProperty(key.toString());
               if (value != null)
               {
                  out.print("[" + value.toString() + "] ");
               }
               else
                  out.print("[]");
            }
         }
         out.println();
      }
     
      if (projectConfig != null)
      {
         Iterator<?> projectConfigKeys = projectConfig.getKeys();
        
         while (projectConfigKeys.hasNext())
         {
            String key = projectConfigKeys.next().toString();
            if (!userConfig.containsKey(key))
            {
               out.print(key.toString());
               out.print("=project: [");
               out.print(projectConfig.getProperty(key.toString()).toString() + "]");
            }
         }
      }
      return Results.success();
   }
View Full Code Here

              + property.valueType + ", not " + value.getClass());
    }

    @SuppressWarnings("unchecked")
    final ConfigTypeConverter<T> converter = (ConfigTypeConverter<T>) converterFactory.getConverter(property.valueType);
    final Configuration config = project.getFacet(ConfigurationFacet.class).getConfiguration();
    final String attribute = getProjectAttribute(property);

    config.setProperty(attribute, converter.convertToString(value));
  }
View Full Code Here

  @Override
  public boolean uninstall() {
    if (isInstalled()) {
      final ConfigurationFacet configFacet = project.getFacet(ConfigurationFacet.class);
      final Configuration config = configFacet.getConfiguration();

      for (final ProjectProperty property : Arrays.asList(ProjectProperty.values())) {
        if (config.containsKey(getProjectAttribute(property))) {
          config.clearProperty(getProjectAttribute(property));
        }
      }

      return true;
    }
View Full Code Here

      return REPOSITORY;
   }

   public String remoteRepository()
   {
      Configuration user = userConfig();
      if (user.containsKey(REPOSITORY_KEY))
      {
         return user.getString(REPOSITORY_KEY);
      }
      return defaultRemoteRepository();
   }
View Full Code Here

      return new File(System.getProperty("user.home") + File.separator + BOILERPLATE_FILE);
   }

   public File localRepository()
   {
      Configuration user = userConfig();
      if (user.containsKey(CLONE_LOCATION_KEY))
      {
         return new File(user.getString(CLONE_LOCATION_KEY));
      }
      return defaultLocalRepository();
   }
View Full Code Here

      if (local)
      {
         Project project = Projects.getSelectedProject(projectFactory, context);
         if (project != null)
         {
            Configuration projectConfig = project.getFacet(ConfigurationFacet.class).getConfiguration();
            projectConfig.setProperty(key, value);
         }
         else
         {
            return Results.fail("No project found in current context. Can't store in local configuration.");
         }
View Full Code Here

      if (local)
      {
         Project project = Projects.getSelectedProject(projectFactory, context);
         if (project != null)
         {
            Configuration projectConfig = project.getFacet(ConfigurationFacet.class).getConfiguration();
            projectConfig.clearProperty(key);
         }
         else
         {
            return Results.fail("No project found in current context. Can't clear from local configuration.");
         }
View Full Code Here

TOP

Related Classes of org.jboss.forge.addon.configuration.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.