Example usage for java.awt Font getStyle

List of usage examples for java.awt Font getStyle

Introduction

In this page you can find the example usage for java.awt Font getStyle.

Prototype

public int getStyle() 

Source Link

Document

Returns the style of this Font .

Usage

From source file:org.openmicroscopy.shoola.agents.fsimporter.util.FileImportComponent.java

/**
 * Adds the specified files to the list of import data.
 * //from   w  w  w . jav  a2 s. c  om
 * @param files The files to import.
 */
private void insertFiles(Map<File, StatusLabel> files) {
    resultIndex = ImportStatus.SUCCESS;
    if (files == null || files.size() == 0)
        return;
    components = new HashMap<File, FileImportComponent>();

    Entry<File, StatusLabel> entry;
    Iterator<Entry<File, StatusLabel>> i = files.entrySet().iterator();
    FileImportComponent c;
    File f;
    DatasetData d = dataset;
    Object node = refNode;
    if (importable.isFolderAsContainer()) {
        node = null;
        d = new DatasetData();
        d.setName(getFile().getName());
    }
    ImportableFile copy;
    while (i.hasNext()) {
        entry = i.next();
        f = entry.getKey();
        copy = importable.copy();
        copy.setFile(f);
        c = new FileImportComponent(copy, browsable, singleGroup, getIndex(), tags);
        if (f.isFile()) {
            c.setLocation(data, d, node);
            c.setParent(this);
        }
        c.setType(getType());
        attachListeners(c);
        c.setStatusLabel(entry.getValue());
        entry.getValue().addPropertyChangeListener(this);
        components.put((File) entry.getKey(), c);
    }

    removeAll();
    pane = EditorUtil.createTaskPane(getFile().getName());
    pane.setCollapsed(false);

    IconManager icons = IconManager.getInstance();
    pane.setIcon(icons.getIcon(IconManager.DIRECTORY));
    Font font = pane.getFont();
    pane.setFont(font.deriveFont(font.getStyle(), font.getSize() - 2));
    layoutEntries(false);
    double[][] size = { { TableLayout.FILL }, { TableLayout.PREFERRED } };
    setLayout(new TableLayout(size));
    add(pane, new TableLayoutConstraints(0, 0));
    validate();
    repaint();
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.AnnotationDataUI.java

/**
 * Creates a menu item.//w  ww  .j  a  v a 2s  .c  o  m
 * 
 * @param index The index associated to the item.
 * @return See above.
 */
private JCheckBoxMenuItem createMenuItem(int index) {
    JCheckBoxMenuItem item = new JCheckBoxMenuItem(NAMES[index]);
    Font f = item.getFont();
    item.setFont(f.deriveFont(f.getStyle(), f.getSize() - 2));
    item.setSelected(filter == index);
    item.addActionListener(this);
    item.setActionCommand("" + index);
    return item;
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.AnnotationDataUI.java

/** Initializes the components composing the display. */
private void initComponents() {
    setLayout(new BorderLayout());
    setBackground(UIUtilities.BACKGROUND);
    setBorder(new SeparatorOneLineBorder());

    toReplace = new ArrayList<FileAnnotationData>();
    IconManager icons = IconManager.getInstance();
    filter = SHOW_ALL;/* w  w w  .  jav  a2s .  co m*/
    filterButton = new JButton(NAMES[SHOW_ALL]);
    filterButton.setToolTipText("Filter tags and attachments.");
    UIUtilities.unifiedButtonLookAndFeel(filterButton);
    Font font = filterButton.getFont();
    filterButton.setFont(font.deriveFont(font.getStyle(), font.getSize() - 2));

    filterButton.setIcon(icons.getIcon(IconManager.UP_DOWN_9_12));

    filterButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    filterButton.addMouseListener(new MouseAdapter() {

        /** 
         * Brings up the menu. 
         * @see MouseListener#mouseReleased(MouseEvent)
         */
        public void mouseReleased(MouseEvent me) {
            Object source = me.getSource();
            if (source instanceof Component)
                displayMenu((Component) source, me.getPoint());
        }

    });

    otherRating = new JLabel();
    otherRating.setBackground(UIUtilities.BACKGROUND_COLOR);
    font = otherRating.getFont();
    otherRating.setFont(font.deriveFont(Font.ITALIC, font.getSize() - 2));
    content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    content.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    tagFlag = false;
    docFlag = false;
    otherFlag = false;
    tagNames = new ArrayList<String>();
    tagsDocList = new ArrayList<DocComponent>();
    filesDocList = new ArrayList<DocComponent>();
    otherList = new ArrayList<DocComponent>();
    existingTags = new HashMap<String, TagAnnotationData>();

    addTagsButton = new JButton(icons.getIcon(IconManager.PLUS_12));
    UIUtilities.unifiedButtonLookAndFeel(addTagsButton);
    addTagsButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    addTagsButton.setToolTipText("Add Tags.");
    addTagsButton.addActionListener(controller);
    addTagsButton.setActionCommand("" + EditorControl.ADD_TAGS);
    addDocsButton = new JButton(icons.getIcon(IconManager.PLUS_12));
    addDocsButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    addDocsButton.setToolTipText("Attach a document.");
    addDocsButton.addMouseListener(new MouseAdapter() {

        public void mouseReleased(MouseEvent e) {
            if (addDocsButton.isEnabled()) {
                Point p = e.getPoint();
                createDocSelectionMenu().show(addDocsButton, p.x, p.y);
            }
        }

    });
    UIUtilities.unifiedButtonLookAndFeel(addDocsButton);

    removeTagsButton = new JButton(icons.getIcon(IconManager.MINUS_12));
    UIUtilities.unifiedButtonLookAndFeel(removeTagsButton);
    removeTagsButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    removeTagsButton.setToolTipText("Remove Tags.");
    removeTagsButton.addMouseListener(controller);
    removeTagsButton.setActionCommand("" + EditorControl.REMOVE_TAGS);

    removeDocsButton = new JButton(icons.getIcon(IconManager.MINUS_12));
    UIUtilities.unifiedButtonLookAndFeel(removeDocsButton);
    removeDocsButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    removeDocsButton.setToolTipText("Remove Attachments.");
    removeDocsButton.addMouseListener(controller);
    removeDocsButton.setActionCommand("" + EditorControl.REMOVE_DOCS);

    removeOtherAnnotationsButton = new JButton(icons.getIcon(IconManager.MINUS_12));
    UIUtilities.unifiedButtonLookAndFeel(removeOtherAnnotationsButton);
    removeOtherAnnotationsButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    removeOtherAnnotationsButton.setToolTipText("Remove Annotations.");
    removeOtherAnnotationsButton.addMouseListener(controller);
    removeOtherAnnotationsButton.setActionCommand("" + EditorControl.REMOVE_OTHER_ANNOTATIONS);

    selectedValue = 0;
    initialValue = selectedValue;
    rating = new RatingComponent(selectedValue, RatingComponent.MEDIUM_SIZE);
    rating.setOpaque(false);
    rating.setBackground(UIUtilities.BACKGROUND_COLOR);
    rating.addPropertyChangeListener(this);
    unrateButton = new JButton(icons.getIcon(IconManager.MINUS_12));
    UIUtilities.unifiedButtonLookAndFeel(unrateButton);
    unrateButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    unrateButton.setToolTipText("Unrate.");
    unrateButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            rating.setValue(0);
            view.saveData(true);
        }
    });
    tagsPane = new JPanel();
    tagsPane.setLayout(new BoxLayout(tagsPane, BoxLayout.Y_AXIS));
    tagsPane.setBackground(UIUtilities.BACKGROUND_COLOR);
    DocComponent doc = new DocComponent(null, model);
    tagsDocList.add(doc);
    tagsPane.add(doc);
    docPane = new JPanel();
    docPane.setLayout(new BoxLayout(docPane, BoxLayout.Y_AXIS));
    docPane.setBackground(UIUtilities.BACKGROUND_COLOR);
    docRef = docPane;
    doc = new DocComponent(null, model);
    filesDocList.add(doc);
    docPane.add(doc);
    publishedBox = new JCheckBox();
    publishedBox.setBackground(UIUtilities.BACKGROUND_COLOR);
    publishedBox.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            firePropertyChange(EditorControl.SAVE_PROPERTY, Boolean.FALSE, Boolean.TRUE);
        }
    });

    mapsPane = new MapAnnotationsComponent(model, view);

    otherPane = new JPanel();
    otherPane.setLayout(new GridBagLayout());
    otherPane.setBackground(UIUtilities.BACKGROUND_COLOR);
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java

/** Initializes the components composing this display. */
private void initComponents() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setBackground(UIUtilities.BACKGROUND_COLOR);
    Font f;
    parentLabel = new JLabel();
    f = parentLabel.getFont();//from w ww . j  a  va2  s .  c  om
    Font newFont = f.deriveFont(f.getStyle(), f.getSize() - 2);
    parentLabel.setOpaque(false);
    parentLabel.setFont(newFont);
    parentLabel.setBackground(UIUtilities.BACKGROUND_COLOR);
    gpLabel = new JLabel();
    gpLabel.setOpaque(false);
    gpLabel.setFont(newFont);
    gpLabel.setBackground(UIUtilities.BACKGROUND_COLOR);

    wellLabel = new JLabel();
    wellLabel.setOpaque(false);
    wellLabel.setFont(newFont);
    wellLabel.setBackground(UIUtilities.BACKGROUND_COLOR);

    idLabel = UIUtilities.setTextFont("");
    idLabel.setName("ID label");
    inplaceIcon = new JLabel(IconManager.getInstance().getIcon(IconManager.INPLACE_IMPORT));
    ClickableTooltip inplaceIconTooltip = new ClickableTooltip(INPLACE_IMPORT_TOOLTIP_TEXT,
            createInplaceIconAction());
    inplaceIconTooltip.attach(inplaceIcon);

    ownerLabel = new JLabel();
    ownerLabel.setBackground(UIUtilities.BACKGROUND_COLOR);
    namePane = createTextPane();
    namePane.setEditable(false);
    editableName = false;
    typePane = createTextPane();
    typePane.setEditable(false);
    namePane.addFocusListener(this);
    f = namePane.getFont();
    newFont = f.deriveFont(f.getStyle(), f.getSize() - 2);

    descriptionWiki = new OMEWikiComponent(false);
    descriptionWiki.installObjectFormatters();
    descriptionWiki.setFont(newFont);
    descriptionWiki.setEnabled(false);
    descriptionWiki.setAllowOneClick(true);
    descriptionWiki.addFocusListener(this);
    descriptionWiki.addPropertyChangeListener(this);

    defaultBorder = namePane.getBorder();
    namePane.setFont(f.deriveFont(Font.BOLD));
    typePane.setFont(f.deriveFont(Font.BOLD));
    typePane.setFont(f.deriveFont(f.getStyle(), f.getSize() - 2));

    f = parentLabel.getFont();
    parentLabel.setFont(f.deriveFont(Font.BOLD));
    parentLabel.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    f = gpLabel.getFont();
    gpLabel.setFont(f.deriveFont(Font.BOLD));
    gpLabel.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    f = wellLabel.getFont();
    wellLabel.setFont(f.deriveFont(Font.BOLD));
    wellLabel.setForeground(UIUtilities.DEFAULT_FONT_COLOR);

    f = ownerLabel.getFont();
    ownerLabel.setFont(f.deriveFont(Font.BOLD, f.getSize() - 2));
    channelsArea = UIUtilities.createComponent(null);

    channelsPane = channelsArea;
    IconManager icons = IconManager.getInstance();
    editName = new JButton(icons.getIcon(IconManager.EDIT_12));
    formatButton(editName, EDIT_NAME_TEXT, EDIT_NAME);
    descriptionButtonEdit = new JButton(icons.getIcon(IconManager.EDIT_12));
    formatButton(descriptionButtonEdit, EDIT_DESC_TEXT, EDIT_DESC);
    editChannel = new JButton(icons.getIcon(IconManager.EDIT_12));
    formatButton(editChannel, EDIT_CHANNEL_TEXT, EDIT_CHANNEL);
    editChannel.setEnabled(false);
    descriptionWiki.setEnabled(false);
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java

/**
 * Lays out the plate fields./*from w w  w.  j  a v a2s. com*/
 * 
 * @param plate The plate to handle.
 * @return See above.
 */
private JPanel layoutPlateContent(PlateData plate) {
    JPanel content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    content.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    content.setLayout(new GridBagLayout());
    JLabel l = new JLabel();
    Font font = l.getFont();
    int size = font.getSize() - 2;

    Map<JLabel, JComponent> components = new LinkedHashMap<JLabel, JComponent>();
    String v = plate.getPlateType();
    JLabel value;
    if (v != null && v.trim().length() > 0) {
        l = UIUtilities.setTextFont(EditorUtil.TYPE, Font.BOLD, size);
        value = UIUtilities.createComponent(null);
        value.setFont(font.deriveFont(font.getStyle(), size));
        value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
        value.setText(v);
        components.put(l, value);
    }
    l = UIUtilities.setTextFont(EditorUtil.EXTERNAL_IDENTIFIER, Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    value.setFont(font.deriveFont(font.getStyle(), size));
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    v = plate.getExternalIdentifier();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);
    l = UIUtilities.setTextFont(EditorUtil.STATUS, Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    value.setFont(font.deriveFont(font.getStyle(), size));
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    v = plate.getStatus();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);
    layoutComponents(content, components);
    return content;
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java

/**
 * Lays out the well fields./* w w w. jav a  2 s  .c o m*/
 * 
 * @param well The well to handle.
 * @return See above.
 */
private JPanel layoutWellContent(WellData well) {
    JPanel content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    content.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    content.setLayout(new GridBagLayout());
    JLabel l = new JLabel();
    Font font = l.getFont();
    int size = font.getSize() - 2;

    Map<JLabel, JComponent> components = new LinkedHashMap<JLabel, JComponent>();
    String v = well.getWellType();
    JLabel value;
    if (v != null && v.trim().length() > 0) {
        l = UIUtilities.setTextFont(EditorUtil.TYPE, Font.BOLD, size);
        value = UIUtilities.createComponent(null);
        value.setFont(font.deriveFont(font.getStyle(), size));
        value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
        value.setText(v);
        components.put(l, value);
    }
    l = UIUtilities.setTextFont(EditorUtil.EXTERNAL_DESCRIPTION, Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    value.setFont(font.deriveFont(font.getStyle(), size));
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    v = well.getExternalDescription();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);
    l = UIUtilities.setTextFont(EditorUtil.STATUS, Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    value.setFont(font.deriveFont(font.getStyle(), size));
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    v = well.getStatus();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);
    layoutComponents(content, components);
    return content;
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java

/**
 * Lays out the screen fields.//from   www.jav  a 2s . c o m
 * 
 * @param screen The screen to handle.
 * @return See above.
 */
private JPanel layoutScreenContent(ScreenData screen) {
    JPanel content = new JPanel();
    content.setBackground(UIUtilities.BACKGROUND_COLOR);
    content.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    content.setLayout(new GridBagLayout());
    JLabel l = new JLabel();
    Font font = l.getFont();
    int size = font.getSize() - 2;

    Map<JLabel, JComponent> components = new LinkedHashMap<JLabel, JComponent>();

    l = UIUtilities.setTextFont("Protocol Identifier:", Font.BOLD, size);
    JLabel value = UIUtilities.createComponent(null);
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    String v = screen.getProtocolIdentifier();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);

    l = UIUtilities.setTextFont("Protocol Description:", Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    value.setFont(font.deriveFont(font.getStyle(), size));
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    v = screen.getProtocolDescription();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);

    l = UIUtilities.setTextFont("ReagentSet Identifier:", Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    value.setFont(font.deriveFont(font.getStyle(), size));
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    v = screen.getReagentSetIdentifier();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);

    l = UIUtilities.setTextFont("ReagentSet Description:", Font.BOLD, size);
    value = UIUtilities.createComponent(null);
    value.setForeground(UIUtilities.DEFAULT_FONT_COLOR);
    value.setFont(font.deriveFont(font.getStyle(), size));
    v = screen.getReagentSetDescripion();
    if (v == null || v.length() == 0)
        v = NO_SET_TEXT;
    value.setText(v);
    components.put(l, value);

    layoutComponents(content, components);
    return content;
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.UserProfile.java

/** Initializes the components composing this display. */
private void initComponents() {
    admin = false;//from   www . j  a v  a  2  s. c  o  m
    active = false;
    groupOwner = false;

    userPicture = new UserProfileCanvas();
    userPicture.setBackground(UIUtilities.BACKGROUND_COLOR);

    IconManager icons = IconManager.getInstance();
    changePhoto = new JLabel("Change Photo");
    changePhoto.setToolTipText("Upload your photo.");
    changePhoto.setForeground(UIUtilities.HYPERLINK_COLOR);
    Font font = changePhoto.getFont();
    changePhoto.setFont(font.deriveFont(font.getStyle(), font.getSize() - 2));
    changePhoto.setBackground(UIUtilities.BACKGROUND_COLOR);
    deletePhoto = new JButton(icons.getIcon(IconManager.DELETE_12));
    boolean b = canModifyPhoto();
    changePhoto.setVisible(b);
    deletePhoto.setToolTipText("Delete the photo.");
    deletePhoto.setBackground(UIUtilities.BACKGROUND_COLOR);
    UIUtilities.unifiedButtonLookAndFeel(deletePhoto);
    deletePhoto.setVisible(false);
    loginArea = new JTextField();
    boolean a = MetadataViewerAgent.isAdministrator();
    loginArea.setEnabled(a);
    loginArea.setEditable(a);
    adminBox = new JCheckBox();
    adminBox.setVisible(false);
    adminBox.setBackground(UIUtilities.BACKGROUND_COLOR);
    ownerBox = new JCheckBox();
    ownerBox.setBackground(UIUtilities.BACKGROUND_COLOR);
    activeBox = new JCheckBox();
    activeBox.setBackground(UIUtilities.BACKGROUND_COLOR);
    activeBox.setVisible(false);
    passwordButton = new JButton("Change password");
    passwordButton.setEnabled(false);
    passwordButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    passwordButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            changePassword();
        }
    });
    saveButton = new JButton("Save");
    saveButton.setEnabled(false);
    saveButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            GroupData g = getSelectedGroup();
            ExperimenterData exp = (ExperimenterData) model.getRefObject();
            if (exp.getDefaultGroup().getId() != g.getId())
                model.fireAdminSaving(g, true);
            view.saveData(true);
        }
    });
    manageButton = new JButton("Group");
    manageButton.setEnabled(false);
    manageButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    manageButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            manageGroup();
        }
    });
    passwordNew = new JPasswordField();
    passwordNew.setBackground(UIUtilities.BACKGROUND_COLOR);
    passwordConfirm = new JPasswordField();
    passwordConfirm.setBackground(UIUtilities.BACKGROUND_COLOR);
    oldPassword = new JPasswordField();
    oldPassword.setBackground(UIUtilities.BACKGROUND_COLOR);
    items = new HashMap<String, JTextField>();
    ExperimenterData user = (ExperimenterData) model.getRefObject();
    Collection<GroupData> groups = user.getGroups();

    GroupData defaultGroup = user.getDefaultGroup();

    groupsBox = new JComboBox();
    SelectableComboBoxModel m = new SelectableComboBoxModel();
    Iterator<GroupData> i = groups.iterator();
    GroupData g;
    Selectable<DataNode> node, selected = null;
    while (i.hasNext()) {
        g = i.next();
        if (!model.isSystemGroup(g.getId(), GroupData.USER)) {
            node = new Selectable<DataNode>(new DataNode(g), true);
            if (g.getId() == defaultGroup.getId())
                selected = node;
            m.addElement(node);
        }
    }
    groupsBox.setModel(m);
    if (selected != null)
        groupsBox.setSelectedItem(selected);
    permissionsPane = new PermissionsPane(defaultGroup.getPermissions(), UIUtilities.BACKGROUND_COLOR);
    permissionsPane.disablePermissions();

    ExperimenterData logUser = model.getCurrentUser();
    if (MetadataViewerAgent.isAdministrator()) {
        //Check that the user is not the one currently logged.
        oldPassword.setVisible(false);
        adminBox.setVisible(true);
        activeBox.setVisible(true);
        adminBox.addChangeListener(this);
        active = user.isActive();
        activeBox.setSelected(active);
        activeBox.setEnabled(!model.isSelf() && !model.isSystemUser(user.getId()));
        activeBox.addChangeListener(this);
        //indicate if the user is an administrator
        admin = isUserAdministrator();
        adminBox.setSelected(admin);
        adminBox.setEnabled(!model.isSelf() && !model.isSystemUser(user.getId()));
        ownerBox.addChangeListener(this);
        ownerBox.setEnabled(!model.isSystemUser(user.getId()));
    } else {
        ownerBox.setEnabled(false);
        passwordConfirm.getDocument().addDocumentListener(new DocumentListener() {

            /**
             * Allows the user to interact with the password controls
             * depending on the value entered.
             * @see DocumentListener#removeUpdate(DocumentEvent)
             */
            public void removeUpdate(DocumentEvent e) {
                handlePasswordEntered();
            }

            /**
             * Allows the user to interact with the password controls
             * depending on the value entered.
             * @see DocumentListener#insertUpdate(DocumentEvent)
             */
            public void insertUpdate(DocumentEvent e) {
                handlePasswordEntered();
            }

            /**
             * Required by the {@link DocumentListener} I/F but 
             * no-operation implementation in our case.
             * @see DocumentListener#changedUpdate(DocumentEvent)
             */
            public void changedUpdate(DocumentEvent e) {
            }
        });
    }
    passwordNew.getDocument().addDocumentListener(new DocumentListener() {

        /**
         * Allows the user to interact with the password controls
         * depending on the value entered.
         * @see DocumentListener#removeUpdate(DocumentEvent)
         */
        public void removeUpdate(DocumentEvent e) {
            handlePasswordEntered();
        }

        /**
         * Allows the user to interact with the password controls
         * depending on the value entered.
         * @see DocumentListener#insertUpdate(DocumentEvent)
         */
        public void insertUpdate(DocumentEvent e) {
            handlePasswordEntered();
        }

        /**
         * Required by the {@link DocumentListener} I/F but
         * no-operation implementation in our case.
         * @see DocumentListener#changedUpdate(DocumentEvent)
         */
        public void changedUpdate(DocumentEvent e) {
        }
    });
    if (user.getId() == logUser.getId()) {
        MouseAdapter adapter = new MouseAdapter() {

            /** Brings up a chooser to load the user image. */
            public void mouseReleased(MouseEvent e) {
                uploadPicture();
            }

        };
        changePhoto.addMouseListener(adapter);
        deletePhoto.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                model.deletePicture();
                setUserPhoto(null);
            }
        });
        if (groups.size() > 1) {
            groupsBox.addActionListener(new ActionListener() {

                /**
                 * Listens to the change of default group.
                 */
                public void actionPerformed(ActionEvent evt) {
                    GroupData g = getSelectedGroup();
                    //update the default group
                    permissionsPane.resetPermissions(g.getPermissions());
                    permissionsPane.disablePermissions();
                    setGroupOwner(g);
                    ExperimenterData exp = (ExperimenterData) model.getRefObject();
                    saveButton.setEnabled(exp.getDefaultGroup().getId() != g.getId());
                }
            });
        }
    }
}

From source file:org.openmicroscopy.shoola.agents.util.ui.ScriptingDialog.java

/**
 * Returns the component displaying the description of the script.
 *
 * @return See above.//w  w  w  .  j  av a 2  s .  com
 */
private JComponent buildDescriptionPane() {
    String description = script.getDescription();
    if (StringUtils.isBlank(description))
        return null;
    OMEWikiComponent area = new OMEWikiComponent(false);
    area.setEnabled(false);
    area.setText(description);
    JPanel content = new JPanel();
    content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
    JLabel label = UIUtilities.setTextFont(script.getName());
    Font f = label.getFont();
    label.setFont(f.deriveFont(f.getStyle(), f.getSize() + 2));
    content.add(UIUtilities.buildComponentPanel(label));
    content.add(Box.createVerticalStrut(5));
    JPanel p = UIUtilities.buildComponentPanel(area);
    p.setBackground(BG_COLOR);
    area.setBackground(BG_COLOR);
    content.add(p);
    return content;
}

From source file:org.openmicroscopy.shoola.agents.util.ui.ScriptingDialog.java

/**
 * Builds the component displaying the parameters.
 *
 * @return See above.//  www. jav a2 s.  co  m
 */
private JPanel buildBody() {
    JPanel p = new JPanel();
    p.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    double[] columns = { TableLayout.PREFERRED, 5, TableLayout.FILL };
    TableLayout layout = new TableLayout();
    layout.setColumn(columns);
    p.setLayout(layout);
    int row = 0;
    JComponent area = buildDescriptionPane();
    JComponent authorsPane = buildScriptDetails();
    if (area != null) {
        layout.insertRow(row, TableLayout.PREFERRED);
        p.add(area, "0," + row + ", 2, " + row);
        row++;
    }

    if (authorsPane != null) {
        layout.insertRow(row, TableLayout.PREFERRED);
        p.add(authorsPane, "0," + row + ", 2, " + row);
        row++;
    }
    layout.insertRow(row, 5);

    row++;
    Entry<String, ScriptComponent> entry;
    Iterator<Entry<String, ScriptComponent>> i = components.entrySet().iterator();
    ScriptComponent comp;
    int required = 0;
    while (i.hasNext()) {
        entry = i.next();
        comp = entry.getValue();
        layout.insertRow(row, TableLayout.PREFERRED);
        comp.buildUI();
        if (comp.isRequired())
            required++;
        p.add(comp, "0," + row + ", 2, " + row);
        row++;
        layout.insertRow(row, 2);
        row++;
    }
    if (required > 0) {
        JLabel label = new JLabel(TEXT_END);
        Font font = label.getFont();
        label.setFont(font.deriveFont(font.getStyle(), font.getSize() - 2));
        label.setForeground(UIUtilities.REQUIRED_FIELDS_COLOR);
        layout.insertRow(row, TableLayout.PREFERRED);
        p.add(UIUtilities.buildComponentPanel(label), "0," + row + ",2, " + row);
    }

    JPanel controls = new JPanel();
    controls.setLayout(new BorderLayout(0, 0));
    controls.add(new JScrollPane(p), BorderLayout.CENTER);
    controls.add(buildControlPanel(), BorderLayout.SOUTH);
    return controls;
}