Search in sources :

Example 1 with CombinedTemplateCreationEntry

use of org.eclipse.gef.palette.CombinedTemplateCreationEntry 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 2 with CombinedTemplateCreationEntry

use of org.eclipse.gef.palette.CombinedTemplateCreationEntry 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)

Example 3 with CombinedTemplateCreationEntry

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

the class TalendPaletteContextMenuProvider method addListNotes.

public void addListNotes(List eleList, Project project, PaletteViewer paletteViewer) {
    for (int i = 0; i < eleList.size(); i++) {
        PaletteEntry elementLi = (PaletteEntry) eleList.get(i);
        if (elementLi instanceof TalendPaletteDrawer) {
            List list = ((TalendPaletteDrawer) elementLi).getChildren();
            addListNotes(list, project, paletteViewer);
        } else if (elementLi instanceof CombinedTemplateCreationEntry) {
            addNotes((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)

Example 4 with CombinedTemplateCreationEntry

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

the class TalendPaletteViewer method removeFavoritesComponent.

public void removeFavoritesComponent(CombinedTemplateCreationEntry component) {
    if (favoritesEditPart != null) {
        TalendEditorPaletteFactory.deleteFavoriteFromPreference(component.getLabel());
        List children = favoritesEditPart.getChildren();
        if (children != null) {
            for (Object obj : children) {
                TalendEntryEditPart entryEditPart = (TalendEntryEditPart) obj;
                CombinedTemplateCreationEntry entryModule = (CombinedTemplateCreationEntry) entryEditPart.getModel();
                if (entryModule.getLabel().equals(component.getLabel())) {
                    PaletteDrawer paletteDrawer = favoritesEditPart.getDrawer();
                    if (paletteDrawer != null) {
                        paletteDrawer.remove(entryModule);
                    }
                    // favoritesEditPart.removeChild(entryEditPart);
                    break;
                }
            }
        }
    }
}
Also used : PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer) List(java.util.List) ArrayList(java.util.ArrayList) CombinedTemplateCreationEntry(org.eclipse.gef.palette.CombinedTemplateCreationEntry)

Example 5 with CombinedTemplateCreationEntry

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

the class TalendPaletteViewer method removeRecentlyUsedComponent.

public void removeRecentlyUsedComponent(CombinedTemplateCreationEntry component) {
    if (recentlyUsedEditPart != null) {
        List children = recentlyUsedEditPart.getChildren();
        if (children != null) {
            for (Object obj : children) {
                TalendEntryEditPart entryEditPart = (TalendEntryEditPart) obj;
                CombinedTemplateCreationEntry entryModule = (CombinedTemplateCreationEntry) entryEditPart.getModel();
                if (entryModule.getLabel().equals(component.getLabel())) {
                    PaletteDrawer paletteDrawer = recentlyUsedEditPart.getDrawer();
                    if (paletteDrawer != null) {
                        paletteDrawer.remove(entryModule);
                    }
                    // favoritesEditPart.removeChild(entryEditPart);
                    break;
                }
            }
        }
    }
}
Also used : PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer) List(java.util.List) ArrayList(java.util.ArrayList) CombinedTemplateCreationEntry(org.eclipse.gef.palette.CombinedTemplateCreationEntry)

Aggregations

CombinedTemplateCreationEntry (org.eclipse.gef.palette.CombinedTemplateCreationEntry)12 ArrayList (java.util.ArrayList)11 List (java.util.List)8 PaletteDrawer (org.eclipse.gef.palette.PaletteDrawer)8 ConnectionCreationToolEntry (org.eclipse.gef.palette.ConnectionCreationToolEntry)3 CreationToolEntry (org.eclipse.gef.palette.CreationToolEntry)3 PaletteEntry (org.eclipse.gef.palette.PaletteEntry)3 IComponent (org.talend.core.model.components.IComponent)3 HashMap (java.util.HashMap)2 Hashtable (java.util.Hashtable)2 Iterator (java.util.Iterator)2 LinkedList (java.util.LinkedList)2 EditPart (org.eclipse.gef.EditPart)2 PaletteRoot (org.eclipse.gef.palette.PaletteRoot)2 SelectionToolEntry (org.eclipse.gef.palette.SelectionToolEntry)2 ToolEntry (org.eclipse.gef.palette.ToolEntry)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)2 EComponentType (org.talend.core.model.components.EComponentType)2 IPaletteFilter (org.talend.designer.core.IPaletteFilter)2