/** * Creates a {@code ProjectEditor} instance. * * @param projectRootNode the project root node */ public ProjectEditor(ProjectRootNode projectRootNode) { this.projectRootNode = projectRootNode; projectId = projectRootNode.getProjectId(); project = Ode.getInstance().getProjectManager().getProject(projectId); openFileEditors = Maps.newHashMap(); fileIds = new ArrayList<String>(); deckPanel = new DeckPanel(); VerticalPanel panel = new VerticalPanel(); panel.add(deckPanel); deckPanel.setSize("100%", "100%"); panel.setSize("100%", "100%"); initWidget(panel); // Note: I'm not sure that the setSize call below does anything useful. setSize("100%", "100%"); }
private void init(RootPanel root) { _deckPanel = new DeckPanel(); _tree = createTree(); _tree.addSelectionHandler(new SelectionHandler<TreeItem>() { public void onSelection(SelectionEvent<TreeItem> event) { TreeItem item = event.getSelectedItem(); if(item.getUserObject() != null) { ContentWidget widget = (ContentWidget)item.getUserObject(); widget.init(); int i = _deckPanel.getWidgetIndex(widget); if(i != -1) _deckPanel.showWidget(i); } } }); FlexTable table = new FlexTable(); table.setWidget(0, 0, _tree); table.setWidget(0, 1, _deckPanel); table.getRowFormatter().setVerticalAlign(0, HasVerticalAlignment.ALIGN_TOP); root.add(table); }
private void makeParentVisible(Widget widget) { if (widget == null) { return; } Widget parent = widget.getParent(); if (parent == null) { return; } makeParentVisible(parent); if (parent instanceof DeckPanel) { DeckPanel deckPanel = (DeckPanel) parent; int widgetIndex = deckPanel.getWidgetIndex(widget); deckPanel.showWidget(widgetIndex); TabPanel tabPanel = (TabPanel) deckPanel.getParent().getParent(); tabPanel.selectTab(widgetIndex); } }
public NavigationLink(String text, long projectId, String targetHistoryToken, Function<Void, TaPagePresenter> createPresenterFunction) { this.targetHistoryToken = targetHistoryToken; this.projectId = projectId; this.createPresenterFunction = createPresenterFunction; panel = new DeckPanel(); SimplePanel fakeLinkPanel = new SimplePanel(); fakeLink = new Label(text); fakeLinkPanel.add(fakeLink); realLink = new Hyperlink(text, getHyperlinkTarget()); panel.add(realLink); panel.add(fakeLinkPanel); enable(); super.initWidget(panel); }
@Test public void testPanels() throws Exception { invokeAllAccessibleMethods(new AbsolutePanel() {}); invokeAllAccessibleMethods(new CellPanel() {}); invokeAllAccessibleMethods(new ComplexPanel() {}); invokeAllAccessibleMethods(new DeckLayoutPanel() {}); invokeAllAccessibleMethods(new DeckPanel() {}); invokeAllAccessibleMethods(new DecoratorPanel() {}); invokeAllAccessibleMethods(new DockLayoutPanel(Unit.PX) {}); invokeAllAccessibleMethods(new DockPanel() {}); invokeAllAccessibleMethods(new FlowPanel() {}); invokeAllAccessibleMethods(new FocusPanel() {}); invokeAllAccessibleMethods(new HorizontalPanel() {}); invokeAllAccessibleMethods(new HTMLPanel("") {}); invokeAllAccessibleMethods(new LayoutPanel() {}); invokeAllAccessibleMethods(new PopupPanel() {}); invokeAllAccessibleMethods(new RenderablePanel("") {}); invokeAllAccessibleMethods(new ResizeLayoutPanel() {}); invokeAllAccessibleMethods(new SimpleLayoutPanel() {}); invokeAllAccessibleMethods(new SimplePanel() {}); invokeAllAccessibleMethods(new SplitLayoutPanel() {}); invokeAllAccessibleMethods(new StackPanel() {}); invokeAllAccessibleMethods(new VerticalPanel() {}); }
private void handleVisible(UIObject uiObject, BuiltInComponentGVO builtInComponentGVO, String setPropertyValue) { boolean value = Boolean.valueOf(setPropertyValue).booleanValue(); if(uiObject instanceof HasVisible) { ((HasVisible)uiObject).processVisible(value); } else if (uiObject instanceof HasDataGridMethods) { HasDataGridMethods hasDataGridMethods = (HasDataGridMethods)uiObject; boolean resolved = false; String uuid = builtInComponentGVO.getComponentIdUUID(); if (uuid != null) { boolean containsColumn = uuid.contains("."); if (containsColumn) { String columnId = uuid.replaceFirst(".+\\.", "").replaceFirst("\\|.+", ""); hasDataGridMethods.setColumnVisible(columnId, value); resolved = true; } } if (!resolved) { uiObject.setVisible(value); hasDataGridMethods.redraw(); } } else { uiObject.setVisible(value); if (uiObject instanceof Panel) { Panel p = (Panel) uiObject; Widget parent = p.getParent(); if (parent != null && parent instanceof DeckPanel) { DeckPanel deckPanel = (DeckPanel) parent; int widgetIndex = deckPanel.getWidgetIndex(p); if (widgetIndex != -1) { if (deckPanel.getParent() != null && deckPanel.getParent().getParent() != null && deckPanel.getParent().getParent() instanceof TabPanel) { TabPanel tabs = ((TabPanel) (deckPanel.getParent().getParent())); TabPanelRenderer.setTabVisibility(tabs, widgetIndex, value, uiObject); } } } } } }
private void makeParentsVisible(Widget w) { if (w.getParent() != null) { Widget parent = w.getParent(); makeParentsVisible(parent); if (parent instanceof DeckPanel) { DeckPanel dp = (DeckPanel) parent; dp.showWidget(dp.getWidgetIndex(w)); ((TabPanel) dp.getParent().getParent()).selectTab(dp.getWidgetIndex(w)); } } }
private static void processAttributes(UIObject uiObject, String valueToSet, List<String> attributes, SetValueGVO setValue,DataContainerGVO valueDTC) { if (uiObject != null && attributes != null) { Iterator<String> itr = attributes.iterator(); while (itr.hasNext()) { String attribute = itr.next(); if ("tooltip".equals(attribute)) { if (uiObject instanceof TitledComponent) { TitledComponent titledComponent = (TitledComponent) uiObject; titledComponent.getTitleComponent().setTitle(valueToSet); } else { uiObject.setTitle(valueToSet); } } else if ("title".equals(attribute)) { if (uiObject instanceof CaptionLayoutPanel) { CaptionLayoutPanel titledPanel = (CaptionLayoutPanel) uiObject; titledPanel.setTitle(valueToSet); } else if (uiObject instanceof Panel) { Panel p = (Panel) uiObject; Widget parent = p.getParent(); if (parent != null && parent instanceof DeckPanel) { DeckPanel deckPanel = (DeckPanel) parent; int widgetIndex = deckPanel.getWidgetIndex(p); if (widgetIndex != -1) { deckPanel.showWidget(widgetIndex); } } } } else if ("prompt".equals(attribute)) { if (uiObject instanceof HasPrompt) { HasPrompt hasPrompt = (HasPrompt) uiObject; hasPrompt.setPrompt(valueToSet); } else if (uiObject instanceof CheckBox) { ((CheckBox) uiObject).setText(valueToSet); } } else if ("value".equals(attribute)) { processValue(uiObject, valueToSet, setValue,valueDTC); } } } }
/** * Returns a collection of classes whose non-abstract methods should always be replaced with * no-ops. By default, this list includes {@link Composite}, {@link DOM} {@link UIObject}, * {@link Widget}, {@link Image}, and most subclasses of {@link Panel}. It will also include any * classes specified via the {@link WithClassesToStub} annotation on the test class. This makes * it much safer to test code that uses or extends these types. * <p> * This list can be customized via {@link WithClassesToStub} or by defining a new test runner * extending {@link GwtMockitoTestRunner} and overriding this method. This allows users to * explicitly stub out particular classes that are causing problems in tests. If you override this * method, you will probably want to retain the classes that are stubbed here by doing something * like this: * * <pre> * @Override * protected Collection<Class<?>> getClassesToStub() { * Collection<Class<?>> classes = super.getClassesToStub(); * classes.add(MyBaseWidget.class); * return classes; * } * </pre> * * @return a collection of classes whose methods should be stubbed with no-ops while running tests */ protected Collection<Class<?>> getClassesToStub() { Collection<Class<?>> classes = new LinkedList<Class<?>>(); classes.add(Composite.class); classes.add(DOM.class); classes.add(UIObject.class); classes.add(Widget.class); classes.add(DataGrid.class); classes.add(HTMLTable.class); classes.add(Image.class); classes.add(AbsolutePanel.class); classes.add(CellList.class); classes.add(CellPanel.class); classes.add(CellTable.class); classes.add(ComplexPanel.class); classes.add(DeckLayoutPanel.class); classes.add(DeckPanel.class); classes.add(DecoratorPanel.class); classes.add(DockLayoutPanel.class); classes.add(DockPanel.class); classes.add(FlowPanel.class); classes.add(FocusPanel.class); classes.add(HorizontalPanel.class); classes.add(HTMLPanel.class); classes.add(LayoutPanel.class); classes.add(Panel.class); classes.add(PopupPanel.class); classes.add(RenderablePanel.class); classes.add(ResizeLayoutPanel.class); classes.add(SimpleLayoutPanel.class); classes.add(SimplePanel.class); classes.add(SplitLayoutPanel.class); classes.add(StackPanel.class); classes.add(VerticalPanel.class); classes.add(ValueListBox.class); WithClassesToStub annotation = unitTestClass.getAnnotation(WithClassesToStub.class); if (annotation != null) { classes.addAll(Arrays.asList(annotation.value())); } return classes; }
/** * This method returns tha panel that displays all the screen in the * application * * @return DeckPanel the panel */ protected DeckPanel getMainPanel() { return rightPanel; }