Example usage for java.util Collections addAll

List of usage examples for java.util Collections addAll

Introduction

In this page you can find the example usage for java.util Collections addAll.

Prototype

@SafeVarargs
public static <T> boolean addAll(Collection<? super T> c, T... elements) 

Source Link

Document

Adds all of the specified elements to the specified collection.

Usage

From source file:com.diversityarrays.kdxplore.trials.SampleGroupExportDialog.java

public SampleGroupExportDialog(Window owner, String title, Trial trial, KdxploreDatabase kdxploreDatabase,
        DeviceType deviceType, DeviceIdentifier devid, SampleGroup sampleGroup,
        Set<Integer> excludeTheseTraitIds, Map<Integer, Trait> allTraitIds, Set<Integer> excludeThesePlotIds) {
    super(owner, title, ModalityType.APPLICATION_MODAL);

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    setGlassPane(backgroundRunner.getBlockingPane());

    this.allTraits = allTraitIds;
    this.trial = trial;
    this.kdxploreDatabase = kdxploreDatabase;
    this.sampleGroup = sampleGroup;
    this.excludeTheseTraitIds = excludeTheseTraitIds;
    this.excludeThesePlotIds = excludeThesePlotIds;

    String deviceName = devid == null ? "Unknown_" + deviceType.name() : devid.getDeviceName();

    if (DeviceType.FOR_SCORING.equals(deviceType)) {
        if (!Check.isEmpty(sampleGroup.getOperatorName())) {
            deviceName = sampleGroup.getOperatorName();
        }// www  .  ja v a  2  s. com
    }

    File directory = KdxplorePreferences.getInstance().getOutputDirectory();
    if (directory == null) {
        directory = new File(System.getProperty("user.home"));
    }
    String filename = Util.getTimestampedOutputFileName(trial.getTrialName(), deviceName);

    File outfile = new File(directory, filename);

    filepathText.setText(outfile.getPath());

    filepathText.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void removeUpdate(DocumentEvent e) {
            updateButtons();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            updateButtons();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            updateButtons();
        }
    });
    updateButtons();

    boolean developer = RunMode.getRunMode().isDeveloper();
    oldKdsmartOption.setForeground(Color.BLUE);
    oldKdsmartOption.setToolTipText("For ElapsedDays value compatiblity with older versions of KDSmart");

    Box exportForOptionsBox = Box.createHorizontalBox();
    for (JComponent comp : exportForOptions) {
        if (developer || comp != oldKdsmartOption) {
            exportForOptionsBox.add(comp);
        }
    }

    Map<JRadioButton, OutputOption> optionByRb = new HashMap<>();
    ActionListener rbListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            selectedOutputOption = optionByRb.get(e.getSource());
            boolean enb = selectedOutputOption.exportFor != null;
            for (JComponent comp : exportForOptions) {
                if (comp == wantMediaFilesOption) {
                    comp.setEnabled(enb && selectedOutputOption.supportsMediaFiles());
                } else if (comp == kdsmartVersion3option) {
                    comp.setEnabled(enb && selectedOutputOption.usesWorkPackage());
                } else {
                    comp.setEnabled(enb);
                }
            }
        }
    };

    boolean anySamplesForIndividuals = true;
    try {
        anySamplesForIndividuals = kdxploreDatabase.getAnySamplesForIndividuals(sampleGroup);
    } catch (IOException e) {
        Shared.Log.w("SampleGroupExportDialog", "getAnySamplesForIndividuals", e);
    }

    ButtonGroup bg = new ButtonGroup();
    Box radioButtons = Box.createHorizontalBox();

    List<OutputOption> options = new ArrayList<>();
    Collections.addAll(options, OutputOption.values());

    if (!anySamplesForIndividuals) {
        // No relevant samples so don't bother offering the option.
        options.remove(OutputOption.CSV_FULL);
    }

    for (OutputOption oo : options) {
        if (!developer && OutputOption.JSON == oo) {
            continue;
        }

        JRadioButton rb = new JRadioButton(oo.displayName);
        if (OutputOption.KDX == oo) {
            kdxExportButton = rb;
        }

        if (OutputOption.ZIP == oo) {
            zipExportButton = rb;
        }

        rb.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                exportExclusionBox.selectAndDeactivateButtons(
                        kdxExportButton.isSelected() || zipExportButton.isSelected());
            }
        });

        if (OutputOption.JSON == oo) {
            rb.setForeground(Color.BLUE);
            rb.setToolTipText("Developer Only");
        }
        bg.add(rb);
        optionByRb.put(rb, oo);
        radioButtons.add(rb);
        rb.addActionListener(rbListener);
        if (bg.getButtonCount() == 1) {
            rb.doClick();
        }
    }

    Box additionalOptionsBox = Box.createHorizontalBox();
    additionalOptionsBox.add(this.wantMediaFilesOption);
    additionalOptionsBox.add(this.kdsmartVersion3option);

    dbVersionLabel.setToolTipText(TTT_DATABASE_VERSION_FOR_EXPORT);
    databaseVersionChoices.setToolTipText(TTT_DATABASE_VERSION_FOR_EXPORT);

    JPanel panel = new JPanel();
    GBH gbh = new GBH(panel);
    int y = 0;

    gbh.add(0, y, 1, 1, GBH.NONE, 0, 1, GBH.EAST, "Output File:");
    gbh.add(1, y, 1, 1, GBH.HORZ, 1, 1, GBH.CENTER, filepathText);
    gbh.add(2, y, 1, 1, GBH.NONE, 1, 1, GBH.WEST, new JButton(browseFileAction));
    ++y;

    gbh.add(0, y, 1, 1, GBH.NONE, 0, 1, GBH.EAST, "Options:");
    gbh.add(1, y, 2, 1, GBH.HORZ, 1, 1, GBH.CENTER, radioButtons);
    ++y;

    gbh.add(0, y, 3, 1, GBH.HORZ, 1, 1, GBH.CENTER, exportExclusionBox);
    ++y;

    gbh.add(0, y, 3, 1, GBH.HORZ, 1, 1, GBH.CENTER, additionalOptionsBox);
    ++y;

    gbh.add(0, y, 1, 1, GBH.NONE, 0, 1, GBH.EAST, dbVersionLabel);
    gbh.add(1, y, 2, 1, GBH.HORZ, 1, 1, GBH.CENTER, BoxBuilder.horizontal().add(databaseVersionChoices).get());

    gbh.add(1, y, 2, 1, GBH.HORZ, 1, 1, GBH.CENTER, exportForOptionsBox);
    ++y;

    Box buttons = Box.createHorizontalBox();
    buttons.add(Box.createHorizontalGlue());
    buttons.add(new JButton(cancelAction));
    buttons.add(new JButton(exportAction));
    buttons.add(new JButton(exportAndCloseAction));

    Container cp = getContentPane();

    cp.add(panel, BorderLayout.CENTER);
    cp.add(buttons, BorderLayout.SOUTH);

    pack();
}

From source file:com.example.app.repository.ui.ResourceSelector.java

/**
 * Set the Entity Actins on the Search UI. This only works if it is called before init.
 *
 * @param actions the Actions to set/*from  w  w w  .  j  a  va2  s  . c  om*/
 */
public void setEntityActions(Action... actions) {
    _entityActions.clear();
    Collections.addAll(_entityActions, actions);
}

From source file:org.jboss.aerogear.unifiedpush.utils.installation.InstallationUtils.java

public static Set<String> getAndroidDefaultCategories() {
    HashSet<String> categories = new HashSet<String>();
    Collections.addAll(categories, ANDROID_DEFAULT_CATEGORIES);
    return categories;
}

From source file:com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck.java

/**
 * Set the list of illegal variable types.
 * @param classNames array of illegal variable types
 *///from w  w w  . j  a  va2 s  .co m
public void setIllegalClassNames(String... classNames) {
    illegalClassNames.clear();
    Collections.addAll(illegalClassNames, classNames);
}

From source file:Heuristics.TermLevelHeuristics.java

public boolean isQuestionMarkAtEndOfStatus(String status) {
    List<String> terms = new ArrayList();
    Collections.addAll(terms, status.split(" "));
    StringBuilder sb = new StringBuilder();
    boolean cleanEnd = false;
    ListIterator<String> termsIterator = terms.listIterator(terms.size());
    while (termsIterator.hasPrevious() & !cleanEnd) {
        String string = termsIterator.previous();
        if (!cleanEnd && (string.contains("/") || string.startsWith("#") || string.startsWith("@")
                || string.equals("\\|") || string.equals("") || string.contains("via")
                || string.equals("..."))) {
            continue;
        } else {/*  ww w.j a v  a2 s.  c om*/
            cleanEnd = true;
        }
        sb.insert(0, string);
    }
    status = sb.toString().trim();
    if (status.length() == 0) {
        return false;
    } else {
        return ("?".equals(String.valueOf(status.charAt(status.length() - 1)))) ? true : false;
    }
}

From source file:com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck.java

/**
 * Set the list of ignore method names.//from  w  w w . j  a va  2 s .  c  om
 * @param methodNames array of ignored method names
 */
public void setIgnoredMethodNames(String... methodNames) {
    ignoredMethodNames.clear();
    Collections.addAll(ignoredMethodNames, methodNames);
}

From source file:edu.ku.brc.specify.utilapps.SetUpBuildDlg.java

/**
 * //from  w  w  w .j a va2s .c  om
 */
protected void fillChoicesWithDefaults() {
    if (collChoiceList == null || collChoiceList.size() == 0) {
        CollectionChoice[] choicesArray = {
                new CollectionChoice(DisciplineType.STD_DISCIPLINES.fish, false, true),
                new CollectionChoice(DisciplineType.STD_DISCIPLINES.fish, true, true),
                new CollectionChoice(DisciplineType.STD_DISCIPLINES.botany, false, true),
                new CollectionChoice(DisciplineType.STD_DISCIPLINES.invertpaleo, false, true), };

        collChoiceList = new Vector<CollectionChoice>();
        Collections.addAll(collChoiceList, choicesArray);

        for (DisciplineType.STD_DISCIPLINES disp : DisciplineType.STD_DISCIPLINES.values()) {
            if (disp != DisciplineType.STD_DISCIPLINES.botany
                    && disp != DisciplineType.STD_DISCIPLINES.invertpaleo
                    && disp != DisciplineType.STD_DISCIPLINES.paleobotany
                    && disp != DisciplineType.STD_DISCIPLINES.fish) {
                DisciplineType dType = DisciplineType.getDiscipline(disp);
                File file = XMLHelper.getConfigDir(dType.getFolder() + File.separator + "taxon_init.xml");
                if (file != null && file.exists()) {
                    CollectionChoice collChoice = new CollectionChoice(disp, false, true);
                    collChoiceList.add(collChoice);
                }
            }
        }

        for (CollectionChoice collChoice : collChoiceList) {
            collChoice.setCatalogNumberingFmtName("CatalogNumberNumeric");
            collChoice.setAccessionNumberingFmtName("AccessionNumber");
            DisciplineType dType = DisciplineType.getDiscipline(collChoice.getType());
            collChoice.setCatNumGroup("Cat " + dType.getTitle() + " Group");
            collChoice.setAccNumGroup("Acc " + dType.getTitle() + " Group");
        }
    }
}

From source file:net.semanticmetadata.lire.builders.GlobalDocumentBuilder.java

/**
 * @param image the image to analyze./* w ww .j a v a 2 s.c  om*/
 * @return Lucene Fields.
 */
@Override
public Field[] createDescriptorFields(BufferedImage image) {
    docsCreated = true;
    LinkedList<Field> resultList = new LinkedList<Field>();
    Field[] fields;
    if (extractorItems.size() > 0) {
        for (Map.Entry<ExtractorItem, String[]> extractorItemEntry : extractorItems.entrySet()) {
            fields = getGlobalDescriptorFields(image, extractorItemEntry.getKey());

            Collections.addAll(resultList, fields);
        }
    }

    return resultList.toArray(new Field[resultList.size()]);
}

From source file:org.jboss.aerogear.unifiedpush.utils.installation.InstallationUtils.java

public static Set<String> getIosDefaultCategories() {
    HashSet<String> categories = new HashSet<String>();
    Collections.addAll(categories, IOS_DEFAULT_CATEGORIES);
    return categories;
}

From source file:com.frostwire.search.KeywordDetector.java

private static void feedStopWords(String... words) {
    Collections.addAll(stopWords, words);
}