当前位置: 首页>>代码示例>>Java>>正文


Java AndroidFacet.getConfigurationManager方法代码示例

本文整理汇总了Java中org.jetbrains.android.facet.AndroidFacet.getConfigurationManager方法的典型用法代码示例。如果您正苦于以下问题:Java AndroidFacet.getConfigurationManager方法的具体用法?Java AndroidFacet.getConfigurationManager怎么用?Java AndroidFacet.getConfigurationManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jetbrains.android.facet.AndroidFacet的用法示例。


在下文中一共展示了AndroidFacet.getConfigurationManager方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getConfiguration

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
protected Configuration getConfiguration(VirtualFile file, String deviceId) {
  AndroidFacet facet = AndroidFacet.getInstance(myModule);
  assertNotNull(facet);
  ConfigurationManager configurationManager = facet.getConfigurationManager();
  assertNotNull(configurationManager);
  Configuration configuration = configurationManager.getConfiguration(file);
  configuration.setDevice(findDeviceById(configurationManager, deviceId), false);

  return configuration;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:RenderTestBase.java

示例2: testGetLocales

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
public void testGetLocales() {
  myFixture.copyFileToProject("xmlpull/layout.xml", "res/layout/layout1.xml");
  myFixture.copyFileToProject("xmlpull/layout.xml", "res/layout-no-rNO/layout1.xml");
  myFixture.copyFileToProject("xmlpull/layout.xml", "res/layout-no/layout1.xml");
  myFixture.copyFileToProject("xmlpull/layout.xml", "res/layout-se/layout2.xml");

  AndroidFacet facet = AndroidFacet.getInstance(myModule);
  assertNotNull(facet);
  ConfigurationManager manager = facet.getConfigurationManager();
  assertNotNull(manager);
  assertSame(manager, facet.getConfigurationManager());

  List<Locale> locales = manager.getLocales();
  assertEquals(Arrays.asList(Locale.create("no"), Locale.create("no-rNO"), Locale.create("se")), locales);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ConfigurationManagerTest.java

示例3: testLocaleSpecificFolder

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
public void testLocaleSpecificFolder() throws Exception {
  VirtualFile file1 = myFixture.copyFileToProject(TEST_FILE, "res/layout/layout1.xml");
  VirtualFile file2 = myFixture.copyFileToProject(TEST_FILE, "res/layout-no-rNO/layout1.xml");
  VirtualFile file3 = myFixture.copyFileToProject(TEST_FILE, "res/layout-no/layout1.xml");
  VirtualFile file4 = myFixture.copyFileToProject(TEST_FILE, "res/layout-xlarge-land/layout1.xml");
  myFixture.copyFileToProject(TEST_FILE, "res/layout-se/layout2.xml");

  final AndroidFacet facet = AndroidFacet.getInstance(myModule);
  assertNotNull(facet);
  ConfigurationManager manager = facet.getConfigurationManager();
  assertNotNull(manager);
  assertSame(manager, facet.getConfigurationManager());

  // Default locale in the project: se
  manager.setLocale(Locale.create("se"));

  Configuration configuration1 = manager.getConfiguration(file1);
  /** This is not yet working; we need to sync all getLocale calls to getProject unless in a locale folder
  assertEquals(Locale.create("se"), configuration1.getLocale());
   */

  Configuration configuration2 = manager.getConfiguration(file2);
  assertEquals(Locale.create("no-rNO"), configuration2.getLocale());

  Configuration configuration3 = manager.getConfiguration(file3);
  assertEquals(Locale.create("no"), configuration3.getLocale());

  Configuration configuration4 = manager.getConfiguration(file4);
  assertEquals("Portrait", configuration1.getDeviceState().getName());
  assertEquals("Landscape", configuration4.getDeviceState().getName());
  assertEquals(ScreenSize.XLARGE, configuration4.getDevice().getDefaultHardware().getScreen().getSize());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:ConfigurationTest.java

示例4: testCaching

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
@SuppressWarnings("UnusedAssignment") // need to null out local vars before GC
public void testCaching() {
  VirtualFile file1 = myFixture.copyFileToProject("xmlpull/layout.xml", "res/layout/layout1.xml");
  VirtualFile file2 = myFixture.copyFileToProject("xmlpull/layout.xml", "res/layout-no-rNO/layout1.xml");

  AndroidFacet facet = AndroidFacet.getInstance(myModule);
  assertNotNull(facet);
  ConfigurationManager manager = facet.getConfigurationManager();
  assertNotNull(manager);
  assertSame(manager, facet.getConfigurationManager());
  assertSame(myModule, manager.getModule());

  Configuration configuration1 = manager.getConfiguration(file1);
  Configuration configuration2 = manager.getConfiguration(file2);
  assertNotSame(configuration1, configuration2);
  assertSame(configuration1, manager.getConfiguration(file1));
  assertSame(configuration2, manager.getConfiguration(file2));
  assertSame(file1, configuration1.getFile());
  assertSame(file2, configuration2.getFile());

  // GC test: Ensure that we keep a cache through the first GC, but not if
  // we nearly run out of memory:

  assertTrue(manager.hasCachedConfiguration(file1));
  assertTrue(manager.hasCachedConfiguration(file2));

  configuration1 = null;
  configuration2 = null;
  System.gc();
  assertTrue(manager.hasCachedConfiguration(file1));
  assertTrue(manager.hasCachedConfiguration(file2));

  try {
    PlatformTestUtil.tryGcSoftlyReachableObjects();
  } catch (Throwable t) {
    // The above method can throw java.lang.OutOfMemoryError; that's fine for this test
  }
  System.gc();
  assertFalse(manager.hasCachedConfiguration(file1));
  assertFalse(manager.hasCachedConfiguration(file2));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:ConfigurationManagerTest.java

示例5: test

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
public void test() throws Exception {
  final AndroidFacet facet = AndroidFacet.getInstance(myModule);
  assertNotNull(facet);
  ConfigurationManager manager = facet.getConfigurationManager();
  assertNotNull(manager);
  assertSame(manager, facet.getConfigurationManager());

  Configuration configuration = Configuration.create(manager, null, new FolderConfiguration());
  assertNotNull(configuration);

  configuration.startBulkEditing();
  configuration.setDisplayName("myconfig");
  configuration.setTheme("@style/Theme1");
  configuration.setNightMode(NightMode.NIGHT);
  configuration.setActivity("tes.tpkg.MyActivity1");
  configuration.setUiMode(UiMode.TELEVISION);
  IAndroidTarget target = configuration.getConfigurationManager().getTarget();
  Device device = configuration.getConfigurationManager().getDefaultDevice();
  State deviceState = device != null ? device.getState("Portrait") : null;
  if (target != null) {
    configuration.setTarget(target);
  }
  if (device != null) {
    configuration.setDevice(device, false);
    assertNotNull(deviceState);
    configuration.setDeviceState(deviceState);
  }
  configuration.setLocale(Locale.create("en-rUS"));
  configuration.finishBulkEditing();

  assertEquals("myconfig", configuration.getDisplayName());
  assertEquals("@style/Theme1", configuration.getTheme());
  assertEquals(NightMode.NIGHT, configuration.getNightMode());
  assertEquals("tes.tpkg.MyActivity1", configuration.getActivity());
  assertEquals(UiMode.TELEVISION, configuration.getUiMode());
  assertEquals(Locale.create("en-rUS"), configuration.getLocale());
  if (target != null) {
    assertSame(target, configuration.getTarget());
  }
  if (device != null) {
    assertSame(device, configuration.getDevice());
    assertNotNull(deviceState);
    assertSame(deviceState, configuration.getDeviceState());
  }

  FolderConfiguration fullConfig = configuration.getFullConfig();
  LocaleQualifier languageQualifier = fullConfig.getLocaleQualifier();
  String configDisplayString = fullConfig.toDisplayString();
  assertNotNull(configDisplayString, languageQualifier);
  assertEquals("en", languageQualifier.getLanguage());
  String region = fullConfig.getLocaleQualifier().getRegion();
  assertNotNull(configDisplayString, region);
  assertEquals("US", region);
  assertEquals(UiMode.TELEVISION, fullConfig.getUiModeQualifier().getValue());
  assertEquals(NightMode.NIGHT, fullConfig.getNightModeQualifier().getValue());
  assertEquals(ScreenOrientation.PORTRAIT, fullConfig.getScreenOrientationQualifier().getValue());

  if (device != null) {
    State landscape = device.getState("Landscape");
    assertNotNull(landscape);
    configuration.setDeviceState(landscape);
    assertEquals(ScreenOrientation.LANDSCAPE, configuration.getFullConfig().getScreenOrientationQualifier().getValue());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:65,代码来源:ConfigurationTest.java

示例6: testListener

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
public void testListener() throws Exception {
  final AndroidFacet facet = AndroidFacet.getInstance(myModule);
  assertNotNull(facet);
  ConfigurationManager manager = facet.getConfigurationManager();
  assertNotNull(manager);
  assertSame(manager, facet.getConfigurationManager());

  Configuration configuration = Configuration.create(manager, null, new FolderConfiguration());
  assertNotNull(configuration);

  ConfigurationListener listener = new ConfigurationListener() {
    @Override
    public boolean changed(int flags) {
      myFlags = flags;
      myChangeCount++;
      return true;
    }
  };
  configuration.addListener(listener);
  myChangeCount = 0;
  myFlags = 0;
  configuration.setTheme("@style/MyTheme");
  assertEquals(1, myChangeCount);
  assertEquals(CFG_THEME, myFlags);

  // No firing when no change:
  configuration.setTheme("@style/MyTheme");
  assertEquals(1, myChangeCount);
  assertEquals(CFG_THEME, myFlags);

  myChangeCount = 0;
  myFlags = 0;
  configuration.startBulkEditing();
  configuration.setTheme("@style/MyTheme2");
  assertEquals(0, myChangeCount);
  assertEquals(0, myFlags);

  configuration.setActivity("foo.bar.MyActivity");
  assertEquals(0, myChangeCount);
  assertEquals(0, myFlags);

  configuration.finishBulkEditing();
  assertEquals(1, myChangeCount);
  assertEquals(CFG_THEME | CFG_ACTIVITY, myFlags);

  myChangeCount = 0;
  myFlags = 0;
  configuration.startBulkEditing();
  configuration.setTheme("@style/MyTheme3");
  configuration.setActivity("foo.bar.MyActivity3");
  configuration.setNightMode(NightMode.NIGHT);
  configuration.finishBulkEditing();
  assertEquals(1, myChangeCount);
  assertEquals(CFG_THEME | CFG_ACTIVITY | CFG_NIGHT_MODE, myFlags);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:56,代码来源:ConfigurationTest.java

示例7: testCreateSimilar

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
public void testCreateSimilar() throws Exception {
  VirtualFile file1 = myFixture.copyFileToProject(TEST_FILE, "res/layout/layout1.xml");
  VirtualFile file2 = myFixture.copyFileToProject(TEST_FILE, "res/layout-no-rNO/layout1.xml");
  VirtualFile file3 = myFixture.copyFileToProject(TEST_FILE, "res/layout-xlarge-land/layout1.xml");
  myFixture.copyFileToProject(TEST_FILE, "res/layout-en/layout2.xml");

  final AndroidFacet facet = AndroidFacet.getInstance(myModule);
  assertNotNull(facet);
  ConfigurationManager manager = facet.getConfigurationManager();
  assertNotNull(manager);
  assertSame(manager, facet.getConfigurationManager());

  Configuration configuration1 = manager.getConfiguration(file1);
  configuration1.getConfigurationManager().setLocale(Locale.create("en"));
  configuration1.setTheme("Theme.Dialog");
  Device device = manager.getDevices().get(manager.getDevices().size() / 2 - 2);
  State state = device.getAllStates().get(device.getAllStates().size() - 1);
  configuration1.getConfigurationManager().selectDevice(device);

  configuration1.setDeviceStateName(state.getName());
  configuration1.save();

  Configuration configuration2 = manager.createSimilar(file2, file1);
  assertEquals(configuration1.getTheme(), configuration2.getTheme());
  Device device2 = configuration2.getDevice();
  assertEquals(configuration1.getDevice(), device2);
  assertEquals(Locale.create("no-rNO"), configuration2.getLocale());
  assertEquals(Locale.create("en"), configuration1.getLocale());

  State portrait = device.getState("Portrait");
  assertNotNull(portrait);
  configuration1.setDeviceState(portrait);

  Configuration configuration3 = manager.createSimilar(file3, file1);
  assertEquals(configuration1.getTheme(), configuration3.getTheme());
  assertNotSame(configuration3.getDeviceState(), portrait);
  assertEquals("Landscape", configuration3.getDeviceState().getName());
  assertEquals(ScreenSize.XLARGE, configuration3.getDevice().getDefaultHardware().getScreen().getSize());
  assertEquals(configuration1.getLocale(), configuration3.getLocale());
  // Ensure project-wide location switching works: both locales should update
  configuration1.getConfigurationManager().setLocale(Locale.create("no"));
  assertEquals(Locale.create("no"), configuration1.getLocale());
  assertEquals(configuration1.getLocale(), configuration3.getLocale());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:45,代码来源:ConfigurationTest.java

示例8: testListener

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
public void testListener() throws Exception {
  final AndroidFacet facet = AndroidFacet.getInstance(myModule);
  assertNotNull(facet);
  ConfigurationManager manager = facet.getConfigurationManager();
  assertNotNull(manager);
  assertSame(manager, facet.getConfigurationManager());

  Configuration parent = Configuration.create(manager, null, new FolderConfiguration());
  assertNotNull(parent);

  NestedConfiguration configuration = NestedConfiguration.create(parent);
  assertNotNull(configuration);

  ConfigurationListener listener = new ConfigurationListener() {
    @Override
    public boolean changed(int flags) {
      myFlags = flags;
      myChangeCount++;
      return true;
    }
  };
  configuration.addListener(listener);
  myChangeCount = 0;
  myFlags = 0;
  configuration.setOverrideLocale(true);
  configuration.setLocale(Locale.create("en-rUS"));
  assertEquals(1, myChangeCount);
  assertEquals(CFG_LOCALE, myFlags);

  // No firing when only seeing overridden changes
  myFlags = 0;
  parent.setLocale(Locale.create("es"));
  assertEquals(1, myChangeCount);
  assertEquals(0, myFlags);

  myFlags = 0;
  parent.setLocale(Locale.create("de"));
  parent.setUiMode(UiMode.APPLIANCE);
  assertEquals(2, myChangeCount);
  assertEquals(CFG_UI_MODE, myFlags);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:NestedConfigurationTest.java

示例9: test

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
public void test() throws Exception {
  VirtualFile file = myFixture.copyFileToProject(TEST_FILE, "res/layout/layout1.xml");
  final AndroidFacet facet = AndroidFacet.getInstance(myModule);
  assertNotNull(facet);
  ConfigurationManager manager = facet.getConfigurationManager();
  assertNotNull(manager);
  assertSame(manager, facet.getConfigurationManager());

  Configuration parent = Configuration.create(manager, file, new FolderConfiguration());
  assertNotNull(parent);

  parent.startBulkEditing();
  parent.setDisplayName("myconfig");
  parent.setTheme("@style/Theme1");
  parent.setNightMode(NightMode.NIGHT);
  parent.setActivity("tes.tpkg.MyActivity1");
  parent.setUiMode(UiMode.TELEVISION);
  IAndroidTarget target = parent.getConfigurationManager().getTarget();
  Device device = parent.getConfigurationManager().getDefaultDevice();
  State deviceState = device != null ? device.getState("Portrait") : null;
  if (target != null) {
    parent.setTarget(target);
  }
  if (device != null) {
    parent.setDevice(device, false);
    assertNotNull(deviceState);
    parent.setDeviceState(deviceState);
  }
  parent.setLocale(Locale.create("en-rUS"));
  parent.finishBulkEditing();

  VaryingConfiguration configuration = VaryingConfiguration.create(parent);
  configuration.setAlternateUiMode(true);
  assertEquals(UiMode.TELEVISION, parent.getUiMode());
  assertEquals(UiMode.APPLIANCE, configuration.getUiMode());
  parent.setUiMode(UiMode.APPLIANCE);
  assertEquals(UiMode.WATCH, configuration.getUiMode());

  assertNotNull(device);
  State portrait = device.getState("Portrait");
  State landscape = device.getState("Landscape");
  assertNotNull(portrait);
  assertNotNull(landscape);
  configuration.setAlternateDeviceState(true);
  assertTrue(configuration.isAlternatingDeviceState());
  assertEquals(ScreenOrientation.LANDSCAPE, configuration.getFullConfig().getScreenOrientationQualifier().getValue());
  parent.setDeviceState(landscape);
  assertEquals(ScreenOrientation.PORTRAIT, configuration.getFullConfig().getScreenOrientationQualifier().getValue());
  assertEquals(portrait, configuration.getDeviceState());
  parent.setDeviceState(portrait);
  assertEquals(ScreenOrientation.LANDSCAPE, configuration.getFullConfig().getScreenOrientationQualifier().getValue());
  assertEquals(landscape, configuration.getDeviceState());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:54,代码来源:VaryingConfigurationTest.java

示例10: test

import org.jetbrains.android.facet.AndroidFacet; //导入方法依赖的package包/类
public void test() throws Exception {
  VirtualFile file1 = myFixture.copyFileToProject("render/layout1.xml", "res/layout/layout1.xml");
  VirtualFile file2 = myFixture.copyFileToProject("render/layout2.xml", "res/layout/layout2.xml");
  VirtualFile file3 = myFixture.copyFileToProject("javadoc/strings/strings.xml", "res/values/strings.xml");
  assertNotNull(file1);
  assertNotNull(file2);
  assertNotNull(file3);
  AndroidFacet facet = AndroidFacet.getInstance(myModule);
  assertNotNull(facet);
  Project project = getProject();
  PsiFile psiFile1 = PsiManager.getInstance(project).findFile(file1);
  assertNotNull(psiFile1);
  PsiFile psiFile2 = PsiManager.getInstance(project).findFile(file2);
  assertNotNull(psiFile2);
  final PsiFile psiFile3 = PsiManager.getInstance(project).findFile(file3);
  assertNotNull(psiFile3);
  ConfigurationManager configurationManager = facet.getConfigurationManager();
  assertNotNull(configurationManager);
  final Configuration configuration1 = configurationManager.getConfiguration(file1);
  Configuration configuration2 = configurationManager.getConfiguration(file2);

  assertNotNull(configuration1.getTheme());
  assertEquals(configuration2.getTheme(), configuration1.getTheme());

  ResourceResolver resolver1 = configuration1.getResourceResolver();
  ResourceResolver resolver2 = configuration2.getResourceResolver();
  assertSame(resolver1, resolver2);
  assertSame(resolver1, configuration1.getResourceResolver());

  configuration1.setTheme("Theme.Light");
  final ResourceResolver resolver1b = configuration1.getResourceResolver();
  assertNotSame(resolver1b, resolver1);
  assertNotSame(resolver1b, resolver2);
  assertSame(resolver1b, configuration1.getResourceResolver());

  configuration2.setTheme("Theme.Light");
  assertSame(resolver1b, configuration2.getResourceResolver());

  // Test project resource changes, should invalidate
  final LocalResourceRepository resources = myFacet.getModuleResources(true);
  assertNotNull(resources); final long generation = resources.getModificationCount();
  assertEquals("Cancel", configuration1.getResourceResolver().findResValue("@string/cancel", false).getValue());
  WriteCommandAction.runWriteCommandAction(null, new Runnable() {
    @Override
    public void run() {
      //noinspection ConstantConditions
      XmlTagValue value = ((XmlFile)psiFile3).getRootTag().getSubTags()[1].getValue();
      assertEquals("Cancel", value.getTrimmedText());
      value.setText("\"FooBar\"");
    }
  });
  assertTrue(resources.isScanPending(psiFile3));
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      assertTrue(generation < resources.getModificationCount());
      assertNotSame(resolver1b, configuration1.getResourceResolver());
      assertEquals("FooBar", configuration1.getResourceResolver().findResValue("@string/cancel", false).getValue());
    }
  });

  ResourceResolverCache cache = configuration1.getConfigurationManager().getResolverCache();
  assertSame(cache, configuration2.getConfigurationManager().getResolverCache());

  ResourceRepository frameworkResources = cache.getFrameworkResources(configuration1.getFullConfig(), configuration1.getTarget());
  assertTrue(frameworkResources instanceof FrameworkResourceLoader.IdeFrameworkResources);
  assertTrue(((FrameworkResourceLoader.IdeFrameworkResources)frameworkResources).getSkippedLocales());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:69,代码来源:ResourceResolverCacheTest.java


注:本文中的org.jetbrains.android.facet.AndroidFacet.getConfigurationManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。