CPD Results

The following document contains the results of PMD's CPD 4.2.2.

Duplications

File Line
org\jtheque\books\view\toolbar\JPanelAuthorToolBar.java 69
org\jtheque\books\view\toolbar\JPanelBookToolBar.java 68
        buttonEdit = new JDropDownButton(new AcManualEditBook(), new AcAutoEditBook());

        if (mode == ViewMode.VIEW) {
            builder.add(buttonAdd, gbc.gbcSet(0, 0));
            builder.add(buttonEdit, gbc.gbcSet(1, 0));
            builder.add(buttonDelete, gbc.gbcSet(2, 0));
        } else {
            builder.add(buttonSave, gbc.gbcSet(0, 0));
            builder.add(buttonCancel, gbc.gbcSet(1, 0));
        }
    }

    /**
     * Set the display mode of the tool bar.
     *
     * @param mode The display mode.
     */
    void setMode(ViewMode mode) {
        if (this.mode != mode) {
            this.mode = mode;

            remove(buttonSave);
            remove(buttonCancel);
            remove(buttonAdd);
            remove(buttonEdit);
            remove(buttonDelete);

            switch (mode) {
                case VIEW:
                    add(buttonAdd, gbc.gbcSet(0, 0));
                    add(buttonEdit, gbc.gbcSet(1, 0));
                    add(buttonDelete, gbc.gbcSet(2, 0));

                    break;
                case NEW:
                case EDIT:
                case AUTO:
                    add(buttonSave, gbc.gbcSet(0, 0));
                    add(buttonCancel, gbc.gbcSet(1, 0));

                    break;
            }

File Line
org\jtheque\books\persistence\dao\impl\DaoBooks.java 256
org\jtheque\books\persistence\dao\impl\DaoBooks.java 282
            Object[] parameters = {
                    book.getTitle(),
                    book.getNote().getValue().intValue(),
                    book.getPages(),
                    book.getResume(),
                    book.getIsbn10(),
                    book.getIsbn13(),
                    book.getYear(),
                    book.getTheEditor() == null ? null : book.getTheEditor().getId(),
                    book.getTheSaga() == null ? null : book.getTheSaga().getId(),
                    book.getTheType() == null ? null : book.getTheType().getId(),
                    book.getTheLending() == null ? null : book.getTheLending().getId(),
                    book.getTheKind() == null ? null : book.getTheKind().getId(),
                    book.getTheLanguage() == null ? null : book.getTheLanguage().getId(),

File Line
org\jtheque\books\view\controllers\state\book\AutoAddBookState.java 58
org\jtheque\books\view\controllers\state\book\ModifyBookState.java 58
        controller.getView().getToolbarView().setDisplayMode(ViewMode.EDIT);

        getViewModel().getCurrentBook().saveToMemento();
    }

    @Override
    public ControllerState autoEdit(Data data) {
        Book book = (Book) data;

        if (Managers.getManager(IViewManager.class).askUserForConfirmation(
                Managers.getManager(ILanguageManager.class).getMessage("book.dialogs.confirmSave"),
                Managers.getManager(ILanguageManager.class).getMessage("book.dialogs.confirmSave.title"))) {
            controller.save();
        } else {
            getViewModel().getCurrentBook().restoreMemento();
        }

        getViewModel().setCurrentBook(book);

        return controller.getAutoAddState();
    }

    @Override
    public ControllerState cancel() {

File Line
org\jtheque\books\view\controllers\state\book\AutoAddBookState.java 129
org\jtheque\books\view\controllers\state\book\ModifyBookState.java 124
        return controller.getViewState();
    }

    @Override
    public ControllerState view(Data data) {
        Book book = (Book) data;

        if (Managers.getManager(IViewManager.class).askUserForConfirmation(
                Managers.getManager(ILanguageManager.class).getMessage("book.dialogs.confirmSave"),
                Managers.getManager(ILanguageManager.class).getMessage("book.dialogs.confirmSave.title"))) {
            controller.save();
        } else {
            getViewModel().getCurrentBook().restoreMemento();
        }

        getViewModel().setCurrentBook(book);

        return controller.getViewState();
    }
}