[Home] DMelt member access. Java source code: org.jhotdraw.draw.action.FontChooserHandler
/**
* @(#)FontChooserHandler.java
*
* Copyright (c) 2008 by the original authors of JHotDraw and all its
* contributors. All rights reserved.
*
* You may not use, copy or modify this file, except in compliance with the
* license agreement you entered into with the copyright holders. For details
* see accompanying license terms.
*/
package org.jhotdraw.draw.action;
import javax.swing.undo.*;
import javax.swing.*;
import java.util.*;
import java.awt.*;
import java.beans.*;
import org.jhotdraw.draw.*;
import org.jhotdraw.gui.JFontChooser;
/**
* FontChooserHandler.
*
* @author Werner Randelshofer
* @version $Id: FontChooserHandler.java 717 2010-11-21 12:30:57Z rawcoder $
*/
public class FontChooserHandler extends AbstractSelectedAction
implements PropertyChangeListener {
protected AttributeKey key;
protected JFontChooser fontChooser;
protected JPopupMenu popupMenu;
protected int isUpdating;
//protected Map attributes;
/** Creates a new instance. */
public FontChooserHandler(DrawingEditor editor, AttributeKey key, JFontChooser fontChooser, JPopupMenu popupMenu) {
super(editor);
this.key = key;
this.fontChooser = fontChooser;
this.popupMenu = popupMenu;
fontChooser.addActionListener(this);
fontChooser.addPropertyChangeListener(this);
updateEnabledState();
}
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (evt.getActionCommand() == JFontChooser.APPROVE_SELECTION) {
applySelectedFontToFigures();
} else if (evt.getActionCommand() == JFontChooser.CANCEL_SELECTION) {
}
popupMenu.setVisible(false);
}
protected void applySelectedFontToFigures() {
final ArrayList selectedFigures = new ArrayList(getView().getSelectedFigures());
final ArrayList