public XulDomContainer loadXul(Document xulDocument, Object context) throws IllegalArgumentException, XulException { setOuterContext(context); XulDomContainer domC = super.loadXul(xulDocument); // SWT has no notion of an "onload" event, so we must simulate it... // This needs to be replaced by an agnostic listener pattern. XulComponent maybeWindow = domC.getDocumentRoot().getRootElement(); if (maybeWindow instanceof SwtWindow) { SwtWindow window = (SwtWindow) maybeWindow; window.notifyListeners(XulRoot.EVENT_ON_LOAD); defaultParent = window; } XulComponent maybeDialog = domC.getDocumentRoot().getRootElement(); if (maybeWindow instanceof SwtDialog) { SwtDialog dialog = (SwtDialog) maybeDialog; dialog.notifyListeners(XulRoot.EVENT_ON_LOAD); defaultParent = dialog; } return domC; }
protected void showErrorDialog(String title, String message) { errorDialog = (XulDialog) container.getDocumentRoot().getElementById("errorDialog"); XulLabel errorLabel = (XulLabel) container.getDocumentRoot().getElementById("errorLabel"); errorDialog.setTitle(title); errorLabel.setValue(message); errorDialog.show(); }
public void dispose() { super.dispose(); List<XulComponent> pops = xulDomContainer.getDocumentRoot().getElementsByTagName("menupopup"); for (XulComponent pop : pops) { ((MenuManager) pop.getManagedObject()).dispose(); } }
public void changeConnectionType() { XulListitem selectedItem = (XulListitem) connectionType.getSelectedItem(); String selectedValue = selectedItem.getLabel(); if (selectedValue.equals("Oracle")) { try { XulDomContainer container = this.xulDomContainer.loadFragment("org/pentaho/ui/xul/samples/datasource_oracle.xul"); XulGroupbox newBox = (XulGroupbox) container.getDocumentRoot().getRootElement(); XulGroupbox oldBox = (XulGroupbox) document.getElementById("database-options-box"); document.getElementById("button-box").replaceChild(oldBox, newBox); } catch (Exception e) { System.out.println("XulException loading fragment: " + e.getMessage()); e.printStackTrace(System.out); } } // hostName.setValue( String.format("%s host name", selectedValue) ); // databaseName.setValue( String.format("%s database name", selectedValue) ); // portNumber.setValue( String.format("%s port number", selectedValue) ); // username.setValue( String.format("%s username", selectedValue) ); // password.setValue( String.format("%s password", selectedValue) ); // }
@Before public void setUp() throws Exception { container = new SwingXulLoader().loadXul("resource/documents/tabpanel.xul"); doc = container.getDocumentRoot(); tabbox = (XulTabbox) doc.getElementById("myTabList"); }
@Before public void setUp() throws Exception { // Do not run on headless environment Assume.assumeTrue(!GraphicsEnvironment.isHeadless()); container = new SwingXulLoader().loadXul("resource/documents/menulist.xul"); doc = container.getDocumentRoot(); list = (XulMenuList) doc.getElementById("list"); }
protected XulMenupopup getXulPopupMenu(String id, String documentPath, IPentahoSession session) { XulDomContainer container = getXulContainer(documentPath, session); if (container != null) { List<XulComponent> components = container.getDocumentRoot().getElementsByTagName("menupopup"); // $NON-NLS-1$ for (XulComponent component : components) { if (component.getId().equals(id) && component instanceof XulMenupopup) { return (XulMenupopup) component; } } } Logger.error( getClass().getName(), Messages.getErrorString( "BaseMenuProvider.ERROR_0003_COULD_NOT_GET_POPUP_MENU")); //$NON-NLS-1$ return null; }
protected XulMenubar getXulMenubar(String id, String documentPath, IPentahoSession session) { XulDomContainer container = getXulContainer(documentPath, session); if (container == null) { return null; } List<XulComponent> components = container.getDocumentRoot().getElementsByTagName("menubar"); // $NON-NLS-1$ for (XulComponent component : components) { if (component instanceof XulMenubar && component.getId().equals(id)) { XulMenubar menubar = (XulMenubar) component; // now get customizations to it IPluginManager pluginManager = PentahoSystem.get(IPluginManager.class, session); List<?> menuCustomizations = pluginManager.getMenuCustomizations(); for (Object custom : menuCustomizations) { if (custom instanceof IMenuCustomization) { IMenuCustomization item = (IMenuCustomization) custom; try { // apply each customization and log any failures MenuUtil.customizeMenu(menubar, item, getXulLoader()); } catch (Exception e) { session.error( Messages.getString( "BaseMenuProvider.ERROR_0004_COULD_NOT_CUSTOMIZE_MENU", item.getId(), item.getLabel()), e); //$NON-NLS-1$ } } } return menubar; } } Logger.error( getClass().getName(), Messages.getErrorString( "BaseMenuProvider.ERROR_0002_COULD_NOT_GET_MENUBAR")); //$NON-NLS-1$ return null; }
/** * Initialize this dialog for the job entry instance provided. * * @param jobEntry The job entry this dialog supports. */ protected void init(E jobEntry) throws XulException { SwtXulLoader swtXulLoader = new SwtXulLoader(); // Register the settings manager so dialog position and size is restored swtXulLoader.setSettingsManager(XulSpoonSettingsManager.getInstance()); swtXulLoader.registerClassLoader(getClass().getClassLoader()); // Register Kettle's variable text box so we can reference it from XUL swtXulLoader.register("VARIABLETEXTBOX", ExtTextbox.class.getName()); swtXulLoader.setOuterContext(shell); // Load the XUL document with the dialog defined in it XulDomContainer container = swtXulLoader.loadXul(getXulFile(), bundle); // Create the controller with a default binding factory for the document we just loaded BindingFactory bf = new DefaultBindingFactory(); bf.setDocument(container.getDocumentRoot()); controller = createController(container, jobEntry, bf); container.addEventHandler(controller); // Load up the SWT-XUL runtime and initialize it with our container final XulRunner runner = new SwtXulRunner(); runner.addContainer(container); runner.initialize(); }
public void dispose() { SwtDialog dialog = (SwtDialog) container.getDocumentRoot().getElementById("repository-explorer-dialog"); dialog.dispose(); initialized = false; }
public void show() { XulDialog dialog = (XulDialog) container.getDocumentRoot().getElementById("repository-explorer-dialog"); dialog.show(); }
public Composite getMainPanel() { if (container == null) { return null; } return (Composite) container.getDocumentRoot().getElementById("mainPanel").getManagedObject(); }
public void xulLoaded(GwtXulRunner gwtXulRunner) { container = gwtXulRunner.getXulDomContainers().get(0); container.addEventHandler(this); BogoPojo bogo = new BogoPojo(); service.gwtWorkaround( bogo, new XulServiceCallback<BogoPojo>() { public void success(BogoPojo retVal) {} public void error(String message, Throwable error) {} }); datasourceService = new DSWDatasourceServiceGwtImpl(); // connectionService = new ConnectionServiceGwtImpl(); csvService = (ICsvDatasourceServiceAsync) GWT.create(ICsvDatasourceService.class); if (wizard == null) { wizard = new EmbeddedWizard(false); wizard.setDatasourceService(datasourceService); // wizard.setConnectionService(connectionService); wizard.setCsvDatasourceService(csvService); wizard.init(null); } messages = new GwtModelerMessages((ResourceBundle) container.getResourceBundles().get(0)); try { ModelerMessagesHolder.setMessages(messages); } catch (Exception ignored) { // Messages may have been set earlier, ignore. } IModelerWorkspaceHelper workspacehelper = model.getWorkspaceHelper(); controller = new ModelerController(model); controller.setWorkspaceHelper(workspacehelper); // controller.setMessages(messages); final BindingFactory bf = new GwtBindingFactory(container.getDocumentRoot()); controller.setBindingFactory(bf); container.addEventHandler(controller); try { controller.init(); } catch (ModelerException e) { e.printStackTrace(); } bf.setBindingType(Binding.Type.ONE_WAY); bf.createBinding( model, "valid", "modeler_dialog_accept", "disabled", new BindingConvertor<Boolean, Boolean>() { @Override public Boolean sourceToTarget(Boolean value) { return !value; } @Override public Boolean targetToSource(Boolean value) { return !value; } }); bf.setBindingType(Binding.Type.BI_DIRECTIONAL); // go get the geocontext from the server. Prop forms are initialized after this call returns as // they // may need them to create the UI datasourceService.getGeoContext( new XulServiceCallback<GeoContext>() { public void success(GeoContext geoContext) { model.setGeoContext(geoContext); ModelerUiHelper.configureControllers( container, model, bf, controller, new ColResolverController()); ModelerDialog.this.constructorListener.asyncConstructorDone(ModelerDialog.this); } public void error(String s, Throwable throwable) { throwable.printStackTrace(); // put in a stub to ensure the rest of the dialog works model.setGeoContext(new GeoContext()); ModelerUiHelper.configureControllers( container, model, bf, controller, new ColResolverController()); ModelerDialog.this.constructorListener.asyncConstructorDone(ModelerDialog.this); } }); }
@Override protected XulDialog getDialog() { return (XulDialog) container.getDocumentRoot().getElementById("modeler_dialog"); }