Package com.google.gdt.eclipse.designer.model.widgets

Examples of com.google.gdt.eclipse.designer.model.widgets.ImageBundlePrototypeDescription


            "  }",
            "}");
    frame.refresh();
    assertNoErrors(frame);
    // prepare prototype
    ImageBundlePrototypeDescription prototype;
    {
      ImageBundleInfo bundle = ImageBundleContainerInfo.getBundles(frame).get(0);
      List<ImageBundlePrototypeDescription> prototypes = bundle.getPrototypes();
      prototype = prototypes.get(0);
    }
    // create new Image
    ImageInfo newImage = prototype.createImageWidget();
    newImage.putArbitraryValue(JavaInfo.FLAG_MANUAL_COMPONENT, Boolean.TRUE);
    // check live properties
    {
      assertNotNull(newImage.getImage());
      assertThat(newImage.getPreferredSize().width).isEqualTo(10);
View Full Code Here


            "    RootPanel rootPanel = RootPanel.get();",
            "  }",
            "}");
    assertNoErrors(frame);
    // prepare prototype
    ImageBundlePrototypeDescription prototype;
    {
      ImageBundleInfo bundle = ImageBundleContainerInfo.getBundles(frame).get(0);
      List<ImageBundlePrototypeDescription> prototypes = bundle.getPrototypes();
      prototype = prototypes.get(0);
    }
    // prepare category/entries
    CategoryInfo category = new CategoryInfo();
    category.setId("com.google.gdt.eclipse.designer.ImageBundle");
    List<EntryInfo> entries = Lists.newArrayList();
    // send palette broadcast
    PaletteEventListener listener = frame.getBroadcast(PaletteEventListener.class);
    listener.entries(category, entries);
    // we should have exactly one entry
    ToolEntryInfo toolEntry;
    {
      assertEquals(1, entries.size());
      toolEntry = (ToolEntryInfo) entries.get(0);
    }
    // check Entry presentation
    {
      assertEquals(ObjectUtils.identityToString(prototype), toolEntry.getId());
      assertThat(toolEntry.getName()).isEqualTo("first");
      assertThat(toolEntry.getDescription()).contains("first()");
      assertSame(prototype.getIcon(), toolEntry.getIcon());
    }
    // use this entry to create new Image widget
    WidgetInfo newImage;
    {
      toolEntry.initialize(null, frame);
View Full Code Here

    @Override
    public void setValue(Object value) throws Exception {
      if (value == Property.UNKNOWN_VALUE) {
        m_property.setValue(Property.UNKNOWN_VALUE);
      } else if (value instanceof ImageBundlePrototypeDescription) {
        ImageBundlePrototypeDescription prototype = (ImageBundlePrototypeDescription) value;
        m_property.setExpression(prototype.getImageSource(), Property.UNKNOWN_VALUE);
      }
    }
View Full Code Here

  // Presentation
  //
  ////////////////////////////////////////////////////////////////////////////
  @Override
  protected String getText(Property property) throws Exception {
    ImageBundlePrototypeDescription prototype =
        (ImageBundlePrototypeDescription) property.getValue();
    if (prototype != null) {
      return prototype.getMethod().getName()
          + "() from "
          + prototype.getBundle().getDescription().getComponentClass().getName();
    }
    return null;
  }
View Full Code Here

        public Image getImage(Object element) {
          if (element instanceof ImageBundleInfo) {
            return ObjectsLabelProvider.INSTANCE.getImage(element);
          }
          if (element instanceof ImageBundlePrototypeDescription) {
            ImageBundlePrototypeDescription prototype = (ImageBundlePrototypeDescription) element;
            return prototype.getIcon();
          }
          return null;
        }

        @Override
        public String getText(Object element) {
          if (element instanceof ImageBundleInfo) {
            return ObjectsLabelProvider.INSTANCE.getText(element);
          }
          if (element instanceof ImageBundlePrototypeDescription) {
            ImageBundlePrototypeDescription prototype = (ImageBundlePrototypeDescription) element;
            return prototype.getMethod().getName() + "()";
          }
          return null;
        }
      }, new ITreeContentProvider() {
        public Object[] getElements(Object inputElement) {
          return ImageBundleContainerInfo.getBundles((JavaInfo) inputElement).toArray();
        }

        public Object[] getChildren(Object parentElement) {
          if (parentElement instanceof ImageBundleInfo) {
            return ((ImageBundleInfo) parentElement).getPrototypes().toArray();
          }
          return ArrayUtils.EMPTY_OBJECT_ARRAY;
        }

        public Object getParent(Object element) {
          if (element instanceof ImageBundlePrototypeDescription) {
            return ((ImageBundlePrototypeDescription) element).getBundle();
          }
          return null;
        }

        public boolean hasChildren(Object element) {
          return getChildren(element).length != 0;
        }

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
      }) {
        @Override
        public void create() {
          super.create();
          getTreeViewer().expandAll();
        }

        @Override
        protected Control createDialogArea(Composite parent) {
          return super.createDialogArea(parent);
        }
      };
      // validator
      selectionDialog.setValidator(new ISelectionStatusValidator() {
        public IStatus validate(Object[] selection) {
          if (selection.length == 1 && selection[0] instanceof ImageBundlePrototypeDescription) {
            return StatusUtils.OK_STATUS;
          } else {
            return StatusUtils.ERROR_STATUS;
          }
        }
      });
      // configure
      selectionDialog.setAllowMultiple(false);
      selectionDialog.setTitle(property.getTitle());
      selectionDialog.setMessage("Select prototype:");
      // set input
      selectionDialog.setInput(m_rootJavaInfo);
      // set initial selection
      selectionDialog.setInitialSelection(property.getValue());
    }
    // open dialog
    if (selectionDialog.open() == Window.OK) {
      ImageBundlePrototypeDescription prototype =
          (ImageBundlePrototypeDescription) selectionDialog.getFirstResult();
      property.setValue(prototype);
    }
  }
View Full Code Here

      assertTrue(bundleProperty.isModified());
      assertEquals("first() from test.client.MyImageBundle", getPropertyText(bundleProperty));
      // set second()
      {
        ImageBundleInfo bundle = ImageBundleContainerInfo.getBundles(frame).get(0);
        ImageBundlePrototypeDescription prototype = bundle.getPrototypes().get(1);
        assertEquals("second", prototype.getMethod().getName());
        bundleProperty.setValue(prototype);
      }
      assertEditor(
          "public class Test implements EntryPoint {",
          "  private static final MyImageBundle m_myBundle = GWT.create(MyImageBundle.class);",
View Full Code Here

TOP

Related Classes of com.google.gdt.eclipse.designer.model.widgets.ImageBundlePrototypeDescription

Copyright © 2018 www.massapicom. 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.