Forum Stats

  • 3,770,497 Users
  • 2,253,126 Discussions


Can a SQL Developer extension add a button to a Worksheet toolbar?

CaryMillsap Member Posts: 3 Red Ribbon
edited Jul 15, 2021 5:12PM in SQL Developer

Can a SQL Developer extension add a button to a Worksheet toolbar? In a 2018 thread (, you said that it was not possible to add a button to the SQL Developer Worksheet toolbar. But it's three years later, and perhaps my context is slightly different.

We currently have pre- and post-execution triggers on the Run Script button that do all our Method R Trace magic. We could improve our interface if we could add a new button to the Worksheet. The new button we'd like to create would execute all the features we execute today, but the code would be simpler, and our interface would be even more elegant for our users.

Similarly, we'd like to be able to append text to the "Task completed in %0.2f seconds" message when an execution completes. ...Like "Task completed in %0.2f seconds, 208,142-byte trace file downloaded."

Are these things possible in 2021?



  • thatJeffSmith-Oracle
    thatJeffSmith-Oracle Distinguished Product Manager Posts: 8,094 Employee

    Our developer extraordinaire says -

    Adding toolbar/ctx menu/both action should be doable, ‘modifying’ the task message - it depends. If you are running your own task & want to use toolbar task display, yes. If you are talking about somehow manipulating what the script runner puts in the output toolbar task display, probably not. Seems like a good addition to the example extensions. 

    So stay tuned...

  • Philipp Salvisberg
    Philipp Salvisberg Member Posts: 158 Silver Badge

    You could run the code in the post-execution triggers in a task. A task runs asynchronously. You can decide if it should run in the background from the start or if a dialog should appear with progress information. This dialog appears after about 2 seconds. You find all running and completed tasks in the task window. And you are in full control of the messages during the execution of a tasks.

    Brian Jeffries created an example project using tasks. You find the relevant class using tasks here:

    For a customer project we started to run all long-running stuff within a task and a dedicated (cloned) connection. This improved the user experience a lot. Here's an example using a real progress bar (not this knight rider progress bar you are used to see in SQLDev):

    public class ValidatorTask extends AbstractBackgroundConnectionTask {
        public static void submit(Context context) {
            ValidatorTask task = new ValidatorTask(ApiResources.getString("VALIDATE_CONTEXT_MENU_LABEL"), context);
        public ValidatorTask(String name, Context context) {
            super(name, context, false);
        protected Void doWork() throws TaskException {
            try {
                Connection conn = getConnection();
                List<Source> sources = SourceFactory.create(context, true);
                List<Issue> issues = new ArrayList<>();
                Set<Class<? extends ApiComponent>> scopes = new HashSet<>();
                int progress = 0;
                for (Source source : sources) {
                    if (getDescriptor().isCancelled()) {
                    getDescriptor().setProgress(progress > 0 ? 100 * progress / sources.size() : 0);
                    if (source.isCapiGeneratorJsonWorksheet()) {
                        issues.addAll(new CapiGeneratorJsonValidator(conn, source).validate());
                    } else {
                        for (Issue issue : source.validate(conn)) {
                            if (source.getChildStartLine() == -1) {
                            } else if (issue.getLineNumber() >= source.getChildStartLine() && issue.getLineNumber() < source.getChildEndLine()) {
                DockableFactory.getValidationWindow().showIssues(scopes, issues, true);
            } catch (Throwable t) {
                String msg = t.getMessage() != null ? t.getMessage() : t.toString();
                String title = ApiResources.getString("VALIDATION_ERROR_TITLE");
                ITaskUI ui = RaptorTaskManager.getInstance().getTaskProgressViewer().getTaskUI(getDescriptor());
                if (ui == null) {
                    MessageDialog.error(null, msg, title, "");
                } else {
                    setMessage(title + ": " + msg);
                throw asTaskException(t);
            return null;

  • Brian Jeffries-Oracle
    Brian Jeffries-Oracle Member Posts: 227 Employee

    New SQL Developer Example

    Worksheet Action

    Example extension showing how to add actions to the worksheet context menu and / or toolbar; execute the action directly or in a background task; and present information in a result panel.

    Philipp Salvisberg