Search in sources :

Example 1 with PaletteContainer

use of org.eclipse.gef.palette.PaletteContainer in project dbeaver by serge-rider.

the class ERDGraphicalViewer method handleTableDeactivate.

public void handleTableDeactivate(DBSEntity table) {
    final PaletteContainer drawer = getContainerPaletteDrawer(table.getDataSource().getContainer());
    if (drawer != null) {
        for (Object entry : drawer.getChildren()) {
            if (entry instanceof ToolEntryTable && ((ToolEntryTable) entry).table == table) {
                drawer.remove((ToolEntryTable) entry);
                break;
            }
        }
    }
    if (table.getDataSource() != null) {
        DBPDataSourceContainer container = table.getDataSource().getContainer();
        if (container != null) {
            synchronized (usedDataSources) {
                DataSourceInfo dataSourceInfo = usedDataSources.get(container);
                if (dataSourceInfo == null) {
                    log.warn("Datasource '" + container + "' not registered in ERD viewer");
                } else {
                    dataSourceInfo.tableCount--;
                    if (dataSourceInfo.tableCount <= 0) {
                        usedDataSources.remove(container);
                        releaseContainer(container);
                    }
                }
            }
        }
    }
}
Also used : PaletteContainer(org.eclipse.gef.palette.PaletteContainer)

Example 2 with PaletteContainer

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

the class BusinessPaletteFactory method createbusiness1Group.

/**
     * @generated
     */
private PaletteContainer createbusiness1Group() {
    //$NON-NLS-1$
    PaletteContainer paletteContainer = new PaletteDrawer("business");
    paletteContainer.add(createDecision1CreationTool());
    paletteContainer.add(createAction2CreationTool());
    paletteContainer.add(createTerminal3CreationTool());
    paletteContainer.add(createData4CreationTool());
    paletteContainer.add(createDocument5CreationTool());
    paletteContainer.add(createInput6CreationTool());
    paletteContainer.add(createList7CreationTool());
    paletteContainer.add(createDatabase8CreationTool());
    paletteContainer.add(createActor9CreationTool());
    paletteContainer.add(createEllipse10CreationTool());
    paletteContainer.add(createGear11CreationTool());
    paletteContainer.add(new PaletteSeparator());
    paletteContainer.add(createRelationship13CreationTool());
    paletteContainer.add(createDirectionalRelationship14CreationTool());
    paletteContainer.add(createBidirectionalRelationship15CreationTool());
    return paletteContainer;
}
Also used : PaletteSeparator(org.eclipse.gef.palette.PaletteSeparator) PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer) PaletteContainer(org.eclipse.gef.palette.PaletteContainer)

Example 3 with PaletteContainer

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

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

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

Aggregations

PaletteContainer (org.eclipse.gef.palette.PaletteContainer)8 ArrayList (java.util.ArrayList)2 EventObject (java.util.EventObject)2 PaletteEntry (org.eclipse.gef.palette.PaletteEntry)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 TalendDrawerEditPart (org.talend.designer.core.ui.editor.palette.TalendDrawerEditPart)2 TalendPaletteDrawer (org.talend.designer.core.ui.editor.palette.TalendPaletteDrawer)2 Iterator (java.util.Iterator)1 List (java.util.List)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 CombinedTemplateCreationEntry (org.eclipse.gef.palette.CombinedTemplateCreationEntry)1 CreationToolEntry (org.eclipse.gef.palette.CreationToolEntry)1 PaletteDrawer (org.eclipse.gef.palette.PaletteDrawer)1 PaletteRoot (org.eclipse.gef.palette.PaletteRoot)1 PaletteSeparator (org.eclipse.gef.palette.PaletteSeparator)1 ToolEntry (org.eclipse.gef.palette.ToolEntry)1