Search in sources :

Example 1 with SelectionToolEntry

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

the class PaletteFactory method createControlGroup.

/**
	 * create control group
	 * 
	 * @param root PaletteRoot
	 * @return componentGroup
	 */
private static PaletteContainer createControlGroup(PaletteRoot root) {
    PaletteGroup componentGroup = new PaletteGroup(Messages.lblComponentGrp);
    List<ToolEntry> toolEntries = new ArrayList<ToolEntry>();
    ToolEntry toolEntry = new SelectionToolEntry();
    toolEntry.setLabel(Messages.lblSelectTool);
    toolEntry.setDescription(Messages.descSelectTool);
    toolEntries.add(toolEntry);
    root.setDefaultEntry(toolEntry);
    toolEntry = new ConnectionCreationToolEntry(Messages.lblConnectionTool, Messages.descConnectionTool, null, CubridManagerUIPlugin.getImageDescriptor("icons/replication/arrow.gif"), CubridManagerUIPlugin.getImageDescriptor("icons/replication/arrow.gif"));
    toolEntries.add(toolEntry);
    componentGroup.addAll(toolEntries);
    return componentGroup;
}
Also used : SelectionToolEntry(org.eclipse.gef.palette.SelectionToolEntry) ArrayList(java.util.ArrayList) ConnectionCreationToolEntry(org.eclipse.gef.palette.ConnectionCreationToolEntry) ToolEntry(org.eclipse.gef.palette.ToolEntry) SelectionToolEntry(org.eclipse.gef.palette.SelectionToolEntry) ConnectionCreationToolEntry(org.eclipse.gef.palette.ConnectionCreationToolEntry) PaletteGroup(org.eclipse.gef.palette.PaletteGroup)

Example 2 with SelectionToolEntry

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

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

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

the class PaletteViewerCreator method createPaletteRoot.

/**
	 * Create palette for ER canvas
	 * 
	 * @return
	 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public PaletteRoot createPaletteRoot(ERSchema erSchema) {
    paletteRoot = new PaletteRoot();
    paletteRoot.setLabel("");
    paletteRoot.setSmallIcon(null);
    paletteRoot.setLargeIcon(null);
    PaletteGroup controls = new PaletteGroup("Controls");
    paletteRoot.add(controls);
    ToolEntry tool = new SelectionToolEntry();
    controls.add(tool);
    paletteRoot.setDefaultEntry(tool);
    controls.add(new MarqueeToolEntry());
    PaletteDrawer drawer = new PaletteDrawer("New Component", null);
    List entries = new ArrayList();
    ConnectionCreationToolEntry connection = getConnectionEntry();
    CombinedTemplateCreationEntry tableEntry = getTableEntry(erSchema);
    entries.add(connection);
    entries.add(tableEntry);
    drawer.addAll(entries);
    paletteRoot.add(drawer);
    return paletteRoot;
}
Also used : PaletteRoot(org.eclipse.gef.palette.PaletteRoot) SelectionToolEntry(org.eclipse.gef.palette.SelectionToolEntry) PaletteDrawer(org.eclipse.gef.palette.PaletteDrawer) ArrayList(java.util.ArrayList) ConnectionCreationToolEntry(org.eclipse.gef.palette.ConnectionCreationToolEntry) ArrayList(java.util.ArrayList) List(java.util.List) MarqueeToolEntry(org.eclipse.gef.palette.MarqueeToolEntry) ToolEntry(org.eclipse.gef.palette.ToolEntry) SelectionToolEntry(org.eclipse.gef.palette.SelectionToolEntry) ConnectionCreationToolEntry(org.eclipse.gef.palette.ConnectionCreationToolEntry) PaletteGroup(org.eclipse.gef.palette.PaletteGroup) CombinedTemplateCreationEntry(org.eclipse.gef.palette.CombinedTemplateCreationEntry) MarqueeToolEntry(org.eclipse.gef.palette.MarqueeToolEntry)

Aggregations

SelectionToolEntry (org.eclipse.gef.palette.SelectionToolEntry)4 ArrayList (java.util.ArrayList)3 PaletteDrawer (org.eclipse.gef.palette.PaletteDrawer)3 PaletteRoot (org.eclipse.gef.palette.PaletteRoot)3 TreeMap (java.util.TreeMap)2 ConnectionCreationToolEntry (org.eclipse.gef.palette.ConnectionCreationToolEntry)2 PaletteGroup (org.eclipse.gef.palette.PaletteGroup)2 ToolEntry (org.eclipse.gef.palette.ToolEntry)2 List (java.util.List)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)1 CombinedTemplateCreationEntry (org.eclipse.gef.palette.CombinedTemplateCreationEntry)1 MarqueeToolEntry (org.eclipse.gef.palette.MarqueeToolEntry)1 PaletteEntry (org.eclipse.gef.palette.PaletteEntry)1 CommandInfo (org.jcryptool.core.operations.CommandInfo)1 ShadowAlgorithmHandler (org.jcryptool.core.operations.algorithm.ShadowAlgorithmHandler)1