Java 类org.eclipse.gef.palette.CombinedTemplateCreationEntry 实例源码

项目:Hydrograph    文件:PaletteContainerListener.java   
@Override
public void mouseHover(MouseEvent e) {
    final java.awt.Point mouseLocation1 = MouseInfo.getPointerInfo().getLocation();
    EditPart paletteInternalController = viewer.findObjectAt(new Point(
            e.x, e.y));

    if(paletteInternalController.getModel() instanceof CombinedTemplateCreationEntry){

        setGenericComponent(paletteInternalController);

        // Hide tooltip if already showing
        hidePaletteToolTip();

        showToolTipWithDelay(mouseLocation1);
    }
}
项目:Hydrograph    文件:PaletteContainerListener.java   
/**
 * 
 * set genericComponent to selected/hovered component in palette
 * 
 * @param paletteInternalController
 * @return
 */
private CreateRequest setGenericComponent(EditPart paletteInternalController) {
    CombinedTemplateCreationEntry addedPaletteTool = (CombinedTemplateCreationEntry) paletteInternalController
            .getModel();

        CreateRequest componentRequest = new CreateRequest();
        componentRequest.setFactory(new SimpleFactory((Class) addedPaletteTool
                .getTemplate()));

    genericComponent = (Component) componentRequest
            .getNewObject();

    logger.debug("genericComponent - " + genericComponent.toString());

    return componentRequest;
}
项目:Hydrograph    文件:CustomPaletteViewer.java   
private boolean checkSearchedComponentFoundInPalette(final ELTGraphicalEditor editor,
        final Map<String, PaletteDrawer> categoryPaletteContainer, final List<Component> componentsConfig,
        List<Component> matchingComponents, String searchedString) {
    boolean matchFound = false;
    for (Component componentConfig : componentsConfig) {
        String componentName = componentConfig.getNameInPalette().toUpperCase();
        if (Constants.UNKNOWN_COMPONENT.equalsIgnoreCase(componentConfig.getName()))
            continue;
        if (componentName.contains(searchedString.trim())) {
            CombinedTemplateCreationEntry component = getComponentToAddInContainer(editor, componentConfig);
            categoryPaletteContainer.get(componentConfig.getCategory().name()).add(component);
            matchingComponents.add(componentConfig);
            matchFound = true;
            if (label != null) {
                label.dispose();

            }
        }
    }
    return matchFound;
}
项目:bdf2    文件:GraphicalPalette.java   
private CreationToolEntry createToolEntry(final Class<?> nodeClass,final String name,String desc,final int width,final int height){
    SimpleFactory nodeFactory=new SimpleFactory(nodeClass){
        @Override
        public Object getNewObject() {
            AbstractNodeElement node=instanceNode(nodeClass,name,width,height);
            return node;
        }
    };
    String nodeName=instanceNode(nodeClass,name,width,height).nodeName();
    NodeImageConfig config=Activator.getPreference().getNodeImageConfigByName(nodeName);
    if(config==null){
        throw new RuntimeException("当前没有为名为"+nodeName+"的节点预定义配置信息!");
    }
    ImageDescriptor descriptor=ImageDescriptor.createFromImage(config.getSmallImage());
    return new CombinedTemplateCreationEntry(name,desc,nodeFactory,descriptor,descriptor);
}
项目:gef-gwt    文件:CopyTemplateAction.java   
/**
 * Sets the selected EditPart and refreshes the enabled state of this
 * action.
 * 
 * @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
 */
public void selectionChanged(SelectionChangedEvent event) {
    ISelection s = event.getSelection();
    if (!(s instanceof IStructuredSelection))
        return;
    IStructuredSelection selection = (IStructuredSelection) s;
    template = null;
    if (selection != null && selection.size() == 1) {
        Object obj = selection.getFirstElement();
        if (obj instanceof EditPart) {
            Object model = ((EditPart) obj).getModel();
            if (model instanceof CombinedTemplateCreationEntry)
                template = ((CombinedTemplateCreationEntry) model)
                        .getTemplate();
            else if (model instanceof PaletteTemplateEntry)
                template = ((PaletteTemplateEntry) model).getTemplate();
        }
    }
    refresh();
}
项目:snaker-designer    文件:PaletteFactory.java   
private CombinedTemplateCreationEntry createCombinedEntry(
        Component compponent) {
    Class<?> clazz = null;
    try {
        clazz = Class.forName(compponent.getClazz());
    } catch (Exception e) {
        clazz = Simple.class;
    }
    if (clazz == null) return null;

    CombinedTemplateCreationEntry combined = new CombinedTemplateCreationEntry(
            compponent.getDisplayName(), compponent.getDescript(), clazz,
            new ModelCreationFactory(compponent, clazz),
            ImageDescriptor.createFromFile(TaskFigure.class,
                    compponent.getIconSmall()),
            ImageDescriptor.createFromFile(TaskFigure.class,
                    compponent.getIconLarge()));
    return combined;
}
项目:birt    文件:MasterPagePaletteFactory.java   
private static CombinedTemplateCreationEntry createAutoText( String label,
        String shortDesc, Object template )
{
    AbstractToolHandleExtends preHandle = BasePaletteFactory.getAbstractToolHandleExtendsFromPaletteName(template);

    ImageDescriptor icon = ReportPlatformUIImages.getImageDescriptor( IReportGraphicConstants.ICON_AUTOTEXT );
    ImageDescriptor largeIcon = ReportPlatformUIImages.getImageDescriptor( IReportGraphicConstants.ICON_AUTOTEXT_LARGE );

    CombinedTemplateCreationEntry entry = new ReportCombinedTemplateCreationEntry( label,
            shortDesc,
            template,
            new ReportElementFactory( template ),
            icon,
            largeIcon,
            preHandle );
    return entry;
}
项目:birt    文件:DesignerPaletteFactory.java   
private static PaletteContainer createQuickTools( )
{

    PaletteCategory quickTools = new PaletteCategory( IPreferenceConstants.PALETTE_CONTENT,
            Messages.getString( "DesignerPaletteFactory.quicktool.title" ), //$NON-NLS-1$
            ReportPlatformUIImages.getImageDescriptor( ISharedImages.IMG_OBJ_FOLDER ) );
    ReportElementFactory factory = new ReportElementFactory( AGG_TEMPLATE );
    CombinedTemplateCreationEntry combined = new QuickToolsCombinedTemplateCreationEntry( Messages.getString( "DesignerPaletteFactory.quicktool.agg.title" ), //$NON-NLS-1$
            Messages.getString( "DesignerPaletteFactory.quicktool.agg.toolTip" ), //$NON-NLS-1$
            AGG_TEMPLATE, 
            factory,
            ReportPlatformUIImages.getImageDescriptor( IReportGraphicConstants.ICON_ELEMENT_AGGREGATION ),
            ReportPlatformUIImages.getImageDescriptor( IReportGraphicConstants.ICON_ELEMENT_AGGREGATION_LARGE ) ) ;
    quickTools.add( combined );

    factory = new ReportElementFactory( TIMEPERIOD_TEMPLATE );
    combined = new QuickToolsCombinedTemplateCreationEntry( Messages.getString( "DesignerPaletteFactory.quicktool.timeperiod.title" ), //$NON-NLS-1$
            Messages.getString( "DesignerPaletteFactory.quicktool.timeperiod.toolTip" ), //$NON-NLS-1$
            TIMEPERIOD_TEMPLATE, 
            factory,
            ReportPlatformUIImages.getImageDescriptor( IReportGraphicConstants.ICON_ELEMENT_TIMEPERIOD ),
            ReportPlatformUIImages.getImageDescriptor( IReportGraphicConstants.ICON_ELEMENT_TIMEPERIOD_LARGE ) ) ;
    quickTools.add( combined );
    return quickTools;
}
项目:seg.jUCMNav    文件:ProgressTests.java   
/**
 * Try to find if the palette can create an element of a certain class. Because of current visibility restrictions, we can't actually look for factories or
 * try to create such an element. For now, we have to simply look for the template class used by the CombinedTemplateCreationEntry. Ideally, we should
 * search for the appropriate model creation factory.
 * 
 * @param c
 *            The template to find in one of UcmPaletteRoot's CombinedTemplateCreationEntry
 * @return the CreationTool that was found in the palette or null if none could be found
 */
private CreationTool getToolEntryForClass(Class c) {

    Stack s = new Stack();
    List l = getPaletteRoot().getChildren();
    for (int i = 0; i < l.size(); i++)
        s.push(l.get(i));

    while (s.size() > 0) {
        Object o = s.pop();
        if (o instanceof PaletteContainer) {
            l = ((PaletteContainer) o).getChildren();
            for (int i = 0; i < l.size(); i++)
                s.push(l.get(i));
        } else if (o instanceof CombinedTemplateCreationEntry) {
            Object template = ((CombinedTemplateCreationEntry) o).getTemplate();

            if (template == c) {
                return (CreationTool) ((CombinedTemplateCreationEntry) o).createTool();
            }
        }
    }
    return null;
}
项目:Hydrograph    文件:HydrographComponentProposalProvider.java   
@Override
public IContentProposal[] getProposals(String contents, int position) {

    proposalList.clear();
    List<PaletteContainer> paletteEntry = paletteRoot.getChildren();
    for (PaletteContainer paletteContainer : paletteEntry) {
        List<PaletteEntry> paletteDrawersList = paletteContainer.getChildren();
        for (PaletteEntry paletteDrawer : paletteDrawersList) {

            if (StringUtils.containsIgnoreCase(
                    paletteDrawer.getParent().getLabel() + " : " + paletteDrawer.getLabel(), contents)) {
                String componentName = ((Class) ((CombinedTemplateCreationEntry) paletteDrawer).getTemplate())
                        .getSimpleName();
                componentDetails = new ComponentDetails();
                Component component = XMLConfigUtil.INSTANCE.getComponent(componentName);
                componentDetails.setName(componentName);
                componentDetails.setCategoryAndPalletteName(
                        paletteDrawer.getParent().getLabel() + " : " + paletteDrawer.getLabel());
                componentDetails.setDescription(component.getDescription());
                componentDetails.setDescriptor(paletteDrawer.getSmallIcon());
                proposalList.add(new ComponentContentProposal(componentDetails));
            }
        }
    }

    componentDetails = new ComponentDetails();
    componentDetails.setName(COMMENT_BOX);
    componentDetails.setCategoryAndPalletteName(COMMENT_BOX);
    componentDetails.setDescription(COMMENT_BOX);
    componentDetails.setDescriptor(getCommentBoxImageDisDescriptor());
    proposalList.add(new ComponentContentProposal(componentDetails));
    return proposalList.toArray(new IContentProposal[0]);
}
项目:Hydrograph    文件:CustomPaletteViewer.java   
private void showAllContainers(final PaletteRoot paletteRoot, final ELTGraphicalEditor editor,
        final Map<String, PaletteDrawer> categoryPaletteContainer, final List<Component> componentsConfig) {
    for (Component componentConfig : componentsConfig) {
        if (Constants.UNKNOWN_COMPONENT.equalsIgnoreCase(componentConfig.getName()))
            continue;
        CombinedTemplateCreationEntry component = getComponentToAddInContainer(editor, componentConfig);

        categoryPaletteContainer.get(componentConfig.getCategory().name()).add(component);
        showClosedPaletteContainersWhenSearchTextBoxIsEmpty(paletteRoot.getChildren());
    }
    if (label != null) {
        label.dispose();
    }
}
项目:Hydrograph    文件:CustomPaletteViewer.java   
private CombinedTemplateCreationEntry getComponentToAddInContainer(ELTGraphicalEditor eLEtlGraphicalEditor,
        Component componentConfig) {
    Class<?> clazz = DynamicClassProcessor.INSTANCE.createClass(componentConfig);

    CombinedTemplateCreationEntry component = new CombinedTemplateCreationEntry(componentConfig.getNameInPalette(),
            null, clazz, new SimpleFactory(clazz),
            ImageDescriptor.createFromURL(eLEtlGraphicalEditor.prepareIconPathURL(componentConfig
                    .getPaletteIconPath())), ImageDescriptor.createFromURL(eLEtlGraphicalEditor
                    .prepareIconPathURL(componentConfig.getPaletteIconPath())));
    return component;
}
项目:Hydrograph    文件:ELTGraphicalEditor.java   
private void createShapesDrawer(PaletteRoot palette) throws RuntimeException, SAXException, IOException {
    Map<String, PaletteDrawer> categoryPaletteConatiner = new HashMap<>();
    for (CategoryType category : CategoryType.values()) {
        if(category.name().equalsIgnoreCase(Constants.UNKNOWN_COMPONENT_CATEGORY)){
            continue;
        }               
        PaletteDrawer p = createPaletteContainer(category.name());
        addContainerToPalette(palette, p);
        categoryPaletteConatiner.put(category.name(), p);
    }
    List<Component> componentsConfig = XMLConfigUtil.INSTANCE.getComponentConfig();

    //To show the components in sorted order in palette
    Collections.sort(componentsConfig, new Comparator<Component>() {
        public int compare(Component component1, Component component2) {
            return  component1.getNameInPalette().compareToIgnoreCase(component2.getNameInPalette());           
        };
    });

    for (Component componentConfig : componentsConfig) {
        Class<?> clazz = DynamicClassProcessor.INSTANCE.createClass(componentConfig);

        if(componentConfig.getName().equalsIgnoreCase(Constants.UNKNOWN_COMPONENT)){
            continue;
        }

        CombinedTemplateCreationEntry component = new CombinedTemplateCreationEntry(
                componentConfig.getNameInPalette(), null, clazz,
                new SimpleFactory(clazz),
                ImageDescriptor.createFromURL(
                        prepareIconPathURL(componentConfig.getPaletteIconPath())),
                        ImageDescriptor.createFromURL(
                                prepareIconPathURL(componentConfig.getPaletteIconPath())));
        categoryPaletteConatiner.get(componentConfig.getCategory().name()).add(component);
    }

}
项目:bdf2    文件:DbToolGefEditorPaletteFactory.java   
private static PaletteDrawer createPaletteDrawer() {
    PaletteDrawer drawer = new PaletteDrawer("Elements");
    CombinedTemplateCreationEntry table = new CombinedTemplateCreationEntry("Table", "This is table tool", Table.class, new SimpleFactory(
            Table.class), Activator.getImageDescriptor(Activator.IMAGE_TABLE_16), Activator.getImageDescriptor(Activator.IMAGE_TABLE_24));
    drawer.add(table);
    CombinedTemplateCreationEntry column = new CombinedTemplateCreationEntry("Column", "This is column tool", Column.class, new SimpleFactory(
            Column.class), Activator.getImageDescriptor(Activator.IMAGE_COLUMN_16), Activator.getImageDescriptor(Activator.IMAGE_COLUMN_24));
    drawer.add(column);
    ConnectionCreationToolEntry connection = new ConnectionCreationToolEntry("Connection", "this is table connection", new SimpleFactory(
            Connection.class), Activator.getImageDescriptor(Activator.IMAGE_CONNECTION_16),
            Activator.getImageDescriptor(Activator.IMAGE_CONNECTION_24));
    drawer.add(connection);
    return drawer;

}
项目:triquetrum    文件:UserLibraryTransferDropListener.java   
@Override
public Object getNewObject() {
  TriqDiagramEditor activeEditor = EditorUtils.getSelectedDiagramEditor();
  if (activeEditor != null) {
    Shell shell = activeEditor.getSite().getShell();
    AddActorToUserLibraryDialog dialog = new AddActorToUserLibraryDialog(shell, handle);
    dialog.setBlockOnOpen(true);
    int dialogReturnCode = dialog.open();
    if (Dialog.OK == dialogReturnCode) {
      String modelName = dialog.modelName;
      String modelClass = dialog.modelClass;
      String libraryName = targetTreeNode.getFullTreePath('.');
      String elementType = "CompositeActor";

      Map<String, String> properties = new HashMap<>();
      properties.put("displayName", modelName);
      properties.put("class", modelClass);
      properties.put("type", elementType);
      properties.put("libraryName", libraryName);

      Event event = new Event(LibraryManager.ADD_EVENT_TOPIC, properties);
      try {
        TriqEditorPlugin.getDefault().getEventAdminService().postEvent(event);
      } catch (NullPointerException e) {
        StatusManager.getManager().handle(
            new Status(IStatus.ERROR, TriqEditorPlugin.getID(), "Event bus not available, impossible to trigger an addition event for the user library."),
            StatusManager.BLOCK);
      }
      TriqFeatureProvider featureProvider = (TriqFeatureProvider) activeEditor.getDiagramTypeProvider().getFeatureProvider();
      ICreateFeature createFeature = featureProvider.buildCreateFeature(null, null, modelName, modelClass, null, null,
          BoCategory.CompositeActor, null);
      TriqPaletteRoot.DefaultCreationFactory cf = new TriqPaletteRoot.DefaultCreationFactory(createFeature, ICreateFeature.class);

      CombinedTemplateCreationEntry pe = new CombinedTemplateCreationEntry(modelName, modelClass, cf, cf, null, null);
      pe.setToolClass(GFCreationTool.class);
      return pe;
    }
  }
  return null;
}
项目:gef-gwt    文件:TemplateTransferDragSourceListener.java   
/**
 * A helper method that returns <code>null</code> or the <i>template</i>
 * Object from the currently selected EditPart.
 * 
 * @return the template
 */
protected Object getTemplate() {
    List selection = getViewer().getSelectedEditParts();
    if (selection.size() == 1) {
        EditPart editpart = (EditPart) getViewer().getSelectedEditParts()
                .get(0);
        Object model = editpart.getModel();
        if (model instanceof PaletteTemplateEntry)
            return ((PaletteTemplateEntry) model).getTemplate();
        if (model instanceof CombinedTemplateCreationEntry)
            return ((CombinedTemplateCreationEntry) model).getTemplate();
    }
    return null;
}
项目:seg.jUCMNav    文件:UrnDragSourceListener.java   
protected Object getTemplate() {
    List selection = getViewer().getSelectedEditParts();
    if (selection.size() == 1) {
        EditPart editpart = (EditPart) getViewer().getSelectedEditParts().get(0);
        Object model = editpart.getModel();
        if (model instanceof PaletteTemplateEntry)
            return ((PaletteTemplateEntry) model).getTemplate();
        if (model instanceof CombinedTemplateCreationEntry)
            return ((CombinedTemplateCreationEntry) model).getToolProperty(CreationTool.PROPERTY_CREATION_FACTORY);
    }
    return null;
}
项目:lunifera-sharky-m2m    文件:ShapesEditorPaletteFactory.java   
/** Create the "Shapes" drawer. */
private static PaletteContainer createShapesDrawer() {
    PaletteDrawer componentsDrawer = new PaletteDrawer("Shapes");

    CombinedTemplateCreationEntry component = new CombinedTemplateCreationEntry("Rectangle",
        "Create a rectangular shape", RectangularShape.class, new SimpleFactory(RectangularShape.class),
        ImageDescriptor.createFromFile(ShapesPlugin.class, "icons/rectangle16.gif"),
        ImageDescriptor.createFromFile(ShapesPlugin.class, "icons/rectangle24.gif"));
    componentsDrawer.add(component);

    return componentsDrawer;
}
项目:lunifera-sharky-m2m    文件:ShapesEditorPaletteFactory.java   
/** Create the "Shapes" drawer. */
private static PaletteContainer createShapesDrawer() {
    PaletteDrawer componentsDrawer = new PaletteDrawer("Shapes");

    CombinedTemplateCreationEntry component = new CombinedTemplateCreationEntry("Rectangle",
        "Create a rectangular shape", RectangularShape.class, new SimpleFactory(RectangularShape.class),
        ImageDescriptor.createFromFile(ShapesPlugin.class, "icons/rectangle16.gif"),
        ImageDescriptor.createFromFile(ShapesPlugin.class, "icons/rectangle24.gif"));
    componentsDrawer.add(component);

    return componentsDrawer;
}
项目:triquetrum    文件:UserLibraryTransferDropListener.java   
@Override
public Object getObjectType() {
  return CombinedTemplateCreationEntry.class;
}
项目:birt    文件:MasterPagePaletteFactory.java   
/**
     * Creates BIRT Master Page specified categories and items.
     * 
     * @return PaletteContainer containing BIRT Master Page specified categories
     */
    private static PaletteContainer createAutoTextDrawer( )
    {
        PaletteCategory category = new PaletteCategory( IPreferenceConstants.PALETTE_AUTOTEXT,
                AUTOTEXT_LABEL,
                ReportPlatformUIImages.getImageDescriptor( ISharedImages.IMG_OBJ_FOLDER ) );
        List entries = new ArrayList( );

        CombinedTemplateCreationEntry combined = null;

        combined = createAutoText( AUTOTEXT_PAGE,
                AUTOTEXT_TOOLTIP_PAGE,
                IReportElementConstants.AUTOTEXT_PAGE );
        entries.add( combined );

        combined = createAutoText( AUTOTEXT_TOTAL_PAGE_COUNT,
                AUTOTEXT_TOOLTIP_TOTAL_PAGE_COUNT,
                IReportElementConstants.AUTOTEXT_TOTAL_PAGE_COUNT );
        entries.add( combined );

        combined = createAutoText( AUTOTEXT_PAGE_X_OF_Y,
        AUTOTEXT_TOOLTIP_PAGE_X_OF_Y,
        IReportElementConstants.AUTOTEXT_PAGEXOFY );
        entries.add( combined );

        combined = createAutoText( AUTOTEXT_AUTHOR_PAGE_DATE,
                AUTOTEXT_TOOLTIP_AUTHOR_PAGE_DATE,
                IReportElementConstants.AUTOTEXT_AUTHOR_PAGE_DATE );
        entries.add( combined );

        combined = createAutoText( AUTOTEXT_CONFIDENTIAL_PAGE,
                AUTOTEXT_TOOLTIP_CONFIDENTIAL_PAGE,
                IReportElementConstants.AUTOTEXT_CONFIDENTIAL_PAGE );
        entries.add( combined );

        combined = createAutoText( AUTOTEXT_DATE,
                AUTOTEXT_TOOLTIP_DATE,
                IReportElementConstants.AUTOTEXT_DATE );
        entries.add( combined );

        combined = createAutoText( AUTOTEXT_CREATED_ON,
                AUTOTEXT_TOOLTIP_CREATED_ON,
                IReportElementConstants.AUTOTEXT_CREATEDON );
        entries.add( combined );

        combined = createAutoText( AUTOTEXT_CREATED_BY,
                AUTOTEXT_TOOLTIP_CREATED_BY,
                IReportElementConstants.AUTOTEXT_CREATEDBY );
        entries.add( combined );

        combined = createAutoText( AUTOTEXT_FILENAME,
                AUTOTEXT_TOOLTIP_FILENAME,
                IReportElementConstants.AUTOTEXT_FILENAME );
        entries.add( combined );

        combined = createAutoText( AUTOTEXT_LAST_PRINTED,
                AUTOTEXT_TOOLTIP_LAST_PRINTED,
                IReportElementConstants.AUTOTEXT_LASTPRINTED );
        entries.add( combined );

        combined = createAutoText( AUTOTEXT_VARIABLE,
                AUTOTEXT_TOOLTIP_VARIABLE,
                IReportElementConstants.AUTOTEXT_VARIABLE );
        entries.add( combined );

//  Remove unsupported function         
//      combined = createAutoText( AUTOTEXT_PAGE_X_OF_Y,
//              AUTOTEXT_TOOLTIP_PAGE_X_OF_Y,
//              IReportElementConstants.AUTOTEXT_PAGEXOFY );
//      entries.add( combined );

        category.addAll( entries );
        return category;
    }
项目:PDFReporter-Studio    文件:JDPaletteFactory.java   
/**
 * Creates a new JDPalette object.
 * 
 * @param iconDescriptor
 *          the icon descriptor
 * @param aclass
 *          the aclass
 * @return the palette entry
 */
public static PaletteEntry createJDEntry(IIconDescriptor iconDescriptor, Class<?> aclass) {
    CombinedTemplateCreationEntry paletteEntry = new CombinedTemplateCreationEntry(iconDescriptor.getTitle(), iconDescriptor.getDescription(), aclass,
            new JDPaletteCreationFactory(aclass), iconDescriptor.getIcon16(), iconDescriptor.getIcon32());
    // Override default CreationTool class with ours
    paletteEntry.setToolClass(JDCreationTool.class);
    return paletteEntry;
}