List of usage examples for com.google.common.base Predicates alwaysFalse
@GwtCompatible(serializable = true) public static <T> Predicate<T> alwaysFalse()
From source file:org.eclipse.sirius.diagram.ui.tools.internal.actions.visibility.HideDDiagramElementAction.java
/** * Indicates if the given ddiagram is allowing pin/unpin. * /* ww w.j a v a 2 s . c o m*/ * @param diagram * the diagram to inspect * @return true if the given ddiagram is allowing layouting mode, false * otherwise */ public static Predicate<DDiagramElement> allowsHideReveal(DDiagram diagram) { // default return value is true for non-Region element (for basic // DDiagram that are not handled // by any DiagramDescriptionProvider). Predicate<DDiagramElement> result = new Predicate<DDiagramElement>() { @Override public boolean apply(DDiagramElement dde) { if (dde instanceof DDiagramElementContainer) { DDiagramElementContainerExperimentalQuery query = new DDiagramElementContainerExperimentalQuery( (DDiagramElementContainer) dde); return !query.isRegion(); } return true; } }; // If an aird has been opened from the Package Explorer View, then // we return false as no diagram is associated to this editor if (diagram == null || diagram.getDescription() == null || !isEditable(diagram)) { return Predicates.alwaysFalse(); } // If diagram is not null, we search for a possible // DiagramDescriptionProvider handling this type of diagram for (final IDiagramTypeDescriptor diagramTypeDescriptor : DiagramTypeDescriptorRegistry.getInstance() .getAllDiagramTypeDescriptors()) { if (diagramTypeDescriptor.getDiagramDescriptionProvider() .handles(diagram.getDescription().eClass().getEPackage())) { // This DiagramDescriptionProvider may forbid hide/reveal // actions. final IDiagramDescriptionProvider provider = diagramTypeDescriptor.getDiagramDescriptionProvider(); result = new Predicate<DDiagramElement>() { @Override public boolean apply(DDiagramElement input) { return provider.allowsHideReveal(input); } }; break; } } return result; }
From source file:org.eclipse.sirius.diagram.ui.tools.internal.dialogs.DiagramElementsSelectionDialog.java
/** * Sets the predicate to use to detect which elements of the diagram are * selected, in the sense of the criterion to be edited. * /*from w ww. ja v a 2s. c o m*/ * @param isGrayedPredicate * the predicate to used to detect selected elements of the * diagram. */ public void setGrayedPredicate(Predicate<Object> isGrayedPredicate) { this.isGrayed = isGrayedPredicate != null ? isGrayedPredicate : Predicates.alwaysFalse(); }
From source file:com.eucalyptus.compute.common.internal.tags.FilterSupport.java
private static <T> Function<? super String, Predicate<? super T>> falseFilter() { return Functions.<Predicate<? super T>>constant(Predicates.alwaysFalse()); }
From source file:org.eclipse.sirius.diagram.ui.tools.internal.dialogs.DiagramElementsSelectionDialog.java
/** * Create an configure a selection dialog which allows the user to select a * sub-set of the elements in the diagram. * // w w w . ja v a 2s .c om * @param parent * the parent shell. * @param initialSelection * the set of elements to display as checked on dialog opening. */ protected void setupDialog(Shell parent, Set<Object> initialSelection) { dialog = new CustomTreeSelectionDialog(parent, new SelectionDialogLabelProvider(), contentProvider); dialog.setTitle(title); String msg = message; if (!Predicates.alwaysFalse().equals(isGrayed)) { StringBuilder sb = new StringBuilder(message); sb.append("\n"); //$NON-NLS-1$ sb.append(Messages.DiagramElementsSelectionDialog_grayedElementDialogMessage); msg = sb.toString(); } dialog.setMessage(msg); dialog.setInput(diagram); dialog.addFilter(new ModeFilter()); dialog.setInitialElementSelections(Lists.newArrayList(initialSelection)); }
From source file:org.obeonetwork.dsl.uml2.core.api.wizards.ModelElementsSelectionDialog.java
/** * Sets the predicate to use to detect which elements of the diagram are * selected, in the sense of the criterion to be edited. * * @param isGrayedPredicate/*from w w w . j a va2s. co m*/ * the predicate to used to detect selected elements of the * diagram. */ @SuppressWarnings("unchecked") public void setGrayedPredicate(Predicate<EObject> isGrayedPredicate) { isGrayed = Predicates.and( (Predicate<? super Object>) (isGrayedPredicate != null ? isGrayedPredicate : Predicates.alwaysFalse()), AddElementToDiagramServices.INSTANCE.isValidForDiagram(diagram, eObject)); }
From source file:org.obeonetwork.dsl.uml2.core.api.wizards.ModelElementsSelectionDialog.java
/** * Create an configure a selection dialog which allows the user to select a * sub-set of the elements in the diagram. * * @param parent//from w ww . j a v a 2s .c o m * the parent shell. * @param initialSelection * the set of elements to display as checked on dialog opening. */ protected void setupDialog(Shell parent, Set<Object> initialSelection) { dialog = new CustomTreeSelectionDialog(parent, new SelectionDialogLabelProvider(), contentProvider); dialog.setTitle(title); String msg = message; if (!Predicates.alwaysFalse().equals(isGrayed)) { final StringBuilder sb = new StringBuilder(message); sb.append("\n"); //$NON-NLS-1$ sb.append("The wizard will have no effect on grayed elements."); //$NON-NLS-1$ msg = sb.toString(); } dialog.setMessage(msg); final Collection<Element> roots = ElementServices.INSTANCE.getAllRootsInSession(eObject); dialog.setInput(roots); dialog.addFilter(new ModeFilter()); dialog.setInitialElementSelections(Lists.newArrayList(initialSelection)); }
From source file:org.obeonetwork.dsl.uml2.design.api.wizards.ModelElementsSelectionDialog.java
/** * Sets the predicate to use to detect which elements of the diagram are selected, in the sense of the * criterion to be edited./* ww w .j a v a 2s. c o m*/ * * @param isGrayedPredicate * the predicate to used to detect selected elements of the diagram. */ @SuppressWarnings("unchecked") public void setGrayedPredicate(Predicate<EObject> isGrayedPredicate) { isGrayed = Predicates.and((Predicate<? super Object>) (isGrayedPredicate != null ? isGrayedPredicate : Predicates.alwaysFalse()), isValidForDiagram()); }