Package org.openquark.gems.client.valueentry

Examples of org.openquark.gems.client.valueentry.ValueEntryPanel$VEPFocusListener


                // Rectangular..
                DisplayedGemShape.InnerComponentInfo info = new DisplayedGemShape.InnerComponentInfo() {

                    public Rectangle getBounds() {
                        // Check for the case where the panel is not created yet..
                        ValueEntryPanel valueEntryPanel = getTableTopPanel().getValueEntryPanel(valueGem);
                        if (valueEntryPanel == null) {
                            return new Rectangle();
                        }
                        return valueEntryPanel.getBounds();
                    }

                    public void paint(TableTop tableTop, Graphics2D g2d) {
                        // Paint a fake VEP image so that the VEP can appear below other gems that might obscure this one.
                        ValueEntryPanel valueEntryPanel = tableTop.getTableTopPanel().getValueEntryPanel(valueGem);
                        Rectangle bounds = valueEntryPanel.getBounds();
                        Graphics vepGraphics = g2d.create(bounds.x, bounds.y, bounds.width, bounds.height);

                        // For some reason you can't just say vep.paint(vepGraphics)..
                        valueEntryPanel.paintOnTableTop(vepGraphics);
                        vepGraphics.dispose();
                    }

                    public List<Rectangle> getInputNameLabelBounds() {
                        return null;
View Full Code Here


     * This adds a value entry panel for use in editing the value for a value gem.
     * @param valueGem the value gem in question.
     */
    void handleValueGemAdded(ValueGem valueGem) {
       
        ValueEntryPanel valueEntryPanel = getValueEntryPanel(valueGem);
       
        // Initially not visible until the user selects the gem.
        valueEntryPanel.setVisible(false);
       
        // Update the position of the panel.
        updateValueGemPanelLocation(valueGem);

        // Add the panel to this component..
        TableTopPanel.this.add(valueEntryPanel);

        // Have to reset closing flag if the gem has been previously placed (eg. add gem, undo, add gem again).
        valueEntryPanel.setEditorIsClosing(false);

        // Add to the hierarchy manager.
        gemCutter.getValueEditorHierarchyManager().addTopValueEditor(valueEntryPanel);
        TableTopPanel.this.revalidate();
    }
View Full Code Here

            final ValueEditorHierarchyManager valueEditorHierarchyManager = gemCutter.getValueEditorHierarchyManager();
            ValueEditorManager valueEditorManager = valueEditorHierarchyManager.getValueEditorManager();
            ValueNode valueNode = valueGem.getValueNode();
   
            // Create the value entry panel.
            final ValueEntryPanel valueEntryPanel =
                (ValueEntryPanel)valueEditorManager.getValueEditorDirector().getRootValueEditor(valueEditorHierarchyManager,
                                                                                                valueNode, null, 0, null);
           
            // Add it to the map.
            valueGemPanelMap.put(valueGem, valueEntryPanel);
           
            // add a listener to propagate changes in the value gem to the VEP.
            valueGem.addValueChangeListener(new ValueGemChangeListener() {
                public void valueChanged(ValueGemChangeEvent e) {
                    ValueGem valueGem = (ValueGem)e.getSource();
                    valueEditorHierarchyManager.collapseHierarchy(valueEntryPanel, false);
                    valueEntryPanel.changeOwnerValue(valueGem.getValueNode());
                    valueEntryPanel.setSize(valueEntryPanel.getPreferredSize());
                    valueEntryPanel.revalidate();
                }
            });
   
            // Set size of the panel.
            valueEntryPanel.setSize(valueEntryPanel.getPreferredSize());
           
            // Add a listener to propagate changes in the VEP to the value gem.
            valueEntryPanel.addValueEditorListener(new ValueEditorAdapter() {
                public void valueCommitted(ValueEditorEvent evt) {
                    ValueNode oldValue = evt.getOldValue();
                    ValueNode newValue = ((ValueEntryPanel)evt.getSource()).getValueNode();
   
                    if (!oldValue.sameValue(newValue)) {
                        valueGem.changeValue(newValue);
                    }
                }
            });
   
            // Add a listener so that a change in the size of the VEP will trigger a change the size of the displayed gem.
            valueEntryPanel.addComponentListener(new ComponentAdapter() {
   
                // change the size of the displayed value gem if the VEP is resized
                public void componentResized(ComponentEvent e) {
                    tableTop.getDisplayedGem(valueGem).sizeChanged();
                }
   
                // Re-position displayed gem if the VEP moves
                // This will happen if the VEP size changes (as a result of a type change), and its size is clamped to the parent's bounds.
                // eg. stick a new VEP on the right edge of the TableTop, and change its type to String.
                public void componentMoved(ComponentEvent e) {
                    Point vepLocation = valueEntryPanel.getLocation();
                    int newX = vepLocation.x - DisplayConstants.BEVEL_WIDTH_X - 1;
                    int newY = vepLocation.y - DisplayConstants.BEVEL_WIDTH_Y - 1;
   
                    Point newPoint = new Point(newX, newY);
                    tableTop.getDisplayedGem(valueGem).setLocation(newPoint);
                }
            });
   
            // Set the vep's context for type switching.
            valueEntryPanel.setContext(new ValueEditorContext() {
                public TypeExpr getLeastConstrainedTypeExpr() {
                    return tableTop.getGemGraph().getLeastConstrainedValueType(valueGem, tableTop.getTypeCheckInfo());
                }
            });
           
            // Set it up so that VEP commits are handled as user edits.
            valueEntryPanel.addValueEditorListener(new ValueEditorAdapter() {
                public void valueCommitted(ValueEditorEvent evt) {
                    tableTop.handleValueGemCommitted(valueGem, evt.getOldValue(), valueEntryPanel.getValueNode());
                }
            });
        }

        return valueGemPanelMap.get(valueGem);
View Full Code Here

    void setValueGemsEnabled(boolean enable) {
        Set<Gem> gemSet = tableTop.getGemGraph().getGems();
       
        for (final ValueGem valueGem : valueGemPanelMap.keySet()) {
            if (gemSet.contains(valueGem)) {
                ValueEntryPanel vep = getValueEntryPanel(valueGem);
                vep.setEditable(enable);

                // Make sure the value panels change colour accordingly.
                repaint(vep.getBounds());
            }
        }
    }
View Full Code Here

    void revalidateValueGemPanels() {
        Set<Gem> gemSet = tableTop.getGemGraph().getGems();
       
        for (final ValueGem valueGem : valueGemPanelMap.keySet()) {
            if (gemSet.contains(valueGem)) {
                ValueEntryPanel valueEntryPanel = getValueEntryPanel(valueGem);
               
                valueEntryPanel.refreshDisplay();
   
                // If a value gem is connected to a broken code gem, its least constrained type
                // will be null. In that case disable editing it.
                valueEntryPanel.setEditable(valueEntryPanel.getContext().getLeastConstrainedTypeExpr() != null);
   
                // Repaint the value gem ghost image to display the right value entry panel.
                repaint(tableTop.getDisplayedGem(valueGem).getBounds());
            }
        }
View Full Code Here

                text.append(GemCutterMessages.getString("ResultTypeToolTip", tableTop.getGemGraph().getTypeString(gem.getResultType(), namingPolicy)));
                text.append("</html>");
                toolTip = text.toString();

            } else if (gem instanceof ValueGem) {
                ValueEntryPanel vep = getValueEntryPanel((ValueGem)gem);
                Point vepPoint = SwingUtilities.convertPoint(this, where, vep);
                toolTip = vep.getToolTipText(vepPoint);
            }
        }
       
        return toolTip;
    }
View Full Code Here

            // Test if we are over a gem part
            DisplayedPart partUnder = tableTop.getGemPartUnder(e.getPoint());
           
            // If we are dragging over a VEP make sure to display the correct cursor.
            if (valueEntryPanelHit(e.getPoint())) {
                ValueEntryPanel vep = getValueEntryPanel((ValueGem)partUnder.getGem());
                Point vepPoint = SwingUtilities.convertPoint(TableTopPanel.this, e.getPoint(), vep);
                setCursor(vep.getCursor(vepPoint));
               
            } else {
                setCursor(Cursor.getDefaultCursor());
            }
           
View Full Code Here

TOP

Related Classes of org.openquark.gems.client.valueentry.ValueEntryPanel$VEPFocusListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.