Commit 36676ba2 authored by stancakapost's avatar stancakapost
Browse files

added shortcuts to the new test wizards

parent c7a0c340
Loading
Loading
Loading
Loading
+28 −0
Original line number Original line Diff line number Diff line
@@ -19,11 +19,13 @@
               label="Positive"
               label="Positive"
               class="org.etsi.mts.ttcn3.part9.popup.actions.NewPositiveTestCase"
               class="org.etsi.mts.ttcn3.part9.popup.actions.NewPositiveTestCase"
               menubarPath="NewTestCase.menu1/group1"
               menubarPath="NewTestCase.menu1/group1"
               definitionId="org.etsi.mts.ttcn3.part9.newTestCase.commands.newPositiveTestcase"
               enablesFor="1"
               enablesFor="1"
               id="NewTestCase.newAction1">
               id="NewTestCase.newAction1">
         </action>
         </action>
         <action
         <action
               label="Negative"
               label="Negative"
               definitionId="org.etsi.mts.ttcn3.part9.newTestCase.commands.newNegativeTestcase"
               class="org.etsi.mts.ttcn3.part9.popup.actions.NewNegativeTestCase"
               class="org.etsi.mts.ttcn3.part9.popup.actions.NewNegativeTestCase"
               menubarPath="NewTestCase.menu1/group1"
               menubarPath="NewTestCase.menu1/group1"
               enablesFor="1"
               enablesFor="1"
@@ -42,6 +44,16 @@
            id="org.etsi.mts.ttcn3.part9.newTestCase.commands.sampleCommand"
            id="org.etsi.mts.ttcn3.part9.newTestCase.commands.sampleCommand"
            name="Sample Command">
            name="Sample Command">
      </command>
      </command>
      <command
            name="New Positive Testcase"
            categoryId="org.eclipse.ui.category.navigate"
            id="org.etsi.mts.ttcn3.part9.newTestCase.commands.newPositiveTestcase">
      </command>
      <command
            name="New Negative Testcase"
            categoryId="org.eclipse.ui.category.navigate"
            id="org.etsi.mts.ttcn3.part9.newTestCase.commands.newNegativeTestcase">
      </command>
   </extension>
   </extension>
   <extension
   <extension
         point="org.eclipse.ui.handlers">
         point="org.eclipse.ui.handlers">
@@ -49,6 +61,14 @@
            class="org.etsi.mts.ttcn3.part9.newtestcase.handlers.CommandHandler"
            class="org.etsi.mts.ttcn3.part9.newtestcase.handlers.CommandHandler"
            commandId="org.etsi.mts.ttcn3.part9.newTestCase.commands.sampleCommand">
            commandId="org.etsi.mts.ttcn3.part9.newTestCase.commands.sampleCommand">
      </handler>
      </handler>
      <handler
            class="org.etsi.mts.ttcn3.part9.newtestcase.handlers.NewPositiveTestCaseHandler"
            commandId="org.etsi.mts.ttcn3.part9.newTestCase.commands.newPositiveTestcase">
      </handler>
      <handler
            class="org.etsi.mts.ttcn3.part9.newtestcase.handlers.NewNegativeTestCaseHandler"
            commandId="org.etsi.mts.ttcn3.part9.newTestCase.commands.newNegativeTestcase">
      </handler>
   </extension>
   </extension>
   <extension
   <extension
         point="org.eclipse.ui.bindings">
         point="org.eclipse.ui.bindings">
@@ -58,6 +78,14 @@
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
            sequence="M1+6">
            sequence="M1+6">
      </key>
      </key>
      <key
            sequence="M1+O"
            commandId="org.etsi.mts.ttcn3.part9.newTestCase.commands.newPositiveTestcase"
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
      <key
            sequence="M1+L"
            commandId="org.etsi.mts.ttcn3.part9.newTestCase.commands.newNegativeTestcase"
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
   </extension>
   </extension>
   <extension
   <extension
         point="org.eclipse.ui.menus">
         point="org.eclipse.ui.menus">
+24 −0
Original line number Original line Diff line number Diff line
package org.etsi.mts.ttcn3.part9.newtestcase.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.etsi.mts.ttcn3.part9.popup.actions.NewNegativeTestCase;
import org.etsi.mts.ttcn3.part9.popup.actions.NewTestCase;

/**
 * Our sample handler extends AbstractHandler, an IHandler base class.
 * @see org.eclipse.core.commands.IHandler
 * @see org.eclipse.core.commands.AbstractHandler
 */
public class NewNegativeTestCaseHandler extends AbstractHandler {
	/**
	 * the command has been executed, so extract extract the needed information
	 * from the application context.
	 */
	public Object execute(ExecutionEvent event) throws ExecutionException {
	  NewTestCase tc = new NewNegativeTestCase();
	  tc.runAsCommand();
    return null;
	}
}
+24 −0
Original line number Original line Diff line number Diff line
package org.etsi.mts.ttcn3.part9.newtestcase.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.etsi.mts.ttcn3.part9.popup.actions.NewPositiveTestCase;
import org.etsi.mts.ttcn3.part9.popup.actions.NewTestCase;

/**
 * Our sample handler extends AbstractHandler, an IHandler base class.
 * @see org.eclipse.core.commands.IHandler
 * @see org.eclipse.core.commands.AbstractHandler
 */
public class NewPositiveTestCaseHandler extends AbstractHandler {
	/**
	 * the command has been executed, so extract extract the needed information
	 * from the application context.
	 */
	public Object execute(ExecutionEvent event) throws ExecutionException {
	  NewTestCase tc = new NewPositiveTestCase();
    tc.runAsCommand();
    return null;
	}
}
+19 −1
Original line number Original line Diff line number Diff line
@@ -14,8 +14,11 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;


public class NewTestCase implements IObjectActionDelegate {
public class NewTestCase implements IObjectActionDelegate {


@@ -68,10 +71,25 @@ public class NewTestCase implements IObjectActionDelegate {
		shell = targetPart.getSite().getShell();
		shell = targetPart.getSite().getShell();
	}
	}


  public void run(IAction action) {
    createTestCase();
  }
  
  //this has to be called if this is executed as command because only as action the selection and
  //the shell are updated automatically
  public void runAsCommand() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null) {
      shell = window.getShell();
      selection = window.getSelectionService().getSelection();
    }
    createTestCase();
  }
  
	/**
	/**
	 * @see IActionDelegate#run(IAction)
	 * @see IActionDelegate#run(IAction)
	 */
	 */
	public void run(IAction action) {
	private void createTestCase() {
        if (selection == null) {
        if (selection == null) {
        	MessageDialog.openError(shell, "New test case", "Unsupported explorer view or no selection");
        	MessageDialog.openError(shell, "New test case", "Unsupported explorer view or no selection");
        	return;
        	return;