List of usage examples for java.util LinkedList addAll
public boolean addAll(Collection<? extends E> c)
From source file:org.fusesource.mop.support.CommandDefinition.java
public void executeCommand(MOP mop, LinkedList<String> argList) throws Exception { this.mop = mop; // lets run the command! LinkedList<String> artifacts = new LinkedList<String>(); LinkedList<String> args = new LinkedList<String>(); splitArgumentList(argList, artifacts, args); boolean addedArgs = false; LinkedList<String> newArguments = new LinkedList<String>(); for (String arg : getAliasArguments()) { arg = replaceVariables(arg);/*from w w w . j a va 2 s . c o m*/ if (arg.equals(ARTIFACTS_VARIABLE)) { newArguments.addAll(artifacts); } else if (arg.equals(ARGS_VARIABLE)) { newArguments.addAll(args); addedArgs = true; } else { newArguments.add(arg); } } if (!addedArgs) { newArguments.addAll(args); } LOG.info("About to execute: " + newArguments); mop.executeCommand(newArguments); }
From source file:statemachinedesigner.EditorApplet.java
/** * create an instance of a simple graph with popup controls to * create a graph./*from ww w. j av a 2 s .c o m*/ * */ public EditorApplet(SimulatorController controller) { // create a simple graph for the demo _controller = controller; _graph = new DirectedSparseGraph<Number, Number>(); this.layout = new StaticLayout<Number, Number>(_graph, new Dimension(600, 600)); vv = new VisualizationViewer<Number, Number>(layout); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(MapTransformer.<Number, String>getInstance( LazyMap.<Number, String>decorate(new HashMap<Number, String>(), new ToStringLabeller<Number>()))); vv.getRenderContext().setEdgeLabelTransformer(MapTransformer.<Number, String>getInstance( LazyMap.<Number, String>decorate(new HashMap<Number, String>(), new ToStringLabeller<Number>()))); vv.setVertexToolTipTransformer(vv.getRenderContext().getVertexLabelTransformer()); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); Factory<Number> vertexFactory = new VertexFactory(); Factory<Number> edgeFactory = new EdgeFactory(); final EditingModalGraphMouse<Number, Number> graphMouse = new EditingModalGraphMouse<Number, Number>( vv.getRenderContext(), vertexFactory, edgeFactory); // the EditingGraphMouse will pass mouse event coordinates to the // vertexLocations function to set the locations of the vertices as // they are created vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); graphMouse.setMode(ModalGraphMouse.Mode.EDITING); JButton submitButton = new JButton("Submit"); submitButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { LinkedList<Number> vertices = new LinkedList<Number>(); vertices.addAll(_graph.getVertices()); for (Number n : vertices) { if (_graph.getNeighborCount(n) == 0) { _graph.removeVertex(n); } } LinkedList<Number> edges = new LinkedList<Number>(); edges.addAll(_graph.getEdges()); for (Number n : edges) { if (_graph.getDest(n) == null) { _graph.removeEdge(n); } else if (_graph.getSource(n) == _graph.getDest(n)) { _graph.removeEdge(n); } } vv.repaint(); } }); JButton clearButton = new JButton("Clear All"); clearButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //add code to clear all nodes vertexCount = 0; edgeCount = 0; LinkedList<Number> vertices = new LinkedList<Number>(); vertices.addAll(_graph.getVertices()); for (Number n : vertices) { _graph.removeVertex(n); } vv.repaint(); } }); JButton clearEdgesButton = new JButton("Clear All Edges"); clearEdgesButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { edgeCount = 0; LinkedList<Number> edges = new LinkedList<Number>(); edges.addAll(_graph.getEdges()); for (Number n : edges) { _graph.removeEdge(n); } vv.repaint(); } }); //to be removed JButton helpButton = new JButton("Help"); helpButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(vv, instructions); } }); JComboBox modeBox = graphMouse.getModeComboBox(); modeBox.removeItemAt(0); //transforming modeBox.removeItemAt(2); //annotating modeBox.setToolTipText( "Editing mode allows for insertion and removal of edges/vertices; Picking mode is for placement"); JPanel controlPanel = new JPanel(); controlPanel.add(new JLabel("Mouse Mode")); controlPanel.add(modeBox); controlPanel.add(submitButton); controlPanel.add(clearButton); controlPanel.add(clearEdgesButton); controlPanel.add(helpButton); content.add(controlPanel, BorderLayout.SOUTH); }
From source file:org.rascalmpl.library.experiments.Compiler.Rascal2muRascal.RandomValueTypeVisitor.java
@Override public IValue visitAbstractData(Type type) { LinkedList<Type> alternatives = new LinkedList<Type>(); alternatives.addAll(definitions.lookupAlternatives(type)); Collections.shuffle(alternatives); for (Type pick : alternatives) { IConstructor result = (IConstructor) this.generate(pick); if (result != null) { RandomValueTypeVisitor visitor = descend(); Map<String, Type> annotations = definitions.getAnnotations(type); for (Map.Entry<String, Type> entry : annotations.entrySet()) { IValue value = visitor.generate(entry.getValue()); if (value == null) { return null; }/*from w w w. ja v a 2s . co m*/ result = result.asAnnotatable().setAnnotation(entry.getKey(), value); } return result; } } return null; }
From source file:org.openmrs.module.chartsearch.solr.ChartSearchSearcher.java
/** * Looks for any added filter fields onto the query and returns its value names and counts * /*from w w w .j a v a2s. c o m*/ * @param response */ public List<Count> getAndUseFacetFieldsNamesAndCounts(QueryResponse response) { List<FacetField> facets = response.getFacetFields(); LinkedList<FacetField> conceptNameFacets = new LinkedList<FacetField>(); conceptNameFacets.addAll(facets); //TODO use iteration when adding other facet fields rather than concept class FacetField conceptNameFacet = conceptNameFacets.get(0); return conceptNameFacet.getValues(); }
From source file:org.openmrs.module.chartsearch.solr.ChartSearchSearcher.java
/** * Adds filter Queries to the query for selected categories returned from the UI * /*from w w w . jav a 2 s.c om*/ * @param query * @param selectedCats */ public void addSelectedFilterQueriesToQuery(SolrQuery query, List<String> selectedCats) { String filterQuery = ""; LinkedList<String> selectedCategories = new LinkedList<String>(); selectedCategories.addAll(selectedCats); if (selectedCategories == null || selectedCategories.isEmpty()) { } else { LinkedList<CategoryFilter> existingCategories = new LinkedList<CategoryFilter>(); existingCategories.addAll(getChartSearchService().getAllCategoryFilters()); int indexOfFirstSelected = selectedCategories.indexOf(selectedCategories.getFirst()); int indexOfLastSelected = selectedCategories.indexOf(selectedCategories.getLast()); int indexOfFirstExisting = existingCategories.indexOf(existingCategories.getFirst()); int indexOfLastExisting = existingCategories.indexOf(existingCategories.getLast()); for (int i = indexOfFirstSelected; i <= indexOfLastSelected; i++) { String currentSelected = selectedCategories.get(i); for (int j = indexOfFirstExisting; j <= indexOfLastExisting; j++) { CategoryFilter currentExisting = existingCategories.get(j); String currentExistingName = currentExisting.getCategoryName(); if (currentSelected.equals(currentExistingName.toLowerCase())) { if (i != indexOfLastSelected) { filterQuery += currentExisting.getFilterQuery() + " OR "; } else filterQuery += currentExisting.getFilterQuery(); } } } query.addFilterQuery(filterQuery); } }
From source file:it.zielke.a2pdf.Anki2PDF.java
private List<String> reorderPages(List<String> sideContent) { LinkedList<String> ret = new LinkedList<String>(); int rowsize = settings.getRowSize(); for (int i = 0; i < sideContent.size(); i += rowsize) { List<String> tmp = sideContent.subList(i, Math.min(i + rowsize, sideContent.size())); Collections.reverse(tmp); ret.addAll(tmp); }/* ww w. j av a 2 s. c om*/ return ret; }
From source file:de.tudarmstadt.ukp.lmf.transform.germanet.SubcategorizationFrameExtractor.java
/** * Returns a sorted list of all subcategorization frames contained in this extractor * @return all subcategorization frames in this extractor * @see SubcategorizationFrame/*from w ww. j a v a 2s . co m*/ * @see SubcategorizationFrameExtractor */ public List<SubcategorizationFrame> getSubcategorizationFrames() { LinkedList<SubcategorizationFrame> result = new LinkedList<SubcategorizationFrame>(); result.addAll(synArgSubcatFrameMapping.values()); Collections.sort(result); return result; }
From source file:org.eclipse.wb.internal.core.model.description.helpers.ComponentDescriptionHelper.java
/** * @param editor/* ww w. j av a 2s .c o m*/ * the {@link AstEditor} in context of which we work now. * @param key * the {@link ComponentDescriptionKey} of requested {@link ComponentDescription}. * @param additionalDescriptionInfos * additional {@link ClassResourceInfo}'s to parse after {@link ClassResourceInfo}'s * collected for component {@link Class}. May be empty, but not <code>null</code>. * * @return the {@link ComponentDescription} of component with given {@link Class}. * @throws Exception * if no {@link ComponentDescription} can be found. */ private static ComponentDescription getDescription0(AstEditor editor, ComponentDescriptionKey key, List<ClassResourceInfo> additionalDescriptionInfos) throws Exception { EditorState state = EditorState.get(editor); ILoadingContext context = EditorStateLoadingContext.get(state); Class<?> componentClass = key.getComponentClass(); // try { // prepare result description ComponentDescription componentDescription = new ComponentDescription(key); addConstructors(editor.getJavaProject(), componentDescription); componentDescription.setBeanInfo(ReflectionUtils.getBeanInfo(componentClass)); componentDescription.setBeanDescriptor(new IntrospectionHelper(componentClass).getBeanDescriptor()); // prepare list of description resources, from generic to specific LinkedList<ClassResourceInfo> descriptionInfos; { descriptionInfos = Lists.newLinkedList(); DescriptionHelper.addDescriptionResources(descriptionInfos, context, componentClass); Assert.isTrueException(!descriptionInfos.isEmpty(), ICoreExceptionConstants.DESCRIPTION_NO_DESCRIPTIONS, componentClass.getName()); // at last append additional description resource descriptionInfos.addAll(additionalDescriptionInfos); } // prepare Digester Digester digester; { digester = new Digester(); digester.setLogger(new NoOpLog()); addRules(digester, editor, componentClass); } // read descriptions from generic to specific for (ClassResourceInfo descriptionInfo : descriptionInfos) { ResourceInfo resourceInfo = descriptionInfo.resource; // read next description { componentDescription.setCurrentClass(descriptionInfo.clazz); digester.push(componentDescription); // do parse InputStream is = resourceInfo.getURL().openStream(); try { digester.parse(is); } finally { IOUtils.closeQuietly(is); } } // clear parts that can not be inherited if (descriptionInfo.clazz == componentClass) { setDescriptionWithInnerTags(componentDescription, resourceInfo); } else { componentDescription.clearCreations(); componentDescription.setDescription(null); } } // set toolkit if (componentDescription.getToolkit() == null) { for (int i = descriptionInfos.size() - 1; i >= 0; i--) { ClassResourceInfo descriptionInfo = descriptionInfos.get(i); ToolkitDescription toolkit = descriptionInfo.resource.getToolkit(); if (toolkit != null) { componentDescription.setToolkit(toolkit); break; } } Assert.isTrueException(componentDescription.getToolkit() != null, ICoreExceptionConstants.DESCRIPTION_NO_TOOLKIT, componentClass.getName()); } // icon, default creation setIcon(context, componentDescription, componentClass); configureDefaultCreation(componentDescription); // final operations { Assert.isNotNull(componentDescription.getModelClass()); componentDescription.joinProperties(); } // add to caches if (key.isPureComponent() && !"true".equals(componentDescription.getParameter("dontCacheDescription")) && shouldCacheDescriptions_inPackage(descriptionInfos.getLast(), componentClass)) { componentDescription.setCached(true); } // mark for caching presentation if (shouldCachePresentation(descriptionInfos.getLast(), componentClass)) { componentDescription.setPresentationCached(true); } // use processors for (IDescriptionProcessor processor : getDescriptionProcessors()) { processor.process(editor, componentDescription); } // well, we have result return componentDescription; } catch (SAXParseException e) { throw new DesignerException(ICoreExceptionConstants.DESCRIPTION_LOAD_ERROR, e.getException(), componentClass.getName()); } }
From source file:org.duracloud.account.app.controller.AccountGroupsController.java
private Collection<DuracloudUser> getAvailableUsers(AccountService as, Collection<DuracloudUser> groupUsers) { Set<DuracloudUser> allUsers = as.getUsers(); LinkedList<DuracloudUser> list = new LinkedList<DuracloudUser>(); list.addAll(allUsers); for (DuracloudUser user : allUsers) { if (user.isRoot()) { list.remove(user);/* w ww. j a v a 2 s . c o m*/ } } if (groupUsers != null) { list.removeAll(groupUsers); } Collections.sort(list, USERNAME_COMPARATOR); return list; }
From source file:org.nanocom.console.input.ArgsInput.java
/** * {@inheritDoc}/*from ww w . j av a 2 s .com*/ */ @Override public Object getParameterOption(List<String> values, Object defaultValue) { LinkedList<String> locTokens = new LinkedList<String>(); locTokens.addAll(tokens); while (!locTokens.isEmpty()) { String token = locTokens.poll(); for (String value : values) { if (value.startsWith(token)) { int pos = token.indexOf("="); if (pos > -1) { return token.substring(pos + 1); } return locTokens.poll(); } } } return defaultValue; }