/** * Displays an information bubble pointing to an operator to indicate a {@link UserError} was * thrown by the operator. * * @param userError the error instance * @return the {@link OperatorInfoBubble} instance, never {@code null} */ public static OperatorInfoBubble displayGenericParameterError(final ParameterError userError) { if (userError == null) { throw new IllegalArgumentException("userError must not be null!"); } Operator op = userError.getOperator(); if (op == null) { throw new IllegalArgumentException("ParameterError operator must not be null!"); } ParameterType param = op.getParameterType(userError.getKey()); if (param == null) { throw new IllegalArgumentException("ParameterError key must point to a valid ParameterType!"); } return displayGenericParameterError(userError, op, param, "generic_paramerror"); }
/** * Displays the best machting error bubble depending on the given {@link UserError}. If no * explicit match can be found, displays a generic error bubble. * * @param error the error in question, must not be {@code null} * @return the bubble instance, never {@code null} */ public static BubbleWindow displayBubbleForUserError(final UserError error) { if (error == null) { throw new IllegalArgumentException("userError must not be null!"); } if (error instanceof PortUserError) { PortUserError userError = (PortUserError) error; if (userError.getCode() == 149) { // for "no data" errors we display an error bubble instead of a dialog return displayInputPortNoDataInformation(userError.getPort()); } else if (userError.getCode() == 156) { return displayInputPortWrongTypeInformation( userError.getPort(), userError.getExpectedType(), userError.getActualType()); } else { return displayGenericPortError(userError); } } else if (error.getClass().equals(UndefinedParameterError.class)) { UndefinedParameterError userError = (UndefinedParameterError) error; if (userError.getCode() == 205 || userError.getCode() == 217) { // for "missing mandatory parameter" errors we display an error bubble // instead of a dialog Operator op = userError.getOperator(); ParameterType param = op != null ? op.getParameterType(userError.getKey()) : null; if (op != null && param != null) { return displayMissingMandatoryParameterInformation(op, param); } else { return displayGenericUserError(error); } } else { Operator op = userError.getOperator(); ParameterType param = op != null ? op.getParameterType(userError.getKey()) : null; if (op != null && param != null) { return displayMissingMandatoryParameterInformation(op, param); } else { return displayGenericUserError(error); } } } else if (error instanceof ParameterError) { ParameterError userError = (ParameterError) error; Operator op = userError.getOperator(); ParameterType param = op != null ? op.getParameterType(userError.getKey()) : null; if (op != null && param != null) { return displayGenericParameterError(userError); } else { return displayGenericUserError(error); } } else if (error instanceof AttributeNotFoundError) { AttributeNotFoundError userError = (AttributeNotFoundError) error; Operator op = userError.getOperator(); ParameterType param = op != null ? op.getParameterType(userError.getKey()) : null; if (op != null && param != null) { return displayAttributeNotFoundParameterInformation(userError); } else { return displayGenericUserError(error); } } else if (error instanceof ProcessExecutionUserErrorError) { ProcessExecutionUserErrorError userError = (ProcessExecutionUserErrorError) error; if (userError.getUserError() != null && userError.getUserError().getOperator() != null) { return displayUserErrorInExecutedProcess(userError); } else { return displayGenericUserError(error); } } else { return displayGenericUserError(error); } }
/** * Displays an information bubble pointing to an operator to indicate a {@link ParameterError} was * thrown by that operator. It will also select the operator and highlight the parameter in * question. * * @param error the error instance * @param op the operator for which to display the error * @param param the parameter for which to display the error * @param i18nKey the i18n key which defines the title, text and button label for the bubble. * Format is "gui.bubble.{i18nKey}.title", "gui.bubble.{i18nKey}.body" and * "gui.bubble.{i18nKey}.button.label". * @return the {@link OperatorInfoBubble} instance, never {@code null} */ private static OperatorInfoBubble displayGenericParameterError( final ParameterError error, final Operator op, final ParameterType param, final String i18nKey) { final JButton ackButton = new JButton(I18N.getGUIMessage("gui.bubble." + i18nKey + ".button.label")); ackButton.setToolTipText(I18N.getGUIMessage("gui.bubble." + i18nKey + ".button.tip")); final BubbleDelegator bubbleDelegator = new BubbleDelegator(); final String message = removeTerminationCharacters(error.getMessage()); final JPanel linkPanel = new JPanel(); LinkButton showDetailsButton = new LinkButton( new ResourceAction(i18nKey + ".button_show_details") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(final ActionEvent e) { BubbleWindow bubble = bubbleDelegator.getBubble(); if (bubble != null) { String text = I18N.getMessage( I18N.getGUIBundle(), "gui.bubble." + i18nKey + ".body", message, error.getDetails()); bubble.setMainText(text); linkPanel.removeAll(); bubble.pack(); } } }); showDetailsButton.setToolTipText( I18N.getGUIMessage("gui.action." + i18nKey + ".button_show_details.tip")); linkPanel.add(showDetailsButton); ParameterErrorBubbleBuilder builder = new ParameterErrorBubbleBuilder( RapidMinerGUI.getMainFrame(), error.getOperator(), param, "generic_parameter_decoration", i18nKey, message, ""); // if no operator or root operator, show in middle, otherwise below AlignedSide prefSide = error.getOperator() == null || error.getOperator() instanceof ProcessRootOperator ? AlignedSide.MIDDLE : AlignedSide.BOTTOM; final OperatorInfoBubble userErrorBubble = builder .setHideOnDisable(true) .setAlignment(prefSide) .setStyle(BubbleStyle.ERROR) .setEnsureVisible(true) .hideCloseButton() .setHideOnProcessRun(true) .setAdditionalComponents(new JComponent[] {ackButton, linkPanel}) .build(); ackButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { userErrorBubble.killBubble(true); } }); bubbleDelegator.setBubbleWindow(userErrorBubble); userErrorBubble.setVisible(true); return userErrorBubble; }