Skip to content

Commit 4b4c366

Browse files
authored
Merge pull request oracle-samples#110 from oracle/SQLDEV-2076
Sqldev 2076 Optionally accept connection info from the command line and/or on a SocketServer
2 parents d85d39d + 4457ae5 commit 4b4c366

24 files changed

+1079
-64
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
*.class
33
*.jar
44
classes/
5+
built/
56
.*

sqldeveloper/extension/.classpath

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<classpath>
3-
<classpathentry kind="src" output="java/DependencyExample/built/classes" path="java/DependencyExample/built/gen-src"/>
4-
<classpathentry kind="src" path="java/InsertTemplateAction/built/gen-src"/>
5-
<classpathentry kind="src" path="java/InsertTemplateAction/src"/>
6-
<classpathentry kind="src" path="java/ContextMenuAction/built/gen-src"/>
7-
<classpathentry kind="src" path="java/ContextMenuAction/src"/>
8-
<classpathentry kind="src" output="java/DependencyExample/built/classes" path="java/DependencyExample/src"/>
9-
<classpathentry kind="src" path="java/DumpObjectTypesAction/src"/>
10-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
11-
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/FXDiagram 0.35.0-SNAPSHOT"/>
12-
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/KIELER KLay Layouters v. 2015.02"/>
13-
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/SQLDeveloper 19.2"/>
14-
<classpathentry kind="output" path="built/classes"/>
15-
</classpath>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="java/DependencyExample/built/classes" path="java/DependencyExample/built/gen-src"/>
4+
<classpathentry kind="src" path="java/ConnectionHelper/built/gen-src"/>
5+
<classpathentry kind="src" path="java/InsertTemplateAction/built/gen-src"/>
6+
<classpathentry kind="src" path="java/InsertTemplateAction/src"/>
7+
<classpathentry kind="src" path="java/ContextMenuAction/built/gen-src"/>
8+
<classpathentry kind="src" path="java/ContextMenuAction/src"/>
9+
<classpathentry kind="src" output="java/DependencyExample/built/classes" path="java/DependencyExample/src"/>
10+
<classpathentry kind="src" path="java/DumpObjectTypesAction/src"/>
11+
<classpathentry kind="src" path="java/ConnectionHelper/src"/>
12+
<classpathentry kind="src" path="java/ConnectionHelperClient/src"/>
13+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
14+
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/FXDiagram 0.35.0-SNAPSHOT"/>
15+
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/KIELER KLay Layouters v. 2015.02"/>
16+
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/SQLDeveloper 20.1"/>
17+
<classpathentry kind="output" path="built/classes"/>
18+
</classpath>

sqldeveloper/extension/README.md

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,41 @@
1-
# [SQL Developer](http://www.oracle.com/technetwork/developer-tools/sql-developer/) Examples
2-
## Extensions
3-
You can add new folders and nodes to navigators, new actions on objects (*or sets of them*), and new editors or viewers.
4-
5-
Depending on requirements, this can be done in either XML or java and deployed by simply copying an XML file to the appropriate directory, or creating an extension jar -- or *check for updates* bundle for XML and/or java.
6-
7-
### New
8-
9-
* [XML Based Favorites Example](xml/favorites)
10-
11-
12-
* [Example Update Center](https://github.com/bjeffrie/sqldev-update-center) (external) with pre-built cfu bundles for these examples.
13-
14-
### Contents
15-
16-
* [Set Up / Tutorial](./setup.md) - A step by step guide to building your first extension and check for updates bundle.
17-
18-
19-
* ["Simple" User Extensions (XML)](xml)
20-
21-
22-
* [Standard Extensions (java)](java)
23-
24-
25-
* [Check For Updates (cfu)](cfu)
26-
1+
# [SQL Developer](http://www.oracle.com/technetwork/developer-tools/sql-developer/) Examples
2+
## Extensions
3+
You can add new folders and nodes to navigators, new actions on objects (*or sets of them*), and new editors or viewers.
4+
5+
Depending on requirements, this can be done in either XML or java and deployed by simply copying an XML file to the appropriate directory, or creating an extension jar -- or *check for updates* bundle for XML and/or java.
6+
7+
### New
8+
9+
* [ConnectionHelper](java/ConnectionHelper)
10+
Optionally accept connection info from the command line and/or on a [SocketServer](https://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html)
11+
12+
* [ConnectionHelperClient](java/ConnectionHelperClient)
13+
A simple command line client for the ConnectionHelper socket server.
14+
15+
* Added resource reference for Philipp Salvisberg's [Example-based tutorials](https://github.com/PhilippSalvisberg/sqldev) to extend SQL Developer functionality. (external)
16+
17+
18+
### Contents
19+
20+
* [Set Up / Tutorial](./setup.md) - A step by step guide to building your first extension and check for updates bundle.
21+
22+
23+
* ["Simple" User Extensions (XML)](xml)
24+
25+
26+
* [XML Based Favorites Example](xml/favorites)
27+
28+
29+
* [Standard Extensions (java)](java)
30+
31+
32+
* [Check For Updates (cfu)](cfu)
33+
34+
35+
### External Resources
36+
Please note these are links to external resources. They are not supplied or supported by Oracle.
37+
38+
* [Example Update Center](https://github.com/bjeffrie/sqldev-update-center) (external) with pre-built cfu bundles for these examples.
39+
40+
* Philipp Salvisberg's [Example-based tutorials](https://github.com/PhilippSalvisberg/sqldev) to extend SQL Developer functionality. (external)
41+

sqldeveloper/extension/build.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
# This is where the builds will deploy the extension
77
# and where we can find our dependencies
88
#sqldev.dir=D:/sqldeveloper-4.2.0.17.089.1709/sqldeveloper
9-
sqldev.dir=D:/sqldeveloper-19.2.1/sqldeveloper
9+
#sqldev.dir=D:/sqldeveloper-19.2.1/sqldeveloper
10+
sqldev.dir=/Users/bjeffrie/eclipse-workspace-20.1/sql-developer/ide
1011

1112
# Information about the company or person creating the extension
1213
extension.owner=Oracle Examples
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# SQL Developer Examples
2+
## ConnectionHelper
3+
Optionally accept connection info from the command line and/or on a [SocketServer](https://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html)
4+
5+
### Command Line
6+
sqldeveloper -_conName_**=**_user_\[**/**\[_pw_]]**@**_host_**:**_port_(**:**_sid_|**/**_svc_)\[**#**_role_]
7+
8+
Where:
9+
- *connName* is the name you would like for the connection
10+
- *user* is the user name for the schema you want to use
11+
- */password* is the password for that user *(optional - if missing e.g., user@ or user/@, SQLDeveloper will prompt for it)*
12+
- *host* is the host that the database is on
13+
- *port* is the port the database is listening on
14+
- *:sid* is the sid for the database *(One of :sid or /svc MUST be supplied)*
15+
- */svc* is the service name for the database *(One of :sid or /svc MUST be supplied)*
16+
- *#role* is the role *(optional - one of SYSDBA, SYSOPER, SYSBACKUP, SYSDG, SYSKM, SYSASM if used)*
17+
18+
### Overview
19+
[extension.xml](ext/extension.xml) declares [ConnectionHelperPreferencePanel](src/oracle/db/example/sqldeveloper/extension/connectionHelper/ConnectionHelperPreferencePanel.java) as a trigger hook so the extension will be fully loaded once the preference page is opened and [ConnectionHelperAddin](src/oracle/db/example/sqldeveloper/extension/connectionhelper/ConnectionHelperAddin.java) as an Addin whos initialize method will be called on SQLDeveloper start up.
20+
21+
[ConnectionHelper](src/oracle/db/example/sqldeveloper/extension/connectionhelper/ConnectionHelper.java) is where the 'do the work' stuff lives.
22+
1. Creates the requested connection in a "Persistent" or "Transient" folder
23+
2. Navigates to and opens the new connection
24+
3. If transient, sets up a hook to remove the connection when SQLDeveloper shuts down
25+
26+
[ConnectionHelperAddin](src/oracle/db/example/sqldeveloper/extension/connectionhelper/ConnectionHelperAddin.java) adds an IdeListener to process ConnectionHelper options once the main window comes up. *(TODO:? Show non-deprecated technique for doing something after the window finishes loading? See OptInHandler$DialogWaitTask)*
27+
28+
[ConnectionHelperPreferenceModel](src/oracle/db/example/sqldeveloper/extension/connectionhelper/ConnectionHelperPreferenceModel.java) is the data class for managing connection helper preferences and integrating with the core preference storage.
29+
30+
[ConnectionHelperPreferencePanel](src/oracle/db/example/sqldeveloper/extension/connectionHelper/ConnectionHelperPreferencePanel.java)
31+
![ConnectionHelperPreferencePanel diagram](images/ConnectionHelperPreferencePanel.png)
32+
* Accept command line connections - Parse SQLDeveloper command line for connection request(s) when checked and on subsequent SQDeveloper start up. *[false]*
33+
* Persist command line connections - Persist connection(s) specified on the command line. Also controls (Persistent/Transient) folder the connection(s) will be placed in. *[false]*
34+
* Autostart connection server - Start the ConnectionHelperServer when checked and on subsequent SQDeveloper start up. *[false]*
35+
* External connection server port - the port to listen for connection requests on. *[51521]*
36+
* Persist external connections - Persist connection(s) received by the ConnectionHelperServer. Also controls (Persistent/Transient) folder the connection(s) will be placed in. *[false]*
37+
* *(TODO:? Replace button actions to start command line/server with property listeners on the preference properties so nothing happens until you OK the preference changes?)*
38+
39+
[ConnectionHelperServer](src/oracle/db/example/sqldeveloper/extension/connectionHelper/ConnectionHelperServer.java) is a [SocketServer](https://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html) that listens for connection requests on a specified port *[51521]*
40+
41+
42+
[//]: # (https://github.com/PhilippSalvisberg/sqldev)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
extension.id=oracle.db.example.sqldeveloper.extension.connectionHelper
2+
extension.name=Connection Helper
3+
extension.descr=Example to accept connection info from the command line (or via a SocketServer?)
4+
extension.version=20.1.0
5+
extension.resources=oracle.db.example.sqldeveloper.extension.connectionHelper.ConnectionHelperResources
6+
7+
extension.lib=external:$oracle.fcp.home$/sqldeveloper/extensions/${extension.id}/lib
8+
osgi.bundle.classpath=.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="windows-1252" ?>
2+
<project name="ConnectionHelper" default="_deploy">
3+
<!-- imports -->
4+
<import file="../../buildtools/ant/build.xml" />
5+
6+
<!-- bundle dependencies -->
7+
<property name="osgi.required.bundles"
8+
value="${osgi.bundle.default.dependencies},${osgi.bundle.sqldev},${osgi.bundle.utils-nodeps},${osgi.bundle.utils},oracle.sqldeveloper.extras" />
9+
10+
<!-- classpath declarations -->
11+
<path id="local.classpath">
12+
<path refid="oracle.sqldeveloper.utils-nodeps"/>
13+
<path refid="oracle.sqldeveloper.utils"/>
14+
<path refid="oracle.sqldeveloper" />
15+
<pathelement location="${sqldev.extensions}/oracle.sqldeveloper.extras.jar" />
16+
</path>
17+
18+
<!-- local targets -->
19+
20+
<!-- target overrides -->
21+
<!-- Build structure from ../../buildtools/ant/build.xml < targets.xml -->
22+
23+
</project>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
<extension xmlns="http://jcp.org/jsr/198/extension-manifest"
19+
id="@@extension.id@@" version="@@extension.version@@.@@extension.build@@"
20+
esdk-version="1.0"
21+
rsbundle-class="@@extension.resources@@">
22+
23+
<name>@@extension.name@@</name>
24+
<owner>@@extension.owner@@ @@extension.owner.url@@</owner>
25+
26+
<!--
27+
<feature-category xmlns="http://xmlns.oracle.com/ide/extension" id="example-category">
28+
<name>${CATEGORY_NAME}</name>
29+
<description>${CATEGORY_DESCRIPTION}</description>
30+
</feature-category>
31+
Duplicate category definitions cause a severe error to be logged.
32+
Only way around it from the outside I can think of is an extension just to add
33+
the category and all the others dependent on it.
34+
The pre-defined ones are:
35+
{db-category=Database, ide-category=IDE, db-migrations-category=Database Migrations,
36+
database-category=Database Development, java-se-category=Java SE,
37+
vcs-category=Version Control, xml-category=XML}
38+
and example-category=Examples, if you've installed the XMLPackedExample
39+
Not supplying a category or giving a non-existent one will just show the extension
40+
at the root of the features tree.
41+
-->
42+
<feature id="@@extension.id@@" xmlns="http://xmlns.oracle.com/ide/extension">
43+
<category-id>db-category</category-id>
44+
<name>@@extension.name@@</name>
45+
<description>@@extension.descr@@</description>
46+
<type>
47+
<service can-user-disable="true" reload-if-used="true"/>
48+
</type>
49+
</feature>
50+
<trigger-hooks xmlns="http://xmlns.oracle.com/ide/extension">
51+
<triggers xmlns:c="http://xmlns.oracle.com/ide/customization">
52+
<settings-ui-hook>
53+
<page id="CONNECTION_HELPER_PREFERENCES_PAGE_ID" parent-idref="/preferences">
54+
<label>${CONNECTION_HELPER_PREFERENCES_TITLE}</label>
55+
<traversable-class>oracle.db.example.sqldeveloper.extension.connectionHelper.ConnectionHelperPreferencePanel</traversable-class>
56+
</page>
57+
</settings-ui-hook>
58+
</triggers>
59+
</trigger-hooks>
60+
<hooks>
61+
<jdeveloper-hook xmlns="http://xmlns.oracle.com/jdeveloper/1013/extension">
62+
<addins>
63+
<addin>oracle.db.example.sqldeveloper.extension.connectionHelper.ConnectionHelperAddin</addin>
64+
</addins>
65+
</jdeveloper-hook>
66+
</hooks>
67+
68+
</extension>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
oracle.db.example.sqldeveloper.extension.connectionHelper.ConnectionHelperResources

0 commit comments

Comments
 (0)