List of usage examples for java.util Collection remove
boolean remove(Object o);
From source file:com.screenslicer.core.util.Util.java
public static String newWindow(RemoteWebDriver driver) throws ActionFailed { try {/*from w ww . j a v a 2 s . c om*/ String origHandle = driver.getWindowHandle(); cleanUpNewWindows(driver, origHandle); try { driver.getKeyboard().sendKeys(Keys.chord(Keys.CONTROL + "n")); } catch (Throwable t) { Log.exception(t); } Util.driverSleepStartup(); Collection<String> handles = new HashSet<String>(driver.getWindowHandles()); handles.remove(origHandle); if (!handles.isEmpty()) { driver.switchTo().window(handles.iterator().next()); } else { driver.executeScript("window.open('');"); Util.driverSleepStartup(); handles = new HashSet<String>(driver.getWindowHandles()); handles.remove(origHandle); if (!handles.isEmpty()) { driver.switchTo().window(handles.iterator().next()); } } return driver.getWindowHandle(); } catch (Throwable t) { Log.exception(t); throw new ActionFailed(t); } }
From source file:HotelManagerImplTest.java
@Test public void testFindGuestsFromRoom() { Room room = newRoom(2, 4, 3);//from w w w . j a v a2 s .c o m roomManager.createRoom(room); Guest guest1 = newGuest("Anna", "1113552"); Guest guest2 = newGuest("Jana", "222454532"); Guest guest3 = newGuest("Hanka", "33345254"); guestManager.createGuest(guest1); guestManager.createGuest(guest2); guestManager.createGuest(guest3); Date startDate = date("2014-2-2"); hotelManager.addGuestToRoom(room, guest1, startDate, date("2017-3-3")); hotelManager.addGuestToRoom(room, guest2, startDate, date("2018-3-3")); hotelManager.addGuestToRoom(room, guest3, startDate, date("2019-3-3")); Collection<Guest> result = new ArrayList<>(); result = hotelManager.findGuestsfromRoom(room, startDate); assertTrue(result.contains(guest1)); assertTrue(result.contains(guest2)); assertTrue(result.contains(guest3)); assertTrue(result.remove(guest1)); assertTrue(result.remove(guest2)); assertTrue(result.remove(guest3)); assertTrue(result.isEmpty()); }
From source file:org.jactr.core.runtime.controller.debug.DebugController.java
/** * @see org.jactr.core.runtime.controller.debug.IDebugController#removeBreakpoint(org.jactr.core.model.IModel, * org.jactr.core.runtime.controller.debug.BreakpointType, * java.lang.Object)/* ww w . ja v a 2s. c om*/ */ public void removeBreakpoint(IModel model, BreakpointType type, Object value) { try { _lock.lock(); Map<BreakpointType, Collection<Object>> breakpoints = _breakpoints.get(model); Collection<Object> values = breakpoints.get(type); if (values != null) values.remove(value); } finally { _lock.unlock(); } }
From source file:org.sipfoundry.sipxconfig.feature.FeatureManagerImpl.java
private <T extends Feature> boolean update(Collection<T> features, T feature, boolean enable) { if (features.contains(feature)) { if (!enable) { features.remove(feature); } else {//from ww w . j a v a2s . c o m return false; } } else { if (enable) { features.add(feature); } else { return false; } } return true; }
From source file:org.springsource.ide.eclipse.commons.browser.swt.StsBrowserManager.java
/** * Calls Javascript functions <i>to</i> the browser, refreshing the browser * after each call/*from w w w . j ava 2s . com*/ */ public void callOnBrowser(final Collection<IEclipseToBrowserFunction> functions) { final Collection<IEclipseToBrowserFunction> waitingFunctions = new CopyOnWriteArrayList<IEclipseToBrowserFunction>(); IEclipseToBrowserFunction.Callback callback = new IEclipseToBrowserFunction.Callback() { @Override public void ready(final IEclipseToBrowserFunction function) { if (waitingFunctions.remove(function)) { if (!disposed) { doCall(function); } } } }; for (IEclipseToBrowserFunction function : functions) { if (!function.isReady()) { waitingFunctions.add(function); function.setCallback(callback); } else { doCall(function); } } callback.ready(null); }
From source file:org.apache.pig.pen.LineageTrimmingVisitor.java
private boolean checkCompleteness(LogicalRelationalOperator op) throws Exception { LineageTracer lineage = Lineage.get(op); Lineage.remove(op);/*from w w w . j a va2 s.c om*/ Collection<IdentityHashSet<Tuple>> affinityGroups = AffinityGroups.get(op); AffinityGroups.remove(op); Map<LOLoad, DataBag> newBaseData = PruneBaseDataConstrainedCoverage(baseData, lineage, affinityGroups); // obtain the derived data Map<Operator, DataBag> derivedData = eg.getData(newBaseData); double newCompleteness = MetricEvaluation.getCompleteness(null, derivedData, eg.getLoToEqClassMap(), true); if (newCompleteness >= completeness) { completeness = newCompleteness; baseData.putAll(newBaseData); } else { continueTrimming = false; } return continueTrimming; }
From source file:org.cesecore.certificates.ca.CvcCA.java
/** * Method to upgrade new (or existing external caservices) * This method needs to be called outside the regular upgrade * since the CA isn't instantiated in the regular upgrade. *//*from w w w.j a va 2s . com*/ @Override @SuppressWarnings("deprecation") public boolean upgradeExtendedCAServices() { boolean retval = false; Collection<Integer> externalServiceTypes = getExternalCAServiceTypes(); if (!CesecoreConfiguration.getCaKeepOcspExtendedService() && externalServiceTypes.contains(ExtendedCAServiceTypes.TYPE_OCSPEXTENDEDSERVICE)) { //This type has been removed, so remove it from any CAs it's been added to as well. externalServiceTypes.remove(ExtendedCAServiceTypes.TYPE_OCSPEXTENDEDSERVICE); data.put(EXTENDEDCASERVICES, externalServiceTypes); retval = true; } return retval; }
From source file:org.polymap.kaps.ui.KapsDefaultFormEditorPageWithFeatureTable.java
protected Composite createTableForm(Composite parent, Control top, boolean addAllowed, boolean deleteAllowed, boolean copyAllowed) { int TOPSPACING = 20; viewer = new FeatureTableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); viewer.getTable().setLayoutData(new SimpleFormData().fill().left(0).height(100).right(85) .top(top, TOPSPACING).bottom(100).create()); // columns/* w w w . j a v a2s. c o m*/ EntityType<T> type = addViewerColumns(viewer); // model/content viewer.setContent(new NamedCompositesFeatureContentProvider(null, type)); // try { // doLoad( new NullProgressMonitor() ); // } // catch (Exception e) { // throw new RuntimeException( e ); // } ActionButton addBtn = null; if (addAllowed) { AddCompositeAction<T> addAction = new AddCompositeAction<T>() { protected void execute() throws Exception { dirty = true; T newComposite = createNewComposite(); selectedComposite.set(newComposite); model.add(0, newComposite); doLoad(new NullProgressMonitor()); viewer.getTable().deselectAll(); viewer.getTable().select(((NamedCompositesFeatureContentProvider) viewer.getContentProvider()) .getIndicesForElements(newComposite)); // refreshReloadables(); // refreshReloadables is triggered bei selection event(); } }; addBtn = new ActionButton(parent, addAction); addBtn.setLayoutData(new SimpleFormData().left(viewer.getTable(), 6).top(top, TOPSPACING).right(100) .height(30).create()); } ActionButton copyBtn = null; if (copyAllowed) { CopyCompositeAction<T> copyAction = new CopyCompositeAction<T>() { protected void execute() throws Exception { if (selectedComposite.get() != null) { T toCopy = selectedComposite.get(); dirty = true; T newComposite = createNewComposite(); selectedComposite.set(newComposite); model.add(0, newComposite); doLoad(new NullProgressMonitor()); viewer.getTable().deselectAll(); viewer.getTable() .select(((NamedCompositesFeatureContentProvider) viewer.getContentProvider()) .getIndicesForElements(newComposite)); copyCompositeData(toCopy); } } }; copyBtn = new ActionButton(parent, copyAction); copyBtn.setLayoutData(new SimpleFormData().left(viewer.getTable(), 6) .top(addBtn != null ? addBtn : top, addBtn != null ? SPACING : TOPSPACING).right(100).height(30) .create()); } if (deleteAllowed) { DeleteCompositeAction<T> deleteAction = new DeleteCompositeAction<T>() { protected void execute() throws Exception { if (selectedComposite.get() != null) { T toSelect = selectedComposite.get(); model.remove(toSelect); if (viewer != null) { Collection<T> viewerInput = (Collection<T>) viewer.getInput(); viewerInput.remove(toSelect); } queueDeleteComposite(toSelect); selectedComposite.set(null); // pageSite.reloadEditor(); doLoad(new NullProgressMonitor()); // refreshReloadables(); dirty = true; // pageSite.fireEvent( this, id, // IFormFieldListener.VALUE_CHANGE, null ); // viewer.refresh( true ); } } }; ActionButton delBtn = new ActionButton(parent, deleteAction); Control topBtn = copyBtn != null ? copyBtn : addBtn; delBtn.setLayoutData(new SimpleFormData().left(viewer.getTable(), 6) .top(topBtn != null ? topBtn : top, topBtn != null ? SPACING : TOPSPACING).right(100).height(30) .create()); } parent.layout(true); viewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { if (!updatingElements) { // Felder fr ausgewhlten Eintrag in UI wurden gendert // keine Selektion hier StructuredSelection selection = (StructuredSelection) event.getSelection(); FeatureTableElement tableRow = (FeatureTableElement) selection.getFirstElement(); if (tableRow != null) { selectedComposite.set((T) tableRow.getComposite()); try { refreshReloadables(); } catch (Exception e) { e.printStackTrace(); } } } } }); if (model.size() > 0) { viewer.getTable().select(0); } return viewer.getTable(); }
From source file:jenkins.triggers.ReverseBuildTrigger.java
@Override public void start(@Nonnull Job project, boolean newInstance) { super.start(project, newInstance); SecurityContext orig = ACL.impersonate(ACL.SYSTEM); try {/*from w w w . j a v a 2 s . c o m*/ for (Job upstream : Items.fromNameList(project.getParent(), upstreamProjects, Job.class)) { if (upstream instanceof AbstractProject && project instanceof AbstractProject) { continue; // handled specially } synchronized (upstream2Trigger) { Collection<ReverseBuildTrigger> triggers = upstream2Trigger.get(upstream); if (triggers == null) { triggers = new LinkedList<>(); upstream2Trigger.put(upstream, triggers); } triggers.remove(this); triggers.add(this); } } } finally { SecurityContextHolder.setContext(orig); } }
From source file:uk.ac.ebi.intact.editor.services.curate.feature.FeatureEditorService.java
private void initialiseDetectionMethods(Collection<CvTerm> detectionMethods) { Collection<CvTerm> dets = new ArrayList<CvTerm>(detectionMethods); for (CvTerm det : dets) { if (!isCvInitialised(det)) { CvTerm reloaded = initialiseCv(det); if (reloaded != det) { detectionMethods.remove(det); detectionMethods.add(reloaded); }/*from w w w . ja v a 2s . c o m*/ } } }