@Override public void contentChanged(Editor editor, String[] blockIds) { // The active block may have been removed then added again in which case // the old instance is invalid but can be restored by remapping the identifier if (activeBlock != null && !activeBlock.isValid()) { activeBlock = editor.getBlockById(activeBlock.getId()); if (activeBlock == null) { update(null, UpdateCause.EDIT); return; } } if (activeBlock != null && Arrays.asList(blockIds).contains(activeBlock.getId())) { if (block == null) block = activeBlock; update(activeBlock, UpdateCause.EDIT); } }
@Override public void selectionChanged(Editor editor, String[] blockIds) { selectedBlock = null; for (int i = 0, n = blockIds.length; i < n; ++i) { ContentBlock block = editor.getBlockById(blockIds[i]); if (block != null && block.getType().equals("Text")) { selectedBlock = block; break; } } update(selectedBlock, UpdateCause.SELECTION); }
private void update(ContentBlock block, final UpdateCause cause) if (block != null && block.getType().equals("Text")) Rectangle rectangle = block.getBox(); float paddingLeft = 0.0f; float paddingRight = 0.0f; if (block.getAttributes().length() > 0) JiixDefinitions.Padding padding = gson.fromJson(block.getAttributes(), JiixDefinitions.Padding.class); if (padding != null) boolean isSameActiveBlock = this.block != null && block.getId().equals(this.block.getId()); if (cause != UpdateCause.EDIT && isSameActiveBlock) final boolean isInDiagram = block.getId().startsWith("diagram/");
final ContentBlock contentBlock = (contentBlock_ != null) && !contentBlock_.getType().equals("Container") ? contentBlock_ : rootBlock; final boolean isRoot = contentBlock.getId().equals(rootBlock.getId()); dialogBuilder.setTitle(contentBlock.getType() + " (id: " + contentBlock.getId() + ")"); dialogBuilder.setItems(items.toArray(new String[items.size()]), new DialogInterface.OnClickListener()
@Override public void activeBlockChanged(Editor editor, String blockId) { activeBlock = editor.getBlockById(blockId); if (block != null && block.getId().equals(blockId)) return; // selectionChanged already changed the active block update(activeBlock, UpdateCause.EDIT); }