1592-1-2

ModifyListener validator = new ModifyListener() { public void modifyText(ModifyEvent e) { setPageComplete(validatePage()); } }; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected boolean validatePage() { return getInitialObjectName() != null && getEncodings().contains(encodingField.getText()); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void setVisible(boolean visible) { super.setVisible(visible); if (visible) { if (initialObjectField.getItemCount() == 1) { initialObjectField.clearSelection(); encodingField.setFocus(); } else { encodingField.clearSelection(); initialObjectField.setFocus(); } } } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getInitialObjectName() { String label = initialObjectField.getText(); for (String name : getInitialObjectNames()) { if (getLabel(name).equals(label)) { return name; } } return null; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getEncoding() { return encodingField.getText(); } /** * Returns the label for the specified type name. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected String getLabel(String typeName) { try { return EcoreEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type"); } catch(MissingResourceException mre) { EcoreEditorPlugin.INSTANCE.log(mre); } return typeName; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected Collection<String> getEncodings() { if (encodings == null) { encodings = new ArrayList<String>(); for (StringTokenizer stringTokenizer = new StringTokenizer(EcoreEditorPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens(); ) { encodings.add(stringTokenizer.nextToken()); } } return encodings; } } /** * The framework calls this to create the contents of the wizard. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void addPages() { // Create a page, set the title, and the initial model file name. // newFileCreationPage = new EcoreModelWizardNewFileCreationPage("Whatever", selection); newFileCreationPage.setTitle(EcoreEditorPlugin.INSTANCE.getString("_UI_EcoreModelWizard_label")); newFileCreationPage.setDescription(EcoreEditorPlugin.INSTANCE.getString("_UI_EcoreModelWizard_description")); newFileCreationPage.setFileName(EcoreEditorPlugin.INSTANCE.getString("_UI_EcoreEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0)); addPage(newFileCreationPage); // Try and get the resource selection to determine a current directory for the file dialog. // if (selection != null && !selection.isEmpty()) { // Get the resource... // Object selectedElement = selection.iterator().next(); if (selectedElement instanceof IResource) { // Get the resource parent, if its a file. // IResource selectedResource = (IResource)selectedElement; if (selectedResource.getType() == IResource.FILE) { selectedResource = selectedResource.getParent(); } // This gives us a directory... // if (selectedResource instanceof IFolder || selectedResource instanceof IProject) { // Set this for the container. // newFileCreationPage.setContainerFullPath(selectedResource.getFullPath()); // Make up a unique new name here. // String defaultModelBaseFilename = EcoreEditorPlugin.INSTANCE.getString("_UI_EcoreEditorFilenameDefaultBase"); String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0); String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension; for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) { modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension; } newFileCreationPage.setFileName(modelFilename); } } } initialObjectCreationPage = new EcoreModelWizardInitialObjectCreationPage("Whatever2"); initialObjectCreationPage.setTitle(EcoreEditorPlugin.INSTANCE.getString("_UI_EcoreModelWizard_label")); initialObjectCreationPage.setDescription(EcoreEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description")); addPage(initialObjectCreationPage); }
ModifyListener validator = new ModifyListener() { public void modifyText(ModifyEvent e) { setPageComplete(validatePage()); } }; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected boolean validatePage() { return getInitialObjectName() != null && getEncodings().contains(encodingField.getText()); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void setVisible(boolean visible) { super.setVisible(visible); if (visible) { if (initialObjectField.getItemCount() == 1) { initialObjectField.clearSelection(); encodingField.setFocus(); } else { encodingField.clearSelection(); initialObjectField.setFocus(); } } } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getInitialObjectName() { String label = initialObjectField.getText(); for (String name : getInitialObjectNames()) { if (getLabel(name).equals(label)) { return name; } } return null; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getEncoding() { return encodingField.getText(); } /** * Returns the label for the specified type name. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected String getLabel(String typeName) { try { return Ecore2EcorePlugin.INSTANCE.getString("_UI_" + typeName + "_type"); } catch(MissingResourceException mre) { Ecore2EcoreEditorPlugin.INSTANCE.log(mre); } return typeName; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected Collection<String> getEncodings() { if (encodings == null) { encodings = new ArrayList<String>(); for (StringTokenizer stringTokenizer = new StringTokenizer(Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens(); ) { encodings.add(stringTokenizer.nextToken()); } } return encodings; } } /** * The framework calls this to create the contents of the wizard. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void addPages() { // Create a page, set the title, and the initial model file name. // newFileCreationPage = new Ecore2EcoreModelWizardNewFileCreationPage("Whatever", selection); newFileCreationPage.setTitle(Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_Ecore2EcoreModelWizard_label")); newFileCreationPage.setDescription(Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_Ecore2EcoreModelWizard_description")); newFileCreationPage.setFileName(Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_Ecore2EcoreEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0)); addPage(newFileCreationPage); // Try and get the resource selection to determine a current directory for the file dialog. // if (selection != null && !selection.isEmpty()) { // Get the resource... // Object selectedElement = selection.iterator().next(); if (selectedElement instanceof IResource) { // Get the resource parent, if its a file. // IResource selectedResource = (IResource)selectedElement; if (selectedResource.getType() == IResource.FILE) { selectedResource = selectedResource.getParent(); } // This gives us a directory... // if (selectedResource instanceof IFolder || selectedResource instanceof IProject) { // Set this for the container. // newFileCreationPage.setContainerFullPath(selectedResource.getFullPath()); // Make up a unique new name here. // String defaultModelBaseFilename = Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_Ecore2EcoreEditorFilenameDefaultBase"); String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0); String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension; for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i) { modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension; } newFileCreationPage.setFileName(modelFilename); } } } initialObjectCreationPage = new Ecore2EcoreModelWizardInitialObjectCreationPage("Whatever2"); initialObjectCreationPage.setTitle(Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_Ecore2EcoreModelWizard_label")); initialObjectCreationPage.setDescription(Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description")); addPage(initialObjectCreationPage); }

Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/presentation/EcoreModelWizard.java |  | File path: /emf-2.4.1/src/org/eclipse/emf/mapping/ecore2ecore/presentation/Ecore2EcoreModelWizard.java
Method name: `` |  | Method name: ``
Number of AST nodes: 0 |  | Number of AST nodes: 0

1

    ModifyListener validator =↵

1

    ModifyListener validator =↵

2

          new ModifyListener()↵

2

          new ModifyListener()↵

3

          {↵

3

          {↵

4

            public void modifyText(ModifyEvent e)↵

4

            public void modifyText(ModifyEvent e)↵

5

            {↵

5

            {↵

6

              setPageComplete(validatePage());↵

6

              setPageComplete(validatePage());↵

7

            }↵

7

            }↵

8

          };↵

8

          };↵

9

        /**↵

9

        /**↵

10

         * <!-- begin-user-doc -->↵

10

         * <!-- begin-user-doc -->↵

11

         * <!-- end-user-doc -->↵

11

         * <!-- end-user-doc -->↵

12

         * @generated↵

12

         * @generated↵

13

         */↵

13

         */↵

14

        protected boolean validatePage()↵

14

        protected boolean validatePage()↵

15

        {↵

15

        {↵

16

          return getInitialObjectName() != null && getEncodings().contains(encodingField.getText());↵

16

          return getInitialObjectName() != null && getEncodings().contains(encodingField.getText());↵

17

        }↵

17

        }↵

18

        /**↵

18

        /**↵

19

         * <!-- begin-user-doc -->↵

19

         * <!-- begin-user-doc -->↵

20

         * <!-- end-user-doc -->↵

20

         * <!-- end-user-doc -->↵

21

         * @generated↵

21

         * @generated↵

22

         */↵

22

         */↵

23

        @Override↵

23

        @Override↵

24

        public void setVisible(boolean visible)↵

24

        public void setVisible(boolean visible)↵

25

        {↵

25

        {↵

26

          super.setVisible(visible);↵

26

          super.setVisible(visible);↵

27

          if (visible)↵

27

          if (visible)↵

28

          {↵

28

          {↵

29

            if (initialObjectField.getItemCount() == 1)↵

29

            if (initialObjectField.getItemCount() == 1)↵

30

            {↵

30

            {↵

31

              initialObjectField.clearSelection();↵

31

              initialObjectField.clearSelection();↵

32

              encodingField.setFocus();↵

32

              encodingField.setFocus();↵

33

            }↵

33

            }↵

34

            else↵

34

            else↵

35

            {↵

35

            {↵

36

              encodingField.clearSelection();↵

36

              encodingField.clearSelection();↵

37

              initialObjectField.setFocus();↵

37

              initialObjectField.setFocus();↵

38

            }↵

38

            }↵

39

          }↵

39

          }↵

40

        }↵

40

        }↵

41

        /**↵

41

        /**↵

42

         * <!-- begin-user-doc -->↵

42

         * <!-- begin-user-doc -->↵

43

         * <!-- end-user-doc -->↵

43

         * <!-- end-user-doc -->↵

44

         * @generated↵

44

         * @generated↵

45

         */↵

45

         */↵

46

        public String getInitialObjectName()↵

46

        public String getInitialObjectName()↵

47

        {↵

47

        {↵

48

          String label = initialObjectField.getText();↵

48

          String label = initialObjectField.getText();↵

49

          for (String name : getInitialObjectNames())↵

49

          for (String name : getInitialObjectNames())↵

50

          {↵

50

          {↵

51

            if (getLabel(name).equals(label))↵

51

            if (getLabel(name).equals(label))↵

52

            {↵

52

            {↵

53

              return name;↵

53

              return name;↵

54

            }↵

54

            }↵

55

          }↵

55

          }↵

56

          return null;↵

56

          return null;↵

57

        }↵

57

        }↵

58

        /**↵

58

        /**↵

59

         * <!-- begin-user-doc -->↵

59

         * <!-- begin-user-doc -->↵

60

         * <!-- end-user-doc -->↵

60

         * <!-- end-user-doc -->↵

61

         * @generated↵

61

         * @generated↵

62

         */↵

62

         */↵

63

        public String getEncoding()↵

63

        public String getEncoding()↵

64

        {↵

64

        {↵

65

          return encodingField.getText();↵

65

          return encodingField.getText();↵

66

        }↵

66

        }↵

67

        /**↵

67

        /**↵

68

         * Returns the label for the specified type name.↵

68

         * Returns the label for the specified type name.↵

69

         * <!-- begin-user-doc -->↵

69

         * <!-- begin-user-doc -->↵

70

         * <!-- end-user-doc -->↵

70

         * <!-- end-user-doc -->↵

71

         * @generated↵

71

         * @generated↵

72

         */↵

72

         */↵

73

        protected String getLabel(String typeName)↵

73

        protected String getLabel(String typeName)↵

74

        {↵

74

        {↵

75

          try↵

75

          try↵

76

          {↵

76

          {↵

77

            return EcoreEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type");↵

77

            return Ecore2EcorePlugin.INSTANCE.getString("_UI_" + typeName + "_type");↵

78

          }↵

78

          }↵

79

          catch(MissingResourceException mre)↵

79

          catch(MissingResourceException mre)↵

80

          {↵

80

          {↵

81

            EcoreEditorPlugin.INSTANCE.log(mre);↵

81

            Ecore2EcoreEditorPlugin.INSTANCE.log(mre);↵

82

          }↵

82

          }↵

83

          return typeName;↵

83

          return typeName;↵

84

        }↵

84

        }↵

85

        /**↵

85

        /**↵

86

         * <!-- begin-user-doc -->↵

86

         * <!-- begin-user-doc -->↵

87

         * <!-- end-user-doc -->↵

87

         * <!-- end-user-doc -->↵

88

         * @generated↵

88

         * @generated↵

89

         */↵

89

         */↵

90

        protected Collection<String> getEncodings()↵

90

        protected Collection<String> getEncodings()↵

91

        {↵

91

        {↵

92

          if (encodings == null)↵

92

          if (encodings == null)↵

93

          {↵

93

          {↵

94

            encodings = new ArrayList<String>();↵

94

            encodings = new ArrayList<String>();↵

95

            for (StringTokenizer stringTokenizer = new StringTokenizer(EcoreEditorPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens(); )↵

95

            for (StringTokenizer stringTokenizer = new StringTokenizer(Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens(); )↵

96

            {↵

96

            {↵

97

              encodings.add(stringTokenizer.nextToken());↵

97

              encodings.add(stringTokenizer.nextToken());↵

98

            }↵

98

            }↵

99

          }↵

99

          }↵

100

          return encodings;↵

100

          return encodings;↵

101

        }↵

101

        }↵

102

      }↵

102

      }↵

103

      /**↵

103

      /**↵

104

       * The framework calls this to create the contents of the wizard.↵

104

       * The framework calls this to create the contents of the wizard.↵

105

       * <!-- begin-user-doc -->↵

105

       * <!-- begin-user-doc -->↵

106

       * <!-- end-user-doc -->↵

106

       * <!-- end-user-doc -->↵

107

       * @generated↵

107

       * @generated↵

108

       */↵

108

       */↵

109

      @Override↵

109

      @Override↵

110

      public void addPages()↵

110

      public void addPages()↵

111

      {↵

111

      {↵

112

        // Create a page, set the title, and the initial model file name.↵

112

        // Create a page, set the title, and the initial model file name.↵

113

        //↵

113

        //↵

114

        newFileCreationPage = new EcoreModelWizardNewFileCreationPage("Whatever", selection);↵

114

        newFileCreationPage = new Ecore2EcoreModelWizardNewFileCreationPage("Whatever", selection);↵

115

        newFileCreationPage.setTitle(EcoreEditorPlugin.INSTANCE.getString("_UI_EcoreModelWizard_label"));↵

115

        newFileCreationPage.setTitle(Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_Ecore2EcoreModelWizard_label"));↵

116

        newFileCreationPage.setDescription(EcoreEditorPlugin.INSTANCE.getString("_UI_EcoreModelWizard_description"));↵

116

        newFileCreationPage.setDescription(Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_Ecore2EcoreModelWizard_description"));↵

117

        newFileCreationPage.setFileName(EcoreEditorPlugin.INSTANCE.getString("_UI_EcoreEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0));↵

117

        newFileCreationPage.setFileName(Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_Ecore2EcoreEditorFilenameDefaultBase") + "." + FILE_EXTENSIONS.get(0));↵

118

        addPage(newFileCreationPage);↵

118

        addPage(newFileCreationPage);↵

119

        // Try and get the resource selection to determine a current directory for the file dialog.↵

119

        // Try and get the resource selection to determine a current directory for the file dialog.↵

120

        //↵

120

        //↵

121

        if (selection != null && !selection.isEmpty())↵

121

        if (selection != null && !selection.isEmpty())↵

122

        {↵

122

        {↵

123

          // Get the resource...↵

123

          // Get the resource...↵

124

          //↵

124

          //↵

125

          Object selectedElement = selection.iterator().next();↵

125

          Object selectedElement = selection.iterator().next();↵

126

          if (selectedElement instanceof IResource)↵

126

          if (selectedElement instanceof IResource)↵

127

          {↵

127

          {↵

128

            // Get the resource parent, if its a file.↵

128

            // Get the resource parent, if its a file.↵

129

            //↵

129

            //↵

130

            IResource selectedResource = (IResource)selectedElement;↵

130

            IResource selectedResource = (IResource)selectedElement;↵

131

            if (selectedResource.getType() == IResource.FILE)↵

131

            if (selectedResource.getType() == IResource.FILE)↵

132

            {↵

132

            {↵

133

              selectedResource = selectedResource.getParent();↵

133

              selectedResource = selectedResource.getParent();↵

134

            }↵

134

            }↵

135

            // This gives us a directory...↵

135

            // This gives us a directory...↵

136

            //↵

136

            //↵

137

            if (selectedResource instanceof IFolder || selectedResource instanceof IProject)↵

137

            if (selectedResource instanceof IFolder || selectedResource instanceof IProject)↵

138

            {↵

138

            {↵

139

              // Set this for the container.↵

139

              // Set this for the container.↵

140

              //↵

140

              //↵

141

              newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());↵

141

              newFileCreationPage.setContainerFullPath(selectedResource.getFullPath());↵

142

              // Make up a unique new name here.↵

142

              // Make up a unique new name here.↵

143

              //↵

143

              //↵

144

              String defaultModelBaseFilename = EcoreEditorPlugin.INSTANCE.getString("_UI_EcoreEditorFilenameDefaultBase");↵

144

              String defaultModelBaseFilename = Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_Ecore2EcoreEditorFilenameDefaultBase");↵

145

              String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0);↵

145

              String defaultModelFilenameExtension = FILE_EXTENSIONS.get(0);↵

146

              String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension;↵

146

              String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension;↵

147

              for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i)↵

147

              for (int i = 1; ((IContainer)selectedResource).findMember(modelFilename) != null; ++i)↵

148

              {↵

148

              {↵

149

                modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension;↵

149

                modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension;↵

150

              }↵

150

              }↵

151

              newFileCreationPage.setFileName(modelFilename);↵

151

              newFileCreationPage.setFileName(modelFilename);↵

152

            }↵

152

            }↵

153

          }↵

153

          }↵

154

        }↵

154

        }↵

155

        initialObjectCreationPage = new EcoreModelWizardInitialObjectCreationPage("Whatever2");↵

155

        initialObjectCreationPage = new Ecore2EcoreModelWizardInitialObjectCreationPage("Whatever2");↵

156

        initialObjectCreationPage.setTitle(EcoreEditorPlugin.INSTANCE.getString("_UI_EcoreModelWizard_label"));↵

156

        initialObjectCreationPage.setTitle(Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_Ecore2EcoreModelWizard_label"));↵

157

        initialObjectCreationPage.setDescription(EcoreEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description"));↵

157

        initialObjectCreationPage.setDescription(Ecore2EcoreEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description"));↵

158

        addPage(initialObjectCreationPage);↵

158

        addPage(initialObjectCreationPage);↵

159

      }

159

      }

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 0
Number of refactorable cases | 0
Number of non-refactorable cases | 0
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.0
Clones location |
Number of node comparisons | 0