You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by fu...@apache.org on 2005/05/23 22:55:17 UTC
svn commit: r178020 [2/3] - in /incubator/derby/code/trunk/plugins: ./
eclipse/ eclipse/org.apache.derby.plugin.doc/
eclipse/org.apache.derby.plugin.doc/topics/
eclipse/org.apache.derby.plugin.doc/topics/images/
eclipse/org.apache.derby.ui/ eclipse/org.apache.derby.ui/icons/
eclipse/org.apache.derby.ui/src/ eclipse/org.apache.derby.ui/src/org/
eclipse/org.apache.derby.ui/src/org/apache/
eclipse/org.apache.derby.ui/src/org/apache/derby/
eclipse/org.apache.derby.ui/src/org/apache/derby/ui/
eclipse/org.apache.derby.ui/src/org/apache/derby/ui/actions/
eclipse/org.apache.derby.ui/src/org/apache/derby/ui/common/
eclipse/org.apache.derby.ui/src/org/apache/derby/ui/decorate/
eclipse/org.apache.derby.ui/src/org/apache/derby/ui/launch/
eclipse/org.apache.derby.ui/src/org/apache/derby/ui/nature/
eclipse/org.apache.derby.ui/src/org/apache/derby/ui/popup/
eclipse/org.apache.derby.ui/src/org/apache/derby/ui/popup/actions/
eclipse/org.apache.derby.ui/src/org/apache/derby/ui/properties/
eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/
Added: incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/plugin.xml
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/plugin.xml?rev=178020&view=auto
==============================================================================
--- incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/plugin.xml (added)
+++ incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/plugin.xml Mon May 23 13:55:15 2005
@@ -0,0 +1,408 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin
+ id="org.apache.derby.ui"
+ name="Apache Derby Ui Plug-in for Eclipse"
+ version="1.0.0"
+ provider-name="The Apache Software Foundation"
+ class="org.apache.derby.ui.DerbyPlugin">
+
+ <runtime>
+ <library name="ui.jar">
+ <export name="*"/>
+ </library>
+ </runtime>
+
+ <requires>
+ <import plugin="org.eclipse.core.resources"/>
+ <import plugin="org.eclipse.ui"/>
+ <import plugin="org.apache.derby.core"/>
+ <import plugin="org.eclipse.jdt.launching"/>
+ <import plugin="org.eclipse.debug.ui"/>
+ <import plugin="org.eclipse.debug.core"/>
+ <import plugin="org.eclipse.jdt.core"/>
+ <import plugin="org.eclipse.core.runtime"/>
+ <import plugin="org.eclipse.ui.console"/>
+ </requires>
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ adaptable="true"
+ objectClass="org.eclipse.jdt.core.IJavaProject"
+ id="org.apache.derby.ui.DerbyMenu">
+ <menu
+ label="Apache Derby"
+ path="additions"
+ id="org.apache.derby.ui.menu1">
+ <separator name="separator1"/>
+ <separator name="separator2"/>
+ <separator name="separator3"/>
+ <separator name="separator4"/>
+ </menu>
+ </objectContribution>
+ <objectContribution
+ objectClass="org.eclipse.jdt.core.IJavaProject"
+ id="org.apache.derby.ui.DerbyActions">
+ <visibility>
+ <not>
+ <objectState
+ value="org.apache.derby.ui.derbyEngine"
+ name="nature"/>
+ </not>
+ </visibility>
+ <action
+ enablesFor="1"
+ label="Add Apache Derby nature"
+ icon="icons/add.gif"
+ class="org.apache.derby.ui.popup.actions.AddDerbyNature"
+ menubarPath="org.apache.derby.ui.menu1/separator1"
+ id="org.apache.derby.ui.action1"/>
+ </objectContribution>
+ <objectContribution
+ objectClass="org.eclipse.jdt.core.IJavaProject"
+ id="org.apache.derby.ui.DerbyProjects">
+ <visibility>
+ <objectState
+ value="org.apache.derby.ui.derbyEngine"
+ name="nature"/>
+ </visibility>
+ <action
+ enablesFor="1"
+ label="Remove Apache Derby nature"
+ icon="icons/rem.gif"
+ class="org.apache.derby.ui.popup.actions.RemoveDerbyNature"
+ menubarPath="org.apache.derby.ui.menu1/separator1"
+ id="org.apache.derby.ui.action2"/>
+ </objectContribution>
+ <objectContribution
+ objectClass="org.eclipse.jdt.core.IJavaProject"
+ id="org.apache.derby.ui.StartStopActions">
+ <visibility>
+ <objectState
+ value="org.apache.derby.ui.derbyEngine"
+ name="nature"/>
+ </visibility>
+ <action
+ label="Stop Derby Network Server"
+ icon="icons/stop.gif"
+ class="org.apache.derby.ui.actions.StopAction"
+ menubarPath="org.apache.derby.ui.menu1/separator2"
+ enablesFor="1"
+ id="org.apache.derby.ui.StopAction">
+ <enablement>
+ <objectState
+ value="org.apache.derby.ui.isrun"
+ name="sessionProperty">
+ </objectState>
+ </enablement>
+ </action>
+ <action
+ label="Start Derby Network Server"
+ icon="icons/start.gif"
+ class="org.apache.derby.ui.actions.StartAction"
+ menubarPath="org.apache.derby.ui.menu1/separator2"
+ enablesFor="1"
+ id="org.apache.derby.ui.StartAction">
+ <enablement>
+ <not>
+ <objectState
+ value="org.apache.derby.ui.isrun"
+ name="sessionProperty">
+ </objectState>
+ </not>
+ </enablement>
+ </action>
+ </objectContribution>
+ <objectContribution
+ objectClass="org.eclipse.jdt.core.IJavaProject"
+ id="org.apache.derby.ui.RunIJ">
+ <visibility>
+ <objectState
+ value="org.apache.derby.ui.derbyEngine"
+ name="nature"/>
+ </visibility>
+ <action
+ enablesFor="1"
+ label="ij (Interactive SQL)"
+ class="org.apache.derby.ui.actions.IJAction"
+ icon="icons/ij.gif"
+ menubarPath="org.apache.derby.ui.menu1/separator3"
+ id="org.apache.derby.ui.ijAction1"/>
+ </objectContribution>
+ <objectContribution
+ objectClass="org.eclipse.jdt.core.IJavaProject"
+ id="org.apache.derby.ui.SysInfo">
+ <visibility>
+ <objectState
+ value="org.apache.derby.ui.derbyEngine"
+ name="nature"/>
+ </visibility>
+ <action
+ enablesFor="1"
+ label="sysinfo (Derby System Information)"
+ icon="icons/sysinfo.gif"
+ class="org.apache.derby.ui.actions.SysInfoAction"
+ menubarPath="org.apache.derby.ui.menu1/separator4"
+ id="org.apache.derby.ui.sysInfo1"/>
+ </objectContribution>
+ </extension>
+ <extension
+ id="derbyEngine"
+ name="Apache Derby "
+ point="org.eclipse.core.resources.natures">
+ <requires-nature id="org.eclipse.jdt.core.javanature"/>
+ <runtime>
+ <run class="org.apache.derby.ui.nature.DerbyNature"/>
+ </runtime>
+ </extension>
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ adaptable="true"
+ objectClass="org.eclipse.core.resources.IFile"
+ nameFilter="*.sql"
+ id="org.apache.derby.ui.DerbyMenu">
+ <menu
+ label="Apache Derby"
+ id="org.apache.derby.ui.menu2">
+ <separator name="separator4"/>
+ </menu>
+ </objectContribution>
+ <objectContribution
+ objectClass="org.eclipse.core.resources.IFile"
+ nameFilter="*.sql"
+ id="org.apache.derby.ui.RunSQLScript">
+ <action
+ enablesFor="1"
+ label="Run SQL Script using 'ij'"
+ class="org.apache.derby.ui.actions.IJAction"
+ icon="icons/ij.gif"
+ menubarPath="org.apache.derby.ui.menu2/separator4"
+ id="org.apache.derby.ui.SQLScript"/>
+ </objectContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ objectClass="org.eclipse.core.resources.IProject"
+ id="org.apache.derby.ui.DerbyMenu">
+ <menu
+ label="Apache Derby"
+ path="additions"
+ id="org.apache.derby.ui.menu2">
+ <separator name="separator1"/>
+ <separator name="separator2"/>
+ <separator name="separator3"/>
+ <separator name="separator4"/>
+ </menu>
+ </objectContribution>
+ <objectContribution
+ objectClass="org.eclipse.core.resources.IProject"
+ id="org.apache.derby.ui.DerbyActions">
+ <visibility>
+ <not>
+ <objectState
+ value="org.apache.derby.ui.derbyEngine"
+ name="nature"/>
+ </not>
+ </visibility>
+ <action
+ enablesFor="1"
+ label="Add Apache Derby nature"
+ icon="icons/add.gif"
+ class="org.apache.derby.ui.popup.actions.AddDerbyNature"
+ menubarPath="org.apache.derby.ui.menu2/separator1"
+ id="org.apache.derby.ui.action1"/>
+ </objectContribution>
+ <objectContribution
+ objectClass="org.eclipse.core.resources.IProject"
+ id="org.apache.derby.ui.DerbyProjects">
+ <visibility>
+ <objectState
+ value="org.apache.derby.ui.derbyEngine"
+ name="nature"/>
+ </visibility>
+ <action
+ enablesFor="1"
+ label="Remove Apache Derby nature"
+ icon="icons/rem.gif"
+ class="org.apache.derby.ui.popup.actions.RemoveDerbyNature"
+ menubarPath="org.apache.derby.ui.menu2/separator1"
+ id="org.apache.derby.ui.action2"/>
+ </objectContribution>
+ <objectContribution
+ objectClass="org.eclipse.core.resources.IProject"
+ id="org.apache.derby.ui.StartStopActions">
+ <visibility>
+ <objectState
+ value="org.apache.derby.ui.derbyEngine"
+ name="nature"/>
+ </visibility>
+ <action
+ enablesFor="1"
+ label="Stop Derby Network Server"
+ icon="icons/stop.gif"
+ class="org.apache.derby.ui.actions.StopAction"
+ menubarPath="org.apache.derby.ui.menu2/separator2"
+ id="org.apache.derby.ui.StopAction">
+ <enablement>
+ <objectState
+ value="org.apache.derby.ui.isrun"
+ name="sessionProperty"/>
+ </enablement>
+ </action>
+ <action
+ enablesFor="1"
+ label="Start Derby Network Server"
+ icon="icons/start.gif"
+ class="org.apache.derby.ui.actions.StartAction"
+ menubarPath="org.apache.derby.ui.menu2/separator2"
+ id="org.apache.derby.ui.StartAction">
+ <enablement>
+ <not>
+ <objectState
+ value="org.apache.derby.ui.isrun"
+ name="sessionProperty"/>
+ </not>
+ </enablement>
+ </action>
+ </objectContribution>
+ <objectContribution
+ objectClass="org.eclipse.core.resources.IProject"
+ id="org.apache.derby.ui.RunIJ">
+ <visibility>
+ <objectState
+ value="org.apache.derby.ui.derbyEngine"
+ name="nature"/>
+ </visibility>
+ <action
+ enablesFor="1"
+ label="ij (Interactive SQL)"
+ icon="icons/ij.gif"
+ class="org.apache.derby.ui.actions.IJAction"
+ menubarPath="org.apache.derby.ui.menu2/separator3"
+ id="org.apache.derby.ui.ijAction2"/>
+ </objectContribution>
+ <objectContribution
+ objectClass="org.eclipse.core.resources.IProject"
+ id="org.apache.derby.ui.Sysinfo">
+ <visibility>
+ <objectState
+ value="org.apache.derby.ui.derbyEngine"
+ name="nature"/>
+ </visibility>
+ <action
+ label="sysinfo (Derby System Information)"
+ icon="icons/sysinfo.gif"
+ class="org.apache.derby.ui.actions.SysInfoAction"
+ menubarPath="org.apache.derby.ui.menu2/separator4"
+ id="org.apache.derby.ui.sysInfo2"/>
+ </objectContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.propertyPages">
+ <page
+ adaptable="true"
+ objectClass="org.eclipse.core.resources.IProject"
+ class="org.apache.derby.ui.properties.DerbyPropertiesPage"
+ name="Apache Derby"
+ id="org.apache.derby.ui.properties.DerbyServerProperty">
+ <filter
+ value="org.apache.derby.ui.derbyEngine"
+ name="nature"/>
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.ui.decorators">
+ <decorator
+ lightweight="true"
+ adaptable="true"
+ label="Derby Network Server Runnning"
+ class="org.apache.derby.ui.decorate.DerbyIsRunningDecorator"
+ state="true"
+ location="TOP_LEFT"
+ id="org.apache.derby.ui.DerbyIsRunningDecorator">
+ <description/>
+ <enablement>
+ <or>
+ <and>
+ <objectClass name="org.eclipse.jdt.core.IJavaProject"/>
+ <objectState
+ value="org.apache.derby.ui.derbyEngine"
+ name="nature"/>
+ </and>
+ <and>
+ <objectClass name="org.eclipse.core.resources.IProject"/>
+ <objectState
+ value="org.apache.derby.ui.derbyEngine"
+ name="nature"/>
+ </and>
+ </or>
+ </enablement>
+ </decorator>
+ </extension>
+ <extension
+ point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+ delegate="org.apache.derby.ui.launch.StartDerbyServerLaunchConfigurationDelegate"
+ public="false"
+ name="Start Apache Derby Network Server"
+ id="org.apache.derby.ui.startDerbyServerLaunchConfigurationType"
+ modes="run, debug"/>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTypeImages">
+ <launchConfigurationTypeImage
+ icon="icons/start.gif"
+ configTypeID="org.apache.derby.ui.startDerbyServerLaunchConfigurationType"
+ id="org.apache.derby.ui.startDerbyServerLaunchConfigurationTypeImage"/>
+ </extension>
+ <extension
+ point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+ delegate="org.apache.derby.ui.launch.StopDerbyServerLaunchConfigurationDelegate"
+ public="false"
+ name="Stop Apache Derby Network Server"
+ id="org.apache.derby.ui.stopDerbyServerLaunchConfigurationType"
+ modes="run, debug"/>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTypeImages">
+ <launchConfigurationTypeImage
+ icon="icons/stop.gif"
+ configTypeID="org.apache.derby.ui.stopDerbyServerLaunchConfigurationType"
+ id="org.apache.derby.ui.stopDerbyServerLaunchConfigurationTypeImage"/>
+ </extension>
+ <extension
+ point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+ delegate="org.apache.derby.ui.launch.IJDerbyLaunchConfigurationDelegate"
+ public="false"
+ name="IJ"
+ id="org.apache.derby.ui.ijDerbyLaunchConfigurationType"
+ modes="run, debug"/>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTypeImages">
+ <launchConfigurationTypeImage
+ icon="icons/ij.gif"
+ configTypeID="org.apache.derby.ui.ijDerbyLaunchConfigurationType"
+ id="org.apache.derby.ui.ijDerbyLaunchConfigurationTypeImage"/>
+ </extension>
+ <extension
+ point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+ delegate="org.apache.derby.ui.launch.SysInfoDerbyLaunchConfigurationDelegate"
+ public="false"
+ name="SysInfo"
+ id="org.apache.derby.ui.sysinfoDerbyLaunchConfigurationType"
+ modes="run, debug"/>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTypeImages">
+ <launchConfigurationTypeImage
+ icon="icons/sysinfo.gif"
+ configTypeID="org.apache.derby.ui.sysinfoDerbyLaunchConfigurationType"
+ id="org.apache.derby.ui.sysinfoDerbyLaunchConfigurationTypeImage"/>
+ </extension>
+</plugin>
Added: incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/DerbyPlugin.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/DerbyPlugin.java?rev=178020&view=auto
==============================================================================
--- incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/DerbyPlugin.java (added)
+++ incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/DerbyPlugin.java Mon May 23 13:55:15 2005
@@ -0,0 +1,64 @@
+/*
+
+ Derby - Class org.apache.derby.ui.DerbyPlugin
+
+ Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.apache.derby.ui;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class DerbyPlugin extends AbstractUIPlugin {
+ //Only a single instance for the Eclipse platform.
+ private static DerbyPlugin plugin;
+
+
+ /**
+ * The constructor.
+ */
+ public DerbyPlugin() {
+ super();
+ plugin = this;
+ }
+
+ /**
+ * This method is called upon plug-in activation
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /**
+ * This method is called when the plug-in is stopped
+ */
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static DerbyPlugin getDefault() {
+ return plugin;
+ }
+
+
+}
Added: incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/actions/IJAction.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/actions/IJAction.java?rev=178020&view=auto
==============================================================================
--- incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/actions/IJAction.java (added)
+++ incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/actions/IJAction.java Mon May 23 13:55:15 2005
@@ -0,0 +1,131 @@
+/*
+
+ Derby - Class org.apache.derby.ui.actions.IJAction
+
+ Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.apache.derby.ui.actions;
+
+
+import org.apache.derby.ui.DerbyPlugin;
+import org.apache.derby.ui.common.CommonNames;
+import org.apache.derby.ui.common.Messages;
+import org.apache.derby.ui.util.DerbyUtils;
+import org.apache.derby.ui.util.Logger;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+
+public class IJAction implements IObjectActionDelegate {
+
+ private IFile currentScript;
+ private IJavaProject currentJavaProject;
+ private IProject currentProject;
+ /**
+ * Constructor for IJAction.
+ */
+ public IJAction() {
+ super();
+ }
+
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
+
+ /**
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(IAction action) {
+
+ Shell shell = new Shell();
+ DerbyPlugin plugin = DerbyPlugin.getDefault();
+ if (plugin== null) {
+ MessageDialog.openInformation(shell,
+ CommonNames.PLUGIN_NAME,
+ Messages.NO_ACTION);
+ }
+ else {
+ try {
+ if(currentJavaProject!=null){
+ currentProject=currentJavaProject.getProject();
+ }
+ if(currentProject.isNatureEnabled(CommonNames.DERBY_NATURE)){
+ DerbyUtils.runIJ(currentScript,currentProject);
+ }else{
+ shell = new Shell();
+ MessageDialog.openInformation(
+ shell,
+ CommonNames.PLUGIN_NAME,
+ Messages.NO_DERBY_NATURE+"\n"+
+ Messages.ADD_N_TRY);
+ }
+ }catch(Exception e){
+ Logger.log("IAction.run() error "+e,IStatus.ERROR);
+ }
+ }
+ }
+
+ /**
+ * @see IActionDelegate#selectionChanged(IAction, ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ currentJavaProject = org.apache.derby.ui.util.SelectionUtil.findSelectedJavaProject(selection);
+ if(currentJavaProject==null){
+ currentProject=org.apache.derby.ui.util.SelectionUtil.findSelectedProject(selection);
+ }
+ currentScript = null;
+ if (selection != null) {
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection)selection;
+ // get the first element, since selection is for single object
+ Object obj = ss.getFirstElement();
+ if (obj instanceof IFile) {
+ currentScript = (IFile)obj;
+ }
+ if(currentScript!=null){
+ currentProject=currentScript.getProject();
+ }
+ }
+ }
+ // To turn off the action item if the DERBY nature is not set
+ // We decided to go with the pop-up dialog way with the message to
+ // add the Derby nature and try.
+
+// try{
+// if((currentScript!=null)&&(currentProject!=null)){
+// if(currentScript.getName().toLowerCase().endsWith(".sql")&&(!currentProject.isNatureEnabled(CommonNames.DERBY_NATURE))){
+// action.setEnabled(false);
+// }
+// }
+// }catch(CoreException ce){
+// Logger.log("IAction.selectionChanged() method error "+ce,IStatus.ERROR);
+// }
+ }
+
+}
Added: incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/actions/StartAction.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/actions/StartAction.java?rev=178020&view=auto
==============================================================================
--- incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/actions/StartAction.java (added)
+++ incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/actions/StartAction.java Mon May 23 13:55:15 2005
@@ -0,0 +1,77 @@
+/*
+
+ Derby - Class org.apache.derby.ui.actions.StartAction
+
+ Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.apache.derby.ui.actions;
+
+import org.apache.derby.ui.common.CommonNames;
+import org.apache.derby.ui.common.Messages;
+import org.apache.derby.ui.util.DerbyServerUtils;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+;
+
+public class StartAction implements IObjectActionDelegate {
+
+ private IJavaProject currentJavaProject;
+ private IProject currentProject;
+
+ public StartAction() {
+ super();
+ }
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
+
+ public void run(IAction action) {
+ try {
+ if(currentJavaProject!=null){
+ currentProject=currentJavaProject.getProject();
+ }
+ DerbyServerUtils.getDefault().startDerbyServer(currentProject);
+
+ }
+ catch (CoreException e) {
+ Shell shell = new Shell();
+ MessageDialog.openInformation(
+ shell,
+ CommonNames.PLUGIN_NAME,
+ Messages.D_NS_START_ERROR +
+ org.apache.derby.ui.util.SelectionUtil.getStatusMessages(e));
+ }
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ currentJavaProject = org.apache.derby.ui.util.SelectionUtil.findSelectedJavaProject(selection);
+
+ if(currentJavaProject==null){
+ currentProject=org.apache.derby.ui.util.SelectionUtil.findSelectedProject(selection);
+ }
+
+ }
+
+}
Added: incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/actions/StopAction.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/actions/StopAction.java?rev=178020&view=auto
==============================================================================
--- incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/actions/StopAction.java (added)
+++ incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/actions/StopAction.java Mon May 23 13:55:15 2005
@@ -0,0 +1,76 @@
+/*
+
+ Derby - Class org.apache.derby.ui.actions.StopAction
+
+ Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.apache.derby.ui.actions;
+
+import org.apache.derby.ui.common.CommonNames;
+import org.apache.derby.ui.common.Messages;
+import org.apache.derby.ui.util.DerbyServerUtils;
+import org.apache.derby.ui.util.SelectionUtil;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+
+public class StopAction implements IObjectActionDelegate {
+
+ private IJavaProject currentJavaProject;
+ private IProject currentProject;
+ private Thread server=null;
+ public StopAction() {
+ super();
+ }
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
+
+ public void run(IAction action) {
+ try {
+ if(currentJavaProject!=null){
+ currentProject=currentJavaProject.getProject();
+
+ }
+ DerbyServerUtils.getDefault().stopDerbyServer(currentProject);
+
+
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ Shell shell = new Shell();
+ MessageDialog.openInformation(
+ shell,
+ CommonNames.PLUGIN_NAME,
+ Messages.D_NS_STOP_ERROR+
+ SelectionUtil.getStatusMessages(e));
+ }
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ currentJavaProject = SelectionUtil.findSelectedJavaProject(selection);
+ if(currentJavaProject==null){
+ currentProject=org.apache.derby.ui.util.SelectionUtil.findSelectedProject(selection);
+ }
+ }
+}
Added: incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/actions/SysInfoAction.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/actions/SysInfoAction.java?rev=178020&view=auto
==============================================================================
--- incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/actions/SysInfoAction.java (added)
+++ incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/actions/SysInfoAction.java Mon May 23 13:55:15 2005
@@ -0,0 +1,95 @@
+/*
+
+ Derby - Class org.apache.derby.ui.actions.SysInfoAction
+
+ Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.apache.derby.ui.actions;
+
+
+import org.apache.derby.ui.DerbyPlugin;
+import org.apache.derby.ui.common.CommonNames;
+import org.apache.derby.ui.common.Messages;
+import org.apache.derby.ui.util.DerbyUtils;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+
+public class SysInfoAction implements IObjectActionDelegate {
+
+ private IJavaProject currentJavaProject;
+ private IProject currentProject;
+ /**
+ * Constructor for Action1.
+ */
+ public SysInfoAction() {
+ super();
+ }
+
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
+
+ /**
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(IAction action) {
+ Shell shell = new Shell();
+ DerbyPlugin plugin = DerbyPlugin.getDefault();
+ if (plugin== null) {
+ MessageDialog.openInformation(shell,
+ CommonNames.PLUGIN_NAME,
+ Messages.NO_ACTION);
+ }
+ else {
+ try {
+ if(currentJavaProject!=null){
+ DerbyUtils.runSysInfo(currentJavaProject.getProject());
+ }else{
+ DerbyUtils.runSysInfo(currentProject);
+ }
+
+ }
+ catch (CoreException ce) {
+ ce.printStackTrace(System.err);
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * @see IActionDelegate#selectionChanged(IAction, ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ currentJavaProject = org.apache.derby.ui.util.SelectionUtil.findSelectedJavaProject(selection);
+ if(currentJavaProject==null){
+ currentProject=org.apache.derby.ui.util.SelectionUtil.findSelectedProject(selection);
+ }
+ }
+
+}
Added: incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/common/CommonNames.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/common/CommonNames.java?rev=178020&view=auto
==============================================================================
--- incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/common/CommonNames.java (added)
+++ incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/common/CommonNames.java Mon May 23 13:55:15 2005
@@ -0,0 +1,59 @@
+/*
+
+ Derby - Class org.apache.derby.ui.common.CommonNames
+
+ Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.apache.derby.ui.common;
+
+
+public class CommonNames {
+ //Network Server related
+ public static String DERBY_SERVER_CLASS="org.apache.derby.drda.NetworkServerControl";
+ public static String DERBY_SERVER="Derby Network Server";
+ public static String START_DERBY_SERVER="start";
+ public static String SHUTDOWN_DERBY_SERVER="shutdown";
+
+ //Tools related
+ public static String SYSINFO_CLASS="org.apache.derby.tools.sysinfo";
+ public static String SYSINFO="SYSINFO";
+ public static String IJ_CLASS="org.apache.derby.tools.ij";
+ public static String IJ="IJ";
+ public static String SQL_SCRIPT="SQL Script";
+
+ //actual information
+ public static String CORE_PATH="org.apache.derby.core";
+ public static String UI_PATH="org.apache.derby.ui";
+ public static String PLUGIN_NAME="Apache Derby Ui Plug-in";
+
+ //The next to be used with UI_PATH for adding nature. isrunning and decorator
+ public static String DERBY_NATURE=UI_PATH+"."+"derbyEngine";
+ public static String ISRUNNING="isrun";
+ public static String RUNDECORATOR=UI_PATH+"."+"DerbyIsRunningDecorator";
+
+ //Launch Config Types
+ public static String START_SERVER_LAUNCH_CONFIG_TYPE=UI_PATH+".startDerbyServerLaunchConfigurationType";
+ public static String STOP_SERVER_LAUNCH_CONFIG_TYPE=UI_PATH+".stopDerbyServerLaunchConfigurationType";
+ public static String IJ_LAUNCH_CONFIG_TYPE=UI_PATH+".ijDerbyLaunchConfigurationType";
+ public static String SYSINFO_LAUNCH_CONFIG_TYPE=UI_PATH+".sysinfoDerbyLaunchConfigurationType";
+
+ //JVM Poperties
+ public static String D_IJ_PROTOCOL=" -Dij.protocol=";
+ public static String DERBY_PROTOCOL="jdbc:derby:";
+ public static String D_SYSTEM_HOME=" -Dderby.system.home=";
+
+}
Added: incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/common/Messages.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/common/Messages.java?rev=178020&view=auto
==============================================================================
--- incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/common/Messages.java (added)
+++ incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/common/Messages.java Mon May 23 13:55:15 2005
@@ -0,0 +1,46 @@
+/*
+
+ Derby - Class org.apache.derby.ui.common.Messages
+
+ Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+
+package org.apache.derby.ui.common;
+
+public class Messages {
+ public static String D_NS_ATTEMPT_STARTED="Attempting to start the Apache Derby Network Server on port ";
+ public static String D_NS_ATTEMPT_STOPPED="Attempting to stop the Apache Derby Network Server on port ";
+
+ //public static String D_NS_STARTED="Apache Derby Network Server started.";
+ //public static String D_NS_STOPPED="Apache Derby Network Server stopped.";
+
+ public static String D_NS_START_ERROR="Error starting Derby Network Server:\n";
+ public static String D_NS_STOP_ERROR="Error stopping Derby Network Server:\n";
+
+ public static String ADDING_NATURE="Adding Apache Derby Nature...";
+ public static String DERBY_NATURE_ADDED="Finished adding Apache Derby Nature to the selected project";
+ public static String ERROR_ADDING_NATURE="Error adding Derby jars to the project";
+
+ public static String REMOVING_NATURE="Removing Apache Derby Nature...";
+ public static String DERBY_NATURE_REMOVED="Finished removing Apache Derby Nature from the selected project";
+ public static String ERROR_REMOVING_NATURE="Error removing Derby jars from the project";
+
+ public static String NO_DERBY_NATURE="The selected project does not have an Apache Derby nature.";
+ public static String ADD_N_TRY="Please add the Derby nature and try again.";
+
+ public static String NO_ACTION="Unable to execute the action";
+}
Added: incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/decorate/DerbyIsRunningDecorator.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/decorate/DerbyIsRunningDecorator.java?rev=178020&view=auto
==============================================================================
--- incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/decorate/DerbyIsRunningDecorator.java (added)
+++ incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/decorate/DerbyIsRunningDecorator.java Mon May 23 13:55:15 2005
@@ -0,0 +1,84 @@
+/*
+
+ Derby - Class org.apache.derby.ui.decorator.DerbyIsRunningDecorator
+
+ Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+
+package org.apache.derby.ui.decorate;
+
+import org.apache.derby.ui.DerbyPlugin;
+import org.apache.derby.ui.common.CommonNames;
+import org.apache.derby.ui.util.DerbyServerUtils;
+import org.apache.derby.ui.util.Logger;
+import org.apache.derby.ui.util.SelectionUtil;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IDecoratorManager;
+
+
+
+public class DerbyIsRunningDecorator extends LabelProvider
+implements ILightweightLabelDecorator {
+
+
+ private static final ImageDescriptor derbyRunningImageDesc = ImageDescriptor.
+ createFromURL(Platform.getBundle(CommonNames.UI_PATH).getEntry("/icons/"+CommonNames.ISRUNNING+".gif"));
+
+ public void decorate(Object element, IDecoration decoration) {
+ IProject proj=null;
+ if(element instanceof IJavaProject){
+ proj = ((IJavaProject)element).getProject();
+ }else{
+ proj=(IProject)element;
+ }
+ try {
+ if (DerbyServerUtils.getDefault().getRunning(proj)) {
+ decoration.addOverlay(derbyRunningImageDesc);
+ }
+ }
+ catch (CoreException ce) {
+ Logger.log(SelectionUtil.getStatusMessages(ce),IStatus.ERROR);
+ }
+ }
+
+
+ private void startUpdateDecor(IProject proj) {
+ final LabelProviderChangedEvent evnt = new LabelProviderChangedEvent(this, proj);
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ fireLabelProviderChanged(evnt);
+ }
+ });
+ }
+
+ public static void performUpdateDecor(IProject proj) {
+ IDecoratorManager dm = DerbyPlugin.getDefault().getWorkbench().getDecoratorManager();
+ DerbyIsRunningDecorator decorator = (DerbyIsRunningDecorator)dm.getBaseLabelProvider(CommonNames.RUNDECORATOR);
+ decorator.startUpdateDecor(proj);
+ }
+
+}
Added: incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/launch/IJDerbyLaunchConfigurationDelegate.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/launch/IJDerbyLaunchConfigurationDelegate.java?rev=178020&view=auto
==============================================================================
--- incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/launch/IJDerbyLaunchConfigurationDelegate.java (added)
+++ incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/launch/IJDerbyLaunchConfigurationDelegate.java Mon May 23 13:55:15 2005
@@ -0,0 +1,29 @@
+/*
+
+ Derby - Class org.apache.derby.ui.launch.IJDerbyLaunchConfigurationDelegate
+
+ Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.apache.derby.ui.launch;
+
+import org.eclipse.jdt.internal.launching.JavaLocalApplicationLaunchConfigurationDelegate;
+
+
+public class IJDerbyLaunchConfigurationDelegate extends
+ JavaLocalApplicationLaunchConfigurationDelegate {
+
+}
Added: incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/launch/StartDerbyServerLaunchConfigurationDelegate.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/launch/StartDerbyServerLaunchConfigurationDelegate.java?rev=178020&view=auto
==============================================================================
--- incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/launch/StartDerbyServerLaunchConfigurationDelegate.java (added)
+++ incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/launch/StartDerbyServerLaunchConfigurationDelegate.java Mon May 23 13:55:15 2005
@@ -0,0 +1,29 @@
+/*
+
+ Derby - Class org.apache.derby.ui.launch.StartDerbyServerLaunchConfigurationDelegate
+
+ Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.apache.derby.ui.launch;
+
+import org.eclipse.jdt.internal.launching.JavaLocalApplicationLaunchConfigurationDelegate;
+
+
+public class StartDerbyServerLaunchConfigurationDelegate extends
+ JavaLocalApplicationLaunchConfigurationDelegate {
+
+}
Added: incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/launch/StopDerbyServerLaunchConfigurationDelegate.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/launch/StopDerbyServerLaunchConfigurationDelegate.java?rev=178020&view=auto
==============================================================================
--- incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/launch/StopDerbyServerLaunchConfigurationDelegate.java (added)
+++ incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/launch/StopDerbyServerLaunchConfigurationDelegate.java Mon May 23 13:55:15 2005
@@ -0,0 +1,29 @@
+/*
+
+ Derby - Class org.apache.derby.ui.launch.StopDerbyServerLaunchConfigurationDelegate
+
+ Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.apache.derby.ui.launch;
+
+import org.eclipse.jdt.internal.launching.JavaLocalApplicationLaunchConfigurationDelegate;
+
+
+public class StopDerbyServerLaunchConfigurationDelegate extends
+ JavaLocalApplicationLaunchConfigurationDelegate {
+
+}
Added: incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/launch/SysInfoDerbyLaunchConfigurationDelegate.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/launch/SysInfoDerbyLaunchConfigurationDelegate.java?rev=178020&view=auto
==============================================================================
--- incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/launch/SysInfoDerbyLaunchConfigurationDelegate.java (added)
+++ incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/launch/SysInfoDerbyLaunchConfigurationDelegate.java Mon May 23 13:55:15 2005
@@ -0,0 +1,29 @@
+/*
+
+ Derby - Class org.apache.derby.ui.launch.SysInfoDerbyLaunchConfigurationDelegate
+
+ Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.apache.derby.ui.launch;
+
+import org.eclipse.jdt.internal.launching.JavaLocalApplicationLaunchConfigurationDelegate;
+
+
+public class SysInfoDerbyLaunchConfigurationDelegate extends
+ JavaLocalApplicationLaunchConfigurationDelegate {
+
+}
Added: incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/nature/DerbyNature.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/nature/DerbyNature.java?rev=178020&view=auto
==============================================================================
--- incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/nature/DerbyNature.java (added)
+++ incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/nature/DerbyNature.java Mon May 23 13:55:15 2005
@@ -0,0 +1,46 @@
+/*
+
+ Derby - Class org.apache.derby.ui.nature.DerbyNature
+
+ Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.apache.derby.ui.nature;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNature;
+
+public class DerbyNature implements IProjectNature {
+ private IProject project = null;
+
+ public DerbyNature() {
+ }
+
+ public void configure() throws CoreException {
+ }
+
+ public void deconfigure() throws CoreException {
+ }
+
+ public IProject getProject() {
+ return project;
+ }
+
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+}
Added: incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/popup/actions/AddDerbyNature.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/popup/actions/AddDerbyNature.java?rev=178020&view=auto
==============================================================================
--- incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/popup/actions/AddDerbyNature.java (added)
+++ incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/popup/actions/AddDerbyNature.java Mon May 23 13:55:15 2005
@@ -0,0 +1,158 @@
+/*
+ *
+ * Derby - Class org.apache.derby.ui.popup.actions.AddDerbyNature
+ *
+ * Copyright 2002, 2004 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ *
+ */
+
+package org.apache.derby.ui.popup.actions;
+
+import org.apache.derby.ui.common.CommonNames;
+import org.apache.derby.ui.common.Messages;
+import org.apache.derby.ui.util.DerbyUtils;
+import org.apache.derby.ui.util.Logger;
+import org.apache.derby.ui.util.SelectionUtil;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.window.ApplicationWindow;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+public class AddDerbyNature implements IObjectActionDelegate
+{
+
+ private IJavaProject currentJavaProject;
+ private IProject currentProject;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction,
+ * org.eclipse.ui.IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart)
+ {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action)
+ {
+ IWorkbenchWindow window = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow();
+ Cursor waitCursor = new Cursor(window.getShell().getDisplay(),
+ SWT.CURSOR_WAIT);
+ try
+ {
+ window.getShell().setCursor(waitCursor);
+ ((ApplicationWindow) window).setStatus(Messages.ADDING_NATURE);
+
+ //new way
+ if (currentJavaProject == null)
+ {
+ // if the java nature is not present
+ // it must be added, along with the Derby nature
+ IProjectDescription description = currentProject
+ .getDescription();
+ String[] natureIds = description.getNatureIds();
+ String[] newNatures = new String[natureIds.length + 2];
+ System.arraycopy(natureIds, 0, newNatures, 0, natureIds.length);
+ newNatures[newNatures.length - 2] = JavaCore.NATURE_ID;
+ newNatures[newNatures.length - 1] = CommonNames.DERBY_NATURE;
+ description.setNatureIds(newNatures);
+ currentProject.setDescription(description, null);
+
+ currentJavaProject = (IJavaProject) JavaCore
+ .create((IProject) currentProject);
+ }
+ else
+ {
+ //add the derby nature, the java nature is already present
+ IProjectDescription description = currentJavaProject
+ .getProject().getDescription();
+ String[] natures = description.getNatureIds();
+ String[] newNatures = new String[natures.length + 1];
+ System.arraycopy(natures, 0, newNatures, 0, natures.length);
+ // must prefix with plugin id
+ newNatures[natures.length] = CommonNames.DERBY_NATURE;
+ description.setNatureIds(newNatures);
+ currentJavaProject.getProject().setDescription(description,
+ null);
+ }
+
+ IClasspathEntry[] rawClasspath = currentJavaProject
+ .getRawClasspath();
+
+ currentJavaProject.setRawClasspath(DerbyUtils
+ .addDerbyJars(rawClasspath), null);
+
+ // refresh project so user sees new files, libraries, etc
+ currentJavaProject.getProject().refreshLocal(
+ IResource.DEPTH_INFINITE, null);
+ ((ApplicationWindow) window).setStatus(Messages.DERBY_NATURE_ADDED);
+
+ } catch ( Exception e)
+ {
+ Logger.log(Messages.ERROR_ADDING_NATURE + " '"
+ + currentJavaProject.getProject().getName() + "' : " + e,
+ IStatus.ERROR);
+ Shell shell = new Shell();
+ MessageDialog.openInformation(shell, CommonNames.PLUGIN_NAME,
+ Messages.ERROR_ADDING_NATURE + ":\n"
+ + SelectionUtil.getStatusMessages(e));
+ } finally
+ {
+ window.getShell().setCursor(null);
+ waitCursor.dispose();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
+ * org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection)
+ {
+ currentJavaProject = SelectionUtil.findSelectedJavaProject(selection);
+
+ if (currentJavaProject == null)
+ {
+ currentProject = org.apache.derby.ui.util.SelectionUtil
+ .findSelectedProject(selection);
+ }
+
+ }
+
+}
\ No newline at end of file
Added: incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/popup/actions/RemoveDerbyNature.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/popup/actions/RemoveDerbyNature.java?rev=178020&view=auto
==============================================================================
--- incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/popup/actions/RemoveDerbyNature.java (added)
+++ incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/popup/actions/RemoveDerbyNature.java Mon May 23 13:55:15 2005
@@ -0,0 +1,121 @@
+/*
+
+ Derby - Class org.apache.derby.ui.popup.actions.RemoveDerbyNature
+
+ Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+package org.apache.derby.ui.popup.actions;
+
+import java.util.ArrayList;
+
+import org.apache.derby.ui.common.CommonNames;
+import org.apache.derby.ui.common.Messages;
+import org.apache.derby.ui.util.DerbyServerUtils;
+import org.apache.derby.ui.util.DerbyUtils;
+import org.apache.derby.ui.util.Logger;
+import org.apache.derby.ui.util.SelectionUtil;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.window.ApplicationWindow;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+public class RemoveDerbyNature implements IObjectActionDelegate {
+
+ private IJavaProject currentJavaProject;
+ private IProject currentProject;
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
+
+
+ private static String[] removeDerbyNature(String [] natures){
+ ArrayList arrL=new ArrayList();
+
+ for (int i=0;i<natures.length;i++){
+ if(!(natures[i].equalsIgnoreCase(CommonNames.DERBY_NATURE))){
+ arrL.add(natures[i]);
+ }
+ }
+ String [] newNatures= new String [arrL.size()];
+ for(int i=0;i<arrL.size();i++){
+ newNatures[i]=(String)arrL.get(i);
+ }
+ return newNatures;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ try {
+ ((ApplicationWindow)window).setStatus(Messages.REMOVING_NATURE);
+
+ if(currentJavaProject==null){
+ currentJavaProject=JavaCore.create(currentProject);
+ }
+ //Shutdown server if running for the current project
+ if(DerbyServerUtils.getDefault().getRunning(currentJavaProject.getProject())){
+ DerbyServerUtils.getDefault().stopDerbyServer(currentJavaProject.getProject());
+ }
+ IClasspathEntry[] rawClasspath = currentJavaProject.getRawClasspath();
+ currentJavaProject.setRawClasspath(DerbyUtils.removeDerbyJars(rawClasspath), null);
+
+ IProjectDescription description = currentJavaProject.getProject().getDescription();
+ String[] natures = description.getNatureIds();
+
+ description.setNatureIds(removeDerbyNature(natures));
+ currentJavaProject.getProject().setDescription(description, null);
+ // refresh project so user sees changes
+ currentJavaProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
+ ((ApplicationWindow)window).setStatus(Messages.DERBY_NATURE_REMOVED);
+ }catch (Exception e) {
+ Logger.log(Messages.ERROR_REMOVING_NATURE+" '"+currentJavaProject.getProject().getName()+"': "+e,IStatus.ERROR);
+
+ Shell shell = new Shell();
+ MessageDialog.openInformation(
+ shell,
+ CommonNames.PLUGIN_NAME,
+ Messages.ERROR_REMOVING_NATURE+":\n" +
+ SelectionUtil.getStatusMessages(e));
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ currentJavaProject = SelectionUtil.findSelectedJavaProject(selection);
+ if(currentJavaProject==null){
+ currentProject=org.apache.derby.ui.util.SelectionUtil.findSelectedProject(selection);
+ }
+ }
+
+}
Added: incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/properties/DerbyProperties.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/properties/DerbyProperties.java?rev=178020&view=auto
==============================================================================
--- incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/properties/DerbyProperties.java (added)
+++ incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/properties/DerbyProperties.java Mon May 23 13:55:15 2005
@@ -0,0 +1,122 @@
+/*
+
+ Derby - Class org.apache.derby.ui.properties.DerbyProperties
+
+ Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.apache.derby.ui.properties;
+
+import org.apache.derby.ui.common.CommonNames;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.jdt.core.IJavaProject;
+
+
+
+public class DerbyProperties {
+
+ public static final String DSPORT = "ds.port";
+ //public static final String DS_RUNNING_PORT = "ds.running.port";
+ public static final String DSHOST = "ds.host";
+ public static final String DS_SYS_HOME = "derby.system.home";
+
+ //Default Derby Properties
+ private int port = 1527;
+ //private int runningPort=0;
+ private String host = "localhost";
+ private String systemHome = ".";
+
+ public DerbyProperties() {}
+
+ public DerbyProperties(IJavaProject javaProject) throws CoreException {
+ load(javaProject.getProject());
+ }
+ public DerbyProperties(IProject project) throws CoreException {
+ load(project);
+ }
+
+ public void save(IProject project) throws CoreException {
+
+ project.setPersistentProperty(new QualifiedName (
+ CommonNames.UI_PATH, DSPORT), Integer.toString(port));
+ project.setPersistentProperty(new QualifiedName (
+ CommonNames.UI_PATH, DSHOST), host);
+ project.setPersistentProperty(new QualifiedName (
+ CommonNames.UI_PATH, DS_SYS_HOME), systemHome);
+// project.setPersistentProperty(new QualifiedName (
+// CommonNames.UI_PATH, DS_RUNNING_PORT), Integer.toString(runningPort));
+ }
+
+ public void load(IProject project) throws CoreException {
+
+ String property = project.getPersistentProperty(new QualifiedName (
+ CommonNames.UI_PATH, DSPORT));
+ port = (property != null && property.length() > 0) ? Integer.parseInt(property) : port;
+ property = project.getPersistentProperty(new QualifiedName (
+ CommonNames.UI_PATH, DSHOST));
+ host = (property != null && property.length() > 0) ? property : host;
+ property = project.getPersistentProperty(new QualifiedName (
+ CommonNames.UI_PATH, DS_SYS_HOME));
+ systemHome = (property != null && property.length() > 0) ? property : systemHome;
+// property = project.getPersistentProperty(new QualifiedName (
+// CommonNames.UI_PATH, DS_RUNNING_PORT));
+// runningPort = (property != null && property.length() > 0) ? Integer.parseInt(property) : runningPort;
+ }
+ public String toString(){
+ return "Derby Server Properties:\n Port = "+getPort()+" Host = "+getHost()+" System Home = "+getSystemHome();
+ }
+
+ /**
+ * @return Returns the host.
+ */
+ public String getHost() {
+ return host;
+ }
+ /**
+ * @param host The host to set.
+ */
+ public void setHost(String host) {
+ this.host = host;
+ }
+ /**
+ * @return Returns the port.
+ */
+ public int getPort() {
+ return port;
+ }
+ /**
+ * @param port The port to set.
+ */
+ public void setPort(int port) {
+ this.port = port;
+ }
+ /**
+ * @return Returns the systemHome.
+ */
+ public String getSystemHome() {
+ return systemHome;
+ }
+ /**
+ * @param systemHome The systemHome to set.
+ */
+ public void setSystemHome(String systemHome) {
+ this.systemHome = systemHome;
+ }
+
+}
+
Added: incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/properties/DerbyPropertiesPage.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/properties/DerbyPropertiesPage.java?rev=178020&view=auto
==============================================================================
--- incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/properties/DerbyPropertiesPage.java (added)
+++ incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/properties/DerbyPropertiesPage.java Mon May 23 13:55:15 2005
@@ -0,0 +1,184 @@
+/*
+
+ Derby - Class org.apache.derby.ui.properties.DerbyPropertiesPage
+
+ Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.apache.derby.ui.properties;
+
+import org.apache.derby.ui.util.Logger;
+import org.apache.derby.ui.util.SelectionUtil;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+
+
+public class DerbyPropertiesPage extends PropertyPage {
+ public DerbyPropertiesPage() {
+ super();
+ }
+ protected DerbyProperties dsProps;
+ protected Text hostText;
+ protected Text portText;
+ protected Text systemHomeText;
+
+
+ protected void addControls(Composite parent) {
+ Composite composite = createDefaultComposite(parent);
+
+ //Network Server Settings
+ Label txt=new Label(composite,SWT.NONE);
+ txt.setBackground(new Color(null,0,0,0));
+ txt.setForeground(new Color(null,255,255,255));
+ txt.setText("Network Server Settings:");
+
+ //separator
+ Label separatorLabel=new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
+ separatorLabel.setLayoutData(getSeperatorLabelGridData());
+
+ org.eclipse.swt.widgets.
+ Label portLabel = new Label(composite, SWT.NONE);
+ portLabel.setText("&Network Server Port:");
+ portText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ GridData gd = new GridData();
+ gd.widthHint = convertWidthInCharsToPixels(6);
+ portText.setLayoutData(gd);
+
+ Label hostLabel = new Label(composite, SWT.NONE);
+ hostLabel.setText("&Network Server Host:");
+ hostText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData();
+ gd.widthHint = convertWidthInCharsToPixels(16);
+ hostText.setLayoutData(gd);
+
+ //Derby System Properties
+ separatorLabel=new Label(composite, SWT.NONE);
+ separatorLabel.setLayoutData(getSeperatorLabelGridData());
+ separatorLabel.setText("");
+
+ Label txt1=new Label(composite,SWT.NONE);
+ txt1.setBackground(new Color(null,0,0,0));
+ txt1.setForeground(new Color(null,255,255,255));
+ txt1.setText("Derby System Properties:");
+
+ //separator
+ separatorLabel=new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
+ separatorLabel.setLayoutData(getSeperatorLabelGridData());
+
+ Label sytemHomeLabel = new Label(composite, SWT.NONE);
+ sytemHomeLabel.setText("&derby.system.home=");
+ systemHomeText = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ gd = new GridData();
+ gd.widthHint = convertWidthInCharsToPixels(16);
+ systemHomeText.setLayoutData(gd);
+ }
+
+ protected Composite createDefaultComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ composite.setLayout(layout);
+
+ GridData data = new GridData();
+ data.verticalAlignment = GridData.FILL;
+ data.horizontalAlignment = GridData.FILL;
+ composite.setLayoutData(data);
+
+ return composite;
+ }
+
+ protected void fillControls() {
+ portText.setText(Integer.toString(dsProps.getPort()));
+ hostText.setText(dsProps.getHost());
+ systemHomeText.setText(dsProps.getSystemHome());
+ }
+
+ protected void getParams() {
+ dsProps = new DerbyProperties();
+ try {
+ dsProps.setPort(Integer.parseInt(portText.getText()));
+ }
+ catch (NumberFormatException ne) {
+ // do nothing; use the default port number
+ }
+ dsProps.setHost(hostText.getText());
+ dsProps.setSystemHome(systemHomeText.getText());
+ }
+
+ protected GridData getSeperatorLabelGridData() {
+
+ GridData gridData = new GridData(GridData.BEGINNING |
+ GridData.HORIZONTAL_ALIGN_FILL |
+ GridData.GRAB_VERTICAL |
+ GridData.BEGINNING |
+ GridData.VERTICAL_ALIGN_BEGINNING |
+ GridData.VERTICAL_ALIGN_FILL) ;
+ gridData.horizontalSpan = 2;
+ gridData.grabExcessVerticalSpace = false;
+ gridData.grabExcessHorizontalSpace = true;
+ return gridData;
+
+ }
+
+ protected void performDefaults() {
+ dsProps = new DerbyProperties();
+ fillControls();
+ }
+ public boolean performOk() {
+ IProject proj = (IProject)getElement();
+ getParams();
+ try {
+
+ dsProps.save(proj.getProject());
+ }
+ catch (CoreException ce) {
+ System.err.println(SelectionUtil.getStatusMessages(ce));
+ return false;
+ }
+ return true;
+ }
+
+ protected Control createContents(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ composite.setLayout(layout);
+ GridData data = new GridData(GridData.FILL);
+ data.grabExcessHorizontalSpace = true;
+ composite.setLayoutData(data);
+ addControls(composite);
+ IProject proj = (IProject)getElement();
+ try {
+ dsProps = new DerbyProperties(proj);
+ fillControls();
+ }
+ catch (CoreException ce) {
+ Logger.log(SelectionUtil.getStatusMessages(ce),IStatus.ERROR);
+ }
+ return composite;
+ }
+
+}
Added: incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/DerbyServerUtils.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/DerbyServerUtils.java?rev=178020&view=auto
==============================================================================
--- incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/DerbyServerUtils.java (added)
+++ incubator/derby/code/trunk/plugins/eclipse/org.apache.derby.ui/src/org/apache/derby/ui/util/DerbyServerUtils.java Mon May 23 13:55:15 2005
@@ -0,0 +1,223 @@
+/*
+
+ Derby - Class org.apache.derby.ui.util.DerbyServerUtils
+
+ Copyright 2002, 2004 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.apache.derby.ui.util;
+
+//import org.apache.ui.decorator.DerbyRunningDecorator;
+
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.apache.derby.ui.common.CommonNames;
+import org.apache.derby.ui.common.Messages;
+import org.apache.derby.ui.decorate.DerbyIsRunningDecorator;
+import org.apache.derby.ui.properties.DerbyProperties;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.widgets.Shell;
+
+
+
+public class DerbyServerUtils {
+
+ //Singleton Class
+ private static DerbyServerUtils dsUtils = new DerbyServerUtils();
+ private HashMap servers = new HashMap();
+
+ private DerbyServerUtils() {
+ super();
+ }
+
+ public static DerbyServerUtils getDefault() {
+ if (dsUtils == null)
+ dsUtils = new DerbyServerUtils();
+ return dsUtils;
+ }
+
+ // listener for DebugEvents, to know if a server was stopped by the client
+ // or died by itself
+
+ private IDebugEventSetListener listener = new IDebugEventSetListener() {
+ public void handleDebugEvents(DebugEvent[] events) {
+ // type of event was a terminate...
+ if(events.length>0){
+ if (events[0].getKind() == DebugEvent.TERMINATE) {
+ Object source = events[0].getSource();
+ if (source instanceof IProcess) {
+ // check for Derby Network Servre process.
+ Object proj = servers.get(source);
+ if (proj != null) {
+ try {
+ //remove it from the hashmap, update the ui
+ servers.remove(source);
+ if(proj instanceof IJavaProject){
+ setRunning(((IJavaProject)proj).getProject(), null);
+ }else if(proj instanceof IProject){
+ setRunning((IProject)proj,null);
+ }
+ }
+ catch (CoreException ce) {
+ Logger.log("DerbyServerTracker.handleDebugEvents: "+ce, IStatus.ERROR);
+ }catch(Exception e){
+ Logger.log("DerbyServerTracker.handleDebugEvents: "+e, IStatus.ERROR);
+ }
+ }
+ }
+ }
+ }
+ }
+ };
+
+ private IResourceChangeListener rlistener = new IResourceChangeListener() {
+ public void resourceChanged(IResourceChangeEvent event){
+ if(event.getType()==IResourceChangeEvent.PRE_CLOSE){
+ try{
+ if(event.getResource().getProject().isNatureEnabled(CommonNames.DERBY_NATURE)){
+ if(getRunning(event.getResource().getProject())){
+ stopDerbyServer(event.getResource().getProject());
+ }
+ }
+ }catch(SWTException swe){
+ //The SWTException is thrown during the Shell creation
+ //Logger.log("Exception shutting down "+swe,IStatus.ERROR);
+ //e.printStackTrace();
+ }catch(Exception e){
+ Logger.log("Exception shutting down "+e,IStatus.ERROR);
+ }
+ }
+ }
+ };
+
+ public boolean getRunning(IProject proj) throws CoreException {
+ Object value = proj.getSessionProperty(new QualifiedName(CommonNames.UI_PATH, CommonNames.ISRUNNING));
+
+ return value != null;
+ }
+
+ public void setRunning(IProject proj, Boolean value) throws CoreException {
+ try{
+ if (value != null && value.equals(Boolean.FALSE)){
+ value = null;
+ }
+ if(proj.isOpen()){
+ proj.setSessionProperty(new QualifiedName(CommonNames.UI_PATH,CommonNames.ISRUNNING ),value);
+ }
+ }catch(Exception e){
+ Logger.log("DerbyServerUtils.setRunning() error: "+e, IStatus.ERROR);
+
+ }
+ DerbyIsRunningDecorator.performUpdateDecor(proj);
+ }
+
+ public void startDerbyServer( IProject proj) throws CoreException {
+ String args = CommonNames.START_DERBY_SERVER;
+ String vmargs="";
+ DerbyProperties dprop=new DerbyProperties(proj);
+ //Starts the server as a Java app
+ args+=" -h "+dprop.getHost()+ " -p "+dprop.getPort();
+
+ //Set Derby System Home from the Derby Properties
+ if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){
+ vmargs=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome();
+ }
+ String procName="["+proj.getName()+"] - "+CommonNames.DERBY_SERVER+" "+CommonNames.START_DERBY_SERVER+" ("+dprop.getHost()+ ", "+dprop.getPort()+")";
+ ILaunch launch = DerbyUtils.launch(proj, procName ,
+ CommonNames.DERBY_SERVER_CLASS, args, vmargs, CommonNames.START_DERBY_SERVER);
+ IProcess ip=launch.getProcesses()[0];
+ //set a name to be seen in the Console list
+ ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);
+
+ // saves the mapping between (server) process and project
+ //servers.put(launch.getProcesses()[0], proj);
+ servers.put(ip, proj);
+ // register a listener to listen, when this process is finished
+ DebugPlugin.getDefault().addDebugEventListener(listener);
+ //Add resource listener
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+
+ workspace.addResourceChangeListener(rlistener);
+ setRunning(proj, Boolean.TRUE);
+ Shell shell = new Shell();
+ MessageDialog.openInformation(
+ shell,
+ CommonNames.PLUGIN_NAME,
+ Messages.D_NS_ATTEMPT_STARTED+dprop.getPort()+".");
+
+ }
+
+ public void stopDerbyServer( IProject proj) throws CoreException, ClassNotFoundException, SQLException {
+ String args = CommonNames.SHUTDOWN_DERBY_SERVER;
+ String vmargs="";
+ DerbyProperties dprop=new DerbyProperties(proj);
+ args+=" -h "+dprop.getHost()+ " -p "+dprop.getPort();
+
+ // Set Derby System Home from the Derby Properties
+ if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){
+ vmargs=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome();
+ }
+ String procName="["+proj.getName()+"] - "+CommonNames.DERBY_SERVER+" "+CommonNames.SHUTDOWN_DERBY_SERVER+" ("+dprop.getHost()+ ", "+dprop.getPort()+")";
+
+ // starts the server as a Java app
+ ILaunch launch = DerbyUtils.launch(proj, procName,
+ CommonNames.DERBY_SERVER_CLASS, args, vmargs,CommonNames.SHUTDOWN_DERBY_SERVER);
+ IProcess ip=launch.getProcesses()[0];
+
+ //set a name to be seen in the Console list
+ ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);
+
+ //update the objectState
+ setRunning(proj, Boolean.FALSE);
+ if(proj.isOpen()){
+ Shell shell = new Shell();
+ MessageDialog.openInformation(
+ shell,
+ CommonNames.PLUGIN_NAME,
+ Messages.D_NS_ATTEMPT_STOPPED+dprop.getPort()+"." );
+ }
+ }
+ public void shutdownAllServers() {
+ Iterator it = servers.values().iterator();
+ while (it.hasNext()) {
+ try {
+ stopDerbyServer((IProject)it.next());
+ }
+ catch (Exception e) {
+ Logger.log("DerbyServerUtils.shutdownServers",IStatus.ERROR);
+ Logger.log(SelectionUtil.getStatusMessages(e), IStatus.ERROR);
+ }
+ }
+ }
+
+}