private boolean hasInstancesFromCache( final NakedObjectSpecification specification) { final NakedObject collection = (NakedObject) cache.get(specification); final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection); if (facet == null) { return false; } return facet.size(collection) > 0; }
public static int size(final NakedObject collection) { final CollectionFacet facet = getCollectionFacetFromSpec(collection); return facet.size(collection); }
private boolean hasInstancesFromCache( final NakedObjectSpecification specification) { final NakedObject collection = (NakedObject) cache.get(specification); final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection); if (facet == null) { return false; } return facet.size(collection) > 0; }
public static int size(final NakedObject collection) { final CollectionFacet facet = getCollectionFacetFromSpec(collection); return facet.size(collection); }
@Override public boolean isEmpty(final NakedObject parentAdapter) { // REVIEW should we be able to determine if a collection is empty without loading it? final NakedObject collection = get(parentAdapter); final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection); return facet.size(collection) == 0; }
@Override public boolean isEmpty(final NakedObject parentAdapter) { // REVIEW should we be able to determine if a collection is empty without loading it? final NakedObject collection = get(parentAdapter); final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection); return facet.size(collection) == 0; }
private ObjectData[] convertToNakedCollection(final NakedObject instances) { final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(instances); final ObjectData[] data = new ObjectData[facet.size(instances)]; final Enumeration elements = facet.elements(instances); int i = 0; while (elements.hasMoreElements()) { final NakedObject element = (NakedObject) elements.nextElement(); data[i++] = encoderDecoder.encodeCompletePersistentGraph(element); } return data; }
private ObjectData[] convertToNakedCollection(final NakedObject instances) { final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(instances); final ObjectData[] data = new ObjectData[facet.size(instances)]; final Enumeration elements = facet.elements(instances); int i = 0; while (elements.hasMoreElements()) { final NakedObject element = (NakedObject) elements.nextElement(); data[i++] = encoderDecoder.encodeCompletePersistentGraph(element); } return data; }
public NakedObject[] elements() { final NakedObject collection = getCollection(); final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection); final NakedObject[] elementsArray = new NakedObject[facet.size(collection)]; int i = 0; final Enumeration elements = facet.elements(collection); while (elements.hasMoreElements()) { elementsArray[i++] = (NakedObject) elements.nextElement(); } return elementsArray; }
/** * A collection tree can only be displayed for a collection that has elements. */ public boolean canDisplay(final Content content, ViewRequirement requirement) { final NakedObject collection = content.getNaked(); if (collection == null) { return false; } else { final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection); return facet != null && facet.size(collection) > 0; } }
public static Object[] getCollectionAsObjectArray(final Object option, final NakedObjectSpecification spec, AdapterManager adapterManager) { final NakedObject collection = adapterManager.adapterFor(option); final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection); final Object[] optionArray = new Object[facet.size(collection)]; int j = 0; for(NakedObject adapter: facet.iterable(collection)) { optionArray[j++] = adapter.getObject(); } return optionArray; }
@Override public int canOpen(final Content content) { final NakedObject collection = ((CollectionContent) content).getCollection(); if (collection.getResolveState().isGhost()) { return UNKNOWN; } else { final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection); return facet.size(collection) > 0 ? CAN_OPEN : CANT_OPEN; } }
public static Object[] getCollectionAsObjectArray(final Object option, final NakedObjectSpecification spec, RuntimeContext runtimeContext) { final NakedObject collection = runtimeContext.adapterFor(option); final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection); final Object[] optionArray = new Object[facet.size(collection)]; int j = 0; for(NakedObject nextElement: facet.iterable(collection)) { optionArray[j++] = nextElement.getObject(); } return optionArray; }
public static Object[] getCollectionAsObjectArray(final Object option, final NakedObjectSpecification spec, RuntimeContext runtimeContext) { final NakedObject collection = runtimeContext.adapterFor(option); final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection); final Object[] optionArray = new Object[facet.size(collection)]; int j = 0; for(NakedObject nextElement: facet.iterable(collection)) { optionArray[j++] = nextElement.getObject(); } return optionArray; }
private Data createCollectionData(final NakedObject object) { final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(object); final Data[] collData = new Data[facet.size(object)]; final Iterator elements = facet.iterator(object); int i = 0; while (elements.hasNext()) { final NakedObject ref = (NakedObject) elements.next(); collData[i++] = new Data(ref.getOid(), ref.getResolveState().name(), ref.getSpecification().getFullName()); } //String elementType = facet.getTypeOfFacet().valueSpec().getFullName(); String elementType = object.getSpecification().getFullName(); return new CollectionData(object.getOid(), object.getResolveState(), elementType , collData); }
public void execute() { NakedObject result; result = action.execute(target, null); if (result != null) { final CollectionFacet facet = result.getSpecification().getFacet(CollectionFacet.class); if (facet != null) { if (facet.size(result) == 1) { result = facet.firstElement(result); } } view.objectActionResult(result, at); } view.getViewManager().disposeUnneededViews(); view.getFeedbackManager().showMessagesAndWarnings(); }
public void testRecreateEmptyCollection() { final TestProxyOid collectionOid = new TestProxyOid(123); final ReferenceData[] elementData = null; final CollectionData data = new DummyCollectionData(collectionOid, Vector.class.getName(), TestPojo.class.getName(), elementData, new TestProxyVersion()); final NakedObject naked = deserializer.restore(data); final Vector restoredCollection = (Vector) naked.getObject(); assertEquals(0, restoredCollection.size()); final CollectionFacet facet = naked.getSpecification().getFacet(CollectionFacet.class); assertEquals(0, facet.size(naked)); }
public void execute() { ActionContent actionContent = ((ActionContent) view.getContent()); NakedObject result = actionContent.execute(); LOG.debug("action invoked with result " + result); if (result != null) { Location dialogLocation = view.getAbsoluteLocation(); move(dialogLocation); CollectionFacet facet = result.getSpecification().getFacet(CollectionFacet.class); if (facet != null) { if (facet.size(result) == 1) { result = facet.firstElement(result); } } View newView = workspace.addWindowFor(result, dialogLocation); view.getViewManager().setKeyboardFocus(newView); } view.getViewManager().disposeUnneededViews(); view.getFeedbackManager().showMessagesAndWarnings(); }
private void setSelectedNode(final Content content) { final NakedObject object = content.getNaked(); final NakedObjectSpecification specification = object.getSpecification(); final CollectionFacet facet = specification.getFacet(CollectionFacet.class); ViewRequirement requirement = new ViewRequirement(content, ViewRequirement.OPEN); if (facet != null && facet.size(object) > 0) { if (mainViewTableSpec.canDisplay(content, requirement)) { showInRightPane(mainViewTableSpec.createView(content, null)); } else if (mainViewListSpec.canDisplay(content, requirement)) { showInRightPane(mainViewListSpec.createView(content, null)); } } else if (specification.isObject()) { if (object != null && mainViewFormSpec.canDisplay(content, requirement)) { showInRightPane(mainViewFormSpec.createView(content, null)); } } }
@Override public void draw(final Canvas canvas) { icon.draw(canvas, 0, getBaseline()); final NakedObject collection = getContent().getNaked(); final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection); if (collection == null || facet.size(collection) == 0) { canvas.drawText("empty", left, getBaseline(), Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY2), Toolkit.getText(ColorsAndFonts.TEXT_NORMAL)); } else { final int x = icon.getSize().getWidth() / 2; final int x2 = x + 4; final int y = icon.getSize().getHeight() + 1; final int y2 = getSize().getHeight() - 5; canvas.drawLine(x, y, x, y2, Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY2)); canvas.drawLine(x, y2, x2, y2, Toolkit.getColor(ColorsAndFonts.COLOR_SECONDARY2)); } super.draw(canvas); }