Search in sources :

Example 1 with TalendPaletteDrawer

use of org.talend.designer.core.ui.editor.palette.TalendPaletteDrawer in project tdi-studio-se by Talend.

the class AbstractTalendEditor method selectPaletteEntry.

private boolean selectPaletteEntry(String componentName, PaletteViewer paletteViewer, List entries) {
    for (Object entry : entries) {
        if (entry instanceof PaletteContainer) {
            PaletteContainer container = (PaletteContainer) entry;
            if (selectPaletteEntry(componentName, paletteViewer, container.getChildren())) {
                return true;
            }
        } else if (entry instanceof TalendPaletteDrawer) {
            TalendPaletteDrawer drawer = (TalendPaletteDrawer) entry;
            if (selectPaletteEntry(componentName, paletteViewer, drawer.getChildren())) {
                return true;
            }
        } else if (entry instanceof ToolEntry) {
            ToolEntry paletteEntry = (ToolEntry) entry;
            if (paletteEntry.getLabel().equals(componentName)) {
                EditPart part = getToolEntryEditPart(paletteViewer, paletteEntry);
                expandPaletteDrawer(paletteViewer, paletteEntry);
                // paletteViewer.setSelection(new StructuredSelection(part));
                // paletteViewer.setFocus(part);
                paletteViewer.select(part);
                paletteViewer.reveal(part);
                paletteViewer.setActiveTool(paletteEntry);
                return true;
            }
        }
    }
    return false;
}
Also used : TalendPaletteDrawer(org.talend.designer.core.ui.editor.palette.TalendPaletteDrawer) EditPart(org.eclipse.gef.EditPart) NodeTreeEditPart(org.talend.designer.core.ui.editor.outline.NodeTreeEditPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) RootEditPart(org.eclipse.gef.RootEditPart) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) TalendDrawerEditPart(org.talend.designer.core.ui.editor.palette.TalendDrawerEditPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) EventObject(java.util.EventObject) ToolEntry(org.eclipse.gef.palette.ToolEntry) PaletteContainer(org.eclipse.gef.palette.PaletteContainer)

Example 2 with TalendPaletteDrawer

use of org.talend.designer.core.ui.editor.palette.TalendPaletteDrawer in project tdi-studio-se by Talend.

the class AbstractTalendEditor method expandPaletteDrawer.

/**
     * DOC hcw Comment method "expandPaletteDrawer".
     * 
     * @param paletteViewer
     * @param paletteEntry
     */
private void expandPaletteDrawer(PaletteViewer paletteViewer, ToolEntry paletteEntry) {
    List<TalendDrawerEditPart> parts = new ArrayList<TalendDrawerEditPart>();
    PaletteContainer parent = paletteEntry.getParent();
    while (parent != null) {
        if (parent instanceof TalendPaletteDrawer) {
            Object editpart = paletteViewer.getEditPartRegistry().get(parent);
            if (editpart instanceof TalendDrawerEditPart) {
                parts.add((TalendDrawerEditPart) editpart);
            }
        }
        parent = parent.getParent();
    }
    for (int i = parts.size() - 1; i >= 0; i--) {
        parts.get(i).setExpanded(true);
    }
}
Also used : TalendPaletteDrawer(org.talend.designer.core.ui.editor.palette.TalendPaletteDrawer) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) EventObject(java.util.EventObject) TalendDrawerEditPart(org.talend.designer.core.ui.editor.palette.TalendDrawerEditPart) PaletteContainer(org.eclipse.gef.palette.PaletteContainer) Point(org.eclipse.draw2d.geometry.Point)

Example 3 with TalendPaletteDrawer

use of org.talend.designer.core.ui.editor.palette.TalendPaletteDrawer in project tdi-studio-se by Talend.

the class TalendEditorPaletteFactory method createComponentDrawer.

private static PaletteDrawer createComponentDrawer(Hashtable<String, PaletteDrawer> ht, String familyToCreate) {
    int index = familyToCreate.lastIndexOf(FAMILY_HIER_SEPARATOR);
    String family;
    PaletteDrawer parentPaletteDrawer = null;
    if (index > -1) {
        family = familyToCreate.substring(index + 1);
        String parentFamily = familyToCreate.substring(0, index);
        parentPaletteDrawer = ht.get(parentFamily);
        if (parentPaletteDrawer == null) {
            parentPaletteDrawer = createComponentDrawer(ht, parentFamily);
        }
    } else {
        family = familyToCreate;
    }
    final PaletteDrawer paletteDrawer = new TalendPaletteDrawer(family);
    paletteDrawer.setInitialState(loadFamilyState(familyToCreate));
    if (parentPaletteDrawer == null) {
        palette.add(paletteDrawer);
    } else {
        parentPaletteDrawer.add(paletteDrawer);
    }
    ht.put(familyToCreate, paletteDrawer);
    return paletteDrawer;
}
Also used : TalendPaletteDrawer(org.talend.designer.core.ui.editor.palette.TalendPaletteDrawer) TalendPaletteDrawer(org.talend.designer.core.ui.editor.palette.TalendPaletteDrawer) PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer)

Aggregations

TalendPaletteDrawer (org.talend.designer.core.ui.editor.palette.TalendPaletteDrawer)3 EventObject (java.util.EventObject)2 PaletteContainer (org.eclipse.gef.palette.PaletteContainer)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 TalendDrawerEditPart (org.talend.designer.core.ui.editor.palette.TalendDrawerEditPart)2 ArrayList (java.util.ArrayList)1 Point (org.eclipse.draw2d.geometry.Point)1 EditPart (org.eclipse.gef.EditPart)1 RootEditPart (org.eclipse.gef.RootEditPart)1 AbstractEditPart (org.eclipse.gef.editparts.AbstractEditPart)1 ScalableFreeformRootEditPart (org.eclipse.gef.editparts.ScalableFreeformRootEditPart)1 PaletteDrawer (org.eclipse.gef.palette.PaletteDrawer)1 ToolEntry (org.eclipse.gef.palette.ToolEntry)1 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)1 NodeTreeEditPart (org.talend.designer.core.ui.editor.outline.NodeTreeEditPart)1