Search in sources :

Example 6 with PaletteDrawer

use of org.eclipse.gef.palette.PaletteDrawer in project cubrid-manager by CUBRID.

the class PaletteFactory method createComponentsDrawer.

/**
	 * create components drawer
	 * 
	 * @return drawer
	 */
private static PaletteContainer createComponentsDrawer() {
    PaletteDrawer drawer = new PaletteDrawer(Messages.lblReplComponent);
    drawer.setLargeIcon(CubridManagerUIPlugin.getImageDescriptor("icons/replication/replication.gif"));
    drawer.setSmallIcon(CubridManagerUIPlugin.getImageDescriptor("icons/replication/replication.gif"));
    List<ToolEntry> toolEntries = new ArrayList<ToolEntry>();
    ToolEntry toolEntry = new CombinedTemplateCreationEntry(Messages.lblHostTool, Messages.descHostTool, HostNode.class, new SimpleFactory(HostNode.class), CubridManagerUIPlugin.getImageDescriptor("icons/navigator/host.png"), CubridManagerUIPlugin.getImageDescriptor("icons/navigator/host.png"));
    toolEntries.add(toolEntry);
    toolEntry = new CombinedTemplateCreationEntry(Messages.lblMasterTool, Messages.descMasterTool, MasterNode.class, new SimpleFactory(MasterNode.class), CubridManagerUIPlugin.getImageDescriptor("icons/replication/master.png"), CubridManagerUIPlugin.getImageDescriptor("icons/replication/master.png"));
    toolEntries.add(toolEntry);
    toolEntry = new CombinedTemplateCreationEntry(Messages.lblDistributorTool, Messages.descDistributorTool, DistributorNode.class, new SimpleFactory(DistributorNode.class), CubridManagerUIPlugin.getImageDescriptor("icons/replication/distributor.gif"), CubridManagerUIPlugin.getImageDescriptor("icons/replication/distributor.gif"));
    toolEntries.add(toolEntry);
    toolEntry = new CombinedTemplateCreationEntry(Messages.lblSlaveTool, Messages.descSlaveTool, SlaveNode.class, new SimpleFactory(SlaveNode.class), CubridManagerUIPlugin.getImageDescriptor("icons/replication/slave.png"), CubridManagerUIPlugin.getImageDescriptor("icons/replication/slave.png"));
    toolEntries.add(toolEntry);
    drawer.addAll(toolEntries);
    return drawer;
}
Also used : MasterNode(com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode) SlaveNode(com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer) ArrayList(java.util.ArrayList) SimpleFactory(org.eclipse.gef.requests.SimpleFactory) ToolEntry(org.eclipse.gef.palette.ToolEntry) SelectionToolEntry(org.eclipse.gef.palette.SelectionToolEntry) ConnectionCreationToolEntry(org.eclipse.gef.palette.ConnectionCreationToolEntry) CombinedTemplateCreationEntry(org.eclipse.gef.palette.CombinedTemplateCreationEntry) DistributorNode(com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)

Example 7 with PaletteDrawer

use of org.eclipse.gef.palette.PaletteDrawer in project dbeaver by dbeaver.

the class ERDGraphicalViewer method releaseContainer.

private void releaseContainer(DBPDataSourceContainer container) {
    PaletteDrawer drawer = getContainerPaletteDrawer(container);
    if (drawer != null) {
        editor.getPaletteRoot().remove(drawer);
    }
    container.getRegistry().removeDataSourceListener(this);
    container.release(editor);
}
Also used : PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer)

Example 8 with PaletteDrawer

use of org.eclipse.gef.palette.PaletteDrawer in project core by jcryptool.

the class AlgorithmPaletteViewer method createTree.

/**
 * creates a tree representation of the algorithm structure
 *
 * @param needles
 *            a search string to filter the algorithms
 */
private void createTree(String[] needles) {
    invisibleRoot = new PaletteRoot();
    TreeMap<String, PaletteDrawer> types = new TreeMap<String, PaletteDrawer>();
    TreeMap<String, SelectionToolEntry> sortList = new TreeMap<String, SelectionToolEntry>();
    Iterator<CommandInfo> it = algorithmList.iterator();
    CommandInfo info = null;
    while (it.hasNext()) {
        info = it.next();
        String text = "";
        String type = "";
        String toolTipText = "";
        boolean isFlexiProviderAlgorithm = false;
        ShadowAlgorithmHandler handler = (ShadowAlgorithmHandler) info.getHandler();
        text = handler.getText();
        type = handler.getType();
        toolTipText = handler.getToolTipText();
        isFlexiProviderAlgorithm = handler.isFlexiProviderAlgorithm();
        // filter
        boolean show = true;
        for (String needle : needles) {
            if (!text.toLowerCase().matches(// $NON-NLS-1$ //$NON-NLS-2$
            ".*" + needle.toLowerCase() + ".*"))
                show = false;
        }
        if (show) {
            // Create Category
            if (types.get(type) == null) {
                // translate
                type = ApplicationActionBarAdvisor.getTypeTranslation(type);
                PaletteDrawer paletteDrawer = new PaletteDrawer(type);
                paletteDrawer.setSmallIcon(ViewsPlugin.getImageDescriptor(TreeView.ICON_FOLDER));
                paletteDrawer.setLargeIcon(ViewsPlugin.getImageDescriptor(TreeView.ICON_FOLDER));
                types.put(type, paletteDrawer);
            }
            // Add element
            SelectionToolEntry paletteEntry = new SelectionToolEntry(text, toolTipText);
            if (isFlexiProviderAlgorithm) {
                // FlexiProvider item
                paletteEntry.setSmallIcon(ViewsPlugin.getImageDescriptor(TreeView.ICON_ITEM_FLEXI));
                paletteEntry.setLargeIcon(ViewsPlugin.getImageDescriptor(TreeView.ICON_ITEM_FLEXI));
            } else {
                // JCrypTool item
                paletteEntry.setSmallIcon(ViewsPlugin.getImageDescriptor(TreeView.ICON_ITEM_JCT));
                paletteEntry.setLargeIcon(ViewsPlugin.getImageDescriptor(TreeView.ICON_ITEM_JCT));
            }
            paletteEntry.setUserModificationPermission(PaletteEntry.PERMISSION_NO_MODIFICATION);
            paletteEntry.setType(type);
            // temporary save in list
            sortList.put(paletteEntry.getLabel(), paletteEntry);
        }
    }
    ArrayList<PaletteDrawer> parents = new ArrayList<PaletteDrawer>(types.values());
    for (SelectionToolEntry paletteEntry : sortList.values()) {
        // read from sorted list
        // put sorted into palette
        types.get(paletteEntry.getType()).add(paletteEntry);
    }
    // attach tree to the root element
    Iterator<PaletteDrawer> parentIterator2 = parents.iterator();
    while (parentIterator2.hasNext()) {
        invisibleRoot.add(parentIterator2.next());
    }
}
Also used : PaletteRoot(org.eclipse.gef.palette.PaletteRoot) ShadowAlgorithmHandler(org.jcryptool.core.operations.algorithm.ShadowAlgorithmHandler) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) CommandInfo(org.jcryptool.core.operations.CommandInfo) SelectionToolEntry(org.eclipse.gef.palette.SelectionToolEntry) PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer)

Example 9 with PaletteDrawer

use of org.eclipse.gef.palette.PaletteDrawer in project core by jcryptool.

the class ViewProviderPaletteViewer method createTree.

/**
 * Creates a tree from the extension point structure.
 *
 * @param needles the search string to filter the elements
 */
private void createTree(String[] needles) {
    invisibleRoot = new PaletteRoot();
    TreeMap<String, PaletteEntry> sortList = new TreeMap<String, PaletteEntry>();
    IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(extensionPointId);
    // $NON-NLS-1$
    String label = "";
    if (extensionPoint.getLabel().equals("analysis")) {
        // $NON-NLS-1$
        label = AlgorithmView.MENU_TEXT_ANALYSIS;
    } else if (extensionPoint.getLabel().equals("games")) {
        // $NON-NLS-1$
        label = AlgorithmView.MENU_TEXT_GAMES;
    } else if (extensionPoint.getLabel().equals("visuals")) {
        // $NON-NLS-1$
        label = AlgorithmView.MENU_TEXT_VISUALS;
    }
    PaletteDrawer category = new PaletteDrawer(label);
    category.setSmallIcon(ViewsPlugin.getImageDescriptor(TreeView.ICON_FOLDER));
    category.setLargeIcon(ViewsPlugin.getImageDescriptor(TreeView.ICON_FOLDER));
    invisibleRoot.add(category);
    IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
    for (IConfigurationElement element : elements) {
        // $NON-NLS-1$
        String name = element.getAttribute("name");
        // filter
        boolean show = true;
        for (String needle : needles) {
            if (// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            !needle.equals("") && !name.toLowerCase().matches(".*" + needle.toLowerCase() + ".*"))
                show = false;
        }
        if (show) {
            SelectionToolEntry paletteEntry = new SelectionToolEntry(element.getAttribute("name"), // $NON-NLS-1$ //$NON-NLS-2$
            "");
            paletteEntry.setSmallIcon(ViewsPlugin.getImageDescriptor(TreeView.ICON_ITEM_JCT));
            paletteEntry.setLargeIcon(ViewsPlugin.getImageDescriptor(TreeView.ICON_ITEM_JCT));
            paletteEntry.setUserModificationPermission(PaletteEntry.PERMISSION_NO_MODIFICATION);
            // $NON-NLS-1$
            paletteEntry.setType("");
            sortList.put(paletteEntry.getLabel(), paletteEntry);
        }
    }
    // attach items to the category
    for (PaletteEntry entry : sortList.values()) {
        category.add(entry);
    }
}
Also used : PaletteRoot(org.eclipse.gef.palette.PaletteRoot) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) SelectionToolEntry(org.eclipse.gef.palette.SelectionToolEntry) PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer) PaletteEntry(org.eclipse.gef.palette.PaletteEntry) TreeMap(java.util.TreeMap) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Example 10 with PaletteDrawer

use of org.eclipse.gef.palette.PaletteDrawer in project liferay-ide by liferay.

the class KaleoEditorPaletteFactory method _createPaletteEntries.

private static void _createPaletteEntries(PaletteContainer container, File paletteFile, ImageDescriptor image) {
    if (paletteFile.isDirectory()) {
        PaletteContainer newDrawer = new PaletteDrawer(paletteFile.getName());
        for (File file : paletteFile.listFiles()) {
            _createPaletteEntries(newDrawer, file, image);
        }
        container.add(newDrawer);
    } else {
        CreationFactory factory = new ScriptCreationFactory(paletteFile);
        String label = new Path(paletteFile.getName()).removeFileExtension().toPortableString();
        CombinedTemplateCreationEntry entry = new CombinedTemplateCreationEntry(label, label, factory, image, image);
        // entry.setToolClass( CreationTool.class );
        container.add(entry);
    }
}
Also used : Path(org.eclipse.core.runtime.Path) PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer) CreationFactory(org.eclipse.gef.requests.CreationFactory) File(java.io.File) CombinedTemplateCreationEntry(org.eclipse.gef.palette.CombinedTemplateCreationEntry) PaletteContainer(org.eclipse.gef.palette.PaletteContainer)

Aggregations

PaletteDrawer (org.eclipse.gef.palette.PaletteDrawer)28 CombinedTemplateCreationEntry (org.eclipse.gef.palette.CombinedTemplateCreationEntry)10 ArrayList (java.util.ArrayList)9 List (java.util.List)6 PaletteRoot (org.eclipse.gef.palette.PaletteRoot)6 TalendPaletteDrawer (org.talend.designer.core.ui.editor.palette.TalendPaletteDrawer)6 SelectionToolEntry (org.eclipse.gef.palette.SelectionToolEntry)4 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)4 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)4 Iterator (java.util.Iterator)3 DBSEntity (org.jkiss.dbeaver.model.struct.DBSEntity)3 IComponent (org.talend.core.model.components.IComponent)3 Node (org.talend.designer.core.ui.editor.nodes.Node)3 TalendCombinedTemplateCreationEntry (org.talend.designer.core.ui.editor.palette.TalendCombinedTemplateCreationEntry)3 HashMap (java.util.HashMap)2 Hashtable (java.util.Hashtable)2 LinkedList (java.util.LinkedList)2 TreeMap (java.util.TreeMap)2 EditPart (org.eclipse.gef.EditPart)2 ConnectionCreationToolEntry (org.eclipse.gef.palette.ConnectionCreationToolEntry)2