@Test public void noAttributes() { propertyAction.begin(ec, null, atts); assertEquals(1, context.getStatusManager().getCount()); assertTrue(checkError()); StatusPrinter.print(context); }
@Before public void setUp() throws Exception { context = new ContextBase(); ec = new InterpretationContext(context, null); propertyAction = new PropertyAction(); propertyAction.setContext(context); }
@Test public void noName() { atts.setValue("value", "v1"); propertyAction.begin(ec, null, atts); assertEquals(1, context.getStatusManager().getCount()); assertTrue(checkError()); }
@Test public void nameValuePair() { atts.setValue("name", "v1"); atts.setValue("value", "work"); propertyAction.begin(ec, null, atts); assertEquals("work", ec.getProperty("v1")); }
@Test public void testLoadNotPossible() { atts.setValue("file", "toto"); propertyAction.begin(ec, null, atts); assertEquals(1, context.getStatusManager().getCount()); assertTrue(checkFileErrors()); }
@Test public void testLoadResource() { atts.setValue("resource", "asResource/joran/propertyActionTest.properties"); propertyAction.begin(ec, null, atts); assertEquals("tata", ec.getProperty("r1")); assertEquals("toto", ec.getProperty("r2")); }
@Test public void testFileNotLoaded() { atts.setValue("file", "toto"); atts.setValue("value", "work"); propertyAction.begin(ec, null, atts); assertEquals(1, context.getStatusManager().getCount()); assertTrue(checkError()); }
@Test public void nameValuePairWithPrerequisiteSubsitution() { context.putProperty("w", "wor"); atts.setValue("name", "v1"); atts.setValue("value", "${w}k"); propertyAction.begin(ec, null, atts); assertEquals("work", ec.getProperty("v1")); }
@Test public void testLoadResourceWithPrerequisiteSubsitution() { context.putProperty("STEM", "asResource/joran"); atts.setValue("resource", "${STEM}/propertyActionTest.properties"); propertyAction.begin(ec, null, atts); assertEquals("tata", ec.getProperty("r1")); assertEquals("toto", ec.getProperty("r2")); }
@Test public void testLoadFile() { atts.setValue( "file", CoreTestConstants.TEST_SRC_PREFIX + "input/joran/propertyActionTest.properties"); propertyAction.begin(ec, null, atts); assertEquals("tata", ec.getProperty("v1")); assertEquals("toto", ec.getProperty("v2")); }
@Test public void testLoadFileWithPrerequisiteSubsitution() { context.putProperty("STEM", CoreTestConstants.TEST_SRC_PREFIX + "input/joran"); atts.setValue("file", "${STEM}/propertyActionTest.properties"); propertyAction.begin(ec, null, atts); assertEquals("tata", ec.getProperty("v1")); assertEquals("toto", ec.getProperty("v2")); }
@Override public Action[] getActions(boolean context) { if (actions == null) { List<Action> actions = new ArrayList<Action>(20); RADComponent topComp = component.getFormModel().getTopRADComponent(); if (component.isReadOnly()) { if (component == topComp) { actions.add(SystemAction.get(TestAction.class)); actions.add(null); } Event[] events = component.getKnownEvents(); for (int i = 0; i < events.length; i++) { if (events[i].hasEventHandlers()) { actions.add(SystemAction.get(EventsAction.class)); actions.add(null); break; } } actions.add(SystemAction.get(CopyAction.class)); } else { if (InPlaceEditLayer.supportsEditingFor(component.getBeanClass(), false)) { actions.add(SystemAction.get(InPlaceEditAction.class)); } if (javax.swing.JTable.class.isAssignableFrom(component.getBeanClass())) { actions.add(SystemAction.get(CustomizeTableAction.class)); } if (component != topComp) { actions.add(SystemAction.get(ChangeVariableNameAction.class)); } else { actions.add(SystemAction.get(TestAction.class)); } if (FormEditor.getBindingSupport(component.getFormModel()) != null) { // zxb:删除掉绑定菜单项。 // actions.add(SystemAction.get(BindAction.class)); } actions.add(SystemAction.get(EventsAction.class)); actions.add(null); java.util.List actionProps = component.getActionProperties(); Iterator iter = actionProps.iterator(); while (iter.hasNext()) { final RADProperty prop = (RADProperty) iter.next(); Action action = PropertyAction.createIfEditable(prop); if (action != null) { actions.add(action); } } addSeparator(actions); if (component instanceof ComponentContainer) { addContainerActions(actions); addLayoutActions(actions); } else { addLayoutActions(actions); addContainerActions(actions); } if (component != topComp) { actions.add(SystemAction.get(MoveUpAction.class)); actions.add(SystemAction.get(MoveDownAction.class)); } if (component instanceof ComponentContainer) { actions.add(SystemAction.get(ReorderAction.class)); } addSeparator(actions); if (component != topComp) { actions.add(SystemAction.get(CutAction.class)); } actions.add(SystemAction.get(CopyAction.class)); if (component instanceof ComponentContainer) { actions.add(SystemAction.get(PasteAction.class)); } if (component != topComp) { actions.add(SystemAction.get(DuplicateAction.class)); actions.add(SystemAction.get(DeleteAction.class)); } actions.add(null); // zxb:删除掉自定义代码菜单项。 // actions.add(SystemAction.get(CustomCodeAction.class)); } actions.add(null); javax.swing.Action[] superActions = super.getActions(context); for (int i = 0; i < superActions.length; i++) actions.add(superActions[i]); this.actions = new Action[actions.size()]; actions.toArray(this.actions); } return actions; }