CPD Results

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

Duplications

File Line
net\sourceforge\joceanus\metis\ui\MetisPreferenceSetView.java 790
net\sourceforge\joceanus\metis\ui\MetisPreferenceSetView.java 885
FilePreferenceElement(final MetisStringPreference pItem) {
            /* Store parameters */
            theItem = pItem;
            theField = theGuiFactory.fieldFactory().newStringField();
            theField.setEditable(true);

            /* Create the button */
            theButton = theGuiFactory.buttonFactory().newButton();
            theButton.setTextOnly();
            theButton.setText(pItem.getDisplay());

            /* Add to the Grid Pane */
            theGrid.addCell(theButton);
            theGrid.addCell(theField);
            theGrid.setCellColumnSpan(theField, 2);
            theGrid.allowCellGrowth(theField);
            theGrid.newRow();

            /* Create listeners */
            theButton.getEventRegistrar().addEventListener(e -> handleDialog());
            theField.getEventRegistrar().addEventListener(e -> {
                pItem.setValue(theField.getValue());
                notifyChanges();
            });
        }

        @Override
        public void updateField() {
            /* Update the field */
            theField.setValue(theItem.getValue());

            /* Set changed indication */
            theField.setTheAttributeState(TethysUIFieldAttribute.CHANGED, theItem.isChanged());
            theField.adjustField();

            /* Handle hidden state */
            final boolean isEnabled = !theItem.isHidden();
            theField.setEnabled(isEnabled);
            theButton.setEnabled(isEnabled);
        }

        /**
         * Handle Dialog.
         */
        private void handleDialog() {
            ensureSelector();
            theSelector.setInitialFile(new File(theItem.getValue()));
File Line
net\sourceforge\joceanus\metis\lethe\list\MetisListSetSingularMap.java 173
net\sourceforge\joceanus\metis\lethe\list\MetisListSetUniqueMap.java 216
if (!myKey.getSingularFields().isEmpty()) {
                /* Obtain the associated change */
                final MetisLetheListChange<MetisFieldVersionedItem> myChange = myChanges.getListChange(myKey);

                /* If there are changes */
                if (myChange != null) {
                    /* handle changes in the base list */
                    processVersionChanges(myKey, myChange);
                }
            }
        }
    }

    /**
     * Process changes as a result of a version change.
     * @param pKey the list key
     * @param pChange the change event
     */
    private void processVersionChanges(final MetisLetheListKey pKey,
                                       final MetisLetheListChange<MetisFieldVersionedItem> pChange) {
        /* Process deleted items */
        processDeletedItems(pKey, pChange.hiddenIterator());
        processDeletedItems(pKey, pChange.deletedIterator());

        /* Process changed items */
        processChangedItems(pKey, pChange.changedIterator());

        /* Process new items */
        processNewItems(pKey, pChange.addedIterator());
        processNewItems(pKey, pChange.restoredIterator());
    }

    /**
     * Process a list of new items.
     * @param pKey the list key
     * @param pIterator the iterator
     */
    private void processNewItems(final MetisLetheListKey pKey,
                                 final Iterator<MetisFieldVersionedItem> pIterator) {
        /* Process each item in the list */
        while (pIterator.hasNext()) {
            final MetisFieldVersionedItem myItem = pIterator.next();
            if (!myItem.isDeleted()) {
                processNewItem(pKey, myItem);
            }
        }
    }

    /**
     * Process newItem.
     * @param pKey the list key
     * @param pItem the item
     */
    public void processNewItem(final MetisLetheListKey pKey,
                               final MetisFieldVersionedItem pItem) {
        /* Obtain the singularMap for this item */
        final MetisListSingularMap mySingularMap = theListMap.computeIfAbsent(pKey, x -> new MetisListSingularMap(pKey, isSession));
File Line
net\sourceforge\joceanus\metis\lethe\list\MetisListSetNameMap.java 208
net\sourceforge\joceanus\metis\lethe\list\MetisListSetSingularMap.java 173
net\sourceforge\joceanus\metis\lethe\list\MetisListSetUniqueMap.java 216
if (myKey.getNameSpace() != null) {
                /* Obtain the associated change */
                final MetisLetheListChange<MetisFieldVersionedItem> myChange = myChanges.getListChange(myKey);

                /* If there are changes */
                if (myChange != null) {
                    /* handle changes in the base list */
                    processVersionChanges(myKey, myChange);
                }
            }
        }
    }

    /**
     * Process changes as a result of a version change.
     * @param pKey the list key
     * @param pChange the change event
     */
    private void processVersionChanges(final MetisLetheListKey pKey,
                                       final MetisLetheListChange<MetisFieldVersionedItem> pChange) {
        /* Process deleted items */
        processDeletedItems(pKey, pChange.hiddenIterator());
        processDeletedItems(pKey, pChange.deletedIterator());

        /* Process changed items */
        processChangedItems(pKey, pChange.changedIterator());

        /* Process new items */
        processNewItems(pKey, pChange.addedIterator());
        processNewItems(pKey, pChange.restoredIterator());
    }

    /**
     * Process a list of new items.
     * @param pKey the list key
     * @param pIterator the iterator
     */
    private void processNewItems(final MetisLetheListKey pKey,
                                 final Iterator<MetisFieldVersionedItem> pIterator) {
        /* Process each item in the list */
        while (pIterator.hasNext()) {
            final MetisFieldVersionedItem myItem = pIterator.next();
            if (!myItem.isDeleted()) {
                processNewItem(pKey, myItem);
            }
        }
    }

    /**
     * Process newItem.
     * @param pKey the list key
     * @param pItem the item
     */
    public void processNewItem(final MetisLetheListKey pKey,
                               final MetisFieldVersionedItem pItem) {
        /* Obtain the nameSpace for this item */
        final MetisLetheListKey myNameSpace = pKey.getNameSpace();
File Line
net\sourceforge\joceanus\metis\help\MetisHelpWindow.java 148
net\sourceforge\joceanus\metis\viewer\MetisViewerWindow.java 349
theDialog.setTitle(MetisHelpResource.TITLE.getValue());

            /* Create the help panel */
            final TethysUIBorderPaneManager myPanel = theFactory.paneFactory().newBorderPane();
            myPanel.setCentre(theSplitTree);
            myPanel.setPreferredWidth(WINDOW_WIDTH);
            myPanel.setPreferredHeight(WINDOW_HEIGHT);
            theDialog.setContent(myPanel);

            /* Set listener */
            theDialog.getEventRegistrar().addEventListener(TethysUIEvent.WINDOWCLOSED, e -> {
                theTree.setVisible(false);
                fireEvent(TethysUIEvent.WINDOWCLOSED, null);
            });
        }

        /* If the dialog is not showing */
        if (!theDialog.isShowing()) {
            /* Make sure that the dialog is showing */
            theTree.setVisible(true);
            theDialog.showDialog();
        }
    }

    /**
     * Hide the dialog.
     */
    public void hideDialog() {
        /* If the dialog exists */
        if (theDialog != null
            && theDialog.isShowing()) {
            /* Make sure that the dialog is hidden */
            theDialog.hideDialog();