Example usage for javax.swing Action toString

List of usage examples for javax.swing Action toString

Introduction

In this page you can find the example usage for javax.swing Action toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:GUI.WebBrowserPanel.java

@Override
public void onLoadingEnded() {
    if (m_frame != null) {
        try {// w w  w . j a  v  a2 s.co  m
            String urltext = getDocument().getDocumentURI();
            URL url = new URL(urltext);
            InputStreamReader isr = new InputStreamReader(url.openStream());
            BufferedReader in = new BufferedReader(isr);
            String inputLine;

            urltext = null;
            url = null;

            m_content.clear();
            while ((inputLine = in.readLine()) != null) {
                m_content.add(inputLine);
            }
            in.close();

            isr = null;
            in = null;
            inputLine = null;

            Action action = parseHtml();
            if (action.value() == Action.ACTION_BROWSER_LOADING_DONE
                    && action.toString().equals(Action.COMMAND_CARD_PREVIEW)) {
                FileUtils.copyURLToFile(new URL(getCardImageURL(m_card.MID)), new File(m_card.getImagePath()));
                fireActionEvent(MainWindow.class, action.value(), action.toString());
            }

            action = null;

        } catch (Exception ex) {
            Dialog.ErrorBox(m_frame, ex.getStackTrace());
        }
    }
    m_loading = false;
}

From source file:com.aw.swing.mvp.action.ActionManager.java

private Object executeInternal(Action action) {
    actionToBeExecuted = action;//  w w w  .j a  va2 s. c  om
    Object actionResult = null;
    logger.debug("The action:<" + actionToBeExecuted + "> will be executed");
    Throwable actionException = null;
    try {
        AWInputVerifier.getInstance().disable();
        Presenter pst = action.getPst();
        if (action.isOnFailedMode()) {
            HbmFailMngr.seFailMode(true);
        }
        actionResult = action.execute();

        if (!(action instanceof RoundTransitionAction)) {
            if (action.refreshGridAtEnd) {
                action.getGridProvider().refresh(pst.getBackBean());
            }
            if (action.repaintGridAtEnd) {
                action.getGridProvider().repaint();
            }
            setActionExecuted(action.toString());
            logger.info("The action:<" + action.toString() + "> was executed");
        }
        String resultMsg = action.getResultMsg();
        if (StringUtils.hasText(resultMsg)) {
            if (resultMsg.indexOf("${") != -1) {
                if (ViewMode.MODE_INSERT.equals(pst.getViewMode())) {
                    int initVar = resultMsg.indexOf("${");
                    int endVar = resultMsg.indexOf("}", initVar);
                    String fieldName = resultMsg.substring(initVar + 2, endVar);
                    BeanWrapper bw = new BeanWrapperImpl(pst.getBackBean());
                    Object value = bw.getPropertyValue(fieldName);
                    resultMsg = resultMsg.substring(0, initVar) + " " + value + " "
                            + resultMsg.substring(endVar + 1);
                    MsgDisplayer.showMessage(resultMsg);
                }
            } else {
                MsgDisplayer.showMessage(resultMsg);
            }
        }
    } catch (FlowBreakSilentlyException ex) {
        logger.info("Exit flow method silently");
        actionException = ex;
        return ex;
    } catch (AWException ex) {
        logger.error("AW Exception:", ex);
        PainterMessages.paintException(ex);
        actionException = ex;
        return ex;
    } catch (DataIntegrityViolationException ex) {
        logger.error("Data Integrity Exception", ex);
        MsgDisplayer.showMessage("Ocurri un error de integridad en la operacin que quizo realizar.");
        actionException = ex;
        return ex;
    } catch (Throwable t) {
        logger.error("General Exception:", t);
        PainterMessages.paintException(t);
        actionException = t;
        return t;
    } finally {
        HbmFailMngr.seFailMode(false);
        action.setOnFailedMode(isExceptionThatChangeFailedMode(actionException));
        AWInputVerifier.getInstance().enable();
    }
    return actionResult;
}

From source file:com.diversityarrays.kdxplore.trialmgr.trait.TraitExplorerPanel.java

private JButton initAction(Action action, ImageId imageId, String toolTip, KeyStroke keyStroke) {
    KDClientUtils.initAction(imageId, action, toolTip, false);
    action.setEnabled(false);/*from  w ww  . j a  v  a  2  s .c  o  m*/

    String command = action.toString();

    JButton result = new JButton(action);
    result.getActionMap().put(command, action);
    result.getInputMap(JComponent.WHEN_FOCUSED).put(keyStroke, command);

    return result;
}

From source file:com.aw.swing.mvp.action.ActionManager.java

public void executeAction(final Action action) {
    atBeginningOfAction(action);// w ww  . j  ava 2s  .c o m
    AWActionTipPainter.instance().hideTipWindow();
    if (action instanceof RoundTransitionAction) {
        ((RoundTransitionAction) action).setTransitionStoppedWithException(false);
    }

    GridProviderManager gridProviderManager = action.getPst().getGridProviderMgr();
    gridProviderManager.removeEditors();

    try {
        action.checkBasicConditions();
    } catch (FlowBreakSilentlyException ex) {
        logger.info("Exit flow method silently");
        return;
    } catch (AWException ex) {
        logger.error("AW Exception:", ex);
        if (action instanceof RoundTransitionAction) {
            ((RoundTransitionAction) action).setTransitionStoppedWithException(true);
        }
        PainterMessages.paintException(ex);
        return;
    }

    String confirmMsg = action.getConfirmMsg();
    if (StringUtils.hasText(confirmMsg)) {
        boolean isCancelAction = action instanceof CancelAction;
        boolean isFindPst = action.getPst() instanceof FindPresenter;
        boolean isModeReadOnly = ViewMode.MODE_READONLY.equals(action.getPst().getViewMode());
        boolean isShowCancelMsgConfirmation = action.getPst().isShowCancelMsgConfirmation();
        if (!isCancelAction || (isShowCancelMsgConfirmation && !isModeReadOnly && !isFindPst)) {
            if (!MsgDisplayer.showConfirmMessage(confirmMsg)) {
                logger.debug(
                        "The action:<" + action.toString() + ">will not be executed because was not confirmed");
                return;
            }
        }
    }
    try {
        action.checkConditions();
        AWInputVerifier.getInstance().disable();
        Presenter pst = action.getPst();
        if (action.execBinding) {
            pst.setValuesToBean();
        }
        if (action.execValidation) {
            pst.validate();
        }
    } catch (AWException ex) {
        if (action instanceof RoundTransitionAction) {
            ((RoundTransitionAction) action).setTransitionStoppedWithException(true);
        }
        if (ex instanceof FlowBreakSilentlyException) {
            return;
        }
        logger.error("AW Exception:", ex);
        PainterMessages.paintException(ex);
        return;
    } finally {
        AWInputVerifier.getInstance().enable();
    }

    if (action.useMessageBlocker) {
        try {
            if (!SwingUtilities.isEventDispatchThread()) {
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        ProcessMsgBlocker.instance().showMessage("Procesando ...");
                    }
                });
            } else {
                ProcessMsgBlocker.instance().showMessage("Procesando ...");
            }
        } catch (Throwable e) {
            e.printStackTrace();
        }

        SwingWorker swingWorker = new SwingWorker() {
            protected Object doInBackground() throws Exception {
                executeActionInternal(action);
                return null;
            }

            protected void done() {
                ProcessMsgBlocker.instance().removeMessage();
                action.afterExecute();
            }
        };
        swingWorker.execute();

    } else {
        executeActionInternal(action);
        action.afterExecute();
    }
}

From source file:com.aw.swing.mvp.action.ActionManager.java

private void executeActionInternal(Action action) {
    try {//ww  w.  j  a v  a 2s.c om
        action.getPst().checkBasicConditionsFor(action);
    } catch (AWException ex) {
        logger.error("AW Exception:", ex);
        PainterMessages.paintException(ex);
        return;
    }

    logger.debug("Before executing action:<" + action.getId() + ">");
    Object actionResult = execute(action);
    logger.debug("After executing action:<" + action.getId() + ">");

    if (actionResult instanceof Throwable) {
        return;
    }
    if (action instanceof RoundTransitionAction) {
        RoundTransitionAction roundTransitionAction = (RoundTransitionAction) action;
        Flow initialFlow = null;
        Flow lastFlow = null;
        FlowManager flowManager = null;
        if ((!roundTransitionAction.isTransitionStopped())
                && (!roundTransitionAction.isTransitionStoppedWithException())) {
            flowManager = AWWindowsManager.instance().getCurrentFlowMgr();
            lastFlow = flowManager.getLastFlow();

            if (lastFlow.getEndPst() != action.getPst().getClass()) {
                return;
            }

            boolean isCancel = lastFlow.getActionExecuted().getId().getActionCmd()
                    .equals(ActionNames.ACTION_CANCEL);
            initialFlow = flowManager.getInitialFlowFor(lastFlow);
            flowManager.remove(lastFlow);
            flowManager.remove(initialFlow);
            if (isCancel)
                return;
            roundTransitionAction.executeOnReturn(initialFlow, lastFlow);
        }
        if (!roundTransitionAction.isTransitionStoppedWithException()) {
            if (action.isRefreshGridAtEnd()) {
                processRefreshGridAtEnd(action, initialFlow, lastFlow);
            }
            if (action.isRepaintGridAtEnd()) {
                action.getGridProvider().repaint();
            }

            String resultMsg = action.getResultMsg();
            if (resultMsg != null) {
                MsgDisplayer.showMessage(resultMsg);
            }
            ActionManager.instance().setActionExecuted(action.toString());
            logger.info("The action:<" + action.toString() + "> was executed");
            if (action.hasToCloseView()) {
                closeView(action, actionResult);
            }
        }
    } else {
        if (action.hasToCloseView()) {
            if (action.getNumberOfViewsToClose() == 1) {
                closeView(action, actionResult);
            } else {
                closeViews(action, actionResult);
            }

        } else if (action.hasToCloseAllView()) {
            closeAllView(action, actionResult);
        }
    }

}

From source file:org.kepler.gui.MenuMapper.java

/**
 * Debugging method/*from   w ww  .j a  v  a 2  s  .c  o  m*/
 */
public void printDebugInfo() {
    System.out.println("_ptiiMenuActionsMap: " + _ptiiMenuActionsMap.size());
    for (String s : _ptiiMenuActionsMap.keySet()) {
        Action a = _ptiiMenuActionsMap.get(s);
        System.out.println(s + " : " + a.toString());
    }
}