Example usage for java.awt.event ActionEvent ActionEvent

List of usage examples for java.awt.event ActionEvent ActionEvent

Introduction

In this page you can find the example usage for java.awt.event ActionEvent ActionEvent.

Prototype

public ActionEvent(Object source, int id, String command) 

Source Link

Document

Constructs an ActionEvent object.

Usage

From source file:com.funambol.LDAP.admin.LDAPSyncSourceConfigPanel.java

/**
 * Create the panel//from w w  w .  j a  v a  2 s .c  o  m
 * @throws Exception if error occures during creation of the panel
 */
private void init() {
    // set layout
    this.setLayout(null);

    int startX = 14;
    int fontHeight = 18;
    int col1Size = 150;
    int col2X = startX + col1Size + 6; //170px 
    int col2Size = 350;
    int col3X = col2X + col2Size + 6; // 550
    int col3Size = 90;
    int chkboxSize = 18;
    // set properties of label, position and border
    // referred to the title of the panel
    titledBorder1 = new TitledBorder("");

    panelName.setFont(titlePanelFont);
    panelName.setText("Edit LDAP SyncSourceContacts");
    panelName.setBounds(new Rectangle(startX, 5, 316, 28));
    panelName.setAlignmentX(SwingConstants.CENTER);
    panelName.setBorder(titledBorder1);

    int baseline = 60;
    sourceUriLabel.setText("Source URI: ");
    sourceUriLabel.setToolTipText("Choose a unique word");
    sourceUriLabel.setFont(defaultFont);
    sourceUriLabel.setBounds(new Rectangle(startX, baseline, col1Size, fontHeight));
    sourceUriValue.setFont(FONT_ARIAL);
    sourceUriValue.setBounds(new Rectangle(col2X, baseline, col2Size, fontHeight));

    baseline += 30;
    nameLabel.setText("Name: ");
    nameLabel.setToolTipText("Choose a word and set this into your client in order to use this connector");
    nameLabel.setFont(defaultFont);
    nameLabel.setBounds(new Rectangle(startX, baseline, col1Size, fontHeight));
    nameValue.setFont(FONT_ARIAL);
    nameValue.setBounds(new Rectangle(col2X, baseline, col2Size, fontHeight));

    baseline += 30;
    typeLabel.setText("Type: ");
    typeLabel.setToolTipText("Only VCARD are supported, SIF is deprecated");
    typeLabel.setFont(defaultFont);
    typeLabel.setBounds(new Rectangle(startX, baseline, col1Size, fontHeight));
    typeValue.setBounds(new Rectangle(col2X, baseline, col2Size, fontHeight));

    baseline += 30;
    providerUrlLabel.setText("LDAP URI: ");
    providerUrlLabel.setToolTipText("eg. ldap://ldap.example.com , ldaps://ldap.example.com:390 ");
    providerUrlLabel.setFont(defaultFont);
    providerUrlLabel.setBounds(new Rectangle(startX, baseline, col1Size, fontHeight));
    providerUrlValue.setFont(FONT_ARIAL);
    providerUrlValue.setBounds(new Rectangle(col2X, baseline, col2Size, fontHeight));

    baseline += 30;
    ldapBaseLabel.setText("LDAP Base DN: ");
    ldapBaseLabel.setToolTipText(
            "This is used to define where to store/read user's data.\nRead install.txt notes to use parameters");
    ldapBaseLabel.setFont(defaultFont);
    ldapBaseLabel.setBounds(new Rectangle(startX, baseline, col1Size, fontHeight));
    ldapBaseValue.setFont(FONT_ARIAL);
    ldapBaseValue.setBounds(new Rectangle(col2X, baseline, col2Size, fontHeight));

    baseline += 30; // TODO contactDaoLabel, entryFilterLabel
    daoNameLabel.setText("DAO Class for converting item to LDAP");
    daoNameLabel.setToolTipText("piTypePerson, inetOrgPerson or organizationalPerson");
    daoNameLabel.setFont(defaultFont);
    daoNameLabel.setBounds(new Rectangle(startX, baseline, col1Size, fontHeight));
    daoNameValue.setFont(FONT_ARIAL);
    daoNameValue.setBounds(new Rectangle(col2X, baseline, col2Size, fontHeight));

    baseline += 30;
    entryFilterLabel.setText("Filter user by");
    entryFilterLabel
            .setToolTipText("A valid  LDAP search filter, eg: (&(objectclass=inetOrgPerson)(active=1))");
    entryFilterLabel.setFont(defaultFont);
    entryFilterLabel.setBounds(new Rectangle(startX, baseline, col1Size, fontHeight));
    entryFilterValue.setFont(FONT_ARIAL);
    entryFilterValue.setBounds(new Rectangle(col2X, baseline, col2Size, fontHeight));

    baseline += 30;
    ldapUserLabel.setText("LDAP User: ");
    ldapUserLabel.setToolTipText("LDAP Bind DN (username) to access the LDAP server");
    ldapUserLabel.setFont(defaultFont);
    ldapUserLabel.setBounds(new Rectangle(startX, baseline, col1Size, fontHeight));
    ldapUserValue.setFont(FONT_ARIAL);
    ldapUserValue.setBounds(new Rectangle(col2X, baseline, col2Size, fontHeight));

    baseline += 30;
    ldapPassLabel.setText("LDAP Password: ");
    ldapPassLabel.setToolTipText("LDAP Bind DN password to access LDAP server");
    ldapPassLabel.setFont(defaultFont);
    ldapPassLabel.setBounds(new Rectangle(startX, baseline, col1Size, fontHeight));
    ldapPassValue.setFont(FONT_ARIAL);
    ldapPassValue.setBounds(new Rectangle(col2X, baseline, col2Size, fontHeight));

    // follow referral
    followReferralLabel.setText("Follow Referral ");
    followReferralLabel.setToolTipText("Select this checkbox if you want ldap to follow smart-referrals");
    followReferralLabel.setFont(defaultFont);
    followReferralLabel.setBounds(new Rectangle(col3X, 270, col3Size, fontHeight));
    followReferralValue.setSelected(false);
    followReferralValue.setBounds(new Rectangle(col3X, 300, col3Size, fontHeight));
    // connection pooling
    connectionPoolingLabel.setText("Pooling ");
    connectionPoolingLabel.setToolTipText("Select this checkbox if you want use connection pooling");
    connectionPoolingLabel.setFont(defaultFont);
    connectionPoolingLabel.setBounds(new Rectangle(col3X + col3Size, 270, col3Size, fontHeight));
    connectionPoolingValue.setSelected(false);
    connectionPoolingValue.setBounds(new Rectangle(col3X + col3Size, 300, col3Size, fontHeight));

    baseline += 30;
    dbNameLabel.setText("Funambol DBMS Name: ");
    dbNameLabel.setToolTipText("Funambol DS table to store metadata. Use fnblcore");
    dbNameLabel.setFont(defaultFont);
    dbNameLabel.setBounds(new Rectangle(startX, baseline, col1Size, fontHeight));
    dbNameValue.setFont(FONT_ARIAL);
    dbNameValue.setBounds(new Rectangle(col2X, baseline, col2Size, fontHeight));

    baseline += 30;
    timeZoneLabel.setFont(defaultFont);
    timeZoneLabel.setBounds(new Rectangle(startX, baseline, col1Size, fontHeight));
    timeZoneValue = new JComboBox(TimeZone.getAvailableIDs());
    timeZoneValue.setBounds(new Rectangle(col2X, baseline, col2Size, fontHeight));
    // rpolli
    baseline += 30;
    ldapServerLabel.setText("LDAP Server Type");
    ldapServerLabel.setFont(defaultFont);
    ldapServerLabel.setBounds(new Rectangle(startX, baseline, col1Size, fontHeight));
    ldapServerValue.setBounds(new Rectangle(col2X, baseline, col2Size, fontHeight));
    ldapServerValue.setToolTipText("Select compatibility unique ID's per items.");
    confirmButton.setFont(defaultFont);
    confirmButton.setText("Add");
    confirmButton.setBounds(col2X, 420, 70, 25);

    confirmButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                validateValues();
                getValues();
                if (getState() == STATE_INSERT) {
                    LDAPSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(
                            LDAPSyncSourceConfigPanel.this, ACTION_EVENT_INSERT, event.getActionCommand()));
                } else {
                    LDAPSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(
                            LDAPSyncSourceConfigPanel.this, ACTION_EVENT_UPDATE, event.getActionCommand()));
                }
            } catch (Exception e) {
                e.printStackTrace();
                notifyError(new AdminException(e.getMessage()));
            }
        }
    });

    // add all components to the panel
    this.add(panelName, null);
    this.add(nameLabel, null);
    this.add(nameValue, null);
    this.add(typeLabel, null);
    this.add(typeValue, null);
    this.add(sourceUriLabel, null);
    this.add(sourceUriValue, null);

    //rpolli
    this.add(ldapServerLabel, null);
    this.add(ldapServerValue, null);
    this.add(this.daoNameLabel, null);
    this.add(this.daoNameValue, null);

    this.add(followReferralLabel, null);
    this.add(followReferralValue, null);
    this.add(connectionPoolingLabel, null);
    this.add(connectionPoolingValue, null);

    this.add(providerUrlLabel, null);
    this.add(providerUrlValue, null);
    //      this.add(ldapPortLabel    , null);
    //      this.add(ldapPortValue    , null);
    //      this.add(isSSLLabel       , null);
    //      this.add(isSSLValue       , null);
    this.add(ldapBaseLabel, null);
    this.add(ldapBaseValue, null);
    this.add(entryFilterLabel, null);
    this.add(entryFilterValue, null);

    this.add(ldapUserLabel, null);
    this.add(ldapUserValue, null);
    this.add(ldapPassLabel, null);
    this.add(ldapPassValue, null);
    this.add(timeZoneLabel, null);
    this.add(timeZoneValue, null);

    this.add(dbNameLabel, null);
    this.add(dbNameValue, null);

    this.add(confirmButton, null);
}

From source file:com.funambol.foundation.admin.FileDataObjectSyncSourceConfigPanel.java

/**
 * Create the panel//from w ww .j av  a2 s. c o  m
 */

private void init() {
    // set layout
    this.setLayout(null);

    // set properties of label, position and border
    //  referred to the title of the panel
    titledBorder1 = new TitledBorder("");

    panelName.setFont(titlePanelFont);
    panelName.setText("Edit File Data Object SyncSource");
    panelName.setBounds(new Rectangle(14, 5, 316, 28));
    panelName.setAlignmentX(SwingConstants.CENTER);
    panelName.setBorder(titledBorder1);

    int y = 60;
    int dy = 30;

    sourceUriLabel.setText("Source URI: ");
    sourceUriLabel.setFont(defaultFont);
    sourceUriLabel.setBounds(new Rectangle(14, y, 150, 18));
    sourceUriValue.setFont(defaultFont);
    sourceUriValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    nameLabel.setText("Name: ");
    nameLabel.setFont(defaultFont);
    nameLabel.setBounds(new Rectangle(14, y, 150, 18));
    nameValue.setFont(defaultFont);
    nameValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    storageProviderLabel.setText("Storage type:");
    storageProviderLabel.setFont(defaultFont);
    storageProviderLabel.setBounds(new Rectangle(14, y, 150, 18));
    //list of supported storage providers
    String[] providers = new String[] { PROVIDER_FILESYSTEM, PROVIDER_S3 };
    storageProviderValue = new JComboBox(providers);
    storageProviderValue.addActionListener(jcloudsProviderValueActionListener);
    storageProviderValue.setFont(defaultFont);
    storageProviderValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    //    storageContainerNameLabel.setText("Provider container name:");
    storageContainerNameLabel.setFont(defaultFont);
    storageContainerNameLabel.setBounds(new Rectangle(14, y, 150, 18));
    storageContainerNameValue.setFont(defaultFont);
    storageContainerNameValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    //    storageIdentityLabel.setText("Provider identity:");
    storageIdentityLabel.setFont(defaultFont);
    storageIdentityLabel.setBounds(new Rectangle(14, y, 150, 18));
    storageIdentityValue.setFont(defaultFont);
    storageIdentityValue.setBounds(new Rectangle(170, y, 350, 18));

    //storage provider identity and storageFilesystemRootPathLabel aren't
    //showed together, so leaving the y coordinate equals the panel has a better
    //aspect for different storage types
    //y += dy;

    //    storageFilesystemRootPathLabel.setText("Local path for filesystem provider:");
    storageFilesystemRootPathLabel.setFont(defaultFont);
    storageFilesystemRootPathLabel.setBounds(new Rectangle(14, y, 150, 18));
    storageFilesystemRootPathValue.setFont(defaultFont);
    storageFilesystemRootPathValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    //    storageCredentialLabel.setText("Provider credential:");
    storageCredentialLabel.setFont(defaultFont);
    storageCredentialLabel.setBounds(new Rectangle(14, y, 150, 18));
    storageCredentialValue.setFont(defaultFont);
    storageCredentialValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    localRootPathLabel.setText("Root local path for temp files: ");
    localRootPathLabel.setFont(defaultFont);
    localRootPathLabel.setBounds(new Rectangle(14, y, 150, 18));
    localRootPathValue.setFont(defaultFont);
    localRootPathValue.setBounds(new Rectangle(170, y, 350, 18));

    y += dy;

    quotaLabel.setText("Quota: ");
    quotaLabel.setFont(defaultFont);
    quotaLabel.setBounds(new Rectangle(14, y, 150, 18));
    model = new RolesTableModel();
    quotaTable = new JTable(model);
    quotaTable.setFont(defaultFont);
    quotaTable.setShowGrid(true);
    quotaTable.setAutoscrolls(true);
    quotaTable.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
    //add the table into a JScrollPanel, otherwise no columns headers and border
    //will be show
    JScrollPane scrollpane = new JScrollPane(quotaTable);
    scrollpane.setBounds(new Rectangle(170, y, 350, 110));
    quotaTable.setPreferredScrollableViewportSize(new Dimension(350, 110));

    y += dy + 75;
    notaLabel.setText(
            "<html>Please enter the number followed by 'M' if it is 'MegaBytes', or 'G' if it is 'GigaBytes'<BR>Example: '100 M' stands for 100 MegaBytes, '2 G' stands for 2 GigaBytes</html>");
    notaLabel.setFont(defaultFont);
    notaLabel.setBounds(new Rectangle(170, y, 350, 54));

    //button separed from other controls, and the height of the table
    y += dy + 36;

    confirmButton.setFont(defaultFont);
    confirmButton.setText("Add");
    confirmButton.setBounds(170, y, 70, 25);

    confirmButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                validateValues();
                getValues();
                if (getState() == STATE_INSERT) {
                    FileDataObjectSyncSourceConfigPanel.this
                            .actionPerformed(new ActionEvent(FileDataObjectSyncSourceConfigPanel.this,
                                    ACTION_EVENT_INSERT, event.getActionCommand()));
                } else {
                    FileDataObjectSyncSourceConfigPanel.this
                            .actionPerformed(new ActionEvent(FileDataObjectSyncSourceConfigPanel.this,
                                    ACTION_EVENT_UPDATE, event.getActionCommand()));
                }
            } catch (Exception e) {
                notifyError(new AdminException(e.getMessage()));
            }
        }
    });

    // add all components to the panel
    this.add(panelName, null);
    this.add(sourceUriLabel, null);
    this.add(sourceUriValue, null);
    this.add(nameLabel, null);
    this.add(nameValue, null);
    this.add(storageProviderLabel, null);
    this.add(storageProviderValue, null);
    this.add(storageContainerNameLabel, null);
    this.add(storageContainerNameValue, null);
    this.add(storageIdentityLabel, null);
    this.add(storageIdentityValue, null);
    this.add(storageCredentialLabel, null);
    this.add(storageCredentialValue, null);
    this.add(storageFilesystemRootPathLabel, null);
    this.add(storageFilesystemRootPathValue, null);
    this.add(localRootPathLabel, null);
    this.add(localRootPathValue, null);
    this.add(quotaLabel, null);
    this.add(scrollpane, null);
    this.add(notaLabel, null);
    this.add(confirmButton, null);
}

From source file:pl.otros.vfs.browser.VfsBrowser.java

License:asdf

private void initGui(final String initialPath) {
    this.setLayout(new BorderLayout());
    JLabel pathLabel = new JLabel(Messages.getMessage("browser.location"));
    pathLabel.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 3));
    pathField = new JTextField(80);
    pathField.setFont(pathLabel.getFont().deriveFont(pathLabel.getFont().getSize() * 1.2f));
    pathField.setToolTipText(Messages.getMessage("nav.pathTooltip"));
    GuiUtils.addBlinkOnFocusGain(pathField);
    pathLabel.setLabelFor(pathField);// w w  w  .  jav  a2 s. c  om
    pathLabel.setDisplayedMnemonic(Messages.getMessage("browser.location.mnemonic").charAt(0));

    InputMap inputMapPath = pathField.getInputMap(JComponent.WHEN_FOCUSED);
    inputMapPath.put(KeyStroke.getKeyStroke("ENTER"), "OPEN_PATH");
    inputMapPath.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), ACTION_FOCUS_ON_TABLE);
    pathField.getActionMap().put("OPEN_PATH", new BaseNavigateAction(this) {

        @Override
        protected void performLongOperation(CheckBeforeActionResult actionResult) {
            try {
                FileObject resolveFile = VFSUtils.resolveFileObject(pathField.getText().trim());
                if (resolveFile != null && resolveFile.getType() == FileType.FILE) {
                    loadAndSelSingleFile(resolveFile);
                    pathField.setText(resolveFile.getURL().toString());
                    actionApproveDelegate.actionPerformed(
                            // TODO:  Does actionResult provide an ID for 2nd param here,
                            // or should use a Random number?
                            new ActionEvent(actionResult, (int) new java.util.Date().getTime(),
                                    "SELECTED_FILE"));
                    return;
                }
            } catch (FileSystemException fse) {
                // Intentionally empty
            }
            goToUrl(pathField.getText().trim());
        }

        @Override
        protected boolean canGoUrl() {
            return true;
        }

        @Override
        protected boolean canExecuteDefaultAction() {
            return false;
        }

    });
    actionFocusOnTable = new

    AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            tableFiles.requestFocusInWindow();
            if (tableFiles.getSelectedRow() < 0 && tableFiles.getRowCount() == 0) {
                tableFiles.getSelectionModel().setSelectionInterval(0, 0);
            }
        }
    };
    pathField.getActionMap().put(ACTION_FOCUS_ON_TABLE, actionFocusOnTable);

    BaseNavigateActionGoUp goUpAction = new BaseNavigateActionGoUp(this);
    goUpButton = new JButton(goUpAction);

    BaseNavigateActionRefresh refreshAction = new BaseNavigateActionRefresh(this);
    JButton refreshButton = new JButton(refreshAction);

    JToolBar upperPanel = new JToolBar(Messages.getMessage("nav.ToolBarName"));
    upperPanel.setRollover(true);
    upperPanel.add(pathLabel);
    upperPanel.add(pathField, "growx");
    upperPanel.add(goUpButton);
    upperPanel.add(refreshButton);

    AddCurrentLocationToFavoriteAction addCurrentLocationToFavoriteAction = new AddCurrentLocationToFavoriteAction(
            this);
    JButton addCurrentLocationToFavoriteButton = new JButton(addCurrentLocationToFavoriteAction);
    addCurrentLocationToFavoriteButton.setText("");
    upperPanel.add(addCurrentLocationToFavoriteButton);

    previewComponent = new PreviewComponent();

    vfsTableModel = new VfsTableModel();

    tableFiles = new JTable(vfsTableModel);
    tableFiles.setFillsViewportHeight(true);
    tableFiles.getColumnModel().getColumn(0).setMinWidth(140);
    tableFiles.getColumnModel().getColumn(1).setMaxWidth(80);
    tableFiles.getColumnModel().getColumn(2).setMaxWidth(80);
    tableFiles.getColumnModel().getColumn(3).setMaxWidth(180);
    tableFiles.getColumnModel().getColumn(3).setMinWidth(120);

    sorter = new TableRowSorter<VfsTableModel>(vfsTableModel);
    final FileNameWithTypeComparator fileNameWithTypeComparator = new FileNameWithTypeComparator();
    sorter.addRowSorterListener(new RowSorterListener() {
        @Override
        public void sorterChanged(RowSorterEvent e) {
            RowSorterEvent.Type type = e.getType();
            if (type.equals(RowSorterEvent.Type.SORT_ORDER_CHANGED)) {
                List<? extends RowSorter.SortKey> sortKeys = e.getSource().getSortKeys();
                for (RowSorter.SortKey sortKey : sortKeys) {
                    if (sortKey.getColumn() == VfsTableModel.COLUMN_NAME) {
                        fileNameWithTypeComparator.setSortOrder(sortKey.getSortOrder());
                    }
                }
            }
        }
    });
    sorter.setComparator(VfsTableModel.COLUMN_NAME, fileNameWithTypeComparator);

    tableFiles.setRowSorter(sorter);
    tableFiles.setShowGrid(false);
    tableFiles.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            try {
                selectionChanged();
            } catch (FileSystemException e1) {
                LOGGER.error("Error during update state", e);
            }
        }
    });
    tableFiles.setColumnSelectionAllowed(false);
    vfsTableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            updateStatusText();
        }
    });

    tableFiles.setDefaultRenderer(FileSize.class, new FileSizeTableCellRenderer());
    tableFiles.setDefaultRenderer(FileNameWithType.class, new FileNameWithTypeTableCellRenderer());
    tableFiles.setDefaultRenderer(Date.class, new MixedDateTableCellRenderer());
    tableFiles.setDefaultRenderer(FileType.class, new FileTypeTableCellRenderer());

    tableFiles.getSelectionModel().addListSelectionListener(new PreviewListener(this, previewComponent));

    JPanel favoritesPanel = new JPanel(new MigLayout("wrap, fillx", "[grow]"));
    favoritesUserListModel = new MutableListModel<Favorite>();

    List<Favorite> favSystemLocations = FavoritesUtils.getSystemLocations();
    List<Favorite> favUser = FavoritesUtils.loadFromProperties(configuration);
    List<Favorite> favJVfsFileChooser = FavoritesUtils.getJvfsFileChooserBookmarks();
    for (Favorite favorite : favUser) {
        favoritesUserListModel.add(favorite);
    }
    favoritesUserListModel.addListDataListener(new ListDataListener() {
        @Override
        public void intervalAdded(ListDataEvent e) {
            saveFavorites();

        }

        @Override
        public void intervalRemoved(ListDataEvent e) {
            saveFavorites();
        }

        @Override
        public void contentsChanged(ListDataEvent e) {
            saveFavorites();
        }

        protected void saveFavorites() {
            FavoritesUtils.storeFavorites(configuration, favoritesUserListModel.getList());
        }
    });

    favoritesUserList = new JList(favoritesUserListModel);
    favoritesUserList.setTransferHandler(new MutableListDropHandler(favoritesUserList));
    new MutableListDragListener(favoritesUserList);
    favoritesUserList.setCellRenderer(new FavoriteListCellRenderer());
    favoritesUserList.addFocusListener(new SelectFirstElementFocusAdapter());

    addOpenActionToList(favoritesUserList);
    addEditActionToList(favoritesUserList, favoritesUserListModel);

    favoritesUserList.getActionMap().put(ACTION_DELETE, new AbstractAction(
            Messages.getMessage("favorites.deleteButtonText"), Icons.getInstance().getMinusButton()) {

        @Override
        public void actionPerformed(ActionEvent e) {
            Favorite favorite = favoritesUserListModel.getElementAt(favoritesUserList.getSelectedIndex());
            if (!Favorite.Type.USER.equals(favorite.getType())) {
                return;
            }
            int response = JOptionPane.showConfirmDialog(VfsBrowser.this,
                    Messages.getMessage("favorites.areYouSureToDeleteConnections"),
                    Messages.getMessage("favorites.confirm"), JOptionPane.YES_NO_OPTION);

            if (response == JOptionPane.YES_OPTION) {
                favoritesUserListModel.remove(favoritesUserList.getSelectedIndex());
            }
        }
    });
    InputMap favoritesListInputMap = favoritesUserList.getInputMap(JComponent.WHEN_FOCUSED);
    favoritesListInputMap.put(KeyStroke.getKeyStroke("DELETE"), ACTION_DELETE);

    ActionMap actionMap = tableFiles.getActionMap();
    actionMap.put(ACTION_OPEN, new BaseNavigateActionOpen(this));
    actionMap.put(ACTION_GO_UP, goUpAction);
    actionMap.put(ACTION_APPROVE, new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (actionApproveButton.isEnabled()) {
                actionApproveDelegate.actionPerformed(e);
            }
        }
    });

    InputMap inputMap = tableFiles.getInputMap(JComponent.WHEN_FOCUSED);
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), ACTION_OPEN);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_MASK), ACTION_APPROVE);

    inputMap.put(KeyStroke.getKeyStroke("BACK_SPACE"), ACTION_GO_UP);
    inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), ACTION_GO_UP);
    addPopupMenu(favoritesUserList, ACTION_OPEN, ACTION_EDIT, ACTION_DELETE);

    JList favoriteSystemList = new JList(new Vector<Object>(favSystemLocations));
    favoriteSystemList.setCellRenderer(new FavoriteListCellRenderer());
    addOpenActionToList(favoriteSystemList);
    addPopupMenu(favoriteSystemList, ACTION_OPEN);
    favoriteSystemList.addFocusListener(new SelectFirstElementFocusAdapter());

    JList favoriteJVfsList = new JList(new Vector<Object>(favJVfsFileChooser));
    addOpenActionToList(favoriteJVfsList);
    favoriteJVfsList.setCellRenderer(new FavoriteListCellRenderer());
    addPopupMenu(favoriteJVfsList, ACTION_OPEN);
    favoriteJVfsList.addFocusListener(new SelectFirstElementFocusAdapter());

    JLabel favoritesSystemLocationsLabel = getTitleListLabel(Messages.getMessage("favorites.systemLocations"),
            COMPUTER_ICON);
    favoritesSystemLocationsLabel.setLabelFor(favoriteSystemList);
    favoritesSystemLocationsLabel
            .setDisplayedMnemonic(Messages.getMessage("favorites.systemLocations.mnemonic").charAt(0));
    favoritesPanel.add(favoritesSystemLocationsLabel, "gapleft 16");
    favoritesPanel.add(favoriteSystemList, "growx");
    JLabel favoritesFavoritesLabel = getTitleListLabel(Messages.getMessage("favorites.favorites"),
            Icons.getInstance().getStar());
    favoritesFavoritesLabel.setLabelFor(favoritesUserList);
    favoritesFavoritesLabel.setDisplayedMnemonic(Messages.getMessage("favorites.favorites.mnemonic").charAt(0));
    favoritesPanel.add(favoritesFavoritesLabel, "gapleft 16");
    favoritesPanel.add(favoritesUserList, "growx");

    if (favoriteJVfsList.getModel().getSize() > 0) {
        JLabel favoritesJVfsFileChooser = getTitleListLabel(
                Messages.getMessage("favorites.JVfsFileChooserBookmarks"), null);
        favoritesJVfsFileChooser.setDisplayedMnemonic(
                Messages.getMessage("favorites.JVfsFileChooserBookmarks.mnemonic").charAt(0));
        favoritesJVfsFileChooser.setLabelFor(favoriteJVfsList);
        favoritesPanel.add(favoritesJVfsFileChooser, "gapleft 16");
        favoritesPanel.add(favoriteJVfsList, "growx");
    }

    tableFiles.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
                tableFiles.getActionMap().get(ACTION_OPEN).actionPerformed(null);
            }
        }
    });
    tableFiles.addKeyListener(new QuickSearchKeyAdapter());

    cardLayout = new CardLayout();
    tablePanel = new JPanel(cardLayout);
    loadingProgressBar = new JProgressBar();
    loadingProgressBar.setStringPainted(true);
    loadingProgressBar.setString(Messages.getMessage("browser.loading"));
    loadingProgressBar.setIndeterminate(true);
    loadingIconLabel = new JLabel(Icons.getInstance().getNetworkStatusOnline());
    skipCheckingLinksButton = new JToggleButton(Messages.getMessage("browser.skipCheckingLinks"));
    skipCheckingLinksButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            if (taskContext != null) {
                taskContext.setStop(skipCheckingLinksButton.isSelected());
            }
        }
    });

    showHidCheckBox = new JCheckBox(Messages.getMessage("browser.showHidden.label"), showHidden);
    showHidCheckBox.setToolTipText(Messages.getMessage("browser.showHidden.tooltip"));
    showHidCheckBox.setMnemonic(Messages.getMessage("browser.showHidden.mnemonic").charAt(0));
    Font tmpFont = showHidCheckBox.getFont();
    showHidCheckBox.setFont(tmpFont.deriveFont(tmpFont.getSize() * 0.9f));
    showHidCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateUiFilters();
        }
    });

    final String defaultFilterText = Messages.getMessage("browser.nameFilter.defaultText");
    filterField = new JTextField("", 16);
    filterField.setForeground(filterField.getDisabledTextColor());
    filterField.setToolTipText(Messages.getMessage("browser.nameFilter.tooltip"));
    PromptSupport.setPrompt(defaultFilterText, filterField);
    filterField.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void insertUpdate(DocumentEvent e) {
            documentChanged();
        }

        void documentChanged() {
            if (filterField.getText().length() == 0) {
                updateUiFilters();
            }
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            documentChanged();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            documentChanged();
        }
    });
    filterField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            updateUiFilters();
        }
    });

    AbstractAction actionClearRegexFilter = new

    AbstractAction(Messages.getMessage("browser.nameFilter.clearFilterText")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            filterField.setText("");
        }
    };
    filterField.getActionMap().put(ACTION_FOCUS_ON_TABLE, actionFocusOnTable);
    filterField.getActionMap().put(ACTION_CLEAR_REGEX_FILTER, actionClearRegexFilter);

    filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), ACTION_FOCUS_ON_TABLE);
    filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), ACTION_FOCUS_ON_TABLE);
    filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0),
            ACTION_FOCUS_ON_TABLE);
    filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            ACTION_FOCUS_ON_TABLE);
    filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            ACTION_CLEAR_REGEX_FILTER);

    JLabel nameFilterLabel = new JLabel(Messages.getMessage("browser.nameFilter"));
    nameFilterLabel.setLabelFor(filterField);
    nameFilterLabel.setDisplayedMnemonic(Messages.getMessage("browser.nameFilter.mnemonic").charAt(0));

    sorter.setRowFilter(createFilter());
    statusLabel = new JLabel();

    actionApproveButton = new JButton();
    actionApproveButton.setFont(actionApproveButton.getFont().deriveFont(Font.BOLD));
    actionCancelButton = new JButton();

    ActionMap browserActionMap = this.getActionMap();
    browserActionMap.put(ACTION_FOCUS_ON_REGEX_FILTER, new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            filterField.requestFocus();
            filterField.selectAll();
            GuiUtils.blinkComponent(filterField);
        }
    });

    browserActionMap.put(ACTION_FOCUS_ON_PATH, new SetFocusOnAction(pathField));
    browserActionMap.put(ACTION_SWITCH_SHOW_HIDDEN, new ClickOnJComponentAction(showHidCheckBox));
    browserActionMap.put(ACTION_REFRESH, refreshAction);
    browserActionMap.put(ACTION_ADD_CURRENT_LOCATION_TO_FAVORITES, addCurrentLocationToFavoriteAction);
    browserActionMap.put(ACTION_GO_UP, goUpAction);
    browserActionMap.put(ACTION_FOCUS_ON_TABLE, new SetFocusOnAction(tableFiles));

    InputMap browserInputMap = this.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    browserInputMap.put(KeyStroke.getKeyStroke("control F"), ACTION_FOCUS_ON_REGEX_FILTER);
    browserInputMap.put(KeyStroke.getKeyStroke("control L"), ACTION_FOCUS_ON_PATH);
    browserInputMap.put(KeyStroke.getKeyStroke("F4"), ACTION_FOCUS_ON_PATH);
    browserInputMap.put(KeyStroke.getKeyStroke("control H"), ACTION_SWITCH_SHOW_HIDDEN);
    browserInputMap.put(KeyStroke.getKeyStroke("control R"), ACTION_REFRESH);
    browserInputMap.put(KeyStroke.getKeyStroke("F5"), ACTION_REFRESH);
    browserInputMap.put(KeyStroke.getKeyStroke("control D"), ACTION_ADD_CURRENT_LOCATION_TO_FAVORITES);
    browserInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.ALT_DOWN_MASK), ACTION_GO_UP);
    browserInputMap.put(KeyStroke.getKeyStroke("control T"), ACTION_FOCUS_ON_TABLE);

    //DO layout
    // create the layer for the panel using our custom layerUI
    tableScrollPane = new JScrollPane(tableFiles);

    JPanel tableScrollPaneWithFilter = new JPanel(new BorderLayout());
    tableScrollPaneWithFilter.add(tableScrollPane);
    JToolBar filtersToolbar = new JToolBar("Filters");
    filtersToolbar.setFloatable(false);
    filtersToolbar.setBorderPainted(true);
    tableScrollPaneWithFilter.add(filtersToolbar, BorderLayout.SOUTH);
    filtersToolbar.add(nameFilterLabel);
    filtersToolbar.add(filterField);
    filtersToolbar.add(showHidCheckBox);
    JSplitPane tableWithPreviewPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true,
            tableScrollPaneWithFilter, previewComponent);
    tableWithPreviewPane.setOneTouchExpandable(true);

    JPanel loadingPanel = new JPanel(new MigLayout());
    loadingPanel.add(loadingIconLabel, "right");
    loadingPanel.add(loadingProgressBar, "left, w 420:420:500,wrap");
    loadingPanel.add(skipCheckingLinksButton, "span, right");
    tablePanel.add(loadingPanel, LOADING);
    tablePanel.add(tableWithPreviewPane, TABLE);

    JSplitPane jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(favoritesPanel),
            tablePanel);
    jSplitPane.setOneTouchExpandable(true);
    jSplitPane.setDividerLocation(180);

    JPanel southPanel = new JPanel(new MigLayout("", "[]push[][]", ""));
    southPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    southPanel.add(statusLabel);
    southPanel.add(actionApproveButton);
    southPanel.add(actionCancelButton);

    this.add(upperPanel, BorderLayout.NORTH);
    this.add(jSplitPane, BorderLayout.CENTER);
    this.add(southPanel, BorderLayout.SOUTH);

    try {
        selectionChanged();
    } catch (FileSystemException e) {
        LOGGER.error("Can't initialize default selection mode", e);
    }
    // Why this not done in EDT?
    // Is it assume that constructor is invoked from an  EDT?
    try {
        if (initialPath == null) {
            goToUrl(VFSUtils.getUserHome());
        } else {
            try {
                FileObject resolveFile = VFSUtils.resolveFileObject(initialPath);
                if (resolveFile != null && resolveFile.getType() == FileType.FILE) {
                    loadAndSelSingleFile(resolveFile);
                    pathField.setText(resolveFile.getURL().toString());
                    targetFileSelected = true;
                    return;
                }
            } catch (FileSystemException fse) {
                // Intentionally empty
            }
            goToUrl(initialPath);
        }
    } catch (FileSystemException e1) {
        LOGGER.error("Can't initialize default location", e1);
    }
    showTable();
}

From source file:net.sf.mzmine.modules.visualization.tic.TICPlot.java

@Override
public void chartProgress(final ChartProgressEvent event) {

    super.chartProgress(event);

    if (event.getType() == ChartProgressEvent.DRAWING_FINISHED) {

        if (visualizer instanceof TICVisualizerWindow) {

            ((TICVisualizerWindow) visualizer).updateTitle();
        }/*from ww  w.j  ava2 s.  c  o m*/

        if (showSpectrumRequest) {

            showSpectrumRequest = false;
            visualizer.actionPerformed(
                    new ActionEvent(event.getSource(), ActionEvent.ACTION_PERFORMED, "SHOW_SPECTRUM"));
        }
    }
}

From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterControl.java

/**
 * Handles a PropertyChangedEvent/*from   ww w  . j  av  a  2s.c o  m*/
 * @param evt The event
 */
private void handlePropertyChangedEvent(PropertyChangeEvent evt) {
    String name = evt.getPropertyName();
    if (ImportDialog.IMPORT_PROPERTY.equals(name)) {
        actionsMap.get(CANCEL_BUTTON).setEnabled(true);
        model.importData((ImportableObject) evt.getNewValue());
    } else if (ImportDialog.LOAD_TAGS_PROPERTY.equals(name)) {
        model.loadExistingTags();
    } else if (ImportDialog.CANCEL_SELECTION_PROPERTY.equals(name)) {
        model.close();
    } else if (ClosableTabbedPane.CLOSE_TAB_PROPERTY.equals(name)) {
        model.removeImportElement(evt.getNewValue());
    } else if (FileImportComponent.SUBMIT_ERROR_PROPERTY.equals(name)) {
        submitFiles((FileImportComponent) evt.getNewValue());
    } else if (ImportDialog.REFRESH_LOCATION_PROPERTY.equals(name)) {
        model.refreshContainers((ImportLocationDetails) evt.getNewValue());
    } else if (ImportDialog.CREATE_OBJECT_PROPERTY.equals(name)) {
        ObjectToCreate l = (ObjectToCreate) evt.getNewValue();
        model.createDataObject(l);
    } else if (StatusLabel.DEBUG_TEXT_PROPERTY.equals(name)) {
        view.appendDebugText((String) evt.getNewValue());
    } else if (MacOSMenuHandler.QUIT_APPLICATION_PROPERTY.equals(name)) {
        Action a = getAction(EXIT);
        ActionEvent event = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "");
        a.actionPerformed(event);
    } else if (ImportDialog.PROPERTY_GROUP_CHANGED.equals(name)) {
        GroupData newGroup = (GroupData) evt.getNewValue();
        model.setUserGroup(newGroup);
    } else if (StatusLabel.FILE_IMPORT_STARTED_PROPERTY.equals(name)
            || FileImportComponent.CANCEL_IMPORT_PROPERTY.equals(name)) {
        checkDisableCancelAllButtons();
    } else if (StatusLabel.IMPORT_DONE_PROPERTY.equals(name)) {
        model.onImportComplete((FileImportComponent) evt.getNewValue());
    } else if (StatusLabel.UPLOAD_DONE_PROPERTY.equals(name)) {
        model.onUploadComplete((FileImportComponent) evt.getNewValue());
    }
}

From source file:com.funambol.foundation.admin.PIMSyncSourceConfigPanel.java

/**
 * Creates the panel's components and layout.
 * @todo adjust layout//from w ww .  j  a  v  a2  s .c  om
 */
private void init() {
    // set layout
    this.setLayout(null);
    // set properties of label, position and border
    //  referred to the title of the panel
    titledBorder = new TitledBorder("");
    panelName.setFont(titlePanelFont);
    panelName.setText(getPanelName());
    panelName.setBounds(new Rectangle(14, 5, 316, 28));
    panelName.setAlignmentX(SwingConstants.CENTER);
    panelName.setBorder(titledBorder);

    final int LABEL_X = 14;
    final int VALUE_X = 170;
    int y = 60;
    final int GAP_X = 150;
    final int GAP_Y = 30;

    sourceUriLabel.setText("Source URI: ");
    sourceUriLabel.setFont(defaultFont);
    sourceUriLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    sourceUriValue.setFont(defaultFont);
    sourceUriValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));

    y += GAP_Y; // New line

    nameLabel.setText("Name: ");
    nameLabel.setFont(defaultFont);
    nameLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    nameValue.setFont(defaultFont);
    nameValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));
    y += GAP_Y; // New line

    typeLabel.setText("Type: ");
    typeLabel.setFont(defaultFont);
    typeLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    typeCombo.setFont(defaultFont);
    typeCombo.setBounds(new Rectangle(VALUE_X, y, 350, 18));

    // What happens when the Type value is changed?
    typeCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (isSIFSelected()) {
                encoding.setSelected(true); // SIFs always encoded
                encoding.setEnabled(false);
            } else {
                encryption.setSelected(false);
                encoding.setSelected(false);
                encoding.setEnabled(true);
            }
        }
    });

    y += GAP_Y; // New line
    int x = LABEL_X;

    y = addExtraComponents(x, y, GAP_X, GAP_Y); // Add other components, if needed

    encryption.setText("Encrypt data");
    encryption.setFont(defaultFont);
    encryption.setSelected(false);
    encryption.setBounds(x, y, 150, 25);

    // What happens if the encryption is enabled?
    encryption.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == e.SELECTED) {
                encoding.setSelected(true); // Encryption implies encoding
                encoding.setEnabled(false);
            }
            if (e.getStateChange() == e.DESELECTED) {
                if (!isSIFSelected()) {
                    encoding.setEnabled(true);
                }
            }
        }
    });

    y += GAP_Y; // New line

    encoding.setText("Encode data in Base 64");
    encoding.setFont(defaultFont);
    encoding.setSelected(false);
    encoding.setBounds(x, y, 150, 25);

    y += GAP_Y; // New line
    y += GAP_Y; // New line

    confirmButton.setFont(defaultFont);
    confirmButton.setText("Add");
    confirmButton.setBounds(VALUE_X, y, 70, 25);

    // What happens when the confirmButton is pressed?
    confirmButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                validateValues();
                getValues();
                if (getState() == STATE_INSERT) {
                    PIMSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(PIMSyncSourceConfigPanel.this,
                            ACTION_EVENT_INSERT, event.getActionCommand()));
                } else {
                    PIMSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(PIMSyncSourceConfigPanel.this,
                            ACTION_EVENT_UPDATE, event.getActionCommand()));
                }
            } catch (Exception e) {
                notifyError(new AdminException(e.getMessage(), e));
            }
        }
    });

    // Adds all components to the panel
    this.add(panelName, null);
    this.add(nameLabel, null);
    this.add(sourceUriLabel, null);
    this.add(sourceUriValue, null);
    this.add(nameValue, null);
    this.add(typeLabel, null);
    this.add(typeCombo, null);
    this.add(encryption, null);
    this.add(encoding, null);
    this.add(confirmButton, null);
}

From source file:com.funambol.exchange.admin.ExchangeSyncSourceConfigPanel.java

/**
 * Creates the panel's components and layout.
 * @todo adjust layout/*from   w  w w.  j  a v  a2 s .c o  m*/
 */
private void init() {
    // set layout
    this.setLayout(null);
    // set properties of label, position and border
    //  referred to the title of the panel
    titledBorder = new TitledBorder("");
    panelName.setFont(titlePanelFont);
    panelName.setText(getPanelName());
    panelName.setBounds(new Rectangle(14, 5, 316, 28));
    panelName.setAlignmentX(SwingConstants.CENTER);
    panelName.setBorder(titledBorder);

    final int LABEL_X = 14;
    final int VALUE_X = 170;
    int y = 60;
    final int GAP_X = 150;
    final int GAP_Y = 30;

    sourceUriLabel.setText("Source URI: ");
    sourceUriLabel.setFont(defaultFont);
    sourceUriLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    sourceUriValue.setFont(defaultFont);
    sourceUriValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));

    y += GAP_Y; // New line

    nameLabel.setText("Name: ");
    nameLabel.setFont(defaultFont);
    nameLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    nameValue.setFont(defaultFont);
    nameValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));
    y += GAP_Y; // New line

    y += GAP_Y; // New line
    typeLabel.setText("Type: ");
    typeLabel.setFont(defaultFont);
    typeLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    typeCombo.setFont(defaultFont);
    typeCombo.setBounds(new Rectangle(VALUE_X, y, 350, 18));

    // What happens when the Type value is changed?
    typeCombo.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (isSIFSelected()) {
                encoding.setSelected(true); // SIFs always encoded
                encoding.setEnabled(false);
            } else {
                encryption.setSelected(false);
                encoding.setSelected(false);
                encoding.setEnabled(true);
            }
        }
    });

    y += GAP_Y; // New line
    int x = LABEL_X;

    y = addExtraComponents(x, y, GAP_X, GAP_Y); // Add other components, if needed

    encryption.setText("Encrypt data");
    encryption.setFont(defaultFont);
    encryption.setSelected(false);
    encryption.setBounds(x, y, 150, 25);

    // What happens if the encryption is enabled?
    encryption.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == e.SELECTED) {
                encoding.setSelected(true); // Encryption implies encoding
                encoding.setEnabled(false);
            }
            if (e.getStateChange() == e.DESELECTED) {
                if (!isSIFSelected()) {
                    encoding.setEnabled(true);
                }
            }
        }
    });

    y += GAP_Y; // New line

    encoding.setText("Encode data in Base 64");
    encoding.setFont(defaultFont);
    encoding.setSelected(false);
    encoding.setBounds(x, y, 150, 25);

    y += GAP_Y; // New line
    y += GAP_Y; // New line

    confirmButton.setFont(defaultFont);
    confirmButton.setText("Add");
    confirmButton.setBounds(VALUE_X, y, 70, 25);

    // What happens when the confirmButton is pressed?
    confirmButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            try {
                validateValues();
                getValues();
                if (getState() == STATE_INSERT) {
                    ExchangeSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(
                            ExchangeSyncSourceConfigPanel.this, ACTION_EVENT_INSERT, event.getActionCommand()));
                } else {
                    ExchangeSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(
                            ExchangeSyncSourceConfigPanel.this, ACTION_EVENT_UPDATE, event.getActionCommand()));
                }
            } catch (Exception e) {
                notifyError(new AdminException(e.getMessage(), e));
            }
        }
    });

    // Adds all components to the panel
    this.add(panelName, null);
    this.add(nameLabel, null);
    this.add(sourceUriLabel, null);
    this.add(sourceUriValue, null);
    this.add(nameValue, null);
    this.add(typeLabel, null);

    this.add(typeCombo, null);
    this.add(encryption, null);
    this.add(encoding, null);
    this.add(confirmButton, null);
}

From source file:ca.phon.app.project.ProjectWindow.java

private void init() {
    /* Layout *//*from  w  w  w  . j  av a  2  s  .com*/
    setLayout(new BorderLayout());

    final ProjectDataTransferHandler transferHandler = new ProjectDataTransferHandler(this);

    /* Create components */
    newCorpusButton = createNewCorpusButton();
    createCorpusButton = createCorpusButton();

    corpusList = new JList<String>();
    corpusModel = new CorpusListModel(getProject());
    corpusList.setModel(corpusModel);
    corpusList.setCellRenderer(new CorpusListCellRenderer());
    corpusList.setVisibleRowCount(20);
    corpusList.addListSelectionListener(e -> {
        if (getSelectedCorpus() != null) {
            String corpus = getSelectedCorpus();
            sessionModel.setCorpus(corpus);
            sessionList.clearSelection();
            corpusDetails.setCorpus(corpus);

            if (getProject().getCorpusSessions(corpus).size() == 0) {
                onSwapNewAndCreateSession(newSessionButton);
            } else {
                onSwapNewAndCreateSession(createSessionButton);
            }
        }
    });
    corpusList.addMouseListener(new MouseInputAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            doPopup(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            doPopup(e);
        }

        public void doPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
                int clickedIdx = corpusList.locationToIndex(e.getPoint());
                if (clickedIdx >= 0 && Arrays.binarySearch(corpusList.getSelectedIndices(), clickedIdx) < 0) {
                    corpusList.setSelectedIndex(clickedIdx);
                }
                showCorpusListContextMenu(e.getPoint());
            }
        }
    });

    final DragSource corpusDragSource = new DragSource();
    corpusDragSource.createDefaultDragGestureRecognizer(corpusList, DnDConstants.ACTION_COPY, (event) -> {
        final List<ProjectPath> paths = new ArrayList<>();
        for (String corpus : getSelectedCorpora()) {
            final ProjectPath corpusPath = new ProjectPath(getProject(), corpus, null);
            paths.add(corpusPath);
        }
        final ProjectPathTransferable transferable = new ProjectPathTransferable(paths);
        event.startDrag(DragSource.DefaultCopyDrop, transferable);
    });

    corpusList.setDragEnabled(true);
    corpusList.setTransferHandler(transferHandler);

    corpusDetails = new CorpusDetailsPane(getProject());
    corpusDetails.setWrapStyleWord(true);
    corpusDetails.setRows(6);
    corpusDetails.setLineWrap(true);
    corpusDetails.setBackground(Color.white);
    corpusDetails.setOpaque(true);
    JScrollPane corpusDetailsScroller = new JScrollPane(corpusDetails);

    sessionList = new JList<String>();
    newSessionButton = createNewSessionButton();
    createSessionButton = createSessionButton();
    sessionModel = new SessionListModel(getProject());
    sessionList.setModel(sessionModel);
    sessionList.setCellRenderer(new SessionListCellRenderer());
    sessionList.setVisibleRowCount(20);
    sessionList.addListSelectionListener(e -> {
        if (sessionList.getSelectedValue() != null && !e.getValueIsAdjusting()) {
            String corpus = getSelectedCorpus();
            String session = getSelectedSessionName();

            sessionDetails.setSession(corpus, session);
        }
    });
    sessionList.addMouseListener(new MouseInputAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2 && e.getButton() == 1) {
                // get the clicked item
                int clickedItem = sessionList.locationToIndex(e.getPoint());
                if (sessionList.getModel().getElementAt(clickedItem) == null)
                    return;

                final String session = sessionList.getModel().getElementAt(clickedItem).toString();
                final String corpus = ((SessionListModel) sessionList.getModel()).getCorpus();

                msgPanel.reset();
                msgPanel.setMessageLabel("Opening '" + corpus + "." + session + "'");
                msgPanel.setIndeterminate(true);
                msgPanel.repaint();

                SwingUtilities.invokeLater(() -> {
                    final ActionEvent ae = new ActionEvent(sessionList, -1, "openSession");
                    (new OpenSessionAction(ProjectWindow.this, corpus, session)).actionPerformed(ae);

                    msgPanel.setIndeterminate(false);
                });
            }
        }

        @Override
        public void mousePressed(MouseEvent e) {
            doPopup(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            doPopup(e);
        }

        public void doPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
                int clickedIdx = sessionList.locationToIndex(e.getPoint());
                if (clickedIdx >= 0 && Arrays.binarySearch(sessionList.getSelectedIndices(), clickedIdx) < 0) {
                    sessionList.setSelectedIndex(clickedIdx);
                }
                showSessionListContextMenu(e.getPoint());
            }
        }
    });

    sessionList.setDragEnabled(true);
    sessionList.setTransferHandler(transferHandler);

    final DragSource sessionDragSource = new DragSource();
    sessionDragSource.createDefaultDragGestureRecognizer(sessionList, DnDConstants.ACTION_COPY, (event) -> {
        final List<ProjectPath> paths = new ArrayList<>();
        final String corpus = getSelectedCorpus();
        if (corpus == null)
            return;
        for (String session : getSelectedSessionNames()) {
            final ProjectPath sessionPath = new ProjectPath(getProject(), corpus, session);
            paths.add(sessionPath);
        }
        final ProjectPathTransferable transferable = new ProjectPathTransferable(paths);
        event.startDrag(DragSource.DefaultCopyDrop, transferable);
    });

    sessionDetails = new SessionDetailsPane(getProject());
    sessionDetails.setLineWrap(true);
    sessionDetails.setRows(6);
    sessionDetails.setWrapStyleWord(true);
    sessionDetails.setBackground(Color.white);
    sessionDetails.setOpaque(true);
    JScrollPane sessionDetailsScroller = new JScrollPane(sessionDetails);

    JScrollPane corpusScroller = new JScrollPane(corpusList);
    JScrollPane sessionScroller = new JScrollPane(sessionList);

    blindModeBox = new JCheckBox("Blind transcription");
    blindModeBox.setSelected(false);

    msgPanel = new StatusPanel();

    corpusPanel = new JPanel(new BorderLayout());
    corpusPanel.add(newCorpusButton, BorderLayout.NORTH);
    corpusPanel.add(corpusScroller, BorderLayout.CENTER);
    corpusPanel.add(corpusDetailsScroller, BorderLayout.SOUTH);

    sessionPanel = new JPanel(new BorderLayout());
    sessionPanel.add(newSessionButton, BorderLayout.NORTH);
    sessionPanel.add(sessionScroller, BorderLayout.CENTER);
    sessionPanel.add(sessionDetailsScroller, BorderLayout.SOUTH);

    final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitPane.setLeftComponent(corpusPanel);
    splitPane.setRightComponent(sessionPanel);
    splitPane.setResizeWeight(0.5);

    // invoke later
    SwingUtilities.invokeLater(() -> {
        splitPane.setDividerLocation(0.5);
    });

    // the frame layout
    String projectName = null;
    projectName = getProject().getName();

    DialogHeader header = new DialogHeader(projectName, StringUtils.abbreviate(projectLoadPath, 80));

    add(header, BorderLayout.NORTH);

    CellConstraints cc = new CellConstraints();
    final JPanel topPanel = new JPanel(new FormLayout("pref, fill:pref:grow, right:pref", "pref"));
    topPanel.add(msgPanel, cc.xy(1, 1));
    topPanel.add(blindModeBox, cc.xy(3, 1));

    add(splitPane, BorderLayout.CENTER);
    add(topPanel, BorderLayout.SOUTH);

    // if no corpora are currently available, 'prompt' the user to create a new one
    if (getProject().getCorpora().size() == 0) {
        SwingUtilities.invokeLater(() -> {
            onSwapNewAndCreateCorpus(newCorpusButton);
        });
    } else {
        SwingUtilities.invokeLater(() -> {
            corpusList.setSelectedIndex(0);
        });
    }
}

From source file:ca.phon.app.session.editor.view.session_information.SessionInfoEditorView.java

public void editParticipant() {
    int selectedRow = participantTable.getSelectedRow();
    if (selectedRow < 0)
        return;//  w  ww.j  a va2 s . c o  m
    selectedRow = participantTable.convertRowIndexToModel(selectedRow);
    if (selectedRow >= 0 && selectedRow < getEditor().getSession().getParticipantCount()) {
        final Participant part = getEditor().getSession().getParticipant(selectedRow);

        final EditParticipantAction act = new EditParticipantAction(getEditor(), this, part);
        act.actionPerformed(new ActionEvent(this, 0, null));
    }
}

From source file:ca.phon.app.session.editor.view.session_information.SessionInfoEditorView.java

public void deleteParticipant() {
    int selectedRow = participantTable.getSelectedRow();
    if (selectedRow < 0)
        return;/*ww  w .ja  va  2 s.com*/
    selectedRow = participantTable.convertRowIndexToModel(selectedRow);

    final SessionEditor editor = getEditor();
    final Session session = editor.getSession();
    if (selectedRow >= 0 && selectedRow < session.getParticipantCount()) {
        final Participant participant = session.getParticipant(selectedRow);

        final DeleteParticipantAction act = new DeleteParticipantAction(getEditor(), this, participant);
        act.actionPerformed(new ActionEvent(this, 0, null));

    }
}