@Override // Exception squid:S1166 - Hide origin exception // Exception squid:S2221 - This code is trans-coded to JavaScript, hence // Exception semantics changes @SuppressWarnings({ "squid:S1166", "squid:S2221" }) protected boolean accept(VDragEvent drag, UIDL configuration) { try { String component = drag.getTransferable().getDragSource().getWidget().getElement().getId(); int c = configuration.getIntAttribute(COMPONENT_COUNT); String mode = configuration.getStringAttribute(MODE); for (int dragSourceIndex = 0; dragSourceIndex < c; dragSourceIndex++) { String requiredPid = configuration.getStringAttribute(COMPONENT + dragSourceIndex); if ((STRICT_MODE.equals(mode) && component.equals(requiredPid)) || (PREFIX_MODE.equals(mode) && component.startsWith(requiredPid))) { return true; } } } catch (Exception e) { // log and continue LOGGER.log(Level.SEVERE, "Error verifying drop target: " + e.getLocalizedMessage()); } return false; } }
@Override // Exception squid:S1166 - Hide origin exception // Exception squid:S2221 - This code is trans-coded to JavaScript, hence // Exception semantics changes @SuppressWarnings({ "squid:S1166", "squid:S2221" }) protected boolean accept(VDragEvent drag, UIDL configuration) { try { String component = drag.getTransferable().getDragSource().getWidget().getElement().getId(); int c = configuration.getIntAttribute(COMPONENT_COUNT); String mode = configuration.getStringAttribute(MODE); for (int dragSourceIndex = 0; dragSourceIndex < c; dragSourceIndex++) { String requiredPid = configuration.getStringAttribute(COMPONENT + dragSourceIndex); if ((STRICT_MODE.equals(mode) && component.equals(requiredPid)) || (PREFIX_MODE.equals(mode) && component.startsWith(requiredPid))) { return true; } } } catch (Exception e) { // log and continue LOGGER.log(Level.SEVERE, "Error verifying drop target: " + e.getLocalizedMessage()); } return false; } }
/** * Checks if this accept criterion is responsible for the current drag * source. Therefore the current drag source id has to start with the drag * source id-prefix configured for the criterion. * * @param drag * the current drag event holding the context. * @param configuration * for the accept criterion to retrieve the configured drag * source id-prefix. * @return <code>true</code> if the criterion is responsible for the current * drag source, otherwise <code>false</code>. */ // Exception squid:S1166 - Hide origin exception // Exception squid:S2221 - This code is trans-coded to JavaScript, hence // Exception semantics changes @SuppressWarnings({ "squid:S1166", "squid:S2221" }) boolean isValidDragSource(final VDragEvent drag, final UIDL configuration) { try { final String dragSource = drag.getTransferable().getDragSource().getWidget().getElement().getId(); final String dragSourcePrefix = configuration.getStringAttribute(DRAG_SOURCE); if (dragSource.startsWith(dragSourcePrefix)) { return true; } } catch (final Exception e) { // log and continue LOGGER.log(Level.SEVERE, "Error verifying drag source: " + e.getLocalizedMessage()); } return false; }
/** * Determines the active UI theme for a given event. * * @param drag * the event the UI theme is retrieved for. * @return the active theme (e.g. "hawkbit"). */ private static String determineActiveTheme(final VDragEvent drag) { return drag.getTransferable().getDragSource().getConnection().getUIConnector().getActiveTheme(); }
/** * Determines the active UI theme for a given event. * * @param drag * the event the UI theme is retrieved for. * @return the active theme (e.g. "hawkbit"). */ private static String determineActiveTheme(final VDragEvent drag) { return drag.getTransferable().getDragSource().getConnection().getUIConnector().getActiveTheme(); }
/** * Checks if this accept criterion is responsible for the current drag * source. Therefore the current drag source id has to start with the drag * source id-prefix configured for the criterion. * * @param drag * the current drag event holding the context. * @param configuration * for the accept criterion to retrieve the configured drag * source id-prefix. * @return <code>true</code> if the criterion is responsible for the current * drag source, otherwise <code>false</code>. */ // Exception squid:S1166 - Hide origin exception // Exception squid:S2221 - This code is trans-coded to JavaScript, hence // Exception semantics changes @SuppressWarnings({ "squid:S1166", "squid:S2221" }) boolean isValidDragSource(final VDragEvent drag, final UIDL configuration) { try { final String dragSource = drag.getTransferable().getDragSource().getWidget().getElement().getId(); final String dragSourcePrefix = configuration.getStringAttribute(DRAG_SOURCE); if (dragSource.startsWith(dragSourcePrefix)) { return true; } } catch (final Exception e) { // log and continue LOGGER.log(Level.SEVERE, "Error verifying drag source: " + e.getLocalizedMessage()); } return false; }
/** * Displays a message box telling that the action is not allowed. * * @param drag * the current drag event holding the context. */ private void showErrorNotification(final VDragEvent drag) { final VNotification n = VNotification.createNotification(SPUILabelDefinitions.SP_DELAY, drag.getTransferable().getDragSource().getWidget()); n.show(getDraggableTemplate().notificationMsg(errorMessage).asString(), Position.BOTTOM_RIGHT, SPUIStyleDefinitions.SP_NOTIFICATION_ERROR_MESSAGE_STYLE); }
/** * Displays a message box telling that the action is not allowed. * * @param drag * the current drag event holding the context. */ private void showErrorNotification(final VDragEvent drag) { final VNotification n = VNotification.createNotification(SPUILabelDefinitions.SP_DELAY, drag.getTransferable().getDragSource().getWidget()); n.show(getDraggableTemplate().notificationMsg(errorMessage).asString(), Position.BOTTOM_RIGHT, SPUIStyleDefinitions.SP_NOTIFICATION_ERROR_MESSAGE_STYLE); }
/** * Styles a multi-row selection with the number of elements. * * @param drag * the current drag event holding the context. */ void setMultiRowDragDecoration(final VDragEvent drag) { final Widget widget = drag.getTransferable().getDragSource().getWidget(); if (widget instanceof VScrollTable) { final VScrollTable table = (VScrollTable) widget; final int rowCount = table.selectedRowKeys.size(); Element dragCountElement = Document.get().getElementById(SP_DRAG_COUNT); if (rowCount > 1 && table.selectedRowKeys.contains(table.focusedRow.getKey())) { if (dragCountElement == null) { dragCountElement = Document.get().createStyleElement(); dragCountElement.setId(SP_DRAG_COUNT); final HeadElement head = HeadElement .as(Document.get().getElementsByTagName(HeadElement.TAG).getItem(0)); head.appendChild(dragCountElement); } final SafeHtml formattedCssStyle = getDraggableTemplate() .multiSelectionStyle(determineActiveTheme(drag), String.valueOf(rowCount)); final StyleElement dragCountStyleElement = StyleElement.as(dragCountElement); dragCountStyleElement.setInnerSafeHtml(formattedCssStyle); } else if (dragCountElement != null) { dragCountElement.removeFromParent(); } } }
/** * Styles a multi-row selection with the number of elements. * * @param drag * the current drag event holding the context. */ void setMultiRowDragDecoration(final VDragEvent drag) { final Widget widget = drag.getTransferable().getDragSource().getWidget(); if (widget instanceof VScrollTable) { final VScrollTable table = (VScrollTable) widget; final int rowCount = table.selectedRowKeys.size(); Element dragCountElement = Document.get().getElementById(SP_DRAG_COUNT); if (rowCount > 1 && table.selectedRowKeys.contains(table.focusedRow.getKey())) { if (dragCountElement == null) { dragCountElement = Document.get().createStyleElement(); dragCountElement.setId(SP_DRAG_COUNT); final HeadElement head = HeadElement .as(Document.get().getElementsByTagName(HeadElement.TAG).getItem(0)); head.appendChild(dragCountElement); } final SafeHtml formattedCssStyle = getDraggableTemplate() .multiSelectionStyle(determineActiveTheme(drag), String.valueOf(rowCount)); final StyleElement dragCountStyleElement = StyleElement.as(dragCountElement); dragCountStyleElement.setInnerSafeHtml(formattedCssStyle); } else if (dragCountElement != null) { dragCountElement.removeFromParent(); } } }
boolean internalDrag = event.getTransferable().getDragSource() == this;
boolean internalDrag = event.getTransferable().getDragSource() == this;