Skip to content

Instantly share code, notes, and snippets.

@xhanin
Created February 13, 2013 22:16
Show Gist options
  • Save xhanin/4948868 to your computer and use it in GitHub Desktop.
Save xhanin/4948868 to your computer and use it in GitHub Desktop.
Insert MongoDB ObjectId IntellijEval plugin
import com.intellij.openapi.actionSystem.AnActionEvent
import static intellijeval.PluginUtil.*
import org.bson.types.*;
// add-to-classpath $HOME/.m2/repository/org/mongodb/mongo-java-driver/2.10.1/mongo-java-driver-2.10.1.jar
registerAction("InsertMongoObjectId", "alt shift O") { AnActionEvent event ->
runDocumentWriteAction(event.project) {
currentEditorIn(event.project).with {
def offset = caretModel.offset
document.insertString(offset, new ObjectId().toString())
}
}
}
show("Registered ObjectId plugin. Use alt shift O to insert a new ObjectId")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment