protected void fillContextMenuForAll()

in CasViewerEclipsePlugin/uimaj-ep-casviewer-core/src/main/java/org/apache/uima/casviewer/ui/internal/style/DefaultColorTreeSectionPart.java [614:694]


    protected void fillContextMenuForAll (IMenuManager menu, Object selectedObject)
    {        
        if (currentSelectedTreeItem == null) {
            return;
        }
        menu.add(new Separator());

        Action action = new Action() {
            public void run() 
            {
                if (currentSelectedTreeItem == null) {
                    return;
                }
                TypeStyle typeStyle = (TypeStyle) ((TypeNode) currentSelectedTreeItem.getData()).getObject();
                RGB value = null, fgRGB = null, bgRGB = null;

                if (currentSelectedColumn == 5) {
                    // Select/Deselect
                    typeStyle.setChecked(!typeStyle.isChecked());  
                    treeViewer.refresh();
                    return;
                } else if (currentSelectedColumn == 6) {
                    // Hide/Hidden
                    typeStyle.setHidden(!typeStyle.isHidden()); 
                    treeViewer.refresh();
                    return;
                } else {
                    fgRGB = typeStyle.getForeground()!=null? typeStyle.getForeground().getRGB():null;
                    bgRGB = typeStyle.getBackground()!=null? typeStyle.getBackground().getRGB():null;
                    if (currentSelectedColumn == 2) {
                        // Edit Foreground Color
                        value = fgRGB;
                    } else {
                        // Edit Background Color
                        value = bgRGB;
                    }                    
                }
                ColorDialog dialog = new ColorDialog(tree.getShell());
                if (value != null) {
                    dialog.setRGB(value);
                }
                value = dialog.open();
                if (value != null) {
                    if (currentSelectedColumn == 2) {
                        fgRGB = value;
                        tsStyle.updateTypeStyleColor(typeStyle, value, null);
                    } else {
                        bgRGB = value;
                        tsStyle.updateTypeStyleColor(typeStyle, null, value);
                    }
//                    tsStyle.setTypeStyle(typeStyle.getTypeName(),
//                                fgRGB, bgRGB);
                    treeViewer.refresh(); // currentSelectedTreeItem);
                    
                    // Notify listener
                    propertyChangeListener.propertyChange(new PropertyChangeEvent(typeStyle,
                            "", null, null));
                }
            }
        };
        TypeStyle typeStyle = (TypeStyle) ((TypeNode) currentSelectedTreeItem.getData()).getObject();
        String text;
        if (currentSelectedColumn == 5) {
            if (typeStyle.isChecked()) {
                text = "Deselect";
            } else {
                text = "Select";
            }
        } else if (currentSelectedColumn == 6) {
            if (typeStyle.isHidden()) {
                text = "Show";
            } else {
                text = "Hide";
            }
        } else {
            text = "Edit color...";
        }
        action.setText(text); 
        menu.add(action);
        action.setEnabled(true);
    }