Examples of Gallery


Examples of org.apache.cayenne.testdo.testmap.Gallery

    public void testReplace() throws Exception {

        Painting p1 = context.newObject(Painting.class);
        p1.setPaintingTitle("xa");

        Gallery g1 = context.newObject(Gallery.class);
        g1.setGalleryName("yTW");

        p1.setToGallery(g1);

        context.commitChanges();
        ObjectContext context2 = runtime.newContext();

        // test database data
        Painting p2 = (Painting) Cayenne.objectForQuery(context2, new SelectQuery(
                Painting.class));
        Gallery g21 = p2.getToGallery();
        assertNotNull(g21);
        assertEquals("yTW", g21.getGalleryName());
        assertEquals(1, g21.getPaintingArray().size());
        assertSame(p2, g21.getPaintingArray().get(0));

        Gallery g22 = context2.newObject(Gallery.class);
        g22.setGalleryName("rE");
        p2.setToGallery(g22);

        // test before save
        assertEquals(0, g21.getPaintingArray().size());
        assertEquals(1, g22.getPaintingArray().size());
        assertSame(p2, g22.getPaintingArray().get(0));

        // do save II
        context2.commitChanges();

        ObjectContext context3 = runtime.newContext();

        Painting p3 = (Painting) Cayenne.objectForQuery(context3, new SelectQuery(
                Painting.class));
        Gallery g3 = p3.getToGallery();
        assertNotNull(g3);
        assertEquals("rE", g3.getGalleryName());
        assertEquals(1, g3.getPaintingArray().size());
        assertSame(p3, g3.getPaintingArray().get(0));
    }
View Full Code Here

Examples of org.apache.cayenne.testdo.testmap.Gallery

        // test database data
        Painting p2 = (Painting) Cayenne.objectForQuery(context2, new SelectQuery(
                Painting.class));
        assertNull(p2.getToGallery());

        Gallery g2 = context2.newObject(Gallery.class);
        g2.setGalleryName("rE");

        p2.setToGallery(g2);

        // test before save
        assertEquals(1, g2.getPaintingArray().size());
        assertSame(p2, g2.getPaintingArray().get(0));

        // do save II
        context2.commitChanges();
        ObjectContext context3 = runtime.newContext();

        Painting p3 = (Painting) Cayenne.objectForQuery(context3, new SelectQuery(
                Painting.class));
        Gallery g3 = p3.getToGallery();
        assertNotNull(g3);
        assertEquals("rE", g3.getGalleryName());
        assertEquals(1, g3.getPaintingArray().size());
        assertSame(p3, g3.getPaintingArray().get(0));
    }
View Full Code Here

Examples of org.apache.cayenne.testdo.testmap.Gallery

        BeanValidationFailure failure = (BeanValidationFailure) failures.get(0);
        assertEquals(Exhibit.TO_GALLERY_PROPERTY, failure.getProperty());

        // fix the problem and see if it goes away
        Gallery gallery = context.newObject(Gallery.class);
        exhibit.setToGallery(gallery);
        result = new ValidationResult();
        exhibit.validateForSave(result);
        assertFalse("No failures expected: " + result, result.hasFailures());
    }
View Full Code Here

Examples of org.apache.cayenne.testdo.testmap.Gallery

        Exhibit anExhibit = (Exhibit) context.newObject("Exhibit");
        anExhibit.setClosingDate(new java.sql.Timestamp(System.currentTimeMillis()));
        anExhibit.setOpeningDate(new java.sql.Timestamp(System.currentTimeMillis()));

        // Needs a gallery... required for data integrity
        Gallery gallery = (Gallery) context.newObject("Gallery");
        gallery.setGalleryName("A Name");

        anExhibit.setToGallery(gallery);

        ArtistExhibit artistExhibit = (ArtistExhibit) context.newObject("ArtistExhibit");
View Full Code Here

Examples of org.apache.cayenne.testdo.testmap.Gallery

        context.commitChanges();
    }

    public void testDenyToMany() {
        // Gallery paintingArray
        Gallery gallery = (Gallery) context.newObject("Gallery");
        gallery.setGalleryName("A Name");
        Painting painting = (Painting) context.newObject("Painting");
        painting.setPaintingTitle("A Title");
        gallery.addToPaintingArray(painting);
        context.commitChanges();

        try {
            context.deleteObjects(gallery);
            fail("Should have thrown an exception");
View Full Code Here

Examples of org.apache.cayenne.testdo.testmap.Gallery

        p.setPaintingTitle("P1");

        Artist a = context.newObject(Artist.class);
        a.setArtistName("A1");

        Gallery g = context.newObject(Gallery.class);
        g.setGalleryName("G1");

        p.setToArtist(a);
        p.setToGallery(g);
        context.commitChanges();
View Full Code Here

Examples of org.apache.cayenne.tutorial.persistent.Gallery

        Artist picasso = context.newObject(Artist.class);
        picasso.setName("Pablo Picasso");
        picasso.setDateOfBirthString("18811025");

        // Creating other objects
        Gallery metropolitan = context.newObject(Gallery.class);
        metropolitan.setName("Metropolitan Museum of Art");

        Painting girl = context.newObject(Painting.class);
        girl.setName("Girl Reading at a Table");

        Painting stein = context.newObject(Painting.class);
View Full Code Here

Examples of org.apache.cayenne.tutorial.persistent.Gallery

    Artist picasso = context.newObject(Artist.class);
    picasso.setName("Pablo Picasso");
    picasso.setDateOfBirthString("18811025");

    // Creating other objects
    Gallery metropolitan = context.newObject(Gallery.class);
    metropolitan.setName("Metropolitan Museum of Art");

    Painting girl = context.newObject(Painting.class);
    girl.setName("Girl Reading at a Table");

    Painting stein = context.newObject(Painting.class);
View Full Code Here

Examples of org.apache.cayenne.tutorial.persistent.Gallery

    Artist picasso = context.newObject(Artist.class);
    picasso.setName("Pablo Picasso");
    picasso.setDateOfBirthString("18811025");

    // Creating other objects
    Gallery metropolitan = context.newObject(Gallery.class);
    metropolitan.setName("Metropolitan Museum of Art");

    Painting girl = context.newObject(Painting.class);
    girl.setName("Girl Reading at a Table");

    Painting stein = context.newObject(Painting.class);
View Full Code Here

Examples of org.eclipse.nebula.widgets.gallery.Gallery

  private void configureTab(final IImageStore store, CTabFolder fld) {
    final CTabItem item = new CTabItem(fld, SWT.NONE);
    item.setText(store.getName());
    final Composite cm = new Composite(fld, SWT.NONE);
    cm.setLayout(new FillLayout());
    final Gallery gallery = new Gallery(cm, SWT.VIRTUAL | SWT.V_SCROLL | SWT.BORDER);
    item.setControl(cm);

    gallery.setVertical(false);

    final DefaultGalleryGroupRenderer gr = new DefaultGalleryGroupRenderer();
    gallery.setGroupRenderer(gr);
    gallery.setItemRenderer(new DefaultGalleryItemRenderer() {

      protected Image getImage(GalleryItem item) {
        final IImageEntry entry = (IImageEntry) item.getData();
        try {
          return ImageCache.getImage(entry);
        } catch (final Exception e) {
          e.printStackTrace();
        }
        return null;
      }

    });
    final DragSource dragSource = new DragSource(gallery, DND.DROP_COPY);
    dragSource.setTransfer(new Transfer[] { FileTransfer.getInstance() });
    dragSource.addDragListener(new DragSourceListener() {

      private String[] dataX;

      public void dragFinished(DragSourceEvent event) {
        this.dataX = null;
      }

      public void dragSetData(DragSourceEvent event) {

        event.data = this.dataX;

      }

      public void dragStart(DragSourceEvent event) {
        event.detail = DND.DROP_COPY;
        final GalleryItem item2 = gallery.getItem(new Point(event.x, event.y));
        if (item2 != null) {
          final Object data = item2.getData();
          if (data instanceof IImageEntry) {
            final IImageEntry e = (IImageEntry) data;
            final String file = e.getFile();
            this.dataX = new String[] { file };
            try {
              event.image = e.getImage();
            } catch (final IOException e1) {
              e1.printStackTrace();
            }
          }
        }
      }

    });

    final IImageEntryCallback cb = new IImageEntryCallback() {

      public void imageLoaded() {
        gallery.redraw();
      }

    };
    ImageCache.addCallback(cb);
    gallery.addDisposeListener(new DisposeListener() {

      public void widgetDisposed(DisposeEvent e) {
        ImageCache.removeCallback(cb);
      }

    });
    item.setData("g", gr);
    gr.setItemHeight(56);
    gr.setItemWidth(72);
    this.fillContextMenu(gallery, gr);

    this.tooltip = new ImagesViewTooltip(gallery, gallery);

    final ArrayList<Object> images = new ArrayList<Object>(store.getContents());
    this.prepareImages(images);
    gallery.addListener(SWT.SetData, new Listener() {

      public void handleEvent(Event event) {
        final GalleryItem item = (GalleryItem) event.item;
        final GalleryItem parentItem = item.getParentItem();
        if (parentItem == null) {
          final int index = gallery.indexOf(item);
          final ItemGroup itemGroup = (ItemGroup) images.get(index);
          item.setText(itemGroup.getName());
          item.setData(itemGroup);
          item.setItemCount(itemGroup.getChildCount());
        } else {
          final int indexOf = parentItem.indexOf(item);
          final ItemGroup ga = (ItemGroup) parentItem.getData();
          item.setItemCount(0);
          final IImageEntry image = ga.getImage(indexOf);
          try {
            item.setImage(image.getImage());
          } catch (IOException e) {
            e.printStackTrace();
          }
          item.setText(image.getName());
          item.setData(image);
        }
      }
    });
    final HashSet<Object> expanded = new HashSet<Object>();
    item.setData("ga", new Collapser() {

      void collapse() {
        for (int a = 0; a < gallery.getItemCount(); a++) {
          final GalleryItem item2 = gallery.getItem(a);
          item2.setExpanded(false);
        }
        expanded.clear();
      }

      void expand() {
        for (int a = 0; a < gallery.getItemCount(); a++) {
          final GalleryItem item2 = gallery.getItem(a);
          item2.setExpanded(true);
          expanded.add(item2.getData());
        }
      }

    });
    gallery.addTreeListener(new TreeListener() {

      public void treeCollapsed(TreeEvent e) {
        expanded.remove(e.data);

      }

      public void treeExpanded(TreeEvent e) {
        expanded.add(e.data);
      }

    });
    final IStoreImageListener storeImageListener = new IStoreImageListener() {

      public void platformChanged() {
        final ArrayList<?> contents = new ArrayList<Object>(store.getContents());
        Display.getDefault().asyncExec(new Runnable() {

          public void run() {
            ImagesView.this.refresh(gallery, images, expanded, contents);
          }

        });

      }

    };
    item.setData("r", new Refresher() {

      public void refresh() {
        final ArrayList<?> contents = new ArrayList<Object>(store.getContents());
        ImagesView.this.refresh(gallery, images, expanded, new ArrayList<Object>(contents));
      }

    });
    store.addListener(storeImageListener);
    gallery.addDisposeListener(new DisposeListener() {

      public void widgetDisposed(DisposeEvent e) {
        store.removeListener(storeImageListener);
      }

    });
    gallery.setItemCount(images.size());
    gallery.setVertical(true);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.