Example usage for java.awt.event ActionEvent getActionCommand

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

Introduction

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

Prototype

public String getActionCommand() 

Source Link

Document

Returns the command string associated with this action.

Usage

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

/**
 * Create the panel//from w ww  . j ava 2s. 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:de.tor.tribes.ui.views.DSWorkbenchDoItYourselfAttackPlaner.java

@Override
public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand() != null) {
        if (e.getActionCommand().equals("Copy")) {
            transferSelection(TRANSFER_TYPE.COPY_TO_INTERNAL_CLIPBOARD);
        } else if (e.getActionCommand().equals("Cut")) {
            transferSelection(TRANSFER_TYPE.CUT_TO_INTERNAL_CLIPBOARD);
        } else if (e.getActionCommand().equals("Paste")) {
            transferSelection(TRANSFER_TYPE.FROM_INTERNAL_CLIPBOARD);
        } else if (e.getActionCommand().equals("Delete")) {
            deleteSelection(true);/*from  ww w .  j  a v a 2 s  . c o  m*/
        } else if (e.getActionCommand().equals("BBCopy")) {
            transferSelection(TRANSFER_TYPE.BB_TO_CLIPBOARD);
        }
    }
}

From source file:edu.ucla.stat.SOCR.analyses.util.moduls.frm.Panels.Jpan_btn.java

@Override
public void actionPerformed(final ActionEvent evt) {
    String action = null;/*from  w ww  . j  a va 2  s  .  com*/
    FitxerDades fitxTmp;
    boolean ambDades = false;
    InternalFrameData ifd;
    double minBase;
    MDComputation mdComputation;

    if (evt.getActionCommand().equals(strLoad)) {
        // LOAD

        if (currentInternalFrame != null)
            currentInternalFrame = null;

        buttonClicked = true;
        action = "Load";
        // Load data from file
        if (fitx == null) {
            fitxTmp = getFitxerDades();
        } else {
            // Last directory
            fitxTmp = getFitxerDades(fitx.getPath());
        }
        if (fitxTmp == null) {
            // Cancel pressed
            ambDades = false;
        } else {
            fitx = fitxTmp;
            ambDades = true;
        }
    } else if (evt.getActionCommand().equals(strUpdate)) {
        // UPDATE        
        buttonClicked = true;

        if (action1 == "Calculate") {
            action = "CalUpdate";

            doLoad(action);
            return;
        }

        ifd = currentInternalFrame.getInternalFrameData();
        if ((Jpan_Menu.getTypeData() == ifd.getTypeData()) && (Jpan_Menu.getMethod() == ifd.getMethod())
                && (Jpan_Menu.getPrecision() == ifd.getPrecision())) {
            action = "Redraw";
        } else {
            action = "Reload";
        }
        ambDades = true;
    }
    if (ambDades && (action.equals("Load") || action.equals("Reload"))) {
        try {
            de = new DadesExternes(fitx);
            if (action.equals("Load")) {
                Jpan_Menu.setPrecision(de.getPrecisio());
            }
            multiDendro = null;
            try {
                multiDendro = de.getMatriuDistancies();
                minBase = Double.MAX_VALUE;
                progressBar.setBorderPainted(true);
                progressBar.setString(null);
                fr.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // Instances of javax.swing.SwingWorker are not reusable,
                // so we create new instances as needed.
                mdComputation = new MDComputation(action, Jpan_Menu.getTypeData(), Jpan_Menu.getMethod(),
                        Jpan_Menu.getPrecision(), multiDendro.getCardinalitat(), minBase);
                mdComputation.addPropertyChangeListener(this);
                mdComputation.execute();
            } catch (final Exception e2) {
                buttonClicked = false;
                showError(e2.getMessage());
            }
        } catch (Exception e1) {
            buttonClicked = false;
            showError(e1.getMessage());
        }
    } else if (ambDades && action.equals("Redraw")) {
        showCalls(action);
    } else {
        buttonClicked = false;
    }
}

From source file:desmoj.extensions.visualization2d.engine.modelGrafic.StatisticGrafic.java

/**
 * Called by popup menu items to show statistics in InfoPane.
 *///from   w w  w .j av  a2s  .c  o m
public void actionPerformed(ActionEvent event) {
    InfoPane infoPane = ViewerPanel.getInfoPane();
    if (infoPane != null) {
        infoPane.setVisible(true);
        if (StatisticGrafic.TEXT_POPUP_MENU[0].equals(event.getActionCommand())) {
            infoPane.addStatistic(this.statistic.getId(), code, StatisticGrafic.ANIMATION_TimeValueDiagram,
                    isIntValue);
        } else if (StatisticGrafic.TEXT_POPUP_MENU[1].equals(event.getActionCommand())) {
            infoPane.addStatistic(this.statistic.getId(), code, StatisticGrafic.ANIMATION_Histogram,
                    isIntValue);
        }
    }
}

From source file:edu.ucla.stat.SOCR.chart.SuperPieChart.java

public void actionPerformed(ActionEvent event) {
    if (event.getSource() == addButton3) {
        addButtonPullout();/*from  w ww .  ja  v a  2  s.c o m*/
    } else if (event.getSource() == removeButton3) {
        removeButtonPullout();
    } else if (event.getActionCommand().equals(ROTATEON)) {
        turnRotateOn();
    } else if (event.getActionCommand().equals(ROTATEOFF)) {
        turnRotateOff();
    }
    super.actionPerformed(event);

}

From source file:com.funambol.json.admin.CalendarSyncSourceAdminPanel.java

/**
 * Create the panel//from w w  w.j a v  a 2s. co  m
 * @throws Exception if error occures during creation of the panel
 */
private void init() {

    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("Client 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));
    typeCombo.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            updateEntityTypeCheckBoxes();
        }
    });

    y += GAP_Y; // New line

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

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

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

    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) {
                    CalendarSyncSourceAdminPanel.this.actionPerformed(new ActionEvent(
                            CalendarSyncSourceAdminPanel.this, ACTION_EVENT_INSERT, event.getActionCommand()));
                } else {
                    CalendarSyncSourceAdminPanel.this.actionPerformed(new ActionEvent(
                            CalendarSyncSourceAdminPanel.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(confirmButton, null);
    this.add(eventValue, null);
    this.add(taskValue, null);
    this.add(datastoretypeLabel, null);
    this.add(datastoretypeCombo, null);

}

From source file:bio.gcat.gui.BDATool.java

@Override
public void actionPerformed(ActionEvent event) {
    String action;/*from   w w w  . j  a  va2 s. co m*/
    switch (action = event.getActionCommand()) {
    case ACTION_OPEN:
        openFile();
        break;
    case ACTION_SAVE_AS:
        saveFileAs();
        break;
    case ACTION_CLOSE:
        hideDialog();
        break;
    case ACTION_BDA_ADD:
        addBinaryDichotomicAlgorithm();
        break;
    case ACTION_BDA_EDIT:
        editBinaryDichotomicAlgorithm();
        break;
    case ACTION_BDA_REMOVE:
        removeBinaryDichotomicAlgorithm();
        break;
    case ACTION_BDAS_CLEAR:
        clearBinaryDichotomicAlgorithms();
        break;
    case ACTION_BDA_MOVE_UP:
        moveBinaryDichotomicAlgorithm(true);
        break;
    case ACTION_BDA_MOVE_DOWN:
        moveBinaryDichotomicAlgorithm(false);
        break;
    case ACTION_ABOUT:
        showAbout();
        break;
    default:
        System.err.println(String.format("Action %s not implemented.", action));
    }
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopSuggestionField.java

public DesktopSuggestionField() {
    composition = new JPanel();
    composition.setLayout(new BorderLayout());
    composition.setFocusable(false);/*from w ww  .ja  v  a  2s  . c  om*/

    comboBox = new SearchComboBox() {
        @Override
        public void setPopupVisible(boolean v) {
            if (!items.isEmpty()) {
                super.setPopupVisible(v);
            } else if (!v) {
                super.setPopupVisible(false);
            }
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            if (SearchAutoCompleteSupport.SEARCH_ENTER_COMMAND.equals(e.getActionCommand())) {
                enterHandling = true;
            }

            super.actionPerformed(e);
        }
    };

    comboBox.addActionListener(e -> {
        if (settingValue || disableActionListener) {
            return;
        }

        if ("comboBoxEdited".equals(e.getActionCommand())) {
            Object selectedItem = comboBox.getSelectedItem();

            if (popupItemSelectionHandling) {
                if (selectedItem instanceof ValueWrapper) {
                    Object selectedValue = ((ValueWrapper) selectedItem).getValue();
                    setValue(selectedValue);
                }
            } else if (enterHandling) {
                if (selectedItem instanceof String) {
                    boolean found = false;
                    String newFilter = (String) selectedItem;
                    if (prevValue != null) {
                        if (Objects.equals(getDisplayString(prevValue), newFilter)) {
                            found = true;
                        }
                    }

                    final boolean searchStringEqualsToCurrentValue = found;
                    // we need to do it later
                    // unable to change current text from ActionListener
                    SwingUtilities.invokeLater(() -> {
                        updateComponent(prevValue);

                        if (!searchStringEqualsToCurrentValue) {
                            handleOnEnterAction(((String) selectedItem));
                        }
                    });
                } else if (currentSearchComponentText != null) {
                    // Disable variants after select
                    final String enterActionString = currentSearchComponentText;
                    SwingUtilities.invokeLater(() -> {
                        updateComponent(prevValue);

                        handleOnEnterAction(enterActionString);
                    });

                    currentSearchComponentText = null;
                }
            }

            clearSearchVariants();

            popupItemSelectionHandling = false;
            enterHandling = false;
        }

        SwingUtilities.invokeLater(this::updateEditState);
    });

    Component editorComponent = comboBox.getEditor().getEditorComponent();
    editorComponent.addKeyListener(new KeyAdapter() {
        @Override
        public void keyTyped(KeyEvent e) {
            SwingUtilities.invokeLater(() -> {
                updateEditState();

                if (e.getKeyChar() != '\n') {
                    handleSearchInput();
                }
            });
        }

        @Override
        public void keyPressed(KeyEvent e) {
            SwingUtilities.invokeLater(() -> {
                if (e.getKeyCode() == KeyEvent.VK_DOWN && arrowDownActionHandler != null
                        && !comboBox.isPopupVisible()) {
                    arrowDownActionHandler.onArrowDownKeyPressed(getComboBoxEditorField().getText());
                }
            });
        }
    });

    comboBox.setEditable(true);
    comboBox.setPrototypeDisplayValue("AAAAAAAAAAAA");

    autoComplete = SearchAutoCompleteSupport.install(comboBox, items);
    autoComplete.setFilterEnabled(false);

    for (int i = 0; i < comboBox.getComponentCount(); i++) {
        Component component = comboBox.getComponent(i);
        component.addFocusListener(new FocusAdapter() {
            @Override
            public void focusLost(FocusEvent e) {
                clearSearchVariants();
                // Reset invalid value

                checkSelectedValue();
            }
        });
    }

    final JTextField searchEditorComponent = getComboBoxEditorField();
    searchEditorComponent.addActionListener(e -> currentSearchComponentText = searchEditorComponent.getText());

    // set value only on PopupMenu closing to avoid firing listeners on keyboard navigation
    comboBox.addPopupMenuListener(new PopupMenuListener() {
        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            comboBox.updatePopupWidth();
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            if (!autoComplete.isEditableState()) {
                popupItemSelectionHandling = comboBox.getSelectedIndex() >= 0;

                // Only if really item changed
                if (!enterHandling) {
                    Object selectedItem = comboBox.getSelectedItem();
                    if (selectedItem instanceof ValueWrapper) {
                        Object selectedValue = ((ValueWrapper) selectedItem).getValue();
                        setValue(selectedValue);

                        clearSearchVariants();
                    }
                }

                updateMissingValueState();
            }
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            clearSearchVariants();
        }
    });

    textField = new JTextField();
    textField.setEditable(false);
    UserSessionSource sessionSource = AppBeans.get(UserSessionSource.NAME);
    valueFormatter = new DefaultValueFormatter(sessionSource.getLocale());

    composition.add(comboBox, BorderLayout.CENTER);
    impl = comboBox;

    DesktopComponentsHelper.adjustSize(comboBox);

    Configuration configuration = AppBeans.get(Configuration.NAME);
    asyncSearchDelayMs = configuration.getConfig(ClientConfig.class).getSuggestionFieldAsyncSearchDelayMs();
}

From source file:org.gumtree.vis.plot1d.Plot1DChartEditor.java

@Override
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (command.equals(SHOW_MARKER_COMMAND)) {
        modifyBaseMarker();/*  www.  j  a v a  2s  .  c o  m*/
    } else if (command.equals(SHOW_ERROR_COMMAND)) {
        modifyBaseError();
    } else if (command.equals(CHANGE_CURVE_COMMAND)) {
        if (isPropertiesChanged) {
            updateChart(chart);
        }
        currentSeriesIndex = seriesCombo.getSelectedIndex();
        XYDataset dataset = chart.getXYPlot().getDataset();
        currentSeriesKey = (String) dataset.getSeriesKey(currentSeriesIndex);
        initialise(currentSeriesIndex);
        isPropertiesChanged = false;
    } else if (command.equals(CURVE_COLOR_COMMAND)) {
        modifyCurvePaint();
    } else if (command.equals(CURVE_STROCK_COMMAND)) {
        modifyCurveStroke();
    } else if (command.equals(MARKER_SHAPE_COMMAND)) {
        modifyMarkerShape();
    } else if (command.equals(MARKER_FILLED_COMMAND)) {
        modifyMarkerFilled();
    } else if (command.equals(CURVE_VISIBLE_COMMAND)) {
        modifyCurveVisibility();
    } else if (command.equals(CHANGE_ROI_COMMAND)) {
        Object obj = roiCombo.getSelectedItem();
        if (obj instanceof RangeMask) {
            newMask = null;
            chooseROI((RangeMask) obj);
        }
    } else if (command.equals(CREATE_NEW_RECT_REGION_COMMAND)) {
        createNewRectangleROI();
    } else if (command.equals(REMOVE_CHANGE_ACTION)) {
        removeROI();
    } else if (command.equals(APPLY_CHANGE_ACTION)) {
        applyROIChange();
        applyButton.setEnabled(false);
    } else if (command.equals(CHANGE_ROI_NAME_COMMAND)) {
        applyButton.setEnabled(true);
    } else if (command.equals(USE_INCLUSIVE_COMMAND)) {
        applyButton.setEnabled(true);
    } else if (command.equals(USE_EXCLUSIVE_COMMAND)) {
        applyButton.setEnabled(true);
    } else {
        super.actionPerformed(event);
    }
    if (!command.equals(CHANGE_CURVE_COMMAND)) {
        isPropertiesChanged = true;
    }
}

From source file:es.emergya.ui.gis.FleetControlMapViewer.java

@Override
public void actionPerformed(final ActionEvent e) {

    final CustomMapView mapViewLocal = this.mapView;

    SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() {
        @Override//from   ww w . jav a 2s  .  co  m
        protected Object doInBackground() throws Exception {

            try {
                final MouseEvent mouseEvent = FleetControlMapViewer.this.eventOriginal;
                if (e.getActionCommand().equals(// Centrar aqui
                        i18n.getString(Locale.ROOT, "map.menu.centerHere"))) {
                    mapViewLocal.zoomToFactor(mapViewLocal.getEastNorth(mouseEvent.getX(), mouseEvent.getY()),
                            mapViewLocal.zoomFactor);

                } else if (e.getActionCommand().equals(// nueva incidencia
                        i18n.getString("map.menu.newIncidence"))) {
                    Incidencia f = new Incidencia();
                    f.setCreador(Authentication.getUsuario());
                    LatLon from = mapViewLocal.getLatLon(mouseEvent.getX(), mouseEvent.getY());
                    GeometryFactory gf = new GeometryFactory();
                    f.setGeometria(gf.createPoint(new Coordinate(from.lon(), from.lat())));
                    IncidenceDialog id = new IncidenceDialog(f, i18n.getString("Incidences.summary.title") + " "
                            + i18n.getString("Incidences.nuevaIncidencia"), "tittleficha_icon_recurso");
                    id.setVisible(true);

                } else if (e.getActionCommand().equals(// ruta desde
                        i18n.getString("map.menu.route.from"))) {
                    routeDialog.showRouteDialog(mapViewLocal.getLatLon(mouseEvent.getX(), mouseEvent.getY()),
                            null, mapViewLocal);

                } else if (e.getActionCommand().equals(// ruta hasta
                        i18n.getString("map.menu.route.to"))) {
                    routeDialog.showRouteDialog(null,
                            mapViewLocal.getLatLon(mouseEvent.getX(), mouseEvent.getY()), mapViewLocal);

                } else if (e.getActionCommand().equals(// Actualizar gps
                        i18n.getString("map.menu.gps"))) {
                    if (!(menuObjective instanceof Recurso)) {
                        return null;
                    }

                    GPSDialog sdsDialog = null;
                    for (Frame f : Frame.getFrames()) {
                        if (f instanceof GPSDialog)
                            if (((GPSDialog) f).getRecurso().equals(menuObjective))
                                sdsDialog = (GPSDialog) f;
                    }
                    if (sdsDialog == null)
                        sdsDialog = new GPSDialog((Recurso) menuObjective);
                    sdsDialog.setVisible(true);
                    sdsDialog.setExtendedState(JFrame.NORMAL);

                } else if (e.getActionCommand().equals(// Ficha
                        i18n.getString("map.menu.summary"))) {
                    if (log.isTraceEnabled()) {
                        log.trace("Mostramos la ficha del objetivo del menu");
                    }
                    if (menuObjective instanceof Recurso) {
                        log.trace(">recurso");
                        SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() {

                            @Override
                            protected Object doInBackground() throws Exception {
                                for (Frame f : JFrame.getFrames()) {
                                    if (f.getName().equals(((Recurso) menuObjective).getIdentificador())
                                            && f instanceof SummaryDialog) {
                                        if (f.isShowing()) {
                                            f.toFront();
                                            f.setExtendedState(JFrame.NORMAL);
                                            return null;
                                        }
                                    }
                                }
                                new SummaryDialog((Recurso) menuObjective).setVisible(true);
                                return null;
                            }
                        };

                        sw.execute();
                    } else if (menuObjective instanceof Incidencia) {
                        if (log.isTraceEnabled()) {
                            log.trace(">incidencia");
                        }
                        SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() {

                            @Override
                            protected Object doInBackground() throws Exception {
                                for (Frame f : JFrame.getFrames()) {
                                    if (f.getName().equals(((Incidencia) menuObjective).getTitulo())
                                            && f instanceof IncidenceDialog) {
                                        if (log.isTraceEnabled()) {
                                            log.trace("Ya lo tenemos abierto");
                                        }
                                        if (f.isShowing()) {
                                            f.toFront();
                                            f.setExtendedState(JFrame.NORMAL);
                                        } else {
                                            f.setVisible(true);
                                            f.setExtendedState(JFrame.NORMAL);
                                        }
                                        return null;
                                    }
                                }
                                if (log.isTraceEnabled()) {
                                    log.trace("Abrimos uno nuevo");
                                }
                                new IncidenceDialog((Incidencia) menuObjective,
                                        i18n.getString("Incidences.summary.title") + " "
                                                + ((Incidencia) menuObjective).getTitulo(),
                                        "tittleficha_icon_recurso").setVisible(true);
                                return null;
                            }
                        };

                        sw.execute();
                    } else {
                        return null;
                    }

                } else if (e.getActionCommand().equals( // Mas cercanos
                        i18n.getString("map.menu.showNearest"))) {
                    if (log.isTraceEnabled()) {
                        log.trace("showNearest");
                    }

                    if (menuObjective != null) {
                        for (Frame f : JFrame.getFrames()) {
                            String identificador = menuObjective.toString();
                            if (menuObjective instanceof Recurso) {
                                identificador = ((Recurso) menuObjective).getIdentificador();
                            }
                            if (menuObjective != null && f.getName().equals(identificador)
                                    && f instanceof NearestResourcesDialog && f.isDisplayable()) {
                                if (log.isTraceEnabled()) {
                                    log.trace("Encontrado " + f);
                                }
                                if (f.isShowing()) {
                                    f.toFront();
                                    f.setExtendedState(JFrame.NORMAL);
                                } else {
                                    f.setVisible(true);
                                    f.setExtendedState(JFrame.NORMAL);
                                }
                                return null;
                            }
                        }
                    }
                    NearestResourcesDialog d;
                    if (menuObjective instanceof Recurso) {
                        d = new NearestResourcesDialog((Recurso) menuObjective, mapViewLocal);
                    } else if (menuObjective instanceof Incidencia) {
                        d = new NearestResourcesDialog((Incidencia) menuObjective,
                                mapViewLocal.getLatLon(mouseEvent.getX(), mouseEvent.getY()), mapViewLocal);
                    } else {
                        d = new NearestResourcesDialog(
                                mapViewLocal.getLatLon(mouseEvent.getX(), mouseEvent.getY()), mapViewLocal);
                    }
                    d.setVisible(true);

                } else {
                    log.error("ActionCommand desconocido: " + e.getActionCommand());
                }
            } catch (Throwable t) {
                log.error("Error al ejecutar la accion del menu contextual", t);
            }
            return null;
        }
    };

    sw.execute();
}