Differences
This shows you the differences between two versions of the page.
|
menus [2012/04/09 17:47] dragan.milicev |
menus [2012/07/09 10:44] (current) srdjan.lukovic [GUI Code] |
||
|---|---|---|---|
| Line 44: | Line 44: | ||
| public void init() throws InitializerFailedException { | public void init() throws InitializerFailedException { | ||
| GUIApplicationComponent application = new GUIApplicationComponent(); | GUIApplicationComponent application = new GUIApplicationComponent(); | ||
| - | application.name.set(Text.fromString("MenusSample")); | + | application.setName("MenusSample"); |
| SoloistServiceServlet.registerApplication(application); | SoloistServiceServlet.registerApplication(application); | ||
| GUIPanelComponent root = GUIPanelComponent.createFlow(application); | GUIPanelComponent root = GUIPanelComponent.createFlow(application); | ||
| - | + | ||
| GUILabelComponent title = GUILabelComponent.create(root, "Menus"); | GUILabelComponent title = GUILabelComponent.create(root, "Menus"); | ||
| - | title.styleName.set(Text.fromString("titleStyle")); | + | title.setStyle("titleStyle"); |
| - | + | ||
| GUIPanelComponent menuPanel = GUIPanelComponent.createFlow(root); | GUIPanelComponent menuPanel = GUIPanelComponent.createFlow(root); | ||
| GUIDeckComponent deck = GUIDeckComponent.create(root); | GUIDeckComponent deck = GUIDeckComponent.create(root); | ||
| - | + | ||
| - | strings = new String[] {"", "A", "A1", "A2", "B", "B1", "B2", "C", "C1", "C2", "D", "D1", "D2", "E", "E1", "E2", "F", "F1", "F2", "G", "G1", "G2", "H"}; | + | strings = new String[] { "", "A", "A1", "A2", "B", "B1", "B2", "C", "C1", "C2", "D", "D1", "D2", "E", "E1", "E2", "F", "F1", "F2", "G", "G1", "G2", "H" }; |
| array = new GUIPanelComponent[strings.length]; | array = new GUIPanelComponent[strings.length]; | ||
| for (int i = 0; i < strings.length; i++) { | for (int i = 0; i < strings.length; i++) { | ||
| array[i] = GUIPanelComponent.createFlow(deck); | array[i] = GUIPanelComponent.createFlow(deck); | ||
| - | GUILabelComponent.create(array[i], strings[i]).styleName.set(Text.fromString("largeText")); | + | GUILabelComponent.create(array[i], strings[i]).setStyle("largeText"); |
| } | } | ||
| - | + | ||
| createGWTMenu(menuPanel, true); | createGWTMenu(menuPanel, true); | ||
| createGWTMenu(menuPanel, false); | createGWTMenu(menuPanel, false); | ||
| createDropDownMenu(menuPanel); | createDropDownMenu(menuPanel); | ||
| - | } | + | } |
| /** | /** | ||
| * Custom drop down menu using links, depends highly on CSS | * Custom drop down menu using links, depends highly on CSS | ||
| Line 70: | Line 70: | ||
| private void createDropDownMenu(GUIPanelComponent mainPanel) { | private void createDropDownMenu(GUIPanelComponent mainPanel) { | ||
| GUIPanelComponent menu = GUIPanelComponent.createFlow(mainPanel); | GUIPanelComponent menu = GUIPanelComponent.createFlow(mainPanel); | ||
| - | menu.styleName.set(Text.fromString("#menu")); | + | menu.setStyle("#menu"); |
| GUIPanelComponent menuWrapper = GUIPanelComponent.createFlow(menu); | GUIPanelComponent menuWrapper = GUIPanelComponent.createFlow(menu); | ||
| - | menuWrapper.styleName.set(Text.fromString("#menu_wrapper")); | + | menuWrapper.setStyle("#menu_wrapper"); |
| - | + | ||
| GUILinkComponent[] links = new GUILinkComponent[strings.length]; | GUILinkComponent[] links = new GUILinkComponent[strings.length]; | ||
| - | + | ||
| for (int i = 0; i < strings.length; i++) { | for (int i = 0; i < strings.length; i++) { | ||
| if (i == 0) { | if (i == 0) { | ||
| links[i] = GUILinkComponent.create(menuWrapper, "Home", "javascript:void"); | links[i] = GUILinkComponent.create(menuWrapper, "Home", "javascript:void"); | ||
| - | links[i].styleName.set(Text.fromString("sol-Link-active")); | + | links[i].setStyle("sol-Link-active"); |
| } else if (i == strings.length - 1) { | } else if (i == strings.length - 1) { | ||
| links[i] = GUILinkComponent.create(menuWrapper, "H", "javascript:void"); | links[i] = GUILinkComponent.create(menuWrapper, "H", "javascript:void"); | ||
| - | } else if (i % 3 == 1){ | + | } else if (i % 3 == 1) { |
| GUIPanelComponent top = GUIPanelComponent.createFlow(menuWrapper); | GUIPanelComponent top = GUIPanelComponent.createFlow(menuWrapper); | ||
| - | top.styleName.set(Text.fromString("#topmenu")); | + | top.setStyle("#topmenu"); |
| links[i] = GUILinkComponent.create(top, strings[i], "javascript:void"); | links[i] = GUILinkComponent.create(top, strings[i], "javascript:void"); | ||
| GUIPanelComponent sub = GUIPanelComponent.createFlow(top); | GUIPanelComponent sub = GUIPanelComponent.createFlow(top); | ||
| - | sub.styleName.set(Text.fromString("#submenu")); | + | sub.setStyle("#submenu"); |
| links[i + 1] = GUILinkComponent.create(sub, strings[i + 1], "javascript:void"); | links[i + 1] = GUILinkComponent.create(sub, strings[i + 1], "javascript:void"); | ||
| links[i + 2] = GUILinkComponent.create(sub, strings[i + 2], "javascript:void"); | links[i + 2] = GUILinkComponent.create(sub, strings[i + 2], "javascript:void"); | ||
| } | } | ||
| - | GUIComponentBinding.create(links[i].openLink, array[i].show); | + | GUIComponentBinding.create(links[i].opOpenLink(), array[i].ipShow()); |
| } | } | ||
| Line 99: | Line 99: | ||
| /** | /** | ||
| - | * Highlights the selected menu or sub-menu. | + | * Highlights selected menu or sub-menu. |
| */ | */ | ||
| private void menuHighlighter(GUIPanelComponent container, GUILinkComponent home, GUILinkComponent... orderedMenuLinks) { | private void menuHighlighter(GUIPanelComponent container, GUILinkComponent home, GUILinkComponent... orderedMenuLinks) { | ||
| GUIBufferComponent[] highlightBuffers = new GUIBufferComponent[orderedMenuLinks.length / 3 + 1]; | GUIBufferComponent[] highlightBuffers = new GUIBufferComponent[orderedMenuLinks.length / 3 + 1]; | ||
| GUIBufferComponent homeBuffer = GUIBufferComponent.create(container, false, Text.fromString("active")); | GUIBufferComponent homeBuffer = GUIBufferComponent.create(container, false, Text.fromString("active")); | ||
| - | GUIComponentBinding.create(homeBuffer.output, home.addStyle); // addStyle pin changes CSS class adding "active" | + | GUIComponentBinding.create(homeBuffer.opOutput(), home.ipAddStyle()); // addStyle pin changes CSS class adding "active" |
| - | GUIComponentBinding.create(home.openLink, homeBuffer.send); | + | GUIComponentBinding.create(home.opOpenLink(), homeBuffer.ipSend()); |
| for (int i = 0; i < orderedMenuLinks.length; i++) { | for (int i = 0; i < orderedMenuLinks.length; i++) { | ||
| if (i % 3 == 0) { | if (i % 3 == 0) { | ||
| highlightBuffers[i / 3] = GUIBufferComponent.create(container, false, Text.fromString("active")); | highlightBuffers[i / 3] = GUIBufferComponent.create(container, false, Text.fromString("active")); | ||
| - | GUIComponentBinding.create(highlightBuffers[i / 3].output, orderedMenuLinks[i].addStyle); | + | GUIComponentBinding.create(highlightBuffers[i / 3].opOutput(), orderedMenuLinks[i].ipAddStyle()); |
| - | GUIComponentBinding.create(orderedMenuLinks[i].openLink, highlightBuffers[i / 3].send); | + | GUIComponentBinding.create(orderedMenuLinks[i].opOpenLink(), highlightBuffers[i / 3].ipSend()); |
| for (int j = 0; j < orderedMenuLinks.length; j += 3) | for (int j = 0; j < orderedMenuLinks.length; j += 3) | ||
| if (!orderedMenuLinks[j].equals(orderedMenuLinks[i])) | if (!orderedMenuLinks[j].equals(orderedMenuLinks[i])) | ||
| - | GUIComponentBinding.create(highlightBuffers[i / 3].output, orderedMenuLinks[j].removeStyle); | + | GUIComponentBinding.create(highlightBuffers[i / 3].opOutput(), orderedMenuLinks[j].ipRemoveStyle()); |
| - | GUIComponentBinding.create(homeBuffer.output, orderedMenuLinks[i].removeStyle); | + | GUIComponentBinding.create(homeBuffer.opOutput(), orderedMenuLinks[i].ipRemoveStyle()); |
| - | GUIComponentBinding.create(highlightBuffers[i / 3].output, home.removeStyle); | + | GUIComponentBinding.create(highlightBuffers[i / 3].opOutput(), home.ipRemoveStyle()); |
| } else { | } else { | ||
| - | GUIComponentBinding.create(orderedMenuLinks[i].openLink, highlightBuffers[i / 3].send); | + | GUIComponentBinding.create(orderedMenuLinks[i].opOpenLink(), highlightBuffers[i / 3].ipSend()); |
| } | } | ||
| } | } | ||
| Line 125: | Line 125: | ||
| GUIMenuComponent myMainMenu = GUIMenuComponent.create(mainPanel, isHorizontal); | GUIMenuComponent myMainMenu = GUIMenuComponent.create(mainPanel, isHorizontal); | ||
| GUIMenuItemComponent[] items = new GUIMenuItemComponent[strings.length]; | GUIMenuItemComponent[] items = new GUIMenuItemComponent[strings.length]; | ||
| - | + | ||
| for (int i = 0; i < strings.length; i++) { | for (int i = 0; i < strings.length; i++) { | ||
| if (i == 0) { | if (i == 0) { | ||
| - | items[i] = GUIMenuItemComponent.create(myMainMenu); | + | items[i] = GUIMenuItemComponent.create(myMainMenu, "Home"); |
| - | items[i].text.set(Text.fromString("Home")); | + | |
| } else if (i == strings.length - 1) { | } else if (i == strings.length - 1) { | ||
| - | items[i] = GUIMenuItemComponent.create(myMainMenu); | + | items[i] = GUIMenuItemComponent.create(myMainMenu, strings[i]); |
| - | items[i].text.set(Text.fromString(strings[i])); | + | } else if (i % 3 == 1) { |
| - | } else if (i % 3 == 1){ | + | items[i] = GUIMenuItemComponent.create(myMainMenu, strings[i]); |
| - | items[i] = GUIMenuItemComponent.create(myMainMenu); | + | GUIMenuComponent subA = GUIMenuComponent.createSubMenu(items[i], !isHorizontal); |
| - | items[i].text.set(Text.fromString(strings[i])); | + | items[i + 1] = GUIMenuItemComponent.create(subA, strings[i + 1]); |
| - | GUIMenuComponent subA = GUIMenuComponent.create(items[i], !isHorizontal); | + | items[i + 2] = GUIMenuItemComponent.create(subA, strings[i + 2]); |
| - | items[i + 1] = GUIMenuItemComponent.create(subA); | + | |
| - | items[i + 1].text.set(Text.fromString(strings[i + 1])); | + | |
| - | items[i + 2] = GUIMenuItemComponent.create(subA); | + | |
| - | items[i + 2].text.set(Text.fromString(strings[i + 2])); | + | |
| } | } | ||
| - | GUIComponentBinding.create(items[i].click, array[i].show); | + | GUIComponentBinding.create(items[i].opClick(), array[i].ipShow()); |
| } | } | ||
| } | } | ||
| - | |||
| } | } | ||
| </code> | </code> | ||