Search in sources :

Example 6 with EJQuestionButton

use of org.entirej.framework.core.enumerations.EJQuestionButton in project rap by entirej.

the class EJRWTListRecordBlockRenderer method askToDeleteRecord.

public void askToDeleteRecord(final EJDataRecord recordToDelete, String msg) {
    if (msg == null) {
        msg = "Are you sure you want to delete the current record?";
    }
    EJMessage message = new EJMessage(msg);
    EJQuestion question = new EJQuestion(new EJForm(_block.getForm()), "DELETE_RECORD", "Delete", message, "Yes", "No") {

        @Override
        public void setAnswer(EJQuestionButton answerButton) {
            super.setAnswer(answerButton);
            if (EJQuestionButton.ONE == answerButton) {
                _block.getBlock().deleteRecord(recordToDelete);
            }
            _block.setRendererFocus(true);
        }
    };
    _block.getForm().getMessenger().askQuestion(question);
}
Also used : EJQuestionButton(org.entirej.framework.core.enumerations.EJQuestionButton) EJQuestion(org.entirej.framework.core.data.controllers.EJQuestion) EJForm(org.entirej.framework.core.EJForm) EJMessage(org.entirej.framework.core.EJMessage)

Example 7 with EJQuestionButton

use of org.entirej.framework.core.enumerations.EJQuestionButton in project rap by entirej.

the class EJRWTLineChartRecordBlockRenderer method askToDeleteRecord.

@Override
public void askToDeleteRecord(final EJDataRecord recordToDelete, String msg) {
    if (msg == null) {
        msg = "Are you sure you want to delete the current record?";
    }
    EJMessage message = new EJMessage(msg);
    EJQuestion question = new EJQuestion(new EJForm(_block.getForm()), "DELETE_RECORD", "Delete", message, "Yes", "No") {

        @Override
        public void setAnswer(EJQuestionButton answerButton) {
            super.setAnswer(answerButton);
            if (EJQuestionButton.ONE == answerButton) {
                _block.getBlock().deleteRecord(recordToDelete);
            }
            _block.setRendererFocus(true);
        }
    };
    _block.getForm().getMessenger().askQuestion(question);
}
Also used : EJQuestionButton(org.entirej.framework.core.enumerations.EJQuestionButton) EJQuestion(org.entirej.framework.core.data.controllers.EJQuestion) EJForm(org.entirej.framework.core.EJForm) EJMessage(org.entirej.framework.core.EJMessage)

Example 8 with EJQuestionButton

use of org.entirej.framework.core.enumerations.EJQuestionButton in project rap by entirej.

the class EJRWTMessenger method askQuestion.

/**
 * Asks the given question and after the user has made an answer, the answer
 * will be sent to the corresponding <code>IActionProcessor</code>
 *
 * @param question
 *            The question to be asked
 */
@Override
public void askQuestion(final EJQuestion question) {
    final EJQuestionButton[] optionsButtons = getOptions(question);
    String[] options = new String[optionsButtons.length];
    for (int i = 0; i < optionsButtons.length; i++) {
        options[i] = question.getButtonText(optionsButtons[i]);
    }
    MessageDialog dialog = new MessageDialog(manager.getShell(), question.getTitle(), null, question.getMessageText(), MessageDialog.QUESTION, options, 2) {

        @Override
        public boolean close() {
            boolean close = super.close();
            int answer = getReturnCode();
            try {
                if (answer > -1) {
                    question.setAnswer(optionsButtons[answer]);
                    question.getActionProcessor().questionAnswered(question);
                }
            } catch (EJApplicationException e) {
                handleException(e);
            }
            return close;
        }
    };
    dialog.setBlockOnOpen(false);
    dialog.open();
}
Also used : EJQuestionButton(org.entirej.framework.core.enumerations.EJQuestionButton) EJApplicationException(org.entirej.framework.core.EJApplicationException) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 9 with EJQuestionButton

use of org.entirej.framework.core.enumerations.EJQuestionButton in project rap by entirej.

the class EJRWTMessenger method askInternalQuestion.

/**
 * Asks the given question and after the user has made an answer, the answer
 * will be sent to the corresponding <code>IActionProcessor</code>
 *
 * @param question
 *            The question to be asked
 */
@Override
public void askInternalQuestion(final EJInternalQuestion question) {
    final EJQuestionButton[] optionsButtons = getOptions(question);
    String[] options = new String[optionsButtons.length];
    for (int i = 0; i < optionsButtons.length; i++) {
        options[i] = question.getButtonText(optionsButtons[i]);
    }
    MessageDialog dialog = new MessageDialog(manager.getShell(), question.getTitle(), null, question.getMessageText(), MessageDialog.QUESTION, options, 2) {

        @Override
        public boolean close() {
            boolean close = super.close();
            int answer = getReturnCode();
            try {
                if (answer > -1) {
                    question.setAnswer(optionsButtons[answer]);
                    question.getActionProcessor().questionAnswered(question);
                }
                question.getForm().internalQuestionAnswered(question);
            } catch (EJApplicationException e) {
                handleException(e);
            }
            return close;
        }
    };
    dialog.setBlockOnOpen(false);
    dialog.open();
}
Also used : EJQuestionButton(org.entirej.framework.core.enumerations.EJQuestionButton) EJApplicationException(org.entirej.framework.core.EJApplicationException) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 10 with EJQuestionButton

use of org.entirej.framework.core.enumerations.EJQuestionButton in project rap by entirej.

the class EJRWTSingleRecordBlockRenderer method askToDeleteRecord.

@Override
public void askToDeleteRecord(final EJDataRecord recordToDelete, String msg) {
    if (msg == null) {
        msg = "Are you sure you want to delete the current record?";
    }
    EJMessage message = new EJMessage(msg);
    EJQuestion question = new EJQuestion(new EJForm(_block.getForm()), "DELETE_RECORD", "Delete", message, "Yes", "No") {

        @Override
        public void setAnswer(EJQuestionButton answerButton) {
            super.setAnswer(answerButton);
            if (EJQuestionButton.ONE == answerButton) {
                _block.getBlock().deleteRecord(recordToDelete);
            }
            _block.setRendererFocus(true);
        }
    };
    _block.getForm().getMessenger().askQuestion(question);
}
Also used : EJQuestionButton(org.entirej.framework.core.enumerations.EJQuestionButton) EJQuestion(org.entirej.framework.core.data.controllers.EJQuestion) EJForm(org.entirej.framework.core.EJForm) EJMessage(org.entirej.framework.core.EJMessage)

Aggregations

EJQuestionButton (org.entirej.framework.core.enumerations.EJQuestionButton)11 EJForm (org.entirej.framework.core.EJForm)9 EJMessage (org.entirej.framework.core.EJMessage)9 EJQuestion (org.entirej.framework.core.data.controllers.EJQuestion)9 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)2 EJApplicationException (org.entirej.framework.core.EJApplicationException)2