Package org.eclipse.wb.internal.core.nls.edit

Examples of org.eclipse.wb.internal.core.nls.edit.IEditableSource


  public IEditableSource createEditableSource(Object o) throws Exception {
    SourceParameters parameters = (SourceParameters) o;
    String className = parameters.m_constant.m_fullClassName;
    String fieldName = parameters.m_fieldName;
    // create editable source
    IEditableSource editableSource;
    {
      // check, may be we already have such Constants class
      if (parameters.m_constant.m_exists) {
        GwtSource source = new GwtSource(m_root, className, fieldName);
        editableSource = source.getEditable();
      } else {
        editableSource = createEmptyEditable(className);
      }
    }
    // configure editable source and return
    editableSource.setKeyGeneratorStrategy(GwtSource.GWT_KEY_GENERATOR);
    return editableSource;
  }
View Full Code Here


    NlsSupport support = NlsSupport.get(frame);
    IEditableSupport editableSupport = support.getEditable();
    //
    List<IEditableSource> editableSources = editableSupport.getEditableSources();
    assertThat(editableSources).hasSize(1);
    IEditableSource editableSource = editableSources.get(0);
    assertEquals(
        "test.client.MyConstants (Constants in variable/field 'CONSTANTS')",
        editableSource.getLongTitle());
  }
View Full Code Here

    NlsSupport support = NlsSupport.get(frame);
    IEditableSupport editableSupport = support.getEditable();
    //
    List<IEditableSource> editableSources = editableSupport.getEditableSources();
    assertThat(editableSources).hasSize(1);
    IEditableSource editableSource = editableSources.get(0);
    assertEquals(
        "test.client.MyConstants (Constants in variable/field 'CONSTANTS')",
        editableSource.getLongTitle());
    assertThat(editableSource.getKeys()).contains("rootPanel_title");
  }
View Full Code Here

    NlsSupport support = NlsSupport.get(frame);
    IEditableSupport editableSupport = support.getEditable();
    //
    List<IEditableSource> editableSources = editableSupport.getEditableSources();
    assertThat(editableSources).hasSize(1);
    IEditableSource editableSource = editableSources.get(0);
    assertEquals(
        "test.client.MyConstants (Constants in variable/field 'CONSTANTS')",
        editableSource.getLongTitle());
    assertThat(editableSource.getKeys()).isEmpty();
  }
View Full Code Here

    NlsSupport support = NlsSupport.get(frame);
    IEditableSupport editableSupport = support.getEditable();
    //
    List<IEditableSource> editableSources = editableSupport.getEditableSources();
    assertThat(editableSources).hasSize(1);
    IEditableSource editableSource = editableSources.get(0);
    assertEquals(
        "test.client.MyMessages (Constants in variable/field 'CONSTANTS')",
        editableSource.getLongTitle());
    assertThat(editableSource.getKeys()).isEmpty();
  }
View Full Code Here

    //
    // STAGE #1: add locale
    //
    {
      IEditableSupport editableSupport = support.getEditable();
      IEditableSource editableSource = editableSupport.getEditableSources().get(0);
      // check initial locales
      {
        LocaleInfo[] locales = editableSource.getLocales();
        assertEquals(1, locales.length);
        assertEquals("(default)", locales[0].getTitle());
      }
      // add locales
      {
        editableSource.addLocale(new LocaleInfo(new Locale("it")), LocaleInfo.DEFAULT);
        editableSource.addLocale(new LocaleInfo(new Locale("fr")), null);
      }
      // check new locales
      {
        LocaleInfo[] locales = editableSource.getLocales();
        assertEquals(3, locales.length);
        assertEquals("(default)", locales[0].getTitle());
        assertEquals("fr", locales[1].getTitle());
        assertEquals("it", locales[2].getTitle());
      }
      // apply commands
      support.applyEditable(editableSupport);
      // checks
      {
        // *.properties: default
        {
          String newProperties = getFileContentSrc("test/client/MyConstants.properties");
          assertTrue(newProperties.contains("rootPanel_title=My title"));
        }
        // *.properties: fr
        {
          String newProperties = getFileContentSrc("test/client/MyConstants_fr.properties");
          assertFalse(newProperties.contains("rootPanel_title=My title"));
        }
        // *.properties: it
        {
          String newProperties = getFileContentSrc("test/client/MyConstants_it.properties");
          assertTrue(newProperties.contains("rootPanel_title=My title"));
        }
        // module
        {
          String module = getFileContentSrc("test/Module.gwt.xml");
          assertTrue(module.contains("<extend-property name=\"locale\" values=\"fr,it\"/>"));
        }
      }
    }
    //
    // STAGE #2: remove locale
    //
    {
      IEditableSupport editableSupport = support.getEditable();
      IEditableSource editableSource = editableSupport.getEditableSources().get(0);
      // remove locales
      {
        editableSource.removeLocale(new LocaleInfo(new Locale("it")));
        editableSource.removeLocale(new LocaleInfo(new Locale("fr")));
        support.applyEditable(editableSupport);
      }
      // check new locales
      {
        LocaleInfo[] locales = editableSource.getLocales();
        assertEquals(1, locales.length);
        assertEquals("(default)", locales[0].getTitle());
      }
      // checks
      {
View Full Code Here

            "  }",
            "}");
    NlsSupport support = NlsSupport.get(frame);
    IEditableSupport editableSupport = support.getEditable();
    // prepare possible source
    IEditableSource editableSource;
    {
      List<IEditableSource> editableSources = editableSupport.getEditableSources();
      assertEquals(1, editableSources.size());
      editableSource = editableSources.get(0);
    }
View Full Code Here

            "    rootPanel.setTitle(CONSTANTS.rootPanel_title());",
            "  }",
            "}");
    NlsSupport support = NlsSupport.get(frame);
    IEditableSupport editableSupport = support.getEditable();
    IEditableSource editableSource = editableSupport.getEditableSources().get(0);
    // do rename
    editableSource.renameKey("rootPanel_title", "rootPanel_title2");
    // apply commands
    support.applyEditable(editableSupport);
    // check
    assertEditor(
        "public class Test implements EntryPoint {",
View Full Code Here

            "    rootPanel.setTitle(CONSTANTS.rootPanel_title());",
            "  }",
            "}");
    NlsSupport support = NlsSupport.get(frame);
    IEditableSupport editableSupport = support.getEditable();
    IEditableSource editableSource = editableSupport.getEditableSources().get(0);
    // do internalize
    editableSource.internalizeKey("rootPanel_title");
    // apply commands
    support.applyEditable(editableSupport);
    // check
    assertEditor(
        "public class Test implements EntryPoint {",
View Full Code Here

            "  }",
            "}");
    NlsSupport support = NlsSupport.get(frame);
    IEditableSupport editableSupport = support.getEditable();
    // prepare editable source
    IEditableSource editableSource = NlsTestUtils.createEmptyEditable("test.client.MyConstants");
    editableSource.setKeyGeneratorStrategy(GwtSource.GWT_KEY_GENERATOR);
    // prepare parameters
    SourceParameters parameters = new SourceParameters();
    IJavaProject javaProject = m_lastEditor.getJavaProject();
    {
      parameters.m_constant = new SourceClassParameters();
View Full Code Here

TOP

Related Classes of org.eclipse.wb.internal.core.nls.edit.IEditableSource

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.