Search in sources :

Example 1 with PaletteEntry

use of org.eclipse.gef.palette.PaletteEntry in project tdi-studio-se by Talend.

the class TalendEditorComponentProposalProvider method getProposals.

/**
     * Return an array of Objects representing the valid content proposals for a field.
     * 
     * @param contents the current contents of the field (only consulted if filtering is set to <code>true</code>)
     * @param position the current cursor position within the field (ignored)
     * @return the array of Objects that represent valid proposals for the field given its current content.
     */
@Override
public IContentProposal[] getProposals(String contents, int position) {
    List<IComponent> relatedComponent = TalendEditorPaletteFactory.getRelatedComponents(componentsFactory, contents);
    if (componentAssistant != null) {
        relatedComponent = componentAssistant.filterComponents(relatedComponent);
    }
    proposalList.clear();
    // add joblet components in joblet editor.
    List<PaletteEntry> extraPaletteEntry = ComponentPaletteUtilities.getExtraPaletteEntry();
    if (extraPaletteEntry != null) {
        for (PaletteEntry entry : extraPaletteEntry) {
            if (entry != null && entry.isVisible() && entry instanceof TalendCreationToolEntry) {
                TalendCreationToolEntry tool = (TalendCreationToolEntry) entry;
                CreationFactory creationFactory = tool.getFactory();
                if (creationFactory != null && creationFactory instanceof PaletteComponentFactory) {
                    PaletteComponentFactory componentFactory = (PaletteComponentFactory) creationFactory;
                    proposalList.add(new ComponentContentProposal(componentFactory.getComponent()));
                }
            }
        }
    }
    if (relatedComponent != null && !relatedComponent.isEmpty()) {
        Iterator<IComponent> iter = relatedComponent.iterator();
        while (iter.hasNext()) {
            IComponent component = iter.next();
            // proposalList.add(new ComponentContentProposal(component.getName(), component.getLongName(),
            // component));
            proposalList.add(new ComponentContentProposal(component));
        }
    }
    /**
         * Always add Note
         */
    //$NON-NLS-1$
    DummyComponent noteComponent = new DummyComponent("Note");
    noteComponent.setIcon16(ImageProvider.getImageDesc(ECoreImage.NOTE_SMALL_ICON));
    //$NON-NLS-1$
    noteComponent.setOriginalFamilyName("Misc");
    proposalList.add(new ComponentContentProposal(noteComponent));
    return proposalList.toArray(new IContentProposal[0]);
}
Also used : PaletteComponentFactory(org.talend.designer.core.ui.editor.PaletteComponentFactory) DummyComponent(org.talend.designer.core.model.components.DummyComponent) IComponent(org.talend.core.model.components.IComponent) CreationFactory(org.eclipse.gef.requests.CreationFactory) PaletteEntry(org.eclipse.gef.palette.PaletteEntry) TalendCreationToolEntry(org.talend.core.ui.component.TalendCreationToolEntry)

Example 2 with PaletteEntry

use of org.eclipse.gef.palette.PaletteEntry in project tdi-studio-se by Talend.

the class PaletteSettingsDialog method retreiveAllEntry.

private void retreiveAllEntry(Set<String> list, PaletteEntry entry) {
    if (entry instanceof PaletteContainer) {
        PaletteContainer container = (PaletteContainer) entry;
        for (Iterator iterator = container.getChildren().iterator(); iterator.hasNext(); ) {
            PaletteEntry en = (PaletteEntry) iterator.next();
            retreiveAllEntry(list, en);
        }
    } else {
        String family = ComponentsFactoryProvider.getPaletteEntryFamily(entry.getParent());
        list.add(family + FAMILY_SPEARATOR + entry.getLabel());
    }
}
Also used : Iterator(java.util.Iterator) PaletteEntry(org.eclipse.gef.palette.PaletteEntry) PaletteContainer(org.eclipse.gef.palette.PaletteContainer)

Example 3 with PaletteEntry

use of org.eclipse.gef.palette.PaletteEntry in project tdi-studio-se by Talend.

the class PaletteSettingsDialog method setComponentVisible.

/**
     * set the selected component as visible or not
     * 
     * @param selection
     * @param b
     */
protected void setComponentVisible(ISelection selection, boolean visible) {
    IStructuredSelection sel = (IStructuredSelection) selection;
    Set<String> names = new HashSet<String>();
    for (Iterator iterator = sel.iterator(); iterator.hasNext(); ) {
        PaletteEntry entry = (PaletteEntry) iterator.next();
        retreiveAllEntry(names, entry);
    }
    for (String string : names) {
        setComponentVisible(string, visible, !RESTORE);
    }
    refreshViewer();
}
Also used : Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PaletteEntry(org.eclipse.gef.palette.PaletteEntry) HashSet(java.util.HashSet)

Example 4 with PaletteEntry

use of org.eclipse.gef.palette.PaletteEntry in project tdi-studio-se by Talend.

the class TalendPaletteContextMenuProvider method buildContextMenu.

@SuppressWarnings("rawtypes")
@Override
public void buildContextMenu(IMenuManager menu) {
    super.buildContextMenu(menu);
    boolean hasSearchComponentAction = true;
    List editParts = getPaletteViewer().getSelectedEditParts();
    if (!editParts.isEmpty()) {
        PaletteEntry element = (PaletteEntry) ((EditPart) editParts.get(0)).getModel();
        if (editParts.size() > 1) {
            // search component only process one .
            hasSearchComponentAction = false;
        } else {
            // check the entry is component or folder
            if (element instanceof CombinedTemplateCreationEntry) {
                Object template = ((CombinedTemplateCreationEntry) element).getTemplate();
                if (template == null || !Node.class.equals(template)) {
                    hasSearchComponentAction = false;
                }
            } else {
                // not component entry
                hasSearchComponentAction = false;
            }
        }
        // don't work for camel.
        if (hasSearchComponentAction && isComponentsTypePalette(ComponentCategory.CATEGORY_4_CAMEL)) {
            hasSearchComponentAction = false;
        }
        // note
        //$NON-NLS-1$
        boolean note = element.getLabel().equals(Messages.getString("TalendEditorPaletteFactory.Note"));
        if (!note) {
            if (hasSearchComponentAction) {
                menu.appendToGroup(GEFActionConstants.MB_ADDITIONS, new SearchComponentAction(getPaletteViewer()));
            }
            boolean showFavorAction = true;
            boolean showAddFavorAction = true;
            PaletteContainer pContainer = element.getParent();
            if (pContainer != null) {
                // Favorites Folder or components in Favorites Folder
                if ((pContainer instanceof PaletteRoot && TalendEditorPaletteFactory.FAVORITES.equals(element.getLabel())) || (pContainer.getParent() instanceof PaletteRoot && TalendEditorPaletteFactory.FAVORITES.equals(pContainer.getLabel()))) {
                    showAddFavorAction = false;
                }
            }
            // for INPUT/OUTPUT/TRIGGER, needn't to add to Favorites
            if (element instanceof CreationToolEntry) {
                Object obj = ((CreationToolEntry) element).getToolProperty(CreationTool.PROPERTY_CREATION_FACTORY);
                if (obj instanceof PaletteComponentFactory) {
                    IComponent component = ((PaletteComponentFactory) obj).getComponent();
                    EComponentType componentType = component.getComponentType();
                    if (componentType == EComponentType.JOBLET_INPUT_OUTPUT || componentType == EComponentType.JOBLET_TRIGGER) {
                        showFavorAction = false;
                    }
                }
            }
            if (showFavorAction) {
                // if (ShowFavoriteAction.state == true) {
                if (showAddFavorAction) {
                    menu.appendToGroup(GEFActionConstants.GROUP_COPY, new FavoriteComponentAction(getPaletteViewer()));
                } else {
                    menu.appendToGroup(GEFActionConstants.GROUP_COPY, new RemoveFavoriteComponentAction(getPaletteViewer()));
                }
            }
        }
    }
    menu.appendToGroup(GEFActionConstants.GROUP_COPY, new HiddenFloderAction(getPaletteViewer()));
    menu.appendToGroup(GEFActionConstants.GROUP_COPY, new DisplayFloderAction(getPaletteViewer()));
}
Also used : PaletteRoot(org.eclipse.gef.palette.PaletteRoot) PaletteComponentFactory(org.talend.designer.core.ui.editor.PaletteComponentFactory) IComponent(org.talend.core.model.components.IComponent) PaletteEntry(org.eclipse.gef.palette.PaletteEntry) PaletteContainer(org.eclipse.gef.palette.PaletteContainer) EComponentType(org.talend.core.model.components.EComponentType) CreationToolEntry(org.eclipse.gef.palette.CreationToolEntry) ArrayList(java.util.ArrayList) List(java.util.List) CombinedTemplateCreationEntry(org.eclipse.gef.palette.CombinedTemplateCreationEntry)

Example 5 with PaletteEntry

use of org.eclipse.gef.palette.PaletteEntry in project tdi-studio-se by Talend.

the class TalendPaletteContextMenuProvider method removeListNotes.

public void removeListNotes(List eleList, Project project, PaletteViewer paletteViewer) {
    Iterator<PaletteEntry> iter = eleList.iterator();
    while (iter.hasNext()) {
        PaletteEntry elementLi = iter.next();
        if (elementLi instanceof TalendPaletteDrawer) {
            List list = ((TalendPaletteDrawer) elementLi).getChildren();
            removeListNotes(list, project, paletteViewer);
        } else if (elementLi instanceof CombinedTemplateCreationEntry) {
            removeNotes((CombinedTemplateCreationEntry) elementLi, project, paletteViewer);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) PaletteEntry(org.eclipse.gef.palette.PaletteEntry) CombinedTemplateCreationEntry(org.eclipse.gef.palette.CombinedTemplateCreationEntry)

Aggregations

PaletteEntry (org.eclipse.gef.palette.PaletteEntry)15 List (java.util.List)4 CombinedTemplateCreationEntry (org.eclipse.gef.palette.CombinedTemplateCreationEntry)4 PaletteContainer (org.eclipse.gef.palette.PaletteContainer)4 ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 AbstractHandler (org.eclipse.core.commands.AbstractHandler)2 Command (org.eclipse.core.commands.Command)2 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)2 ExecutionException (org.eclipse.core.commands.ExecutionException)2 IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)2 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)2 PaletteGroup (org.eclipse.gef.palette.PaletteGroup)2 PaletteRoot (org.eclipse.gef.palette.PaletteRoot)2 PaletteEditPart (org.eclipse.gef.ui.palette.editparts.PaletteEditPart)2 MouseAdapter (org.eclipse.swt.events.MouseAdapter)2 MouseEvent (org.eclipse.swt.events.MouseEvent)2 ICommandService (org.eclipse.ui.commands.ICommandService)2 IHandlerService (org.eclipse.ui.handlers.IHandlerService)2