Example usage for java.util SortedSet addAll

List of usage examples for java.util SortedSet addAll

Introduction

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

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Adds all of the elements in the specified collection to this set if they're not already present (optional operation).

Usage

From source file:CASUAL.communicationstools.heimdall.odin.Odin.java

public String[] getHeimdallFileParametersFromOdinFile(String tempFolder, File[] files)
        throws CorruptOdinFileException, FileNotFoundException {
    //Sorted set allows for only one instance of each file to exist
    SortedSet<File> set = new java.util.TreeSet<File>();

    //decompress Odin files into regular files and track them
    for (File file : files) {
        OdinFile o;//from ww  w  . ja  v a2  s . c  o m
        try {
            o = new OdinFile(file);
            o.extractOdinContents(tempFolder);
            set.addAll(Arrays.asList(o.extractOdinContents(tempFolder)));
        } catch (IOException ex) {
            throw new FileNotFoundException();
        } catch (NoSuchAlgorithmException ex) {
            throw new CorruptOdinFileException("This computer cannot handle the file");
        } catch (CorruptOdinFileException ex) {
            throw new CorruptOdinFileException("The Archive is corrupt");
        } catch (ArchiveException ex) {
            throw new CorruptOdinFileException("The Archive is corrupt");
        }
    }

    //create list of --PARTITION filename for Heimdall
    ArrayList<String> list = new ArrayList<String>();
    for (File f : set) {
        String partname = pit.findEntryByFilename(f.getName()).getPartitionName();
        list.add("--" + partname);
        list.add(f.getAbsolutePath());
    }

    //return that list. 
    return list.toArray(new String[list.size()]);
}

From source file:net.sf.groovyMonkey.actions.RecreateMonkeyMenuAction.java

private void createTheMenu(final List<Association> menuData, final IAction action) {
    final MenuManager outerManager = ((WorkbenchWindow) window).getMenuManager();
    if (outerManager == null)
        return;/*w  w  w .  j a  v a 2 s  .c  o  m*/
    final String menuName = getDefault().getPreferenceStore().getString(MONKEY_MENU_NAME);
    final IMenuManager menuManager = new MenuManager(menuName, MENU_PATH);
    outerManager.replaceItem(MENU_PATH, menuManager);
    final MonkeyMenuStruct current = new MonkeyMenuStruct();
    current.key = "";
    current.menu = menuManager;
    current.submenu = new MonkeyMenuStruct();
    final SortedSet<Association> sorted = new TreeSet<Association>();
    sorted.addAll(menuData);
    for (final Association association : sorted)
        addNestedMenuAction(current, association.key, association.file);
    final IWorkbenchWindow _window = window;
    if (sorted.size() != 0)
        menuManager.add(new Separator());
    menuManager.add(new Action("Create New Script") {
        @Override
        public void run() {
            final IWorkbenchWindowActionDelegate delegate = new NewGroovyMonkeyScriptAction();
            delegate.init(_window);
            delegate.run(action);
        }
    });
    menuManager.add(new Action("Paste New Script") {
        @Override
        public void run() {
            final IWorkbenchWindowActionDelegate delegate = new PasteScriptFromClipboardAction();
            delegate.init(_window);
            delegate.run(action);
        }
    });
    menuManager.add(new Action("Pull scripts from URL") {
        @Override
        public void run() {
            final IWorkbenchWindowActionDelegate delegate = new PasteScriptsFromURL();
            delegate.init(_window);
            delegate.run(action);
        }
    });
    if (sorted.size() == 0)
        menuManager.add(new Action("Examples") {
            @Override
            public void run() {
                final IWorkbenchWindowActionDelegate delegate = new CreateGroovyMonkeyExamplesAction();
                delegate.init(_window);
                delegate.run(action);
            }
        });
    final IMenuManager editMenu = menuManager.findMenuUsingPath(MENU_EDIT_PATH) != null
            ? menuManager.findMenuUsingPath(MENU_EDIT_PATH)
            : new MenuManager("Edit Script", MENU_EDIT_PATH);
    menuManager.add(editMenu);
    current.key = "";
    current.menu = editMenu;
    current.submenu = new MonkeyMenuStruct();
    for (final Association association : sorted)
        addNestedMenuEditAction(current, association.key, association.file);
    outerManager.updateAll(true);
}

From source file:org.tonguetied.keywordmanagement.Keyword.java

/**
 * Remove a {@link Translation} from this <code>Keyword</code>s list of 
 * <code>translations</code>. This method is a convenience method acting as
 * a wrapper around the lists' remove method. 
 * /*w ww . j  a  va  2s .  com*/
 * @param translation the {@link Translation} to remove.
 */
public void remove(Translation translation) {
    if (translation.getId() != null) {
        SortedSet<Translation> tempSet = new TreeSet<Translation>(new TranslationIdComparator());
        tempSet.addAll(this.translations);
        this.translations = tempSet;
    }

    if (this.translations.remove(translation)) {
        translation.setKeyword(null);
    } else {
        logger.warn("failed to remove translation: " + translation);
    }
}

From source file:name.livitski.databag.cli.Syntax.java

@SuppressWarnings("unchecked")
public void usage(PrintStream out) {
    PrintWriter pw = new PrintWriter(out, true);
    pw.println(getMessage("USAGE"));
    pw.println();/*w  w  w. j av a2 s . co  m*/
    pw.println("    " + getMessage("SYNTAX"));
    pw.println();
    pw.println(getMessage("COMMANDS"));
    pw.println();
    SortedSet<Option> commands = new TreeSet<Option>(OPTION_COMPARATOR);
    commands.addAll(COMMAND_OPTION_GROUP.getOptions());
    listOptions(commands, pw);
    pw.println(getMessage("OPTIONS"));
    pw.println();
    SortedSet<Option> options = new TreeSet<Option>(OPTION_COMPARATOR);
    options.addAll(OPTIONS.getOptions());
    options.removeAll(commands);
    listOptions(options, pw);
    getHelpFormatter().printWrapped(pw, OUTPUT_WIDTH, getMessage("MORE"));
    pw.println();
    pw.close();
}

From source file:com.aurel.track.exchange.excel.ExcelFieldMatchAction.java

/**
 * Render the field match: first time and after a sheet change
 *///from w  ww . ja  v a2 s. c  o m
@Override
public String execute() {
    File fileOnDisk = new File(excelMappingsDirectory, fileName);
    workbook = ExcelFieldMatchBL.loadWorkbook(excelMappingsDirectory, fileName);
    if (workbook == null) {
        JSONUtility.encodeJSON(servletResponse,
                JSONUtility.encodeJSONFailure(getText("admin.actions.importExcel.err.noWorkbook")), false);
        fileOnDisk.delete();
        return null;
    }
    if (selectedSheet == null) {
        //first rendering (not submit because of sheet change)
        selectedSheet = Integer.valueOf(0);
    }
    //get the previous field mappings
    Map<String, Integer> columNameToFieldIDMap = null;
    Set<Integer> lastSavedIdentifierFieldIDIsSet = null;
    try {
        FileInputStream fis = new FileInputStream(new File(excelMappingsDirectory, mappingFileName));

        ObjectInputStream objectInputStream = new ObjectInputStream(fis);
        columNameToFieldIDMap = (Map<String, Integer>) objectInputStream.readObject();
        lastSavedIdentifierFieldIDIsSet = (Set<Integer>) objectInputStream.readObject();
        objectInputStream.close();
    } catch (FileNotFoundException e) {
        LOGGER.info("Creating the input stream for mapping failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    } catch (IOException e) {
        LOGGER.warn("Saving the mapping failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    } catch (ClassNotFoundException e) {
        LOGGER.warn("Class not found for  the mapping " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    //get the column index to header names from the excel sheet
    SortedMap<Integer, String> columnIndexToColumNameMap = ExcelFieldMatchBL.getFirstRowHeaders(workbook,
            selectedSheet);

    SortedSet<String> excelColumnNames = new TreeSet<String>();
    excelColumnNames.addAll(columnIndexToColumNameMap.values());
    //prepare the best field matching
    if (columNameToFieldIDMap == null) {
        columNameToFieldIDMap = new HashMap<String, Integer>();
    }
    ExcelFieldMatchBL.prepareBestMatchByLabel(excelColumnNames, columNameToFieldIDMap, locale);
    columnIndexToFieldIDMap = ExcelFieldMatchBL.getColumnIndexToFieldIDMap(columNameToFieldIDMap,
            columnIndexToColumNameMap);
    columnIndexIsIdentifierMap = new HashMap<Integer, Boolean>();
    //the saved identifier columns
    if (lastSavedIdentifierFieldIDIsSet != null && !lastSavedIdentifierFieldIDIsSet.isEmpty()) {
        for (Integer columnIndex : columnIndexToFieldIDMap.keySet()) {
            Integer fieldID = columnIndexToFieldIDMap.get(columnIndex);
            columnIndexIsIdentifierMap.put(columnIndex,
                    new Boolean(lastSavedIdentifierFieldIDIsSet.contains(fieldID)));
        }
    }
    //if issueNo is present it is always identifier (first time it should be preselected and any time when mapped also preselected)
    if (columnIndexToFieldIDMap.values().contains(SystemFields.INTEGER_ISSUENO)) {
        for (Integer columnIndex : columnIndexToFieldIDMap.keySet()) {
            Integer fieldID = columnIndexToFieldIDMap.get(columnIndex);
            if (SystemFields.INTEGER_ISSUENO.equals(fieldID)) {
                columnIndexIsIdentifierMap.put(columnIndex, new Boolean(true));
            }
        }
    }
    List<IntegerStringBean> sheetNames = ExcelFieldMatchBL.loadSheetNames(workbook);
    List<IntegerStringBean> matchableFieldsList = ExcelFieldMatchBL.getFieldConfigs(personID, locale);
    Map<Integer, String> columnIndexNumericToLetter = ExcelFieldMatchBL.getFirstRowNumericToLetter(workbook,
            selectedSheet);
    Set<Integer> possibleIdentifiersSet = ExcelFieldMatchBL.getPossibleIdentifierFields();
    Set<Integer> mandatoryIdentifiersSet = ExcelFieldMatchBL.getMandatoryIdentifierFields();
    JSONUtility.encodeJSON(servletResponse,
            ExcelImportJSON.getExcelFieldMatcherJSON(fileName, selectedSheet, sheetNames, matchableFieldsList,
                    columnIndexToColumNameMap, columnIndexNumericToLetter, columnIndexToFieldIDMap,
                    columnIndexIsIdentifierMap, possibleIdentifiersSet, mandatoryIdentifiersSet),
            false);
    return null;
}

From source file:com.aurel.track.item.link.ItemLinkBL.java

/**
 * Add processed chunk data to final map
 * @param finalMap/*  w  ww .  j a va2s .  c  o m*/
 * @param chunkMap
 */
private static void addChuck(Map<Integer, SortedSet<Integer>> finalMap,
        Map<Integer, SortedSet<Integer>> chunkMap) {
    if (chunkMap != null) {
        for (Map.Entry<Integer, SortedSet<Integer>> chunkEntry : chunkMap.entrySet()) {
            Integer baseWorkItemID = chunkEntry.getKey();
            SortedSet<Integer> linkedValueIDs = chunkEntry.getValue();
            SortedSet<Integer> finalValues = finalMap.get(baseWorkItemID);
            if (finalValues == null) {
                finalValues = new TreeSet<Integer>();
                finalMap.put(baseWorkItemID, finalValues);
            }
            finalValues.addAll(linkedValueIDs);
        }
    }
}

From source file:com.telenav.expandablepager.SlidingContainer.java

/**
 * Stops sliding at the specified values.
 * @param stopValues list of stop values
 *///from w  ww .j  ava2s  .  c  o m
public void setStopValues(Float... stopValues) {
    SortedSet<Float> s = new TreeSet<>(Collections.reverseOrder());
    s.addAll(Arrays.asList(stopValues));
    this.stopValues.clear();
    this.stopValues.addAll(s);
    this.stopValues.add(0f);
    stopValueIndex = 0;
}

From source file:io.wcm.handler.media.format.impl.MediaFormatHandlerImpl.java

/**
 * Get media formats defined by a CMS application that is responsible for the given media library path.
 * @param comparator Comparator for set//from  w  w  w  .j  av  a  2  s  . com
 * @return Media formats
 */
@Override
public SortedSet<MediaFormat> getMediaFormats(Comparator<MediaFormat> comparator) {
    SortedSet<MediaFormat> set = new TreeSet<>(comparator);
    set.addAll(getMediaFormatsForApplication());
    return ImmutableSortedSet.copyOf(set);
}

From source file:net.sourceforge.fenixedu.presentationTier.renderers.providers.candidacy.ExecutionYearsForDegree.java

@Override
public Object provide(Object source, Object currentValue) {
    final SortedSet<ExecutionYear> result = new TreeSet<ExecutionYear>(
            new ReverseComparator(ExecutionYear.COMPARATOR_BY_YEAR));

    final DFACandidacyBean bean = (DFACandidacyBean) source;
    if (bean.getDegree() != null) {
        for (final DegreeCurricularPlan dcp : bean.getDegree().getDegreeCurricularPlansSet()) {
            result.addAll(dcp.getExecutionYears());
        }//from w  ww  . j av a2 s. c o m
    } else {
        bean.setExecutionYear(null);
    }
    return result;
}

From source file:net.sourceforge.fenixedu.domain.organizationalStructure.DepartmentUnit.java

@Override
public List<Group> getDefaultGroups() {
    List<Group> groups = super.getDefaultGroups();

    ExecutionYear currentYear = ExecutionYear.readCurrentExecutionYear();
    Department department = this.getDepartment();
    if (department != null) {

        groups.add(TeacherGroup.get(department, currentYear));
        groups.add(UnitGroup.recursiveWorkers(department.getDepartmentUnit()));

        SortedSet<Degree> degrees = new TreeSet<Degree>(Degree.COMPARATOR_BY_DEGREE_TYPE_AND_NAME_AND_ID);
        degrees.addAll(department.getDegreesSet());

        for (Degree degree : degrees) {
            groups.add(StudentGroup.get(degree, null));
        }//from w  w  w  .j a  v a2s  . c  om
    }

    return groups;
}