List of usage examples for java.util SortedSet addAll
boolean addAll(Collection<? extends E> c);
From source file:org.polymap.p4.style.StyleEditor.java
protected void createEditorFields(Composite parent, StyleComposite style, int level) { SortedSet<PropertyInfo<?>> sorted = new TreeSet(new UIOrderComparator()); sorted.addAll(style.info().getProperties()); for (PropertyInfo<?> propInfo : sorted) { // StylePropertyValue if (StylePropertyValue.class.isAssignableFrom(propInfo.getType())) { Property<StylePropertyValue> prop = (Property<StylePropertyValue>) propInfo.get(style); StylePropertyField field = new StylePropertyField(createFieldSite(prop)); fields.add(field);//from ww w .jav a2 s . c om Control control = field.createContents(parent); // the widthHint is a minimal width; without the fields expand the enclosing section control.setLayoutData(ColumnDataFactory.defaults().widthHint(100).create()); } // StyleComposite else if (StyleComposite.class.isAssignableFrom(propInfo.getType())) { Section section = tk.createSection(parent, i18nField.get(propInfo.getDescription().orElse(propInfo.getName())), ExpandableComposite.TWISTIE, Section.SHORT_TITLE_BAR, Section.FOCUS_TITLE, SWT.BORDER); section.setToolTipText( i18nField.get(propInfo.getDescription().orElse(propInfo.getName()) + "Tooltip")); section.setExpanded(false); section.setBackground( new HSLColor(parent.getBackground()).adjustSaturation(-10f).adjustLuminance(-4f).toSWT()); ((Composite) section.getClient()).setLayout( ColumnLayoutFactory.defaults().columns(1, 1).margins(0, 0, 5, 0).spacing(5).create()); createEditorFields((Composite) section.getClient(), ((Property<StyleComposite>) propInfo.get(style)).get(), level + 1); } } }
From source file:jenkins.scm.impl.subversion.SubversionSCMSource.java
/** * Groups a set of path segments based on a supplied prefix. * * @param pathSegments the input path segments. * @param prefix the prefix to group on. * @return a map, all keys will {@link #startsWith(java.util.List, java.util.List)} the input prefix and be longer * than the input prefix, all values will {@link #startsWith(java.util.List, * java.util.List)} their corresponding key. *///from w w w . java2 s . c om @NonNull static SortedMap<List<String>, SortedSet<List<String>>> groupPaths( @NonNull SortedSet<List<String>> pathSegments, @NonNull List<String> prefix) { // ensure pre-condition is valid and ensure we are using a copy pathSegments = filterPaths(pathSegments, prefix); SortedMap<List<String>, SortedSet<List<String>>> result = new TreeMap<List<String>, SortedSet<List<String>>>( COMPARATOR); while (!pathSegments.isEmpty()) { List<String> longestPrefix = null; int longestIndex = -1; for (List<String> pathSegment : pathSegments) { if (longestPrefix == null) { longestPrefix = pathSegment; longestIndex = indexOfNextWildcard(pathSegment, prefix.size()); } else { int index = indexOfNextWildcard(pathSegment, prefix.size()); if (index > longestIndex) { longestPrefix = pathSegment; longestIndex = index; } } } assert longestPrefix != null; longestPrefix = new ArrayList<String>(longestPrefix.subList(0, longestIndex)); SortedSet<List<String>> group = filterPaths(pathSegments, longestPrefix); result.put(longestPrefix, group); pathSegments.removeAll(group); } String optimization; while (null != (optimization = getOptimizationPoint(result.keySet(), prefix.size()))) { List<String> optimizedPrefix = copyAndAppend(prefix, optimization); SortedSet<List<String>> optimizedGroup = new TreeSet<List<String>>(COMPARATOR); for (Iterator<Map.Entry<List<String>, SortedSet<List<String>>>> iterator = result.entrySet() .iterator(); iterator.hasNext();) { Map.Entry<List<String>, SortedSet<List<String>>> entry = iterator.next(); if (startsWith(entry.getKey(), optimizedPrefix)) { iterator.remove(); optimizedGroup.addAll(entry.getValue()); } } result.put(optimizedPrefix, optimizedGroup); } return result; }
From source file:org.projectforge.web.scripting.ScriptingPage.java
private void initScriptVariables() { if (scriptVariables != null) { // Already initialized. return;/*w ww. ja va2s .c om*/ } scriptVariables = new HashMap<String, Object>(); scriptVariables.put("reportStorage", null); scriptVariables.put("reportScriptingStorage", null); scriptDao.addScriptVariables(scriptVariables); final SortedSet<String> set = new TreeSet<String>(); set.addAll(scriptVariables.keySet()); final StringBuffer buf = new StringBuffer(); buf.append("scriptResult"); // first available variable. for (final String key : set) { buf.append(", ").append(key); } if (availableScriptVariablesLabel == null) { body.add(availableScriptVariablesLabel = new Label("availableScriptVariables", buf.toString())); } scriptDao.addAliasForDeprecatedScriptVariables(scriptVariables); // buf = new StringBuffer(); // boolean first = true; // for (final BusinessAssessmentRowConfig rowConfig : AccountingConfig.getInstance().getBusinessAssessmentConfig().getRows()) { // if (rowConfig.getId() == null) { // continue; // } // if (first == true) { // first = false; // } else { // buf.append(", "); // } // buf.append('r').append(rowConfig.getNo()).append(", ").append(rowConfig.getId()); // } // if (businessAssessmentRowsVariablesLabel == null) { // body.add(businessAssessmentRowsVariablesLabel = new Label("businessAssessmentRowsVariables", buf.toString())); // } }
From source file:org.apache.ode.utils.fs.TempFileManager.java
@SuppressWarnings("unchecked") private synchronized void _cleanup() { try {/* www .j a v a 2 s . com*/ // collect all subdirectory contents that still exist, ordered files-first SortedSet<File> allFiles = new TreeSet(Collections.reverseOrder(null)); for (File f : _registeredFiles) { if (f.exists()) { allFiles.addAll(FileUtils.directoryEntriesInPath(f)); } } if (__log.isDebugEnabled()) { __log.debug("cleaning up " + allFiles.size() + " files."); } // now delete all files for (File f : allFiles) { if (__log.isDebugEnabled()) { __log.debug("deleting: " + f.getAbsolutePath()); } if (f.exists() && !f.delete()) { __log.error("Unable to delete file " + f.getAbsolutePath() + "; this may be caused by a descriptor leak and should be reported."); // fall back to deletion on VM shutdown f.deleteOnExit(); } } } finally { _registeredFiles.clear(); __workDir = null; __log.debug("cleanup done."); } }
From source file:com.devnexus.ting.core.service.impl.DefaultTwitterService.java
/** {@inheritDoc} */ @Override//from www. j av a2 s .c o m public Collection<TwitterMessage> getTwitterMessages() { SortedSet<TwitterMessage> twitterMessages = new TreeSet<TwitterMessage>(new Comparator<TwitterMessage>() { @Override public int compare(TwitterMessage twitterMessage1, TwitterMessage twitterMessage2) { return twitterMessage2.getCreatedAt().compareTo(twitterMessage1.getCreatedAt()); } }); twitterMessages.addAll(this.twitterMessages.asMap().values()); return twitterMessages; }
From source file:org.apache.felix.webconsole.plugins.scriptconsole.internal.ScriptEngineManager.java
private void refreshScriptEngineManager() { EngineManagerState tmp = new EngineManagerState(); // register script engines from bundles final SortedSet<Object> extensions = new TreeSet<Object>(); synchronized (this.engineSpiBundles) { for (final Bundle bundle : this.engineSpiBundles) { extensions.addAll(registerFactories(tmp, bundle)); }/* w w w . j a va2s .c o m*/ } // register script engines from registered services synchronized (this.engineSpiServices) { for (final ScriptEngineFactoryState state : this.engineSpiServices.values()) { extensions.addAll(registerFactory(tmp, state.scriptEngineFactory, state.properties)); } } synchronized (this) { this.state = tmp; } }
From source file:io.yields.plugins.kpi.BuildActionResultsDisplay.java
private SortedSet<String> getKPINames(int size, String testName) { KPIReport kpiReport = getKPIReport(); if (kpiReport == null) { return new TreeSet<String>(); } else {/*w ww . java 2 s .c om*/ SortedSet<String> kpiNames = new TreeSet<String>(); ScoreResult kpiScore = kpiReport.getKpiScore(testName); if (kpiScore != null) { kpiNames.addAll(kpiScore.getKpiResults().keySet()); int total = 1; while (total < size) { KPIReport previous = kpiReport.getPrevious(); if (previous == null) { break; } ScoreResult scoreResult = previous.getKpiScore(testName); if (scoreResult != null) { kpiNames.addAll(scoreResult.getKpiResults().keySet()); } total++; } } return kpiNames; } }
From source file:org.sonatype.nexus.ldap.internal.connector.DefaultLdapConnector.java
public SortedSet<String> getAllGroups() throws LdapDAOException { LdapContext context = null;// w w w. j av a 2s . co m try { SortedSet<String> results = new TreeSet<String>(); context = this.getLdapContextFactory().getSystemLdapContext(); LdapAuthConfiguration conf = this.getLdapAuthConfiguration(); results.addAll(this.ldapGroupManager.getAllGroups(context, conf)); return results; } catch (NamingException e) { String message = "Failed to retrieve ldap information for users."; throw new LdapDAOException(message, e); } finally { this.closeContext(context); } }
From source file:net.sourceforge.fenixedu.presentationTier.Action.publico.ViewHomepageDA.java
public ActionForward show(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) {/*from ww w .j a v a2s .c o m*/ Homepage homepage = getHomepage(request); if (homepage == null || !homepage.getActivated().booleanValue()) { final ActionMessages actionMessages = new ActionMessages(); actionMessages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("homepage.not.found")); saveMessages(request, actionMessages); return notFound(mapping, actionForm, request, response); } else { SortedSet<Attends> personAttendsSortedByExecutionCourseName = new TreeSet<Attends>( Attends.ATTENDS_COMPARATOR_BY_EXECUTION_COURSE_NAME); personAttendsSortedByExecutionCourseName.addAll(homepage.getPerson().getCurrentAttends()); request.setAttribute("personAttends", personAttendsSortedByExecutionCourseName); request.setAttribute("homepage", homepage); return mapping.findForward("view-homepage"); } }
From source file:de.fischer.thotti.reportgen.diagram.ChartGenerator.java
public ChartMetaData generateSingleVariantsChart(final String testId, String jvmArgsId, String paramGrpId) { String variantId = String.format("%s-%s-%s", testId, jvmArgsId, paramGrpId); File chartFile;/*w ww. j ava 2 s . c o m*/ try { final TimeSeriesCollection collection = new TimeSeriesCollection(); String chartTitle = String.format("%s-%s-%s", testId, jvmArgsId, paramGrpId); String svgFilename = String.format("%s-%s-%s.svg", testId, jvmArgsId, paramGrpId); chartFile = new File(baseDir, svgFilename); TimeSeries series = new TimeSeries(String.format("Average of %s", variantId), Day.class); TimeSeries mediaSeries = new TimeSeries(String.format("Median of %s", variantId), Day.class); List<NDResultEntity> results = persistenceHelper.findAllResultsForVariant(testId, jvmArgsId, paramGrpId); SortedSet<NDResultEntity> sortedSet = new TreeSet<NDResultEntity>( new TestVariantModel.DateComparator()); sortedSet.addAll(results); Iterator<Measurement> itr = new AverageDayCombinerIterator(sortedSet.iterator()); while (itr.hasNext()) { Measurement singleResult = itr.next(); Date startDate = singleResult.getPointInTime(); double time = singleResult.getDuration(); double t2 = convertMilliSecsToSeconds(time); series.add(new Day(startDate), t2); } collection.addSeries(series); Iterator<DatePoint> medianItr = new MedianIterator(sortedSet.iterator()); while (medianItr.hasNext()) { DatePoint singleResult = medianItr.next(); Date startDate = singleResult.getPointInTime(); double value = convertMilliSecsToSeconds(singleResult.getValue()); mediaSeries.add(new Day(startDate), value); } collection.addSeries(mediaSeries); final JFreeChart chart = createChart(chartTitle, collection); saveChartAsSVG(chart, svgFilename); System.out.println(String.format("Written %s", chartFile.toString())); return new ChartMetaData().withFilename(chartFile.getName()).withWidth(DEFAULT_CHAR_WIDTH) .withHeight(DEFAULT_CHAR_HEIGHT).withFormat("SVG"); } catch (IOException ioe) { // @todo Throw an better exception! ioe.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } return null; }