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:net.sf.firemox.DeckBuilder.java

/**
 * Invoked when an action occurs.// w ww.j  a va 2 s  . c om
 * 
 * @param e
 *          attached event
 */
@SuppressWarnings("unchecked")
public void actionPerformed(ActionEvent e) {
    String command = e.getActionCommand();
    if ("menu_help_about".equals(command)) {
        new About(form).setVisible(true);
    } else if ("menu_db_exit".equals(command)) {
        exitForm();
    } else if ("menu_db_new".equals(command)) {
        if (!verifyModification()) {
            return;
        }
        setTitle("DeckBuilder");
        deckNameTxt.setText("");
        rightListModel.getCards().clear();
        datasets.removeAll();
        modifiedSinceSave = false;
        updateChecker();
        setAsNew();
    } else if ("menu_convert_DCK_MP".equals(command)) {
        /*
         * Convert an entire directory from a format to MP one
         */
        try {
            Converter
                    .convertDCK(MToolKit
                            .showDialogFile("Choose a directory of DCK to convert", 'o', null, FILTER_DECK,
                                    this, JFileChooser.OPEN_DIALOG, JFileChooser.DIRECTORIES_ONLY)
                            .getCanonicalPath());
        } catch (IOException e1) {
            JOptionPane.showMessageDialog(this, "Error occurred reading the specified directory",
                    "File problem", JOptionPane.ERROR_MESSAGE);
        } catch (Exception e1) {
            // cancel of user;
        }
    } else if ("menu_db_constraints".equals(command)) {
        // Show the deck constraints applied on the current TBS
        new DeckRules(this).setVisible(true);
    } else if ("menu_help_help".equals(command)) {
        /*
         * This method is invoked when user has chosen to see the help file. <br>
         * TODO documentation is not yet done for this form
         */
        JOptionPane.showMessageDialog(form, "Sorry, no documentation available for deck builder",
                "Negative yet implemented", JOptionPane.INFORMATION_MESSAGE);
    } else if ("menu_db_load".equals(command)) {
        if (verifyModification()) {
            String deckFile = MToolKit.getDeckFile(this, JFileChooser.OPEN_DIALOG);
            if (deckFile != null) {
                loadDeck(deckFile, rightListModel.getCards());
            }
        }
    } else if ("menu_db_saveas".equals(command)) {
        String deckFile = MToolKit.getDeckFile(this, JFileChooser.SAVE_DIALOG);
        if (deckFile != null) {
            MSaveDeck.saveDeck(deckFile, rightListModel.getCards(), form);
            setAsSaved();
        }
    } else if ("menu_db_save".equals(command)) {
        saveCurrentDeck();
        setAsSaved();
    } else {
        // several implemented filters
        final MListModel<MCardCompare> model = (MListModel<MCardCompare>) leftList.getModel();

        final FileInputStream dbStream = MdbLoader.resetMdb();

        final List<MCardCompare> toRemove = new ArrayList<MCardCompare>();

        if ("clear".equals(command)) {
            // Reset the color filters
            for (Component component : toolBar.getComponents()) {
                if (component instanceof JToggleButton) {
                    ((JToggleButton) component).setSelected(true);
                }
            }
        }
        model.addAll(model.removedDelegate);

        final int cardType = CardFactory.getIdCard((String) idCardComboBox.getSelectedItem());
        if (cardType != -1) {
            // "All" is not selected in card type filter
            // we remove the cards that don't have the selected card id
            for (MCardCompare cardCompare : model.delegate) {
                try {
                    final CardModel cardModel = cardCompare.getModel(dbStream);
                    if (!MCard.hasIdCard(cardModel.getIdCard(), cardType)) {
                        toRemove.add(cardCompare);
                    }
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
            model.removeAll(toRemove);
            toRemove.clear();
        }

        // property filter
        // we search for the property value, if it isn't found it's because "All"
        // is selected in the comboBox
        int property = CardFactory.getProperty((String) propertiesComboBox.getSelectedItem());

        if (property != -1) {
            // "All" is not selected in property filter
            // we remove the cards that don't have the selected property
            for (MCardCompare cardCompare : model.delegate) {
                try {
                    final CardModel cardModel = cardCompare.getModel(dbStream);
                    if (!MCard.hasProperty(cardModel.getProperties(), property)) {
                        toRemove.add(cardCompare);
                    }
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
            model.removeAll(toRemove);
            toRemove.clear();
        }

        // color filters
        for (int i = 1; i < IdCardColors.CARD_COLOR_VALUES.length + 1; i++) {
            final JToggleButton colorButton = (JToggleButton) toolBar.getComponent(i);
            if (!colorButton.isSelected()) {
                for (MCardCompare cardCompare : model.delegate) {
                    try {
                        final CardModel cardModel = cardCompare.getModel(dbStream);
                        if (i == 1) {
                            if (cardModel.getIdColor() == 0) {
                                toRemove.add(cardCompare);
                            }
                        } else if ((cardModel.getIdColor()
                                & IdCardColors.CARD_COLOR_VALUES[i - 1]) == IdCardColors.CARD_COLOR_VALUES[i
                                        - 1]) {
                            toRemove.add(cardCompare);
                        }
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    }
                }
                model.removeAll(toRemove);
                toRemove.clear();
            }
        }
        leftList.repaint();
        if (!model.isEmpty())
            leftList.setSelectedIndex(0);
    }
}

From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.java

public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equalsIgnoreCase("Rename ...")) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        QueryMasterData ndata = (QueryMasterData) node.getUserObject();
        Object inputValue = JOptionPane.showInputDialog(this, "Rename this query to: ", "Rename Query Dialog",
                JOptionPane.PLAIN_MESSAGE, null, null,
                ndata.name().substring(0, ndata.name().lastIndexOf("[") - 1));

        if (inputValue != null) {
            String newQueryName = (String) inputValue;
            String requestXml = ndata.writeRenameQueryXML(newQueryName);
            lastRequestMessage = requestXml;

            setCursor(new Cursor(Cursor.WAIT_CURSOR));

            String response = QueryListNamesClient.sendQueryRequestREST(requestXml);
            if (response.equalsIgnoreCase("CellDown")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent,
                                "Trouble with connection to the remote server, "
                                        + "this is often a network error, please try again",
                                "Network Error", JOptionPane.INFORMATION_MESSAGE);
                    }//from  ww  w . j a  v  a2  s .c om
                });
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                return;
            }
            lastResponseMessage = response;

            if (response != null) {
                JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();

                try {
                    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                    ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                    StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                    String status = statusType.getType();

                    if (status.equalsIgnoreCase("DONE")) {
                        ndata.name(newQueryName + " [" + ndata.userId() + "]");
                        node.setUserObject(ndata);
                        //DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();

                        jTree1.repaint();
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
    } else if (e.getActionCommand().equalsIgnoreCase("Delete")) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        QueryMasterData ndata = (QueryMasterData) node.getUserObject();
        Object selectedValue = JOptionPane.showConfirmDialog(this, "Delete Query \"" + ndata.name() + "\"?",
                "Delete Query Dialog", JOptionPane.YES_NO_OPTION);
        if (selectedValue.equals(JOptionPane.YES_OPTION)) {
            System.out.println("delete " + ndata.name());
            String requestXml = ndata.writeDeleteQueryXML();
            lastRequestMessage = requestXml;
            //System.out.println(requestXml);

            setCursor(new Cursor(Cursor.WAIT_CURSOR));

            String response = QueryListNamesClient.sendQueryRequestREST(requestXml);
            if (response.equalsIgnoreCase("CellDown")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent,
                                "Trouble with connection to the remote server, "
                                        + "this is often a network error, please try again",
                                "Network Error", JOptionPane.INFORMATION_MESSAGE);
                    }
                });
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                return;
            }
            lastResponseMessage = response;

            if (response != null) {
                JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();

                try {
                    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                    ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                    StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                    String status = statusType.getType();

                    if (status.equalsIgnoreCase("DONE")) {
                        treeModel.removeNodeFromParent(node);

                        //jTree1.repaint();
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
    } else if (e.getActionCommand().equalsIgnoreCase("Refresh All")) {
        String status = loadPreviousQueries(false);
        if (status.equalsIgnoreCase("")) {
            reset(200, false);
        } else if (status.equalsIgnoreCase("CellDown")) {
            final JPanel parent = this;
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(parent,
                            "Trouble with connection to the remote server, "
                                    + "this is often a network error, please try again",
                            "Network Error", JOptionPane.INFORMATION_MESSAGE);
                }
            });
        }
    }
}

From source file:edu.ucla.stat.SOCR.applications.demo.PortfolioApplication2.java

public void actionPerformed(ActionEvent evt) {
    for (int i = 0; i < 2; i++)
        if (evt.getActionCommand().equals(switchArray[i])) {
            switchedFlag = true;// w ww  .j  a v  a  2  s  .  c  om
            covarianceFlag = !covarianceFlag;
            setSliders();
        }
    for (int i = 0; i < numStocksArray.length; i++)
        if (evt.getActionCommand().equals(numStocksArray[i])) {
            setNumberStocks(numStocksArray[i]);
        }

    for (int i = 0; i < on_off.length; i++)
        if (evt.getActionCommand().equals(on_off[i])) {
            if (i == 0)
                setTangent(true);
            else
                setTangent(false);
        }
}

From source file:de.dmarcini.submatix.pclogger.gui.spx42LogGraphPanel.java

@Override
public void actionPerformed(ActionEvent ev) {
    String cmd = ev.getActionCommand();
    String entry = null;// w  ww  .ja  v a  2  s .  c  o  m
    int dbId;
    String device;
    //
    // /////////////////////////////////////////////////////////////////////////
    // Button
    if (ev.getSource() instanceof JButton) {
        // JButton srcButton = ( JButton )ev.getSource();
        // /////////////////////////////////////////////////////////////////////////
        // Anzeigebutton?
        if (cmd.equals("show_log_graph")) {
            lg.debug("show log graph initiated.");
            // welches Device ?
            if (deviceComboBox.getSelectedIndex() < 0) {
                // kein Gert ausgewhlt
                lg.warn("no device selected.");
                return;
            }
            // welchen Tauchgang?
            if (diveSelectComboBox.getSelectedIndex() < 0) {
                lg.warn("no dive selected.");
                return;
            }
            device = ((DeviceComboBoxModel) deviceComboBox.getModel())
                    .getDeviceSerialAt(deviceComboBox.getSelectedIndex());
            dbId = ((LogListComboBoxModel) diveSelectComboBox.getModel())
                    .getDatabaseIdAt(diveSelectComboBox.getSelectedIndex());
            lg.debug("Select Device-Serial: " + device + ", DBID: " + dbId);
            if (dbId < 0) {
                lg.error("can't find database id for dive.");
                return;
            }
            makeGraphForLog(dbId, device);
            return;
        } else if (cmd.equals("set_detail_for_show_graph")) {
            lg.debug("select details for log selected.");
            SelectGraphDetailsDialog sgd = new SelectGraphDetailsDialog();
            if (sgd.showModal()) {
                lg.debug("dialog returned 'true' => change propertys...");
                computeGraphButton.doClick();
            }
        } else if (cmd.equals("edit_notes_for_dive")) {
            if (chartPanel == null || showingDbIdForDiveWasShowing == -1) {
                lg.warn("it was not showing a dive! do nothing!");
                return;
            }
            lg.debug("edit a note for this dive...");
            showNotesEditForm(showingDbIdForDiveWasShowing);
        } else {
            lg.warn("unknown button command <" + cmd + "> recived.");
        }
        return;
    }
    // /////////////////////////////////////////////////////////////////////////
    // Combobox
    else if (ev.getSource() instanceof JComboBox<?>) {
        @SuppressWarnings("unchecked")
        JComboBox<String> srcBox = (JComboBox<String>) ev.getSource();
        // /////////////////////////////////////////////////////////////////////////
        // Gert zur Grafischen Darstellung auswhlen
        if (cmd.equals("change_device_to_display")) {
            if (srcBox.getModel() instanceof DeviceComboBoxModel) {
                entry = ((DeviceComboBoxModel) srcBox.getModel()).getDeviceSerialAt(srcBox.getSelectedIndex());
                lg.debug("device <" + entry + ">...Index: <" + srcBox.getSelectedIndex() + ">");
                fillDiveComboBox(entry);
            }
        }
        // /////////////////////////////////////////////////////////////////////////
        // Dive zur Grafischen Darstellung auswhlen
        else if (cmd.equals("change_dive_to_display")) {
            entry = (String) srcBox.getSelectedItem();
            lg.debug("dive <" + entry + ">...Index: <" + srcBox.getSelectedIndex() + ">");
            // fillDiveComboBox( entry );
        } else {
            lg.warn("unknown combobox command <" + cmd + "> recived.");
        }
        return;
    } else {
        lg.warn("unknown action command <" + cmd + "> recived.");
    }
}

From source file:com.vgi.mafscaling.ClosedLoop.java

@Override
public void actionPerformed(ActionEvent e) {
    if (checkActionPerformed(e))
        return;//from   w w  w  .  j a  va2s. c  o m
    if ("dvdt".equals(e.getActionCommand())) {
        JCheckBox checkBox = (JCheckBox) e.getSource();
        if (checkBox.isSelected()) {
            clearNotRunDataCheckboxes();
            clearRunDataCheckboxes();
            if (plotDvdtData())
                checkBox.setSelected(true);
        } else
            runData.clear();
        setRanges();
    } else if ("iat".equals(e.getActionCommand())) {
        JCheckBox checkBox = (JCheckBox) e.getSource();
        if (checkBox.isSelected()) {
            clearNotRunDataCheckboxes();
            clearRunDataCheckboxes();
            if (plotIatData())
                checkBox.setSelected(true);
        } else
            runData.clear();
        setRanges();
    } else if ("trpm".equals(e.getActionCommand())) {
        JCheckBox checkBox = (JCheckBox) e.getSource();
        if (checkBox.isSelected()) {
            clearNotRunDataCheckboxes();
            clearRunDataCheckboxes();
            if (plotTrimRpmData())
                checkBox.setSelected(true);
        } else {
            runData.clear();
            currMafData.clear();
        }
        setRanges();
    } else if ("mnmd".equals(e.getActionCommand())) {
        JCheckBox checkBox = (JCheckBox) e.getSource();
        if (checkBox.isSelected()) {
            clearNotRunDataCheckboxes();
            clearRunDataCheckboxes();
            if (plotMeanModeData())
                checkBox.setSelected(true);
        } else {
            currMafData.clear();
            corrMafData.clear();
            runData.clear();
        }
        setRanges();
    } else if ("corrdata".equals(e.getActionCommand())) {
        JCheckBox checkBox = (JCheckBox) e.getSource();
        if (checkBox.isSelected()) {
            clearRunDataCheckboxes();
            if (!plotCorrectionData())
                checkBox.setSelected(false);
        } else
            runData.clear();
        setRanges();
    } else if ("current".equals(e.getActionCommand())) {
        JCheckBox checkBox = (JCheckBox) e.getSource();
        if (checkBox.isSelected()) {
            clearRunDataCheckboxes();
            if (!plotCurrentMafData())
                checkBox.setSelected(false);
        } else
            currMafData.clear();
        setRanges();
    } else if ("corrected".equals(e.getActionCommand())) {
        JCheckBox checkBox = (JCheckBox) e.getSource();
        if (checkBox.isSelected()) {
            clearRunDataCheckboxes();
            if (!setCorrectedMafData())
                checkBox.setSelected(false);
        } else
            corrMafData.clear();
        setRanges();
    } else if ("smoothed".equals(e.getActionCommand())) {
        JCheckBox checkBox = (JCheckBox) e.getSource();
        if (checkBox.isSelected()) {
            clearRunDataCheckboxes();
            if (!setSmoothedMafData())
                checkBox.setSelected(false);
        } else
            smoothMafData.clear();
        setRanges();
    } else if ("smoothing".equals(e.getActionCommand())) {
        JCheckBox checkBox = (JCheckBox) e.getSource();
        if (checkBox.isSelected())
            enableSmoothingView(true);
        else
            enableSmoothingView(false);
        setRanges();
    }
}

From source file:com.floreantpos.ui.model.MenuItemForm.java

public void actionPerformed(ActionEvent e) {
    String actionCommand = e.getActionCommand();
    if (actionCommand.equals("AddModifierGroup")) { //$NON-NLS-1$
        addMenuItemModifierGroup();//w ww .  j ava2 s. com
    } else if (actionCommand.equals("EditModifierGroup")) { //$NON-NLS-1$
        editMenuItemModifierGroup();
    } else if (actionCommand.equals("DeleteModifierGroup")) { //$NON-NLS-1$
        deleteMenuItemModifierGroup();
    } else if (actionCommand.equals(com.floreantpos.POSConstants.ADD_SHIFT)) {
        addShift();
    } else if (actionCommand.equals(com.floreantpos.POSConstants.DELETE_SHIFT)) {
        deleteShift();
    }
}

From source file:de.tor.tribes.ui.views.DSWorkbenchReportFrame.java

@Override
public void actionPerformed(ActionEvent e) {
    ReportTableTab activeTab = getActiveTab();
    if (e.getActionCommand() != null && activeTab != null) {
        if (e.getActionCommand().equals("Copy")) {
            activeTab.transferSelection(ReportTableTab.TRANSFER_TYPE.COPY_TO_INTERNAL_CLIPBOARD);
        } else if (e.getActionCommand().equals("BBCopy")) {
            activeTab.transferSelection(ReportTableTab.TRANSFER_TYPE.CLIPBOARD_BB);
        } else if (e.getActionCommand().equals("Cut")) {
            activeTab.transferSelection(ReportTableTab.TRANSFER_TYPE.CUT_TO_INTERNAL_CLIPBOARD);
        } else if (e.getActionCommand().equals("Paste")) {
            activeTab.transferSelection(ReportTableTab.TRANSFER_TYPE.FROM_INTERNAL_CLIPBOARD);
        } else if (e.getActionCommand().equals("Delete")) {
            activeTab.deleteSelection(true);
        } else if (e.getActionCommand().equals("Find")) {
            BufferedImage back = ImageUtils.createCompatibleBufferedImage(3, 3, BufferedImage.TRANSLUCENT);
            Graphics g = back.getGraphics();
            g.setColor(new Color(120, 120, 120, 120));
            g.fillRect(0, 0, back.getWidth(), back.getHeight());
            g.setColor(new Color(120, 120, 120));
            g.drawLine(0, 0, 3, 3);//from   ww w. ja v  a2s. c o m
            g.dispose();
            TexturePaint paint = new TexturePaint(back,
                    new Rectangle2D.Double(0, 0, back.getWidth(), back.getHeight()));
            jxSearchPane.setBackgroundPainter(new MattePainter(paint));
            DefaultListModel model = new DefaultListModel();

            for (int i = 0; i < activeTab.getReportTable().getColumnCount(); i++) {
                TableColumnExt col = activeTab.getReportTable().getColumnExt(i);
                if (col.isVisible()) {
                    if (!col.getTitle().equals("Status") && !col.getTitle().equals("Typ")
                            && !col.getTitle().equals("Sonstiges")) {
                        model.addElement(col.getTitle());
                    }
                }
            }
            jXColumnList.setModel(model);
            jXColumnList.setSelectedIndex(0);
            jxSearchPane.setVisible(true);
        }
    }
}

From source file:org.fhaes.fhsamplesize.view.FHSampleSize.java

/**
 * TODO/*w  w w .jav  a  2  s.  com*/
 */
@Override
public void actionPerformed(ActionEvent evt) {

    if (evt.getActionCommand().equals("Reset")) {
        // Reset the GUI for a new run
        int response = JOptionPane.showConfirmDialog(this, "Are you sure you want to start a new analysis?");
        if (response != JOptionPane.YES_OPTION)
            return;

        this.txtInputFile.setText(null);
        this.cboEventType.setSelectedIndex(0);
        this.spnSimulations.setValue(1000);
        this.spnSeed.setValue(30188);
        this.cboResampling.setSelectedIndex(0);
        this.cboThresholdType.setSelectedIndex(0);
        this.spnThresholdValueGT.setValue(1);
        segmentationPanel.chkSegmentation.setSelected(false);
        segmentationPanel.table.tableModel.clearSegments();
        this.panelChart.removeAll();
        this.panelChart.repaint();
        this.simulationsTable.removeAllRows();
        this.cboChartMetric.setEnabled(false);
        this.cboSegment.setEnabled(false);
    } else if (evt.getActionCommand().equals("NewFileTyped")) {
        // A new file name was typed
        try {
            if (filePathHasValidFile(txtInputFile.getText())) {
                actionRun.setEnabled(true);
                actionSaveTable.setEnabled(true);
                segmentationPanel.chkSegmentation.setEnabled(true);
            } else {
                actionRun.setEnabled(false);
                actionSaveTable.setEnabled(false);
                segmentationPanel.chkSegmentation.setEnabled(false);
            }
        } catch (Exception ex) {
            actionRun.setEnabled(false);
            actionSaveTable.setEnabled(false);
            segmentationPanel.chkSegmentation.setEnabled(false);
        }
    } else if (evt.getActionCommand().equals("UpdateChart")) {
        updateChart();
    } else if (evt.getActionCommand().equals("CancelAnalysis")) {
        // Cancel the analysis that is currently running
        taskWasCancelled = true;
        task.cancel(true);
    } else if (evt.getActionCommand().equals("LessThanThresholdStatus")) {
        setGUIForThresholdStatus();
    }
}

From source file:com.lp.client.frame.component.PanelDokumentenablage.java

protected void eventActionSpecial(ActionEvent e) throws Throwable {
    if (e.getActionCommand().equals(ACTION_SPECIAL_PARTNER)) {
        panelQueryFLRPartner = PartnerFilterFactory.getInstance().createPanelFLRPartner(getInternalFrame(),
                partnerDto == null ? null : partnerDto.getIId(), false);
        new DialogQuery(panelQueryFLRPartner);
    } else if (e.getActionCommand().equals(ACTION_SPECIAL_CHOOSE)) {
        chooseFile();/*w w  w. j  av a 2s  .  c  o  m*/
        wtfFilename.setText(file.getName());
        if (file.getName().lastIndexOf(".") != -1) {
            wtfMIME.setText(file.getName().substring(file.getName().lastIndexOf(".")));
        } else {
            wtfMIME.setText("");
        }
    } else if (e.getActionCommand().equals(ACTION_SPECIAL_SHOW)) {
        showFile();
    } else if (e.getActionCommand().equals(ACTION_SPECIAL_SAVE)) {
        saveFile();
    } else if (e.getActionCommand().equals(BUTTON_SCAN)) {
        try {
            if (file == null) {
                // Es wird ein Neues Dokument angelegt
                bNewNode = true;
                clearComponents();

                file = getInternalFrame().scanFile();

                if (file != null) {
                    enableToolsPanelButtons(true, PanelBasis.ACTION_SAVE, PanelBasis.ACTION_DISCARD,
                            BUTTON_SCAN);
                    enableToolsPanelButtons(false, PanelBasis.ACTION_UPDATE, PanelBasis.ACTION_NEW);
                    setDefaultsForNew();
                    enableAllComponents(this, true);

                    tree.setEnabled(false);
                }
            } else {
                // Es wird eine neue Version angelegt
                file = getInternalFrame().scanFile();
                wtfFilename.setText(file.getName());
                if (file.getName().lastIndexOf(".") != -1) {
                    wtfMIME.setText(file.getName().substring(file.getName().lastIndexOf(".")));
                } else {
                    wtfMIME.setText("");
                }
            }
        } catch (Throwable t) {
            DialogFactory.showModalDialog(LPMain.getTextRespectUISPr("lp.error"),
                    LPMain.getTextRespectUISPr("lp.error.scannen"));

        }

    } else {
        super.eventActionSpecial(e);
    }
}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.imagem.analise_geral.PanelAnaliseGeral.java

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    if (cmd == "Salvar") {
        // salvaAlteracoes.salvar();

    } else if (cmd.equals("SelecionarTudo")) {
        boxCode.getTextPane().selectAll();
        boxCode.getTextPane().requestFocus();
    } else if (cmd == "Abrir") {
        abrirArquivoLocal();//from  w  w w  .  j a v a2  s  .c  o m
    } else if (cmd == "SaveAs") {
        salvaAlteracoes.salvarComo();
        // salvarComo();
    } else if (cmd == "AbrirURL") {
        abreUrl();
    } else if (cmd == "Sair") {
        salvaAlteracoes.sair();
    } else if (cmd == "Desfazer") {
        // boxCode.undo();
        // boxCode.coloreSource();
        // reavalia(boxCode.getText());
    } else if (cmd == "AumentaFonte") {
        boxCode.aumentaFontSize();
    } else if (cmd == "DiminuiFonte") {
        boxCode.diminuiFontSize();
    } else if (cmd == "Creditos") {
        new Creditos();
    } else if (cmd == "Contraste") {
        boxCode.autoContraste();

        int selectedStart = 0;
        int selectedEnd = 0;
        int corretordePosicoesdoLabel = 0;
        int corretordePosicoesdoControle = 0;
        ArrayList<Integer> ordenador = new ArrayList<Integer>();
        ArrayList<String> conteudoParticRotuloOrdenado = new ArrayList<String>();
        conteudoParticRotulo = null;
        conteudoParticRotulo = tArParticipRotulo.getTextoEPos();
        String[] conteudo = new String[3];
        String codHTML = boxCode.getTextPane().getText().replace("\r", "");
        // System.out.println(codHTML.substring((Integer) (getPosTagRepEnd()
        // + corretordePosicoesdoControle - 1), (getPosTagRepEnd() +
        // corretordePosicoesdoControle - 1) + 36));

        while (codHTML.indexOf("SIL" + inicial) != -1) {
            inicial++;
        }

        ColorModel cm = tArParticipRotulo.getColorModel();

        for (String conteudoPR : conteudoParticRotulo) {
            conteudo = conteudoPR.split("@");
            ordenador.add(Integer.parseInt(conteudo[1]));
        }

        int[] ordem = new int[ordenador.size()];
        for (int i = 0; i < ordem.length; i++) {
            ordem[i] = ordenador.get(i);
        }

        Arrays.sort(ordem);

        for (int i = 0; i < ordem.length; i++) {
            for (String conteudoPR : conteudoParticRotulo) {
                conteudo = conteudoPR.split("@");

                if (Integer.parseInt(conteudo[1]) == ordem[i]) {
                    conteudoParticRotuloOrdenado.add(conteudoPR);
                }

            }
        }
        for (String conteudoPR : conteudoParticRotuloOrdenado) {
            conteudo = conteudoPR.split("@");

            // System.out.println("posico: " +
            // Integer.parseInt(conteudo[1]));

        }

        for (String conteudoPR : conteudoParticRotuloOrdenado) {

            conteudo = conteudoPR.split("@");
            conteudo[0] = "<label for=\"SIL" + inicial + "\">" + conteudo[0] + "</label>";
            selectedStart = Integer.parseInt(conteudo[1]) + corretordePosicoesdoLabel;
            selectedEnd = Integer.parseInt(conteudo[2]) + corretordePosicoesdoLabel;
            // corretordePosicoesdoLabel += ("<label for=\"SIL" + inicial +
            // "\"></label>").length();

            if ((selectedStart < getPosTagRepInit() + corretordePosicoesdoLabel)) {
                corretordePosicoesdoControle = corretordePosicoesdoLabel;

            }
            /*
             * if((selectedStart>getPosTagRepInit()+corretordePosicoesdoLabel)){
             * //arTextPainelCorrecao.select(selectedStart+("id=x").length(),
             * selectedEnd+("id=x").length());
             * 
             * }else{ }
             */
            // scrollPaneCorrecaoLabel.getTextPane().select(selectedStart,
            // selectedEnd);
            // arTextPainelCorrecao.setTextoParaSelecionado(conteudo[0]);
            arTextPainelCorrecao.setASet(arTextPainelCorrecao.getSc().addAttributes(SimpleAttributeSet.EMPTY,
                    SimpleAttributeSet.EMPTY));
            boxCode.getTextPane().select(selectedStart, selectedEnd);
            arTextPainelCorrecao.setColorForSelectedText(new Color(255, 204, 102), new Color(0, 0, 0));
            boxCode.getTextPane().setCharacterAttributes(arTextPainelCorrecao.getASet(), false);

        }

        // arTextPainelCorrecao.formataHTML();
        // tArParticipRotulo.apagaTexto();

        TabelaAnaliseGeral tcl = tableLinCod;
        int linha = (Integer) dtm.getValueAt(tcl.getSelectedRow(), 0);
        int coluna = (Integer) dtm.getValueAt(tcl.getSelectedRow(), 1);
        int endTag = 0;
        int posAtual = 0;
        int posFinal = 0;
        codHTML = boxCode.getTextPane().getText().replace("\r", "");
        int i;
        for (i = 0; i < (linha - 1); i++) {
            posAtual = codHTML.indexOf("\n", posAtual + 1);
        }
        i = 0;
        // gambiarra provisria
        posFinal = codHTML.indexOf((String) dtm.getValueAt(tcl.getSelectedRow(), 2), posAtual + coluna);
        while (codHTML.charAt(posFinal + i) != '>') {
            i++;
        }

        setPosTagRepInit(posFinal);
        setPosTagRepEnd(posFinal + i + 1);

        boxCode.goToLine(linha);
        boxCode.getTextPane().select(getPosTagRepInit(), getPosTagRepEnd());

        arTextPainelCorrecao.setColorForSelectedText(Color.decode("0xEEEEEE"), new Color(255, 0, 0));
        arTextPainelCorrecao.setUnderline();
        // TODO Auto-generated method stub
        // tArParticipRotulo.apagaTexto();

    }

}