GladeForrestPlugin/src/java/org/metamorphosis/glade/actions StartForrestAction.java,NONE,1.1
Nick Chalko <[email protected]> Mon, 19 Jul 2004 05:43:57 +0000
| Newsgroups | gmane.comp.krysalis.metamorphosis.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/metamorphosis/GladeForrestPlugin/src/java/org/metamorphosis/glade/actions
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28611/src/java/org/metamorphosis/glade/actions
Added Files:
StartForrestAction.java
Log Message:
Playing with an eclipse plugin for forrest.
--- NEW FILE: StartForrestAction.java ---
package org.metamorphosis.glade.actions;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.Launch;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.jface.dialogs.MessageDialog;
import org.metamorphosis.glade.ForrestStarterPlugin;
import org.metamorphosis.glade.preferences.GladePreferencePage;
/**
* Our sample action implements workbench action delegate. The action proxy will
* be created by the workbench and shown in the UI. When the user tries to use
* the action, this delegate will be created and execution will be delegated to
* it.
*
* @see IWorkbenchWindowActionDelegate
*/
public class StartForrestAction implements IWorkbenchWindowActionDelegate {
private IWorkbenchWindow window;
/**
* The constructor.
*/
public StartForrestAction() {
}
/**
* The action has been activated. The argument of the method represents the
* 'real' action sitting in the workbench UI.
*
* @see IWorkbenchWindowActionDelegate#run
*/
public void run(IAction action) {
IPreferenceStore preferenceStore = ForrestStarterPlugin.getDefault()
.getPreferenceStore();
MessageDialog
.openInformation(window.getShell(), "ForrestStarter Plug-in",
"Hello, Eclipse world:"
+ preferenceStore
.getString(GladePreferencePage.P_PATH));
try {
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type =
manager.getLaunchConfigurationType("type");
ILaunchConfiguration[] configurations =
manager.getLaunchConfigurations(type);
for (int i = 0; i < configurations.length; i++) {
ILaunchConfiguration configuration = configurations[i];
if (configuration.getName().equals("Start Tomcat")) {
configuration.delete();
break;
}
}
ILaunchConfigurationWorkingCopy workingCopy =
type.newInstance(null, "Start Tomcat");
workingCopy.setAttribute(ATTR_MAIN_TYPE_NAME,
"org.apache.catalina.startup.Bootstrap");
workingCopy.setAttribute(ATTR_PROGRAM_ARGUMENTS, "start");
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* Selection in the workbench has been changed. We can change the state of
* the 'real' action here if we want, but this can only happen after the
* delegate has been created.
*
* @see IWorkbenchWindowActionDelegate#selectionChanged
*/
public void selectionChanged(IAction action, ISelection selection) {
}
/**
* We can use this method to dispose of any system resources we previously
* allocated.
*
* @see IWorkbenchWindowActionDelegate#dispose
*/
public void dispose() {
}
/**
* We will cache window object in order to be able to provide parent shell
* for the message dialog.
*
* @see IWorkbenchWindowActionDelegate#init
*/
public void init(IWorkbenchWindow window) {
this.window = window;
}
}
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click