private static void writeContextData( @NotNull DiffContext context, @NotNull TransferableFileEditorState state) { Map<String, Map<String, String>> map = context.getUserData(TRANSFERABLE_FILE_EDITOR_STATE); if (map == null) { map = ContainerUtil.newHashMap(); context.putUserData(TRANSFERABLE_FILE_EDITOR_STATE, map); } map.put(state.getEditorId(), state.getTransferableOptions()); }
private static void readContextData( @NotNull DiffContext context, @NotNull FileEditor editor, @NotNull TransferableFileEditorState state) { Map<String, Map<String, String>> map = context.getUserData(TRANSFERABLE_FILE_EDITOR_STATE); Map<String, String> options = map != null ? map.get(state.getEditorId()) : null; if (options == null) return; state.setTransferableOptions(options); editor.setState(state); }
public void updateContextHints(@NotNull DiffRequest request, @NotNull DiffContext context) { if (!isEnabled()) return; Set<String> updated = ContainerUtil.newHashSet(); for (BinaryEditorHolder holder : myHolders) { TransferableFileEditorState state = getEditorState(holder.getEditor()); if (state != null) { boolean processed = !updated.add(state.getEditorId()); if (!processed) writeContextData(context, state); } } }
private void updateEditor( @NotNull FileEditor editor, @NotNull String id, @NotNull Map<String, String> options) { try { myDuringUpdate = true; TransferableFileEditorState state = getEditorState(editor); if (state != null && state.getEditorId().equals(id)) { state.setTransferableOptions(options); editor.setState(state); } } finally { myDuringUpdate = false; } }
@Override public void propertyChange(PropertyChangeEvent evt) { if (myDuringUpdate || !isEnabled()) return; if (!(evt.getSource() instanceof FileEditor)) return; TransferableFileEditorState sourceState = getEditorState(((FileEditor) evt.getSource())); if (sourceState == null) return; Map<String, String> options = sourceState.getTransferableOptions(); String id = sourceState.getEditorId(); for (FileEditor editor : myEditors) { if (evt.getSource() != editor) { updateEditor(editor, id, options); } } }