public void testModelOnSession() throws Exception { inter.setScope("session"); inter.setName("king"); User user = new User(); user.setName("King George"); Map session = new HashMap(); ActionContext.getContext().setSession(session); ActionContext.getContext().getSession().put("king", user); ScopedModelDriven action = new MyUserScopedModelDrivenAction(); MockActionInvocation mai = new MockActionInvocation(); MockActionProxy map = new MockActionProxy(); ActionConfig ac = new ActionConfig.Builder("", "", "").build(); map.setConfig(ac); mai.setAction(action); mai.setProxy(map); inter.intercept(mai); inter.destroy(); assertNotNull(action.getModel()); assertNotNull(action.getScopeKey()); assertEquals("king", action.getScopeKey()); Object model = ActionContext.getContext().getSession().get(action.getScopeKey()); assertNotNull(model); assertTrue("Model should be an User object", model instanceof User); assertEquals("King George", ((User) model).getName()); }
public ActionContext unmarshall(JsonUnmarshallerContext context) throws Exception { ActionContext actionContext = new ActionContext(); int originalDepth = context.getCurrentDepth(); String currentParentElement = context.getCurrentParentElement(); int targetDepth = originalDepth + 1; JsonToken token = context.getCurrentToken(); if (token == null) token = context.nextToken(); if (token == VALUE_NULL) return null; while (true) { if (token == null) break; if (token == FIELD_NAME || token == START_OBJECT) { if (context.testExpression("name", targetDepth)) { context.nextToken(); actionContext.setName(context.getUnmarshaller(String.class).unmarshall(context)); } } else if (token == END_ARRAY || token == END_OBJECT) { if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) { if (context.getCurrentDepth() <= originalDepth) break; } } token = context.nextToken(); } return actionContext; }
@Override protected void setUp() throws Exception { super.setUp(); converter = container.getInstance(XWorkConverter.class); ac = ActionContext.getContext(); ac.setLocale(Locale.US); context = ac.getContextMap(); }
public String execute() throws Exception { // 创建ActionContext实例 ActionContext ctx = ActionContext.getContext(); // 获取HttpSession中的user属性 String mgrName = (String) ctx.getSession().get(WebConstant.USER); // 获取需要被当前经理处理的全部申请 setApps(mgr.getAppsByMgr(mgrName)); return SUCCESS; }
// -- Action --// public void render(ActionContext ac, boolean nested) throws DspException, IOException { if (!isEffective()) return; if (nested) throw new DspException( MWeb.DSP_NESTED_ACTION_NOT_ALLOWED, new Object[] {this, new Integer(ac.getLineNumber())}); if (_page == null) throw new DspException( MWeb.DSP_ATTRIBUTE_REQUIRED, new Object[] {this, "page", new Integer(ac.getLineNumber())}); ac.include(_page, null); }
public String execute() throws Exception { // 创建ActionContext实例 ActionContext ctx = ActionContext.getContext(); // 获取HttpSession中的user属性 String mgrName = (String) ctx.getSession().get(WebConstant.USER); // 调用业务逻辑方法取得当前员工的全部发薪列表 List<SalaryBean> result = mgr.getSalaryByMgr(mgrName); System.out.println("--------------" + result); setSals(result); return SUCCESS; }
public void setDebug(boolean pDebug, ActionContext pAc) { if (setDebug(pDebug)) { pAc.getActionResponse().addLineToMessage("debug updated with value '" + pDebug + "'"); } else { pAc.getActionResponse() .addLineToMessage( "debug could not be updated with value '" + pDebug + "' and remains set to " + Boolean.toString(this.isDebug())); } }
/** * Invokes ac.renderFragment() and trim the output if trim is true. * * @param out the return value of {@link #getFragmentOut}. */ /*package*/ static void renderFragment(ActionContext ac, StringWriter out, boolean trim) throws DspException, IOException { if (trim) { final StringBuffer buf = (out != null ? out : (StringWriter) ac.getOut()).getBuffer(); // ac.getOut must be StringWriter if out is null and trim final int index = buf.length(); ac.renderFragment(out); Strings.trim(buf, index); } else { ac.renderFragment(out); } }
public String stack() { ValueStack stack = ActionContext.getContext().getValueStack(); // DefaultTextProvider, NestedActionTest pushed on by the test, and the NestedAction Assert.assertEquals(3, stack.size()); Assert.assertNotNull(stack.findValue(ActionNestingTest.KEY)); Assert.assertEquals( ActionContext.getContext().getValueStack().findValue(ActionNestingTest.KEY), ActionNestingTest.VALUE); Assert.assertEquals( ActionNestingTest.NESTED_VALUE, stack.findValue(ActionNestingTest.NESTED_KEY)); return SUCCESS; }
// 拦截Action处理的拦截方法 public String intercept(ActionInvocation invocation) throws Exception { // 取得请求相关的ActionContext实例 ActionContext ctx = invocation.getInvocationContext(); Map session = ctx.getSession(); // 取出名为user的Session属性 String user = (String) session.get("user"); // 如果没有登录,或者登录所用的用户名不是scott,都返回重新登录 if (user != null && user.equals("crazyit.org")) { return invocation.invoke(); } // 没有登录,将服务器提示设置成一个HttpServletRequest属性 ctx.put("tip", "您还没有登录,请输入crazyit.org,leegang登录系统"); // 直接返回login的逻辑视图 return Action.LOGIN; }
// -- Action --// public void render(ActionContext ac, boolean nested) throws DspException, IOException { if (nested && isEffective()) { final StringWriter out = getFragmentOut(ac, _trim); renderFragment(ac, out, _trim); if (out != null) ac.getOut().write(out.toString()); } }
public void testWildCardEvaluation() throws Exception { ActionContext.setContext(null); ActionProxy proxy = actionProxyFactory.createActionProxy(null, "WildCard", null); assertEquals("success", proxy.execute()); assertEquals(VoidResult.class, proxy.getInvocation().getResult().getClass()); ActionContext.setContext(null); proxy = actionProxyFactory.createActionProxy(null, "WildCardInput", null); assertEquals("input", proxy.execute()); assertEquals(MockResult.class, proxy.getInvocation().getResult().getClass()); ActionContext.setContext(null); proxy = actionProxyFactory.createActionProxy(null, "WildCardError", null); assertEquals("error", proxy.execute()); assertEquals(MockResult.class, proxy.getInvocation().getResult().getClass()); }
public void testGenericPropertiesFromGetter() { GenericsBean gb = new GenericsBean(); ValueStack stack = ac.getValueStack(); stack.push(gb); assertEquals(1, gb.getGetterList().size()); assertEquals("42.42", stack.findValue("getterList.get(0).toString()")); assertEquals(new Double(42.42), stack.findValue("getterList.get(0)")); assertEquals(new Double(42.42), gb.getGetterList().get(0)); }
public String noStack() { ValueStack stack = ActionContext.getContext().getValueStack(); // Action + DefaultTextProvider on the stack Assert.assertEquals(2, stack.size()); Assert.assertNull(stack.findValue(ActionNestingTest.KEY)); Assert.assertEquals( ActionNestingTest.NESTED_VALUE, stack.findValue(ActionNestingTest.NESTED_KEY)); return SUCCESS; }
public void testGenericProperties() { GenericsBean gb = new GenericsBean(); ValueStack stack = ac.getValueStack(); stack.push(gb); String[] value = new String[] {"123.12", "123.45"}; stack.setValue("doubles", value); assertEquals(2, gb.getDoubles().size()); assertEquals(Double.class, gb.getDoubles().get(0).getClass()); assertEquals(new Double(123.12), gb.getDoubles().get(0)); assertEquals(new Double(123.45), gb.getDoubles().get(1)); }
public void useDefaultCeServerIfNeeded( String pDefCeRootUrl, String pDefCeCurrentUrl, ActionContext pAc) { // Only use the specified default CE Server if there is not one specified already if (this.defaultCeRootUrl == null) { this.setDefaultCeRootUrl(pDefCeRootUrl); if (pAc.getCeConfig().isDebug()) { reportDebug( "Using this (default) root url for REST requests: " + this.defaultCeRootUrl, pAc); } } // Only use the specified default CE Server if there is not one specified already if (this.defaultCeCurrentUrl == null) { this.setDefaultCeCurrentUrl(pDefCeCurrentUrl); if (pAc.getCeConfig().isDebug()) { reportDebug( "Using this (default) current url for REST requests: " + this.defaultCeCurrentUrl, pAc); } } }
public void testFindConversionErrorMessage() { ModelDrivenAnnotationAction action = new ModelDrivenAnnotationAction(); ValueStack stack = ActionContext.getContext().getValueStack(); stack.push(action); stack.push(action.getModel()); String message = XWorkConverter.getConversionErrorMessage("birth", stack); assertNotNull(message); assertEquals("Invalid date for birth.", message); message = XWorkConverter.getConversionErrorMessage("foo", stack); assertNotNull(message); assertEquals("Invalid field value for field \"foo\".", message); }
// TODO: Fixme... This test does not work with GenericsObjectDeterminer! public void testStringToCollectionConversion() { ValueStack stack = ActionContext.getContext().getValueStack(); Map<String, Object> stackContext = stack.getContext(); stackContext.put(ReflectionContextState.CREATE_NULL_OBJECTS, Boolean.TRUE); stackContext.put(ReflectionContextState.DENY_METHOD_EXECUTION, Boolean.TRUE); stackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE); AnnotationUser user = new AnnotationUser(); stack.push(user); stack.setValue("list", "asdf"); assertNotNull(user.getList()); assertEquals(1, user.getList().size()); assertEquals(String.class, user.getList().get(0).getClass()); assertEquals("asdf", user.getList().get(0)); }
public void testGenericPropertiesFromSetter() { GenericsBean gb = new GenericsBean(); ValueStack stack = ac.getValueStack(); stack.push(gb); stack.setValue("genericMap[123.12]", "66"); stack.setValue("genericMap[456.12]", "42"); assertEquals(2, gb.getGenericMap().size()); assertEquals("66", stack.findValue("genericMap.get(123.12).toString()")); assertEquals("42", stack.findValue("genericMap.get(456.12).toString()")); assertEquals(66, stack.findValue("genericMap.get(123.12)")); assertEquals(42, stack.findValue("genericMap.get(456.12)")); assertEquals(true, stack.findValue("genericMap.containsValue(66)")); assertEquals(true, stack.findValue("genericMap.containsValue(42)")); assertEquals(true, stack.findValue("genericMap.containsKey(123.12)")); assertEquals(true, stack.findValue("genericMap.containsKey(456.12)")); }
public void testFindConversionMappingForInterface() { ModelDrivenAnnotationAction2 action = new ModelDrivenAnnotationAction2(); ValueStack stack = ActionContext.getContext().getValueStack(); stack.push(action); stack.push(action.getModel()); Map<String, Object> ognlStackContext = stack.getContext(); ognlStackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE); String value = "asdf:123"; Object o = converter.convertValue( ognlStackContext, action.getModel(), null, "barObj", value, Bar.class); assertNotNull(o); assertTrue("class is: " + o.getClass(), o instanceof Bar); Bar b = (Bar) o; assertEquals(value, b.getTitle() + ":" + b.getSomethingElse()); }
public void testScopedModelDrivenAction() throws Exception { inter.setScope("request"); ScopedModelDriven action = new MyUserScopedModelDrivenAction(); MockActionInvocation mai = new MockActionInvocation(); MockActionProxy map = new MockActionProxy(); ActionConfig ac = new ActionConfig.Builder("", "", "").build(); map.setConfig(ac); mai.setAction(action); mai.setProxy(map); inter.intercept(mai); inter.destroy(); assertNotNull(action.getModel()); assertNotNull(action.getScopeKey()); assertEquals("com.opensymphony.xwork2.test.User", action.getScopeKey()); Object model = ActionContext.getContext().get(action.getScopeKey()); assertNotNull(model); assertTrue("Model should be an User object", model instanceof User); }
public void testFieldErrorMessageAddedWhenConversionFailsOnModelDriven() { ModelDrivenAnnotationAction action = new ModelDrivenAnnotationAction(); ValueStack stack = ActionContext.getContext().getValueStack(); stack.push(action); stack.push(action.getModel()); Map<String, Object> ognlStackContext = stack.getContext(); ognlStackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE); String[] value = new String[] {"invalid date"}; assertEquals( "Conversion should have failed.", OgnlRuntime.NoConversionPossible, converter.convertValue(ognlStackContext, action, null, "birth", value, Date.class)); stack.pop(); stack.pop(); Map conversionErrors = (Map) ognlStackContext.get(ActionContext.CONVERSION_ERRORS); assertNotNull(conversionErrors); assertEquals(1, conversionErrors.size()); assertNotNull(conversionErrors.get("birth")); assertEquals(value, conversionErrors.get("birth")); }
// FIXME: Implement nested Generics such as: List of Generics List, Map of Generic keys/values, // etc... public void no_testGenericPropertiesWithNestedGenerics() { GenericsBean gb = new GenericsBean(); ValueStack stack = ac.getValueStack(); stack.push(gb); stack.setValue("extendedMap[123.12]", new String[] {"1", "2", "3", "4"}); stack.setValue("extendedMap[456.12]", new String[] {"5", "6", "7", "8", "9"}); System.out.println("gb.getExtendedMap(): " + gb.getExtendedMap()); assertEquals(2, gb.getExtendedMap().size()); System.out.println(stack.findValue("extendedMap")); assertEquals(4, stack.findValue("extendedMap.get(123.12).size")); assertEquals(5, stack.findValue("extendedMap.get(456.12).size")); assertEquals("1", stack.findValue("extendedMap.get(123.12).get(0)")); assertEquals("5", stack.findValue("extendedMap.get(456.12).get(0)")); assertEquals(Integer.class, stack.findValue("extendedMap.get(123.12).get(0).class")); assertEquals(Integer.class, stack.findValue("extendedMap.get(456.12).get(0).class")); assertEquals(List.class, stack.findValue("extendedMap.get(123.12).class")); assertEquals(List.class, stack.findValue("extendedMap.get(456.12).class")); }
public void testFieldErrorMessageAddedForComplexProperty() { SimpleAnnotationAction action = new SimpleAnnotationAction(); action.setBean(new AnnotatedTestBean()); ValueStack stack = ActionContext.getContext().getValueStack(); stack.push(action); Map<String, Object> ognlStackContext = stack.getContext(); ognlStackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE); ognlStackContext.put(XWorkConverter.CONVERSION_PROPERTY_FULLNAME, "bean.birth"); String[] value = new String[] {"invalid date"}; assertEquals( "Conversion should have failed.", OgnlRuntime.NoConversionPossible, converter.convertValue( ognlStackContext, action.getBean(), null, "birth", value, Date.class)); stack.pop(); Map conversionErrors = (Map) stack.getContext().get(ActionContext.CONVERSION_ERRORS); assertNotNull(conversionErrors); assertTrue(conversionErrors.size() == 1); assertEquals(value, conversionErrors.get("bean.birth")); }
public void testResolveModel() throws Exception { ActionContext ctx = ActionContext.getContext(); ctx.setSession(new HashMap()); ObjectFactory factory = ObjectFactory.getObjectFactory(); Object obj = inter.resolveModel(factory, ctx, "java.lang.String", "request", "foo"); assertNotNull(obj); assertTrue(obj instanceof String); assertTrue(obj == ctx.get("foo")); obj = inter.resolveModel(factory, ctx, "java.lang.String", "session", "foo"); assertNotNull(obj); assertTrue(obj instanceof String); assertTrue(obj == ctx.getSession().get("foo")); obj = inter.resolveModel(factory, ctx, "java.lang.String", "session", "foo"); assertNotNull(obj); assertTrue(obj instanceof String); assertTrue(obj == ctx.getSession().get("foo")); }
public String intercept(ActionInvocation actionInvocation) throws Exception { ServletContext context = ServletActionContext.getServletContext(); ActionContext act = actionInvocation.getInvocationContext(); Map<String, Object> application = act.getApplication(); String gingkgoHome = System.getProperty("gingkgo.home"); if (null == gingkgoHome) System.setProperty("gingkgo.home", context.getRealPath("")); // 设置系统模块 if (null == application.get(EbizCommon.EBIZ_APP_MODULES)) { List<Module> modules = moduleService.roGetModuleList(true); Set<String> ms = new HashSet<String>(0); for (Module module : modules) { ms.add(module.getModuleName()); } application.put(EbizCommon.EBIZ_APP_MODULES, ms); } // 设置产品组成 if (null == application.get(EbizCommon.EBIZ_APP_PACKAGE_ITEM)) { List<ProductItem> items = productService.getProductItems(ProductType.Package); application.put(EbizCommon.EBIZ_APP_PACKAGE_ITEM, items); } // 主菜单 if (null == application.get(EbizCommon.EBIZ_APP_MAIN_MENU)) { List<MenuItem> items = new ArrayList<MenuItem>(); items.add(new MenuItem("Desktop", "桌面", "", "ROLE_USER")); items.add(new MenuItem("Products", "产品资源", "", "ROLE_PRODUCT")); items.add(new MenuItem("Order", "订单管理", "", "ROLE_SALES")); items.add(new MenuItem("Operate", "计调操作", "", "ROLE_OPERATOR")); items.add(new MenuItem("Express", "配送管理", "", "ROLE_TRANSPORT")); items.add(new MenuItem("CRM", "客户管理", "", "ROLE_AGENT_MANAGER")); items.add(new MenuItem("Finance", "财务结算", "", "ROLE_FINANCE")); items.add(new MenuItem("Stat", "统计分析", "", "ROLE_SUPERUSER")); items.add(new MenuItem("System", "系统设置", "", "ROLE_SUPERUSER")); items.add(new MenuItem("Config", "设置", "", "ROLE_SUPERUSER")); items.add(new MenuItem("Company", "公司设置", "", "ROLE_SUPERUSER")); for (MenuItem menuItem : items) { List<Shortcut> cuts = shortcutManager.getShortcutByModule(menuItem.getItemName()); for (Shortcut shortcut : cuts) { menuItem .getChild() .add( new MenuItem( shortcut.getModuleName(), shortcut.getDisplayName(), shortcut.getRelativePath(), shortcut.getRoles())); } } application.put(EbizCommon.EBIZ_APP_MAIN_MENU, items); } // 设置产品组成 if (null == application.get(EbizCommon.EBIZ_SYS_CONFIG)) { List<SysConfig> items = configService.getAllConfig(); for (SysConfig config : items) { application.put(config.getName(), config.getValue()); } application.put(EbizCommon.EBIZ_SYS_CONFIG, "OK"); } // XML设置参数 if (null == application.get(EbizCommon.EBIZ_RES_CONFIG)) { try { application.put( EbizCommon.EBIZ_RES_CONFIG, XMLUtility.getInstance(context.getRealPath(XML_PATH))); } catch (ParserConfigurationException pce) { logger.error("", pce); } catch (IOException ioe) { logger.error("", ioe); } catch (SAXException saxe) { logger.error("", saxe); } catch (Exception e) { logger.error("", e); } } ActionContext.getContext().getValueStack().push(this); return actionInvocation.invoke(); }
protected void setPropertyByName(ActionContext pAc, String pPropName, String pPropVal) { if (pPropName != null) { if (pPropName.equals(PROP_DEBUG)) { setDebug(new Boolean(pPropVal).booleanValue(), pAc); } else if (pPropName.equals(PROP_LOGCETOFILE)) { this.logCeToFiles = new Boolean(pPropVal).booleanValue(); pAc.getActionResponse() .addLineToMessage( "logCeToFiles updated with value '" + pPropVal + "' to become " + Boolean.toString(this.logCeToFiles)); } else if (pPropName.equals(PROP_LOGQUERIES)) { this.logQueries = new Boolean(pPropVal).booleanValue(); pAc.getActionResponse() .addLineToMessage( "logQueries updated with value '" + pPropVal + "' to become " + Boolean.toString(this.logQueries)); } else if (pPropName.equals(PROP_GENFOLDERS)) { this.autogenerateFolders = new Boolean(pPropVal).booleanValue(); pAc.getActionResponse() .addLineToMessage( "autogenerateFolders updated with value '" + pPropVal + "' to become " + Boolean.toString(this.autogenerateFolders)); } else if (pPropName.equals(PROP_MAXSENS)) { this.maxSentences = new Integer(pPropVal).intValue(); pAc.getActionResponse() .addLineToMessage( "maxSentences updated with value '" + pPropVal + "' to become " + Integer.toString(this.maxSentences)); } else if (pPropName.equals(PROP_LOGJSON)) { this.logJsonToFiles = new Boolean(pPropVal).booleanValue(); pAc.getActionResponse() .addLineToMessage( "logJsonToFiles updated with value '" + pPropVal + "' to become " + Boolean.toString(this.logJsonToFiles)); } else if (pPropName.equals(PROP_CATCHERRS)) { this.catchAgentErrors = new Boolean(pPropVal).booleanValue(); pAc.getActionResponse() .addLineToMessage( "catchAgentErrors updated with value '" + pPropVal + "' to become " + Boolean.toString(this.catchAgentErrors)); } else if (pPropName.equals(PROP_UIDCLASSNAME)) { this.uidClassName = pPropVal; pAc.getActionResponse() .addLineToMessage( "uidClassName updated with value '" + pPropVal + "' to become " + this.uidClassName); } else if (pPropName.equals(PROP_UIDFILENAME)) { this.uidFilename = pPropVal; pAc.getActionResponse() .addLineToMessage( "uidFilename updated with value '" + pPropVal + "' to become " + this.uidFilename); } else if (pPropName.equals(PROP_UIDVALUES)) { this.uidValues = pPropVal; pAc.getActionResponse() .addLineToMessage( "uidValues updated with value '" + pPropVal + "' to become " + this.uidValues); } else if (pPropName.equals(PROP_UIDPREFIXES)) { this.uidAllowPrefixes = new Boolean(pPropVal).booleanValue(); pAc.getActionResponse() .addLineToMessage( "uidAllowPrefixes updated with value '" + pPropVal + "' to become " + Boolean.toString(this.uidAllowPrefixes)); } else if (pPropName.equals(PROP_UIDBATCH)) { this.uidBatchSize = new Integer(pPropVal).intValue(); pAc.getActionResponse() .addLineToMessage( "uidBatchSize updated with value '" + pPropVal + "' to become " + Long.toString(this.uidBatchSize)); } else if (pPropName.equals(PROP_CACHEPROPS)) { this.cacheInstanceProperties = new Boolean(pPropVal).booleanValue(); pAc.getActionResponse() .addLineToMessage( "cacheInstanceProperties updated with value '" + pPropVal + "' to become " + Boolean.toString(this.cacheInstanceProperties)); } else if (pPropName.equals(PROP_CACHECE)) { this.cacheCeText = new Boolean(pPropVal).booleanValue(); pAc.getActionResponse() .addLineToMessage( "cacheCeText updated with value '" + pPropVal + "' to become " + Boolean.toString(this.cacheCeText)); } else if (pPropName.equals(PROP_CASESEN)) { this.caseSensitive = new Boolean(pPropVal).booleanValue(); pAc.getActionResponse() .addLineToMessage( pPropName + " updated with value '" + pPropVal + "' to become " + Boolean.toString(this.caseSensitive)); } else if (pPropName.equals(PROP_DEFCESVR)) { this.defaultCeRootUrl = pPropVal; pAc.getActionResponse() .addLineToMessage( "defaultCeServer updated with value '" + pPropVal + "' to become " + this.defaultCeRootUrl); } else { reportError( "Cannot update property value (" + pPropVal + ") as the property name '" + pPropName + "' is unknown", pAc); } } else { reportError( "Cannot update property value (" + pPropVal + ") as no property name is specified", pAc); } }
@Override protected void processKeyEvent(KeyEvent evt) { if (evt.getID() == KeyEvent.KEY_PRESSED) { ActionContext ac = VFSBrowser.getActionContext(); int row = parentDirectories.getSelectedIndex(); switch (evt.getKeyCode()) { case KeyEvent.VK_DOWN: evt.consume(); if (row < parentDirectories.getSize().height - 1) parentDirectories.setSelectedIndex(++row); break; case KeyEvent.VK_LEFT: if ((evt.getModifiers() & InputEvent.ALT_MASK) > 0) { evt.consume(); browser.previousDirectory(); } else super.processEvent(evt); break; case KeyEvent.VK_RIGHT: if ((evt.getModifiers() & InputEvent.ALT_MASK) > 0) { evt.consume(); browser.nextDirectory(); } else super.processEvent(evt); break; case KeyEvent.VK_TAB: evt.consume(); if ((evt.getModifiers() & InputEvent.SHIFT_MASK) > 0) browser.focusOnDefaultComponent(); else table.requestFocus(); break; case KeyEvent.VK_UP: evt.consume(); if (row > 0) { parentDirectories.setSelectedIndex(--row); } break; case KeyEvent.VK_BACK_SPACE: evt.consume(); EditAction up = ac.getAction("vfs.browser.up"); ac.invokeAction(evt, up); break; case KeyEvent.VK_F5: evt.consume(); EditAction reload = ac.getAction("vfs.browser.reload"); ac.invokeAction(evt, reload); break; case KeyEvent.VK_ENTER: evt.consume(); if (row != -1) { // basically the same handling as in ParentMouseHandler#mouseReleased Object obj = parentDirectories.getModel().getElementAt(row); if (obj instanceof VFSFile) { VFSFile dirEntry = (VFSFile) obj; browser.setDirectory(dirEntry.getPath()); if (browser.getMode() == VFSBrowser.BROWSER) focusOnFileView(); } } break; /* These actions don't work because they look at the EntryTable for the current selected * item. We need actions that look at the parentDirectoryList item instead. * case KeyEvent.VK_DELETE: evt.consume(); ea = ac.getAction("vfs.browser.delete"); ac.invokeAction(evt, ea); break; case KeyEvent.CTRL_MASK | KeyEvent.VK_N: evt.consume(); ea = ac.getAction("vfs.browser.new-file"); ac.invokeAction(evt, ea); break; case KeyEvent.VK_INSERT: evt.consume(); ea = ac.getAction("vfs.browser.new-directory"); ac.invokeAction(evt, ea); break; */ } } else if (evt.getID() == KeyEvent.KEY_TYPED) { if (evt.isControlDown() || evt.isAltDown() || evt.isMetaDown()) { evt.consume(); return; } switch (evt.getKeyChar()) { case '~': evt.consume(); if (browser.getMode() == VFSBrowser.BROWSER) browser.setDirectory(System.getProperty("user.home")); break; case '/': evt.consume(); if (browser.getMode() == VFSBrowser.BROWSER) browser.rootDirectory(); break; case '-': evt.consume(); if (browser.getMode() == VFSBrowser.BROWSER) { browser.setDirectory(browser.getView().getBuffer().getDirectory()); } break; } } if (!evt.isConsumed()) super.processKeyEvent(evt); }
@Override protected void tearDown() throws Exception { ActionContext.setContext(null); }
public void testValueStackWithTypeParameter() { ValueStack stack = ActionContext.getContext().getValueStack(); stack.push(new Foo1()); Bar1 bar = (Bar1) stack.findValue("bar", Bar1.class); assertNotNull(bar); }