Examples of WorkspaceEvent


Examples of edu.mit.blocks.workspace.WorkspaceEvent

        undoManager.setLimit(1000);
        textArea.getDocument().addUndoableEditListener(undoManager);
        textArea.addKeyListener(new KeyAdapter() {

            public void keyPressed(KeyEvent e) {
                Comment.this.workspace.notifyListeners(new WorkspaceEvent(Comment.this.workspace, getCommentSource().getParentWidget(), WorkspaceEvent.BLOCK_COMMENT_CHANGED));

                if (e.isControlDown() || ((e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0)) {
                    if (e.getKeyCode() == KeyEvent.VK_Z) {
                        try {
                            undoManager.undo();
                        } catch (CannotUndoException exception) {
                        }
                    } else if (e.getKeyCode() == KeyEvent.VK_Y) {
                        try {
                            undoManager.redo();
                        } catch (CannotRedoException exception) {
                        }
                    }
                }
            }
        });

        //initialize scrollPane
        scrollPane = new CTracklessScrollPane(textArea,
                ScrollPolicy.VERTICAL_BAR_AS_NEEDED,
                ScrollPolicy.HORIZONTAL_BAR_NEVER,
                10, this.borderColor, Comment.background);
        this.add(scrollPane, 0);

        //set up listeners
        CommentEventListener eventListener = new CommentEventListener();
        this.jCompDH = new JComponentDragHandler(workspace, this);
        this.addMouseListener(eventListener);
        this.addMouseMotionListener(eventListener);
        textArea.addMouseListener(new MouseAdapter() {

            /**
             * Implement MouseListener interface
             */
            public void mouseEntered(MouseEvent e) {
                Comment comment = Comment.this;
                comment.setPressed(true);
                comment.showOnTop();
            }
        });
        textArea.addFocusListener(eventListener);
        textArea.setEditable(true);
        this.reformComment();

        this.arrow = new CommentArrow(this);

        commentLabel = new CommentLabel(workspace, source.getBlockID());
        source.add(commentLabel);
        commentLabel.setActive(true);

        this.reformComment();

        workspace.notifyListeners(new WorkspaceEvent(workspace, getCommentSource().getParentWidget(), WorkspaceEvent.BLOCK_COMMENT_ADDED));
    }
View Full Code Here

Examples of edu.mit.blocks.workspace.WorkspaceEvent

    /**
     * Handle the removal of this comment from its comment source
     */
    public void delete() {
        workspace.notifyListeners(new WorkspaceEvent(workspace, getCommentSource().getParentWidget(), WorkspaceEvent.BLOCK_COMMENT_REMOVED));

        getParent().remove(arrow.arrow);
        setParent(null);

        if (commentSource instanceof RenderableBlock) {
View Full Code Here

Examples of edu.mit.blocks.workspace.WorkspaceEvent

                double ww = e.getX() > MINIMUM_WIDTH * zoom ? e.getX() : MINIMUM_WIDTH * zoom;
                double hh = e.getY() > MINIMUM_HEIGHT * zoom ? e.getY() : MINIMUM_HEIGHT * zoom;
                width = (int) ww;
                height = (int) hh;
                reformComment();
                workspace.notifyListeners(new WorkspaceEvent(workspace, getCommentSource().getParentWidget(), WorkspaceEvent.BLOCK_COMMENT_RESIZED));
            } else {
                jCompDH.mouseDragged(e);
                arrow.updateArrow();
                workspace.notifyListeners(new WorkspaceEvent(workspace, getCommentSource().getParentWidget(), WorkspaceEvent.BLOCK_COMMENT_MOVED));
            }
        }
View Full Code Here

Examples of edu.mit.blocks.workspace.WorkspaceEvent

            }

            int size = idList.size();
            for (int i = 0; i < size; i++) {
                workspace.notifyListeners(
                        new WorkspaceEvent(workspace, this.getParentWidget(),
                        argList.get(i).getBlockID(),
                        WorkspaceEvent.BLOCK_ADDED, true));

                //must call this method to update the dimensions of this
                //TODO ria in the future would be good to just link the default args
View Full Code Here

Examples of edu.mit.blocks.workspace.WorkspaceEvent

                        }

                        // drop the block and connect its link
                        stopDragging(this, widget);
                        link.connect();
                        workspace.notifyListeners(new WorkspaceEvent(workspace, widget, link, WorkspaceEvent.BLOCKS_CONNECTED));
                        workspace.getEnv().getRenderableBlock(link.getSocketBlockID()).moveConnectedBlocks();
                    }

                    //set the locations for X and Y based on zoom at 1.0
                    this.unzoomedX = this.calculateUnzoomedX(this.getX());
                    this.unzoomedY = this.calculateUnzoomedY(this.getY());

                    workspace.notifyListeners(new WorkspaceEvent(workspace, widget, link, WorkspaceEvent.BLOCK_MOVED, true));
                    if (widget instanceof MiniMap) {
                        workspace.getMiniMap().animateAutoCenter(this);
                    }
                }
            }           
View Full Code Here

Examples of edu.mit.blocks.workspace.WorkspaceEvent

                        link.disconnect();
                        //socket is removed internally from block's socket list if socket is expandable
                        workspace.getEnv().getRenderableBlock(parent.getBlockID()).blockDisconnected(socket);

                        //NOTIFY WORKSPACE LISTENERS OF DISCONNECTION
                        workspace.notifyListeners(new WorkspaceEvent(workspace, widget, link, WorkspaceEvent.BLOCKS_DISCONNECTED));
                    }
                    startDragging(this, widget);
                }

                // drag this block and all attached to it
View Full Code Here

Examples of edu.mit.blocks.workspace.WorkspaceEvent

    public void mouseClicked(MouseEvent e) {
        if (SwingUtilities.isLeftMouseButton(e)) {
            dragHandler.mouseClicked(e);
            if (e.getClickCount() == 2 && !dragging) {
                workspace.notifyListeners(new WorkspaceEvent(workspace, this.getParentWidget(), this.getBlockID(), WorkspaceEvent.BLOCK_STACK_COMPILED));
            }
        }
    }
View Full Code Here

Examples of edu.mit.blocks.workspace.WorkspaceEvent

                    }
                }
            }
            RenderableBlock rb = workspace.getEnv().getRenderableBlock(blockID);
            if (rb != null) {
                workspace.notifyListeners(new WorkspaceEvent(workspace, rb.getParentWidget(), blockID, WorkspaceEvent.BLOCK_RENAMED));
            }
        }
    }
View Full Code Here

Examples of edu.mit.blocks.workspace.WorkspaceEvent

        if (widget.hasSiblings()) {
            Block oldBlock = workspace.getEnv().getBlock(blockID);
            oldBlock.changeGenusTo(genus);
            RenderableBlock rb = workspace.getEnv().getRenderableBlock(blockID);
            rb.repaintBlock();
            workspace.notifyListeners(new WorkspaceEvent(workspace, rb.getParentWidget(), blockID, WorkspaceEvent.BLOCK_GENUS_CHANGED));
        }
    }
View Full Code Here

Examples of edu.mit.blocks.workspace.WorkspaceEvent

                            workspace.getEnv().getBlock(afterBlockID),
                            parentConnectorToBlock,
                            workspace.getEnv().getBlock(afterBlockID).getBeforeConnector());
                    if (link != null) {
                        link.connect();
                        workspace.notifyListeners(new WorkspaceEvent(
                                workspace,
                                workspace.getEnv().getRenderableBlock(link.getPlugBlockID()).getParentWidget(),
                                link, WorkspaceEvent.BLOCKS_CONNECTED));
                        workspace.getEnv().getRenderableBlock(link.getPlugBlockID()).repaintBlock();
                        workspace.getEnv().getRenderableBlock(link.getPlugBlockID()).repaint();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.