Package org.eclipse.gef.requests

Examples of org.eclipse.gef.requests.CreationFactory


        }
        return controls;
    }

    private PaletteEntry createEntry(ElementTypeDefinition elementType) {
        CreationFactory factory = new GEFElementCreationFactory(elementType.getName(), editor.getDefinition());
        IConfigurationElement info = elementType.getEntryConfigElement();
        String id = info.getAttribute("id");
        String label = info.getAttribute("label");
        String type = info.getAttribute("type");
        String imageName = info.getAttribute("icon");
View Full Code Here


    public PaletteEntry createConnectionEntry() {
        final ElementConnectionFactory normalConnectionFactory = new ConnectionWrapperFactory();
        PaletteEntry tool = new ConnectionCreationToolEntry(
            "Connection Creation",
            "Creating connections",
            new CreationFactory() {
                public Object getNewObject() {
                    return normalConnectionFactory.createElementConnection();
                }
                public Object getObjectType() {
                    return ConnectionWrapper.class;
View Full Code Here

    scoreDef.setStaffGrp(staffGrp);
    return scoreDef;
  }

  public static CreationFactory getOneSystemFactory() {
    return new CreationFactory() {
      @Override
      public Object getNewObject() {
        return createModel();
      }
View Full Code Here

        // Add a marquee tool to the group
        toolbar.add(new MarqueeToolEntry());

        // Add (solid-line) connection tool
        tool = new ConnectionCreationToolEntry("Solid connection", "Create a solid-line connection",
                new CreationFactory() {
                    public Object getNewObject() {
                        return null;
                    }

                    // see ShapeEditPart#createEditPolicies()
                    // this is abused to transmit the desired line style
                    public Object getObjectType() {
                        return ShapeConstants.SOLID_CONNECTION;
                    }
                },
                ImageDescriptor.createFromFile(ShapesPlugin.class, "icons/connection_s16.gif"),
                ImageDescriptor.createFromFile(ShapesPlugin.class, "icons/connection_s24.gif"));

        toolbar.add(tool);

        // Add (dashed-line) connection tool
        tool = new ConnectionCreationToolEntry("Dashed connection", "Create a dashed-line connection",
                new CreationFactory() {
                    public Object getNewObject() {
                        return null;
                    }

                    // see ShapeEditPart#createEditPolicies()
View Full Code Here

    public PaletteEntry createConnectionEntry() {
        final ElementConnectionFactory normalConnectionFactory = new ConnectionWrapperFactory();
        PaletteEntry tool = new ConnectionCreationToolEntry(
            "Sequence Flow",
            "Creating connections",
            new CreationFactory() {
                public Object getNewObject() {
                    return normalConnectionFactory.createElementConnection();
                }
                public Object getObjectType() {
                    return ConnectionWrapper.class;
View Full Code Here

    public PaletteEntry createConnectionEntry() {
        final ElementConnectionFactory normalConnectionFactory = new ConnectionWrapperFactory();
        PaletteEntry tool = new ConnectionCreationToolEntry(
            "Connection Creation",
            "Creating connections",
            new CreationFactory() {
                public Object getNewObject() {
                    return normalConnectionFactory.createElementConnection();
                }
                public Object getObjectType() {
                    return ConnectionWrapper.class;
View Full Code Here

    public PaletteEntry createConnectionEntry() {
        final ElementConnectionFactory normalConnectionFactory = new ConnectionWrapperFactory();
        PaletteEntry tool = new ConnectionCreationToolEntry(
            "Sequence Flow",
            "Creating connections",
            new CreationFactory() {
                public Object getNewObject() {
                    return normalConnectionFactory.createElementConnection();
                }
                public Object getObjectType() {
                    return ConnectionWrapper.class;
View Full Code Here

      ImageData imageData = connectionPalette.getSmallIcon();
            ImageDescriptor smallImage = SwtUtil.toImageDescriptor(imageData);
      ImageData imageData2 = connectionPalette.getLargeIcon();
            ImageDescriptor largeImage = SwtUtil.toImageDescriptor(imageData2);

            CreationFactory factory = new ConnectionCreationFactory(connDef);
      String tpLabel = connDef.getToolPaletteLabel().content();
      if (tpLabel != null)
      {
        tpLabel = IDiagramConnectionDef.PROP_TOOL_PALETTE_LABEL.getLocalizationService().text(
                tpLabel, CapitalizationType.TITLE_STYLE, false);
      }
      String tpDesc = connDef.getToolPaletteDescription().content();
      if (tpDesc != null)
      {
        tpDesc = IDiagramConnectionDef.PROP_TOOL_PALETTE_DESCRIPTION.getLocalizationService().text(
                tpDesc, CapitalizationType.TITLE_STYLE, false);
      }
      if (tpLabel != null) {
          ToolEntry tool = new SapphireConnectionCreationToolEntry(tpLabel, tpDesc, factory, smallImage, largeImage);
         
          DiagramPaletteDrawer drawer = getDiagramPaletteDrawer(drawers, connDef.getToolPaletteCompartment().content());
          List<ToolEntry> list = entries.get(drawer.getId());
          if (list == null) {
            list = new ArrayList<ToolEntry>();
            entries.put(drawer.getId(), list);
          }
          list.add(tool);
      }
      else
      {
        // TODO which case is this??
      }
    }
   
        for (DiagramNodeTemplate nodeTemplate : nodeTemplates)
        {
          IDiagramNodeDef nodeDef = nodeTemplate.definition();

            List<ImageData> imageDatas = nodeTemplate.getToolPaletteImages();
            List<ImageDescriptor> imageDescriptors = new ArrayList<ImageDescriptor>();
            for (ImageData imageData : imageDatas)
            {
              imageDescriptors.add(SwtUtil.toImageDescriptor(imageData));
            }
            ImageDescriptor smallImage = null;
            ImageDescriptor largeImage = null;
            if (imageDescriptors.size() == 1)
            {
              smallImage = largeImage = imageDescriptors.get(0);
            }
            else if (imageDescriptors.size() == 2)
            {
              org.eclipse.swt.graphics.ImageData id1 = imageDescriptors.get(0).getImageData();
              org.eclipse.swt.graphics.ImageData id2 = imageDescriptors.get(1).getImageData();
              if (id1.width > id2.width || id1.height > id2.height)
              {
                smallImage = imageDescriptors.get(1);
                largeImage = imageDescriptors.get(0);
              }
              else
              {
                smallImage = imageDescriptors.get(0);
                largeImage = imageDescriptors.get(1);               
              }
            }
            CreationFactory factory = new NodeCreationFactory(nodeTemplate);

      String tpLabel = nodeDef.getToolPaletteLabel().content();
      if (tpLabel != null)
      {
        tpLabel = IDiagramNodeDef.PROP_TOOL_PALETTE_LABEL.getLocalizationService().text(
View Full Code Here

          return (CreationFactory) template;
        } else if (template instanceof Class) {
          return new SimpleFactory((Class) template);
        } else {
          Activator.getLogger().debug("============= Template: " + template + " is not a CreationFactory or Class! " + Objects.typeName(template));
          return new CreationFactory() {

            @Override
            public Object getNewObject() {
              return template;
            }
View Full Code Here

    Object obj = selection.get(0);
    if (obj instanceof GraphicalEditPart) {
      GraphicalEditPart gep = (GraphicalEditPart)obj;
      Object template = getClipboardContents();
      if (template != null) {
        CreationFactory factory = getFactory(template);
        if (factory != null) {
          CreateRequest request = new CreateRequest();
          request.setFactory(factory);
          request.setLocation(getPasteLocation(gep));
          result = gep.getCommand(request);
View Full Code Here

TOP

Related Classes of org.eclipse.gef.requests.CreationFactory

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.