public void restoreCursor() { for (Iterator iter = dialogStack.iterator(); iter.hasNext(); ) { JDialog dlg = (JDialog) iter.next(); // TODO: RECUPERAR EL CURSOR dlg.setCursor(null); dlg.getGlassPane().setVisible(false); } }
/** @return */ public void setWaitCursor() { dialogCursors.clear(); for (Iterator iter = dialogStack.iterator(); iter.hasNext(); ) { JDialog dlg = (JDialog) iter.next(); dialogCursors.add(dlg.getCursor()); dlg.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); dlg.getGlassPane().setVisible(true); } }
static void showWaitDialog() { JLabel label = new JLabel("Finding classes..."); label.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, Color.BLUE)); label.setHorizontalAlignment(SwingConstants.CENTER); Font font = label.getFont().deriveFont(32f); label.setFont(font); dialog.add(label); dialog.setUndecorated(true); dialog.setAlwaysOnTop(true); dialog.setSize(300, 100); dialog.setLocationRelativeTo(null); dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); dialog.setVisible(true); }
// ====================================================== // ====================================================== private void treeMousePressed(java.awt.event.MouseEvent evt) { int mask = evt.getModifiers(); if ((mask & MouseEvent.BUTTON1_MASK) != 0) { TreePath selectedPath = getPathForLocation(evt.getX(), evt.getY()); if (selectedPath == null) return; DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectedPath.getPathComponent(selectedPath.getPathCount() - 1); Object o = node.getUserObject(); if (o instanceof String) { TransferHandler transfer = this.getTransferHandler(); transfer.exportAsDrag(this, evt, TransferHandler.COPY); dragged_node = node; parent.setCursor(renderer.getNodeCursor(node)); } } }
private void loadList() { final JDialog form = this; final ReadOnlyCellTableModel model = (ReadOnlyCellTableModel) subscriptionTable.getModel(); while (model.getRowCount() > 0) model.removeRow(0); form.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); Vector<String> vector = new Vector<String>(); vector.add("(loading... )"); vector.add(""); model.addRow(vector); ApplicationManager.getApplication() .invokeLater( new Runnable() { @Override public void run() { try { while (model.getRowCount() > 0) model.removeRow(0); subscriptionList = AzureRestAPIManager.getManager().getSubscriptionList(); if (subscriptionList != null && subscriptionList.size() > 0) { for (Subscription subs : subscriptionList) { Vector<String> row = new Vector<String>(); row.add(subs.getName()); row.add(subs.getId().toString()); model.addRow(row); } removeButton.setEnabled(true); } else { removeButton.setEnabled(false); } form.setCursor(Cursor.getDefaultCursor()); } catch (AzureCmdException e) { form.setCursor(Cursor.getDefaultCursor()); UIHelper.showException("Error getting subscription list", e); } } }); }
// ====================================================== // ====================================================== private void treeMouseReleased(java.awt.event.MouseEvent evt) { int mask = evt.getModifiers(); if ((mask & MouseEvent.BUTTON1_MASK) != 0) { if (dragged_node == null) return; TreePath selectedPath = getPathForLocation(evt.getX(), evt.getY()); if (selectedPath == null) if ((selectedPath = getUpperPath(evt.getX(), evt.getY())) == null) return; DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectedPath.getPathComponent(selectedPath.getPathCount() - 1); Object o = node.getUserObject(); int pos = 0; if (o instanceof String) { DefaultMutableTreeNode p_node = (DefaultMutableTreeNode) node.getParent(); pos = p_node.getIndex(node); node = p_node; } moveLeaf(node, dragged_node, pos); dragged_node = null; Cursor cursor = new Cursor(Cursor.DEFAULT_CURSOR); parent.setCursor(cursor); } }
/** * Creates and adds the edit panel for the currently selected annotation to the process renderer. */ private void createEditPanel() { final WorkflowAnnotation selected = model.getSelected(); Rectangle2D loc = selected.getLocation(); // panel containing buttons editPanel = new JPanel(); editPanel.setCursor(Cursor.getDefaultCursor()); editPanel.setLayout(new BoxLayout(editPanel, BoxLayout.LINE_AXIS)); updateEditPanelPosition(loc, false); editPanel.setOpaque(true); editPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); // consume mouse events so focus is not lost editPanel.addMouseListener( new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { e.consume(); } @Override public void mousePressed(MouseEvent e) { e.consume(); } @Override public void mouseClicked(MouseEvent e) { e.consume(); } }); // add alignment controls final List<JButton> alignmentButtonList = new LinkedList<JButton>(); for (AnnotationAlignment align : AnnotationAlignment.values()) { final Action action = align.makeAlignmentChangeAction(model, model.getSelected()); final JButton alignButton = new JButton(); alignButton.setIcon((Icon) action.getValue(Action.SMALL_ICON)); alignButton.setBorderPainted(false); alignButton.setBorder(null); alignButton.setFocusable(false); if (align == selected.getStyle().getAnnotationAlignment()) { alignButton.setBackground(Color.LIGHT_GRAY); } alignButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removeColorPanel(); colorButton.setBackground(null); for (JButton button : alignmentButtonList) { button.setBackground(null); } alignButton.setBackground(Color.LIGHT_GRAY); int caretPos = editPane.getCaretPosition(); // remember if we were at last position because doc length can change after 1st // save boolean lastPos = caretPos == editPane.getDocument().getLength(); int selStart = editPane.getSelectionStart(); int selEnd = editPane.getSelectionEnd(); // change alignment and save current comment action.actionPerformed(e); saveEdit(selected); // reload edit pane with changes editPane.setText(AnnotationDrawUtils.createStyledCommentString(selected)); // special handling for documents of length 1 to avoid not being able to type if (editPane.getDocument().getLength() == 1) { caretPos = 1; } else if (lastPos) { caretPos = editPane.getDocument().getLength(); } else { caretPos = Math.min(editPane.getDocument().getLength(), caretPos); } editPane.setCaretPosition(caretPos); if (selEnd - selStart > 0) { editPane.setSelectionStart(selStart); editPane.setSelectionEnd(selEnd); } editPane.requestFocusInWindow(); } }); editPanel.add(alignButton); alignmentButtonList.add(alignButton); } // add small empty space editPanel.add(Box.createHorizontalStrut(2)); // add color controls colorOverlay = new JDialog(ApplicationFrame.getApplicationFrame()); colorOverlay.setCursor(Cursor.getDefaultCursor()); colorOverlay .getRootPane() .setLayout(new BoxLayout(colorOverlay.getRootPane(), BoxLayout.LINE_AXIS)); colorOverlay.setUndecorated(true); colorOverlay.getRootPane().setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY)); colorOverlay.setFocusable(false); colorOverlay.setAutoRequestFocus(false); // consume mouse events so focus is not lost colorOverlay.addMouseListener( new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { e.consume(); } @Override public void mousePressed(MouseEvent e) { e.consume(); } @Override public void mouseClicked(MouseEvent e) { e.consume(); } }); for (final AnnotationColor color : AnnotationColor.values()) { final Action action = color.makeColorChangeAction(model, selected); JButton colChangeButton = new JButton(); colChangeButton.setText(null); colChangeButton.setBorderPainted(false); colChangeButton.setBorder(null); colChangeButton.setFocusable(false); final Icon icon = SwingTools.createIconFromColor( color.getColor(), Color.BLACK, 16, 16, new Rectangle2D.Double(1, 1, 14, 14)); colChangeButton.setIcon(icon); colChangeButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // change color and save current comment action.actionPerformed(e); saveEdit(selected); // set edit pane bg color editPane.requestFocusInWindow(); if (color == AnnotationColor.TRANSPARENT) { editPane.setBackground(Color.WHITE); } else { editPane.setBackground(color.getColorHighlight()); } // adapt color of main button, remove color panel colorButton.setIcon(icon); if (removeColorPanel()) { colorButton.setBackground(null); view.repaint(); } } }); colorOverlay.getRootPane().add(colChangeButton); } colorButton = new JButton("\u25BE"); colorButton.setBorderPainted(false); colorButton.setFocusable(false); AnnotationColor color = selected.getStyle().getAnnotationColor(); colorButton.setIcon( SwingTools.createIconFromColor( color.getColor(), Color.BLACK, 16, 16, new Rectangle2D.Double(1, 1, 14, 14))); colorButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (removeColorPanel()) { colorButton.setBackground(null); view.repaint(); return; } updateColorPanelPosition(); colorOverlay.setVisible(true); colorButton.setBackground(Color.LIGHT_GRAY); editPane.requestFocusInWindow(); view.repaint(); } }); editPanel.add(colorButton); // add separator JLabel separator = new JLabel() { private static final long serialVersionUID = 1L; @Override public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setColor(Color.LIGHT_GRAY); g2.drawLine(2, 0, 2, 20); } }; separator.setText(" "); // dummy text to show label editPanel.add(separator); // add delete button final JButton deleteButton = new JButton( I18N.getMessage(I18N.getGUIBundle(), "gui.action.workflow.annotation.delete.label")); deleteButton.setForeground(Color.RED); deleteButton.setContentAreaFilled(false); deleteButton.setFocusable(false); deleteButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { model.deleteAnnotation(selected); removeEditor(); } }); deleteButton.addMouseListener( new MouseAdapter() { @Override @SuppressWarnings({"unchecked", "rawtypes"}) public void mouseExited(MouseEvent e) { Font font = deleteButton.getFont(); Map attributes = font.getAttributes(); attributes.put(TextAttribute.UNDERLINE, -1); deleteButton.setFont(font.deriveFont(attributes)); } @SuppressWarnings({"unchecked", "rawtypes"}) @Override public void mouseEntered(MouseEvent e) { Font font = deleteButton.getFont(); Map attributes = font.getAttributes(); attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); deleteButton.setFont(font.deriveFont(attributes)); } }); editPanel.add(deleteButton); // add panel to view view.add(editPanel); }