PMD CPD Reports

Minimum Token Count : 50

Duplication 57 Lines, 245 Tokens

D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\prop\editor\PropertyDamagerRepairer.java (L.46-) and D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\web\velocityeditor\MultiDamagerRepairer.java (L.46-)

    public MultiDamagerRepairer(ITokenScanner scanner) {
        super(scanner);
    }
    
    /**
     * @param presentation 評価を反映する先
     * @param region 評価する範囲
     */
    public void createPresentation(TextPresentation presentation,
            ITypedRegion region) {
        
        if (fScanner == null) {
            addRange(presentation, region.getOffset(), region.getLength(), fDefaultTextAttribute);
            return;
        }
        
        fScanner.setRange(fDocument, region.getOffset(), region.getLength());
        
        while (true) {
            IToken token = fScanner.nextToken();         
            if (token.isEOF()) {
                break;
            }
            
            MultiTextAttribute multiAttribute = getMultiTextAttribute(token);
            for (int i = 0; i < multiAttribute.size(); i++) {
                int start = fScanner.getTokenOffset() + multiAttribute.getOffset(i);
                int length = multiAttribute.getLength(i);
                addRange(presentation, start, length, multiAttribute.get(i));
            }
        }

    }
    
    /**
     * 属性を取得します。
     * @param token トークン
     * @return 属性
     */
    private MultiTextAttribute getMultiTextAttribute(IToken token) {
        Object data = token.getData();
        if (data instanceof MultiTextAttribute) {
            return (MultiTextAttribute)data;
        }
        return defaultAttr;
    }
    
    protected void addRange(
            TextPresentation presentation, int offset, int length, TextAttribute attr) {
        if (attr != null) {
            presentation.addStyleRange(
                    new StyleRange(offset, length, attr.getForeground(),
                            attr.getBackground(), attr.getStyle()));
        }
    }

}

Duplication 16 Lines, 95 Tokens

D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\common\jface\AbstractLimyPreferencePage.java (L.63-) and D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\common\jface\AbstractLimyPropertyPage.java (L.46-)

    @Override
    public boolean performOk() {
        for (Iterator it = fields.iterator(); it.hasNext();) {
            FieldEditor editor = it.next();
            editor.store();
        }
        return super.performOk();
    }
    
    protected void performDefaults() {
        for (Iterator it = fields.iterator(); it.hasNext();) {
            FieldEditor editor = it.next();
            editor.loadDefault();
        }
        super.performDefaults();
    }

Duplication 12 Lines, 88 Tokens

D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\mark\cobertura\CoberturaMarkAppender.java (L.214-) and D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\mark\cobertura\CoberturaMarkAppender.java (L.260-)

            IRegion region, IDocument document)
            throws CoreException {
        
        try {
            int lineNumber = document.getLineOfOffset(region.getOffset());
            
            Map attrs = new HashMap();
            attrs.put(IMarker.CHAR_START, Integer.valueOf(
                    document.getLineOffset(lineNumber)));
            attrs.put(IMarker.CHAR_END, Integer.valueOf(
                    document.getLineOffset(lineNumber + 1) - 1));
            attrs.put(LimyQalabMarker.TEST_NAME, method.getElementName());

Duplication 12 Lines, 88 Tokens

D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\code\accessor\AccessorUtils.java (L.141-) and D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\code\accessor\AccessorUtils.java (L.165-)

    public static void createPublicGetter(IField javaField,
            IProgressMonitor monitor) throws JavaModelException {
        
        List fields = createLimyClass(
                javaField.getDeclaringType()).getFields();

        IType javaClass = (IType)javaField.getParent();

        for (int i = 0; i < fields.size(); i++) {
            LimyFieldObject nowField = fields.get(i);
            if (nowField.getField().equals(javaField)) {
                IJavaElement sibling = decideSibling(fields, i);

Duplication 14 Lines, 85 Tokens

D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\prop\editor\PropertyCodeScanner.java (L.57-) and D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\web\velocityeditor\VelocityCodeScanner.java (L.68-)

        VelocityCodeScanner scanner = new VelocityCodeScanner(provider);
        Map colors = getColorsFromProvider(provider);
        
        for (int i = 0; i < colorFieldEditors.length; i++) {
            LimyColorFieldEditor editor = colorFieldEditors[i];
            RGB color = editor.getColorSelector().getColorValue();
            String preferenceName = editor.getPreferenceName();
            
            addColor(colors, color, preferenceName);
            scanner.setRules(createRules(colors));
        }
        
        sourceViewer.unconfigure();
        sourceViewer.configure(new VelocitySourceViewerConfiguration(scanner));

Duplication 15 Lines, 83 Tokens

D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\prop\editor\PropertyEditor.java (L.57-) and D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\web\velocityeditor\VelocityEditor.java (L.123-)

        foldingGroup = new FoldingActionGroup(this, getSourceViewer());
    }
    
    protected void doSetInput(IEditorInput input) throws CoreException {
        super.doSetInput(input);
        setPreferenceStore(LimyEclipsePlugin.getDefault().getPreferenceStore());
    }
    
    protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
        super.handlePreferenceStoreChanged(event);
        
        ProviderManager.getInstance().updateProviders();
        if (getSourceViewer() instanceof SourceViewer) {
            ((SourceViewer)getSourceViewer()).unconfigure();
            getSourceViewer().configure(new VelocitySourceViewerConfiguration(this));

Duplication 11 Lines, 77 Tokens

D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\prop\preference\LimyPropPreferencePage.java (L.126-) and D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\web\preference\LimyWebPreferencePage.java (L.133-)

                LimyWebConstants.CONTENT_PREVIEW);
        IDocument document = new Document(content);
        previewViewer.setDocument(document);
        previewViewer.setEditable(false);
        Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
        previewViewer.getTextWidget().setFont(font);
        previewViewer.getTextWidget().setBackground(
                LimyEclipsePlugin.getDefault().getColorProvider().getColor(
                        LimyEclipseConstants.P_BGCOLOR));
        
        Control preview = previewViewer.getControl();

Duplication 18 Lines, 75 Tokens

D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\velocity\task\VmParseMacro.java (L.177-) and D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\velocity\task\VmParseMacro.java (L.200-)

            }
            if (item instanceof Map) {
                Map map = (Map)item;
                Object result = privatesearchParentM(map, target);
                if (result != null) {
                    return result;
                }
            }
            if (item instanceof Collection) {
                Collection list = (Collection)item;
                Object result = privatesearchParentC(root, list, target);
                if (result != null) {
                    return result;
                }
            }
        }
        return null;
    }

Duplication 15 Lines, 72 Tokens

D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\propertypage\ExternalFileSelector.java (L.74-) and D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\propertypage\MultiTypeFileSelector.java (L.163-)

    }

    /**
     * 外部リソースからファイルを選択します。
     */
    private void setFromExternal() {
        
        FileDialog dialog = new FileDialog(new Shell(), SWT.OPEN);
        dialog.setFilterExtensions(new String[] { "*." + targetExt });
        String file = dialog.open();
        if (file != null) {
            control.setText(file);
            if (listener != null) {
                PropertyChangeEvent evt = new PropertyChangeEvent(
                        control, "result", null, file

Duplication 21 Lines, 67 Tokens

D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\ant\Java2HtmlCreator.java (L.44-) and D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\ant\JavadocCreator.java (L.41-)

        appendAllElements(root, env);
    }
    
    public String[] getQalabClassNames() {
        return new String[0];
    }

    public String[] getReportXmlNames() {
        return new String[0];
    }

    public int getSummaryGroup() {
        return 3;
    }

    public String[] getSummaryTypes() {
        return new String[0];
    }

    public String getTargetName() {
        return "umlgraph";

Duplication 14 Lines, 62 Tokens

D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\qaview\QalabView.java (L.147-) and D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\ui\TestResultListener.java (L.72-)

    }

    // ------------------------ Implement Methods

    public void selectionChanged(IWorkbenchPart part, ISelection selection) {
        
        if (!(selection instanceof IStructuredSelection)) {
            return;
        }
        Object element = ((IStructuredSelection)selection).getFirstElement();
        if (!(element instanceof IJavaElement)) {
            return;
        }
        IResource resource = ((IJavaElement)element).getResource();

Duplication 20 Lines, 62 Tokens

D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\ant\JDependCreator.java (L.44-) and D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\ant\UmlgraphCreator.java (L.45-)

public class UmlgraphCreator extends AbstractAntCreator {

    // ------------------------ Implement Methods

    public void exec(XmlElement root, LimyQalabEnvironment env)
            throws CoreException, FileNotFoundException {
        
        appendAllElements(root, env);
    }
    
    public String[] getQalabClassNames() {
        return new String[0];
    }

    public String[] getReportXmlNames() {
        return new String[0];
    }

    public int getSummaryGroup() {
        return 3;

Duplication 12 Lines, 62 Tokens

D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\action\CreateReportAction.java (L.44-) and D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\action\CreateReportProcessAction.java (L.50-)

public class CreateReportProcessAction extends AbstractJavaElementAction {

    @Override
    protected void doAction(IJavaElement javaElement, IProgressMonitor monitor)
            throws CoreException {
        
        IProject project = javaElement.getJavaProject().getProject();
        LimyQalabEnvironment env = LimyQalabPluginUtils.createEnv(project);
        CreateBuildXml builder = new CreateBuildXml();
        
        final BuildWarning warningInfo = builder.prepareBuildFiles(env);
        builder.createFiles(env);

Duplication 19 Lines, 61 Tokens

D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\propertypage\PageItem.java (L.61-) and D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\propertypage\PageTesting.java (L.66-)

    public PageTesting(Composite parent, int style, LimyQalabEnvironment env) {
        super(parent, style, env.getStore());
        this.project = env.getProject();

        try {
            createContents(this);
        } catch (CoreException e) {
            LimyEclipsePluginUtils.log(e);
        }

    }

    // ------------------------ Private Methods

    /**
     * @param comp
     * @throws CoreException 
     */
    private void createContents(Composite comp) throws CoreException {

Duplication 12 Lines, 60 Tokens

D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\propertypage\MultiTypeFileSelector.java (L.129-) and D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\ui\FileButtonSelection.java (L.114-)

                    return "xml".equals(file.getFileExtension());
                }
                if (element instanceof IProject) {
                    IProject tempTroject = (IProject)element;
                    return tempTroject.equals(project);
                }
                return true;
            }
        };
        dialog.addFilter(filter);
        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
        dialog.setInput(root);

Duplication 6 Lines, 55 Tokens

D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\propertypage\PageMain.java (L.213-) and D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\propertypage\PageReport.java (L.244-)

        label.setText(Messages.LABEL_TESTENV);
        label.setLayoutData(FormDataCreater.maxWidthControlDown(targetComp, 8));
        
        Composite gridComp = new Composite(comp, SWT.NONE);
        gridComp.setLayout(new GridLayout(2, false));
        gridComp.setLayoutData(FormDataCreater.maxWidthControlBottom(label, 0, 100, 0));

Duplication 5 Lines, 52 Tokens

D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\task\Java2HtmlTask.java (L.142-) and D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\task\TodoReportTask.java (L.143-)

        for (FileSet fileSet : fileSets) {
            DirectoryScanner scanner = fileSet.getDirectoryScanner(getProject());
            for (String fileStr : scanner.getIncludedFiles()) {
                File targetBaseDir = fileSet.getDir(getProject());
                File file = new File(targetBaseDir, fileStr);

Duplication 19 Lines, 52 Tokens

D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\task\Java2HtmlTask.java (L.89-) and D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\qalab\task\TodoReportTask.java (L.68-)

        TodoReport cmd = new TodoReport();
        
        try {
            
            if (fileSets.isEmpty()) {
                execWithSrcDir(cmd);
                return;
            }
            
            if (srcDir != null) {
                throw new BuildException(
                        "srcDir と fileset 要素はどちらか一つだけ記述する必要があります。");
            }
            
            execWithFileset(cmd);
        } catch (IOException e) {
            throw new BuildException(e);
        }
    }

Duplication 24 Lines, 52 Tokens

D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\code\LimyCodePlugin.java (L.86-) and D:\var\prog\eclipse-plugin\latest\limy-eclipse-all\dest\src\org\limy\eclipse\web\LimyWebPlugin.java (L.78-)

        return AbstractUIPlugin.imageDescriptorFromPlugin("org.limy.eclipse.web", path);
    }
    
    // ------------------------ Public Methods
    
    /**
     * リソース文字列を返します。
     * @param key リソースキー
     * @return リソース文字列
     */
    public static String getResourceString(String key) {
        ResourceBundle bundle = getDefault().getResourceBundle();
        try {
            return (bundle != null) ? bundle.getString(key) : key;
        } catch (MissingResourceException e) {
            return key;
        }
    }
    
    /**
     * リソースバンドルを返します。
     * @return リソースバンドル
     */
    public ResourceBundle getResourceBundle() {